2 * SPDX-License-Identifier: LGPL-2.1-only
4 * Copyright (C) 2016 EfficiOS Inc.
5 * Copyright (C) 2016 Alexandre Montplaisir <alexmonthy@efficios.com>
8 package org.lttng.ust.agent.client;
10 import java.nio.ByteBuffer;
11 import java.nio.ByteOrder;
14 * Session daemon command indicating to the Java agent that an
15 * application-specific context was disabled in the tracing session.
17 * @author Alexandre Montplaisir
19 class SessiondDisableAppContextCommand extends SessiondCommand {
21 private final String retrieverName;
22 private final String contextName;
24 private final boolean commandIsValid;
26 public SessiondDisableAppContextCommand(byte[] data) {
28 throw new IllegalArgumentException();
30 ByteBuffer buf = ByteBuffer.wrap(data);
31 buf.order(ByteOrder.BIG_ENDIAN);
34 * The buffer contains the retriever name first, followed by the
37 retrieverName = readNextString(buf);
38 contextName = readNextString(buf);
40 /* If any of these strings were null then the command was invalid */
41 commandIsValid = ((retrieverName != null) && (contextName != null));
45 public LttngAgentResponse execute(ILttngTcpClientListener agent) {
46 if (!commandIsValid) {
47 return LttngAgentResponse.FAILURE_RESPONSE;
50 boolean success = agent.appContextDisabled(retrieverName, contextName);
51 return (success ? LttngAgentResponse.SUCESS_RESPONSE : DISABLE_APP_CONTEXT_FAILURE_RESPONSE);
55 * Response sent when the disable-context command asks to disable an
56 * unknown context name.
58 private static final LttngAgentResponse DISABLE_APP_CONTEXT_FAILURE_RESPONSE = new LttngAgentResponse() {
60 public ReturnCode getReturnCode() {
61 /* Same return code used for unknown event/logger names */
62 return ReturnCode.CODE_UNKNOWN_LOGGER_NAME;