5f0fbd948ce5801c89eab64400dc8076ebc94a6e
[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 import org.lttng.ust.agent.AbstractLttngAgent;
25
26 /**
27 * Session daemon command indicating to the Java agent that some events were
28 * enabled in the tracing session.
29 *
30 * @author Alexandre Montplaisir
31 * @author David Goulet
32 */
33 class SessiondEnableEventCommand implements ISessiondCommand {
34
35 private static final int INT_SIZE = 4;
36
37 /** Event name to enable in the tracing session */
38 private final String eventName;
39
40 public SessiondEnableEventCommand(byte[] data) {
41 if (data == null) {
42 throw new IllegalArgumentException();
43 }
44 int dataOffset = INT_SIZE * 2;
45
46 ByteBuffer buf = ByteBuffer.wrap(data);
47 buf.order(ByteOrder.LITTLE_ENDIAN);
48 buf.getInt(); // logLevel, currently unused
49 buf.getInt(); // logLevelType, currently unused
50 eventName = new String(data, dataOffset, data.length - dataOffset).trim();
51 }
52
53 @Override
54 public ILttngAgentResponse execute(AbstractLttngAgent<?> agent) {
55 boolean success = agent.eventEnabled(this.eventName);
56 return (success ? ILttngAgentResponse.SUCESS_RESPONSE : ILttngAgentResponse.FAILURE_RESPONSE);
57 }
58 }
This page took 0.029492 seconds and 3 git commands to generate.