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 enabled in the tracing session.
17 * @author Alexandre Montplaisir
19 class SessiondEnableAppContextCommand
extends SessiondCommand
{
21 private final String retrieverName
;
22 private final String contextName
;
24 private final boolean commandIsValid
;
26 public SessiondEnableAppContextCommand(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
.appContextEnabled(retrieverName
, contextName
);
51 return (success ? LttngAgentResponse
.SUCESS_RESPONSE
: LttngAgentResponse
.FAILURE_RESPONSE
);