X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=liblttng-ust-java-agent%2Fjava%2Flttng-ust-agent-common%2Forg%2Flttng%2Fust%2Fagent%2Fclient%2FSessiondDisableAppContextCommand.java;fp=liblttng-ust-java-agent%2Fjava%2Flttng-ust-agent-common%2Forg%2Flttng%2Fust%2Fagent%2Fclient%2FSessiondDisableAppContextCommand.java;h=157ad7565c18fe05432bdf6bcf93f3f12a206c78;hb=8ab5c06b92ac9a06ba2743470a38e4e1cfc6a3c9;hp=0000000000000000000000000000000000000000;hpb=1d193914f13dd604d60df9db680001c9a4af5f9d;p=lttng-ust.git diff --git a/liblttng-ust-java-agent/java/lttng-ust-agent-common/org/lttng/ust/agent/client/SessiondDisableAppContextCommand.java b/liblttng-ust-java-agent/java/lttng-ust-agent-common/org/lttng/ust/agent/client/SessiondDisableAppContextCommand.java new file mode 100644 index 00000000..157ad756 --- /dev/null +++ b/liblttng-ust-java-agent/java/lttng-ust-agent-common/org/lttng/ust/agent/client/SessiondDisableAppContextCommand.java @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2016 - EfficiOS Inc., Alexandre Montplaisir + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License, version 2.1 only, + * as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package org.lttng.ust.agent.client; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; + +/** + * Session daemon command indicating to the Java agent that an + * application-specific context was disabled in the tracing session. + * + * @author Alexandre Montplaisir + */ +class SessiondDisableAppContextCommand extends SessiondCommand { + + private final String retrieverName; + private final String contextName; + + private final boolean commandIsValid; + + public SessiondDisableAppContextCommand(byte[] data) { + if (data == null) { + throw new IllegalArgumentException(); + } + ByteBuffer buf = ByteBuffer.wrap(data); + buf.order(ByteOrder.BIG_ENDIAN); + + /* + * The buffer contains the retriever name first, followed by the + * context's name. + */ + retrieverName = readNextString(buf); + contextName = readNextString(buf); + + /* If any of these strings were null then the command was invalid */ + commandIsValid = ((retrieverName != null) && (contextName != null)); + } + + @Override + public LttngAgentResponse execute(ILttngTcpClientListener agent) { + if (!commandIsValid) { + return LttngAgentResponse.FAILURE_RESPONSE; + } + + boolean success = agent.appContextDisabled(retrieverName, contextName); + return (success ? LttngAgentResponse.SUCESS_RESPONSE : DISABLE_APP_CONTEXT_FAILURE_RESPONSE); + } + + /** + * Response sent when the disable-context command asks to disable an + * unknown context name. + */ + private static final LttngAgentResponse DISABLE_APP_CONTEXT_FAILURE_RESPONSE = new LttngAgentResponse() { + @Override + public ReturnCode getReturnCode() { + /* Same return code used for unknown event/logger names */ + return ReturnCode.CODE_UNKNOWN_LOGGER_NAME; + } + }; +}