Commit | Line | Data |
---|---|---|
d60dfbe4 | 1 | /* |
c0c0989a | 2 | * SPDX-License-Identifier: LGPL-2.1-only |
d60dfbe4 | 3 | * |
c0c0989a MJ |
4 | * Copyright (C) 2015 EfficiOS Inc. |
5 | * Copyright (C) 2015 Alexandre Montplaisir <alexmonthy@efficios.com> | |
6 | * Copyright (C) 2013 David Goulet <dgoulet@efficios.com> | |
d60dfbe4 AM |
7 | */ |
8 | ||
9 | package org.lttng.ust.agent.client; | |
10 | ||
11 | import java.nio.ByteBuffer; | |
12 | import java.nio.ByteOrder; | |
13 | ||
301a3ddb AM |
14 | /** |
15 | * Session daemon command indicating to the Java agent that some events were | |
16 | * disabled in the tracing session. | |
17 | * | |
18 | * @author Alexandre Montplaisir | |
19 | * @author David Goulet | |
20 | */ | |
1d193914 | 21 | class SessiondDisableEventCommand extends SessiondCommand { |
d60dfbe4 | 22 | |
f35c6aa0 AM |
23 | /** |
24 | * Response sent when the disable-event command asks to disable an | |
25 | * unknown event. | |
26 | */ | |
27 | private static final LttngAgentResponse DISABLE_EVENT_FAILURE_RESPONSE = new LttngAgentResponse() { | |
28 | @Override | |
29 | public ReturnCode getReturnCode() { | |
30 | return ReturnCode.CODE_UNKNOWN_LOGGER_NAME; | |
31 | } | |
32 | }; | |
33 | ||
d60dfbe4 | 34 | /** Event name to disable from the tracing session */ |
301a3ddb | 35 | private final String eventName; |
d60dfbe4 | 36 | |
301a3ddb AM |
37 | public SessiondDisableEventCommand(byte[] data) { |
38 | if (data == null) { | |
39 | throw new IllegalArgumentException(); | |
40 | } | |
d60dfbe4 | 41 | ByteBuffer buf = ByteBuffer.wrap(data); |
abac44cd | 42 | buf.order(ByteOrder.BIG_ENDIAN); |
22191ffd | 43 | eventName = new String(data, SESSIOND_PROTOCOL_CHARSET).trim(); |
d60dfbe4 AM |
44 | } |
45 | ||
46 | @Override | |
3165c2f5 | 47 | public LttngAgentResponse execute(ILttngTcpClientListener agent) { |
301a3ddb | 48 | boolean success = agent.eventDisabled(this.eventName); |
93253569 | 49 | return (success ? LttngAgentResponse.SUCESS_RESPONSE : DISABLE_EVENT_FAILURE_RESPONSE); |
d60dfbe4 | 50 | } |
2c240349 | 51 | |
f35c6aa0 AM |
52 | @Override |
53 | public String toString() { | |
54 | return "SessiondDisableEventCommand[" | |
55 | + "eventName=" + eventName | |
56 | +"]"; | |
57 | } | |
d60dfbe4 | 58 | } |