7af4667e633c7f322a48de83daa6b0e3abb24e0b
[lttng-ust.git] /
1 /*
2 * Copyright (C) 2015 - EfficiOS Inc., Alexandre Montplaisir <alexmonthy@efficios.com>
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 /**
25 * Session daemon command indicating to the Java agent that some events were
26 * disabled in the tracing session.
27 *
28 * @author Alexandre Montplaisir
29 * @author David Goulet
30 */
31 class SessiondDisableEventCommand extends SessiondCommand {
32
33 /**
34 * Response sent when the disable-event command asks to disable an
35 * unknown event.
36 */
37 private static final LttngAgentResponse DISABLE_EVENT_FAILURE_RESPONSE = new LttngAgentResponse() {
38 @Override
39 public ReturnCode getReturnCode() {
40 return ReturnCode.CODE_UNKNOWN_LOGGER_NAME;
41 }
42 };
43
44 /** Event name to disable from the tracing session */
45 private final String eventName;
46
47 public SessiondDisableEventCommand(byte[] data) {
48 if (data == null) {
49 throw new IllegalArgumentException();
50 }
51 ByteBuffer buf = ByteBuffer.wrap(data);
52 buf.order(ByteOrder.BIG_ENDIAN);
53 eventName = new String(data, SESSIOND_PROTOCOL_CHARSET).trim();
54 }
55
56 @Override
57 public LttngAgentResponse execute(ILttngTcpClientListener agent) {
58 boolean success = agent.eventDisabled(this.eventName);
59 return (success ? LttngAgentResponse.SUCESS_RESPONSE : DISABLE_EVENT_FAILURE_RESPONSE);
60 }
61
62 @Override
63 public String toString() {
64 return "SessiondDisableEventCommand["
65 + "eventName=" + eventName
66 +"]";
67 }
68 }
This page took 0.029389 seconds and 3 git commands to generate.