Commit | Line | Data |
---|---|---|
d60dfbe4 | 1 | /* |
301a3ddb | 2 | * Copyright (C) 2015 - EfficiOS Inc., Alexandre Montplaisir <alexmonthy@efficios.com> |
d60dfbe4 AM |
3 | * Copyright (C) 2013 - David Goulet <dgoulet@efficios.com> |
4 | * | |
5 | * This library is free software; you can redistribute it and/or modify it | |
6 | * under the terms of the GNU Lesser General Public License, version 2.1 only, | |
7 | * as published by the Free Software Foundation. | |
8 | * | |
9 | * This library is distributed in the hope that it will be useful, but WITHOUT | |
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License | |
12 | * for more details. | |
13 | * | |
14 | * You should have received a copy of the GNU Lesser General Public License | |
15 | * along with this library; if not, write to the Free Software Foundation, | |
16 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
17 | */ | |
18 | ||
19 | package org.lttng.ust.agent.client; | |
20 | ||
21 | import java.nio.ByteBuffer; | |
22 | import java.nio.ByteOrder; | |
23 | ||
24 | import org.lttng.ust.agent.AbstractLttngAgent; | |
25 | ||
301a3ddb AM |
26 | /** |
27 | * Session daemon command indicating to the Java agent that some events were | |
28 | * disabled in the tracing session. | |
29 | * | |
30 | * @author Alexandre Montplaisir | |
31 | * @author David Goulet | |
32 | */ | |
33 | class SessiondDisableEventCommand implements ISessiondCommand { | |
d60dfbe4 AM |
34 | |
35 | /** Event name to disable from the tracing session */ | |
301a3ddb | 36 | private final String eventName; |
d60dfbe4 | 37 | |
301a3ddb AM |
38 | public SessiondDisableEventCommand(byte[] data) { |
39 | if (data == null) { | |
40 | throw new IllegalArgumentException(); | |
41 | } | |
d60dfbe4 AM |
42 | ByteBuffer buf = ByteBuffer.wrap(data); |
43 | buf.order(ByteOrder.LITTLE_ENDIAN); | |
44 | eventName = new String(data).trim(); | |
45 | } | |
46 | ||
47 | @Override | |
93253569 | 48 | public LttngAgentResponse execute(AbstractLttngAgent<?> agent) { |
301a3ddb | 49 | boolean success = agent.eventDisabled(this.eventName); |
93253569 | 50 | return (success ? LttngAgentResponse.SUCESS_RESPONSE : DISABLE_EVENT_FAILURE_RESPONSE); |
d60dfbe4 | 51 | } |
2c240349 AM |
52 | |
53 | /** | |
54 | * Response sent when the disable-event command asks to disable an | |
55 | * unknown event. | |
56 | */ | |
93253569 | 57 | private static final LttngAgentResponse DISABLE_EVENT_FAILURE_RESPONSE = new LttngAgentResponse() { |
2c240349 AM |
58 | @Override |
59 | public ReturnCode getReturnCode() { | |
60 | return ReturnCode.CODE_UNK_LOGGER_NAME; | |
61 | } | |
2c240349 | 62 | }; |
d60dfbe4 | 63 | } |