ff8eff3a35debd1d41d349328833664b276c8c62
[lttng-ust.git] /
1 /*
2 * SPDX-License-Identifier: LGPL-2.1-only
3 *
4 * Copyright (C) 2015 EfficiOS Inc.
5 * Copyright (C) 2015 Alexandre Montplaisir <alexmonthy@efficios.com>
6 * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
7 */
8
9 package org.lttng.ust.agent.client;
10
11 import java.nio.ByteBuffer;
12 import java.nio.ByteOrder;
13
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 */
21 class SessiondDisableEventCommand extends SessiondCommand {
22
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
34 /** Event name to disable from the tracing session */
35 private final String eventName;
36
37 public SessiondDisableEventCommand(byte[] data) {
38 if (data == null) {
39 throw new IllegalArgumentException();
40 }
41 ByteBuffer buf = ByteBuffer.wrap(data);
42 buf.order(ByteOrder.BIG_ENDIAN);
43 eventName = new String(data, SESSIOND_PROTOCOL_CHARSET).trim();
44 }
45
46 @Override
47 public LttngAgentResponse execute(ILttngTcpClientListener agent) {
48 boolean success = agent.eventDisabled(this.eventName);
49 return (success ? LttngAgentResponse.SUCESS_RESPONSE : DISABLE_EVENT_FAILURE_RESPONSE);
50 }
51
52 @Override
53 public String toString() {
54 return "SessiondDisableEventCommand["
55 + "eventName=" + eventName
56 +"]";
57 }
58 }
This page took 0.030953 seconds and 3 git commands to generate.