2 * Copyright (C) 2016 - EfficiOS Inc., Alexandre Montplaisir <alexmonthy@efficios.com>
4 * This library is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License, version 2.1 only,
6 * as published by the Free Software Foundation.
8 * This library is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this library; if not, write to the Free Software Foundation,
15 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 package org.lttng.ust.agent.client;
20 import java.nio.ByteBuffer;
21 import java.nio.ByteOrder;
24 * Session daemon command indicating to the Java agent that an
25 * application-specific context was enabled in the tracing session.
27 * @author Alexandre Montplaisir
29 class SessiondEnableAppContextCommand extends SessiondCommand {
31 private final String retrieverName;
32 private final String contextName;
34 private final boolean commandIsValid;
36 public SessiondEnableAppContextCommand(byte[] data) {
38 throw new IllegalArgumentException();
40 ByteBuffer buf = ByteBuffer.wrap(data);
41 buf.order(ByteOrder.BIG_ENDIAN);
44 * The buffer contains the retriever name first, followed by the
47 retrieverName = readNextString(buf);
48 contextName = readNextString(buf);
50 /* If any of these strings were null then the command was invalid */
51 commandIsValid = ((retrieverName != null) && (contextName != null));
55 public LttngAgentResponse execute(ILttngTcpClientListener agent) {
56 if (!commandIsValid) {
57 return LttngAgentResponse.FAILURE_RESPONSE;
60 boolean success = agent.appContextEnabled(retrieverName, contextName);
61 return (success ? LttngAgentResponse.SUCESS_RESPONSE : LttngAgentResponse.FAILURE_RESPONSE);