import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.ILttngRelaydConnector;
import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.LttngRelaydConnectorFactory;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.AttachSessionResponse;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.Command;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.ConnectResponse;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.CreateSessionResponse;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.CreateSessionReturnCode;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.GetNextIndex;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.IndexResponse;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.NextIndexReturnCode;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.SessionResponse;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.StreamResponse;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.ViewerCommand;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.AttachSessionResponse;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.Command;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.ConnectResponse;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.CreateSessionResponse;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.CreateSessionReturnCode;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.GetNextIndex;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.IndexResponse;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.NextIndexReturnCode;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.SessionResponse;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.StreamResponse;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.ViewerCommand;
import org.junit.Test;
/**
org.eclipse.tracecompass.internal.lttng2.control.core.model;x-friends:="org.eclipse.tracecompass.lttng2.control.ui,org.eclipse.tracecompass.lttng2.control.ui.tests,org.eclipse.tracecompass.lttng2.control.core.tests",
org.eclipse.tracecompass.internal.lttng2.control.core.model.impl;x-friends:="org.eclipse.tracecompass.lttng2.control.ui,org.eclipse.tracecompass.lttng2.control.ui.tests,org.eclipse.tracecompass.lttng2.control.core.tests",
org.eclipse.tracecompass.internal.lttng2.control.core.relayd;x-friends:="org.eclipse.tracecompass.lttng2.control.core.tests,org.eclipse.tracecompass.lttng2.control.ui,org.eclipse.tracecompass.lttng2.control.ui.tests",
+ org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands;x-friends:="org.eclipse.tracecompass.lttng2.control.core.tests,org.eclipse.tracecompass.lttng2.control.ui,org.eclipse.tracecompass.lttng2.control.ui.tests",
org.eclipse.tracecompass.internal.lttng2.control.core.relayd.impl;x-friends:="org.eclipse.tracecompass.lttng2.control.core.tests,org.eclipse.tracecompass.lttng2.control.ui,org.eclipse.tracecompass.lttng2.control.ui.tests",
- org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands;x-friends:="org.eclipse.tracecompass.lttng2.control.core.tests,org.eclipse.tracecompass.lttng2.control.ui,org.eclipse.tracecompass.lttng2.control.ui.tests",
org.eclipse.tracecompass.lttng2.control.core.session
Import-Package: com.google.common.collect
import java.io.IOException;
import java.util.List;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.AttachSessionResponse;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.CreateSessionResponse;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.IndexResponse;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.SessionResponse;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.StreamResponse;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.TracePacketResponse;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.AttachSessionResponse;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.CreateSessionResponse;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.IndexResponse;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.SessionResponse;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.StreamResponse;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.TracePacketResponse;
/**
* Connector for Lttng Relayd
import java.io.IOException;
import java.net.Socket;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.Command;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.ConnectResponse;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.ConnectionType;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.ViewerCommand;
import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.impl.LttngRelaydConnector_2_4;
import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.impl.LttngRelaydConnector_Unsupported;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.Command;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.ConnectResponse;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.ConnectionType;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.ViewerCommand;
/**
* LTTng RelayD connector factory
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2014 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Matthew Khouzam - Initial implementation and API
+ * Marc-Andre Laperle - Initial implementation and API
+ **********************************************************************/
+
+package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands;
+
+/**
+ * Return codes for "viewer attach" command
+ *
+ * @author Matthew Khouzam
+ */
+public enum AttachReturnCode implements IBaseCommand {
+
+ /** If the attach command succeeded. */
+ VIEWER_ATTACH_OK(1),
+ /** If a viewer is already attached. */
+ VIEWER_ATTACH_ALREADY(2),
+ /** If the session ID is unknown. */
+ VIEWER_ATTACH_UNK(3),
+ /** If the session is not live. */
+ VIEWER_ATTACH_NOT_LIVE(4),
+ /** Seek error. */
+ VIEWER_ATTACH_SEEK_ERR(5),
+ /** No session */
+ VIEWER_ATTACH_NO_SESSION(6);
+
+ private final int fCode;
+
+ private AttachReturnCode(int c) {
+ fCode = c;
+ }
+
+ @Override
+ public int getCommand() {
+ return fCode;
+ }
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2014 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Matthew Khouzam - Initial implementation and API
+ * Marc-Andre Laperle - Initial implementation and API
+ **********************************************************************/
+
+package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands;
+
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+
+/**
+ * VIEWER_ATTACH_SESSION payload.
+ *
+ * @author Matthew Khouzam
+ */
+public class AttachSessionRequest implements IRelayCommand {
+
+ /**
+ * Command size
+ *
+ * fSessionId + fOffset + fSeek
+ */
+ public static final int SIZE = (Long.SIZE + Long.SIZE) / 8 + SeekCommand.SIZE;
+ /** the id of a session */
+ private final long fSessionId;
+ /** unused for now */
+ private final long fOffset;
+ /** enum lttng_viewer_seek */
+ private final SeekCommand fSeek;
+
+ /**
+ * Attach session request constructor
+ *
+ * @param id
+ * the session id
+ * @param seekCommand
+ * the seek command
+ */
+ public AttachSessionRequest(long id, SeekCommand seekCommand) {
+ this(id, 0, seekCommand);
+ }
+
+ /**
+ * Attach session request constructor
+ *
+ * @param id
+ * the session id
+ * @param offset
+ * unused for now
+ * @param seekCommand
+ * the seek command
+ */
+
+ public AttachSessionRequest(long id, int offset, SeekCommand seekCommand) {
+ fSessionId = id;
+ fOffset = offset;
+ fSeek = seekCommand;
+
+ }
+
+ @Override
+ public byte[] serialize() {
+ byte data[] = new byte[SIZE];
+ ByteBuffer bb = ByteBuffer.wrap(data);
+ bb.order(ByteOrder.BIG_ENDIAN);
+ bb.putLong(fSessionId);
+ bb.putLong(fOffset);
+ bb.putInt(fSeek.getCommand());
+ return data;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2014 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Matthew Khouzam - Initial implementation and API
+ * Marc-Andre Laperle - Initial implementation and API
+ **********************************************************************/
+
+package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands;
+
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.util.List;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableList.Builder;
+
+/**
+ * Attach session response
+ *
+ * @author Matthew Khouzam
+ */
+public class AttachSessionResponse implements IRelayResponse {
+
+ /**
+ * Response size
+ *
+ * fStatus + fStreamsCount (first half of a packet) */
+ private static final int SIZE = (Integer.SIZE + Integer.SIZE) / 8;
+ /** enum lttng_viewer_attach_return_code */
+ private final AttachReturnCode fStatus;
+ /** how many streams are there */
+ private final int fStreamsCount;
+ /** public class lttng_viewer_stream */
+ private final List<StreamResponse> fStreamList;
+
+ /**
+ * Attach session response network constructor
+ *
+ * @param inNet
+ * network input stream
+ * @throws IOException
+ * network error
+ */
+ public AttachSessionResponse(DataInputStream inNet) throws IOException {
+ byte[] data = new byte[SIZE];
+ inNet.readFully(data, 0, SIZE);
+ ByteBuffer bb = ByteBuffer.wrap(data);
+ bb.order(ByteOrder.BIG_ENDIAN);
+ fStatus = AttachReturnCode.values()[bb.getInt() - 1];
+ fStreamsCount = bb.getInt();
+ Builder<StreamResponse> streamResponses = ImmutableList.builder();
+ for (int i = 0; i < getNbStreams(); i++) {
+ streamResponses.add(new StreamResponse(inNet));
+ }
+ fStreamList = streamResponses.build();
+
+ }
+
+ /**
+ * Gets the Status
+ *
+ * @return the Status
+ */
+ public AttachReturnCode getStatus() {
+ return fStatus;
+ }
+
+ /**
+ * Gets the StreamsCount
+ *
+ * @return the StreamsCount
+ */
+ public int getNbStreams() {
+ return fStreamsCount;
+ }
+
+ /**
+ * Gets the StreamList
+ *
+ * @return the StreamList
+ */
+ public List<StreamResponse> getStreamList() {
+ return fStreamList;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2014 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Matthew Khouzam - Initial implementation and API
+ * Marc-Andre Laperle - Initial implementation and API
+ **********************************************************************/
+
+package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands;
+
+/**
+ * Viewer commands
+ *
+ * @author Matthew Khouzam
+ */
+public enum Command implements IBaseCommand {
+
+ /** get version */
+ VIEWER_CONNECT(1),
+ /** list all lttng sessions */
+ VIEWER_LIST_SESSIONS(2),
+ /** attach to a session */
+ VIEWER_ATTACH_SESSION(3),
+ /** get the next index */
+ VIEWER_GET_NEXT_INDEX(4),
+ /** get packet */
+ VIEWER_GET_PACKET(5),
+ /** get metadata */
+ VIEWER_GET_METADATA(6),
+ /** get new streams */
+ VIEWER_GET_NEW_STREAMS(7),
+ /** create a new session */
+ VIEWER_CREATE_SESSION(8);
+
+ /**
+ * Command size (fCode)
+ */
+ public static final int SIZE = Integer.SIZE / 8;
+
+ private final int fCode;
+
+ private Command(int c) {
+ fCode = c;
+ }
+
+ @Override
+ public int getCommand() {
+ return fCode;
+ }
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2014 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Matthew Khouzam - Initial implementation and API
+ * Marc-Andre Laperle - Initial implementation and API
+ **********************************************************************/
+
+package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands;
+
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+
+/**
+ * CONNECT payload.
+ *
+ * @author Matthew Khouzam
+ */
+public class ConnectResponse implements IRelayResponse, IRelayCommand {
+
+ /**
+ * Response or command size
+ *
+ * fViewerSessionId + fMajor + fMinor + fType
+ */
+ public static final int SIZE = (Long.SIZE + Integer.SIZE + Integer.SIZE + Integer.SIZE) / 8;
+ /** session id, counts from 1 and increments by session */
+ private final long fViewerSessionId;
+ /**
+ * Major version, hint, it's at least 2
+ */
+ private final int fMajor;
+ /**
+ * Minor version, hint, it's at least 4
+ */
+ private final int fMinor;
+ /**
+ * type of connect to {@link ConnectionType}
+ */
+ private final ConnectionType fType;
+
+ /**
+ * Connection response reply constructor
+ *
+ * @param inStream
+ * the data input stream
+ * @throws IOException
+ * a network error
+ */
+ public ConnectResponse(DataInputStream inStream) throws IOException {
+ byte data[] = new byte[SIZE];
+ inStream.readFully(data);
+ ByteBuffer bb = ByteBuffer.wrap(data);
+ bb.order(ByteOrder.BIG_ENDIAN);
+ fViewerSessionId = bb.getLong();
+ fMajor = bb.getInt();
+ fMinor = bb.getInt();
+ bb.getInt(); // Should not be used, see http://bugs.lttng.org/issues/728
+ fType = ConnectionType.VIEWER_CLIENT_COMMAND;
+ }
+
+ /**
+ * Constructor for command
+ *
+ * @param sessionID
+ * session id
+ * @param major
+ * the major version
+ * @param minor
+ * the minor version
+ * @param connection
+ * the connection type, typically VIEWER_CLIENT_COMMAND
+ */
+ public ConnectResponse(long sessionID, int major, int minor, ConnectionType connection) {
+ fViewerSessionId = sessionID;
+ fMajor = major;
+ fMinor = minor;
+ fType = connection;
+ }
+
+ /**
+ * get the major version
+ *
+ * @return the major version
+ */
+ public int getMajor() {
+ return fMajor;
+ }
+
+ /**
+ * get the minor version
+ *
+ * @return the minor version
+ */
+ public int getMinor() {
+ return fMinor;
+ }
+
+ @Override
+ public byte[] serialize() {
+ byte data[] = new byte[SIZE];
+ ByteBuffer bb = ByteBuffer.wrap(data);
+ bb.order(ByteOrder.BIG_ENDIAN);
+ bb.putLong(fViewerSessionId);
+ bb.putInt(fMajor);
+ bb.putInt(fMinor);
+ bb.putInt(fType.getCommand());
+ return data;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2014 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Matthew Khouzam - Initial implementation and API
+ * Marc-Andre Laperle - Initial implementation and API
+ **********************************************************************/
+
+package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands;
+
+/**
+ * Get viewer connection type
+ *
+ * @author Matthew Khouzam
+ */
+public enum ConnectionType implements IBaseCommand {
+
+ /** Command sent */
+ VIEWER_CLIENT_COMMAND(1),
+ /** Notification sent */
+ VIEWER_CLIENT_NOTIFICATION(2);
+
+ private final int fCode;
+
+ private ConnectionType(int c) {
+ fCode = c;
+ }
+
+ @Override
+ public int getCommand() {
+ return fCode;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2014 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Matthew Khouzam - Initial implementation and API
+ * Marc-Andre Laperle - Initial implementation and API
+ **********************************************************************/
+
+package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands;
+
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+
+/**
+ * Response to a "create session" command
+ *
+ * @author Matthew Khouzam
+ */
+public class CreateSessionResponse implements IRelayResponse {
+
+ /**
+ * Response size (fStatus)
+ */
+ public static final int SIZE = Integer.SIZE / 8;
+
+ /** enum lttng_viewer_create_session_return_code */
+ private final CreateSessionReturnCode fStatus;
+
+ /**
+ * Create session response network constructor
+ *
+ * @param inNet
+ * network input stream
+ * @throws IOException
+ * network error
+ */
+ public CreateSessionResponse(DataInputStream inNet) throws IOException {
+ byte[] data = new byte[SIZE];
+ inNet.readFully(data);
+ ByteBuffer bb = ByteBuffer.wrap(data);
+ bb.order(ByteOrder.BIG_ENDIAN);
+ fStatus = (CreateSessionReturnCode.values()[bb.getInt() - 1]);
+ }
+
+ /**
+ * Get status
+ *
+ * @return the status
+ */
+ public CreateSessionReturnCode getStatus() {
+ return fStatus;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2014 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Matthew Khouzam - Initial implementation and API
+ * Marc-Andre Laperle - Initial implementation and API
+ **********************************************************************/
+
+package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands;
+
+/**
+ * Create new session return code
+ *
+ * @author Matthew Khouzam
+ */
+public enum CreateSessionReturnCode implements IBaseCommand {
+
+ /** If new streams are being sent. */
+ LTTNG_VIEWER_CREATE_SESSION_OK(1),
+ /** Fatal error on the server-side. */
+ LTTNG_VIEWER_CREATE_SESSION_ERR(2);
+
+ private final int fCode;
+
+ private CreateSessionReturnCode(int c) {
+ fCode = c;
+ }
+
+ @Override
+ public int getCommand() {
+ return fCode;
+ }
+}
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2014 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Matthew Khouzam - Initial implementation and API
+ * Marc-Andre Laperle - Initial implementation and API
+ **********************************************************************/
+
+package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands;
+
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+
+/**
+ * VIEWER_GET_METADATA payload.
+ *
+ * @author Matthew Khouzam
+ */
+public class GetMetadata implements IRelayCommand {
+
+ /**
+ * Command size (fStreamId)
+ */
+ public static final int SIZE = Long.SIZE / 8;
+
+ /**
+ * The stream id
+ */
+ private final long fStreamId;
+
+ /**
+ * Set the stream id
+ *
+ * @param streamId
+ * the stream id
+ */
+ public GetMetadata(long streamId) {
+ fStreamId = streamId;
+ }
+
+ /**
+ * Get the stream id
+ *
+ * @return the stream id
+ */
+ public long getStreamId() {
+ return fStreamId;
+ }
+
+ @Override
+ public byte[] serialize() {
+ byte data[] = new byte[SIZE];
+ ByteBuffer bb = ByteBuffer.wrap(data);
+ bb.order(ByteOrder.BIG_ENDIAN);
+ bb.putLong(getStreamId());
+ return data;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2014 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Matthew Khouzam - Initial implementation and API
+ * Marc-Andre Laperle - Initial implementation and API
+ **********************************************************************/
+
+package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands;
+
+/**
+ * Get metadata return code
+ *
+ * @author Matthew Khouzam
+ */
+public enum GetMetadataReturnCode implements IBaseCommand {
+
+ /** Response was OK */
+ VIEWER_METADATA_OK(1),
+ /** Response was nothing new */
+ VIEWER_NO_NEW_METADATA(2),
+ /** Response was Error */
+ VIEWER_METADATA_ERR(3);
+
+ private final int fCode;
+
+ private GetMetadataReturnCode(int c) {
+ fCode = c;
+ }
+
+ @Override
+ public int getCommand() {
+ return fCode;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2014 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Matthew Khouzam - Initial implementation and API
+ * Marc-Andre Laperle - Initial implementation and API
+ **********************************************************************/
+
+package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands;
+
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+
+/**
+ * VIEWER_GET_NEXT_INDEX payload.
+ *
+ * @author Matthew Khouzam
+ */
+public class GetNextIndex implements IRelayCommand {
+
+ /**
+ * Command size (fStreamId)
+ */
+ public static final int SIZE = Long.SIZE / 8;
+ /**
+ * the id of the stream
+ */
+ private final long fStreamId;
+
+ /**
+ * Constructor
+ *
+ * @param streamId
+ * the index stream id
+ */
+ public GetNextIndex(long streamId) {
+ fStreamId = streamId;
+ }
+
+ /**
+ * Gets the stream id
+ *
+ * @return the stream id
+ */
+ public long getStreamId() {
+ return fStreamId;
+ }
+
+ @Override
+ public byte[] serialize() {
+ byte data[] = new byte[SIZE];
+ ByteBuffer bb = ByteBuffer.wrap(data);
+ bb.order(ByteOrder.BIG_ENDIAN);
+ bb.putLong(getStreamId());
+ return data;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2014 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Matthew Khouzam - Initial implementation and API
+ * Marc-Andre Laperle - Initial implementation and API
+ **********************************************************************/
+
+package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands;
+
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+
+/**
+ * VIEWER_GET_PACKET payload.
+ *
+ * @author Matthew Khouzam
+ */
+public class GetPacket implements IRelayCommand {
+
+ /**
+ * Command size
+ *
+ * fStreamId + fOffset + fLength
+ */
+ public static final int SIZE = (Long.SIZE + Long.SIZE + Integer.SIZE) / 8;
+ /** the stream Id */
+ private final long fStreamId;
+ /** the offset */
+ private final long fOffset;
+ /** the length of the packet */
+ private final int fLength;
+
+ /**
+ * Get packet constructor
+ *
+ * @param streamId
+ * the stream id
+ * @param offset
+ * the offset
+ * @param length
+ * the packet length
+ */
+ public GetPacket(long streamId, long offset, int length) {
+ fStreamId = streamId;
+ fOffset = offset;
+ fLength = length;
+ }
+
+ /**
+ * Get the length of the packet
+ *
+ * @return the length of the packet in bytes
+ */
+ public int getLength() {
+ return fLength;
+ }
+
+ /**
+ * Gets the offset of the packet
+ *
+ * @return the offset
+ */
+ public long getOffset() {
+ return fOffset;
+ }
+
+ /**
+ * Gets the stream id
+ *
+ * @return the stream id
+ */
+ public long getStreamId() {
+ return fStreamId;
+ }
+
+ @Override
+ public byte[] serialize() {
+ byte data[] = new byte[SIZE];
+ ByteBuffer bb = ByteBuffer.wrap(data);
+ bb.order(ByteOrder.BIG_ENDIAN);
+ bb.putLong(getStreamId());
+ bb.putLong(getOffset());
+ bb.putInt(getLength());
+ return data;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2014 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Matthew Khouzam - Initial implementation and API
+ * Marc-Andre Laperle - Initial implementation and API
+ **********************************************************************/
+
+package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands;
+
+/**
+ * Get packet return code
+ *
+ * @author Matthew Khouzam
+ */
+public enum GetPacketReturnCode implements IBaseCommand {
+
+ /** Response was OK */
+ VIEWER_GET_PACKET_OK(1),
+ /** Response was RETRY */
+ VIEWER_GET_PACKET_RETRY(2),
+ /** Response was ERROR */
+ VIEWER_GET_PACKET_ERR(3),
+ /** Response was End of File */
+ VIEWER_GET_PACKET_EOF(4);
+
+ private final int fCode;
+
+ private GetPacketReturnCode(int c) {
+ fCode = c;
+ }
+
+ @Override
+ public int getCommand() {
+ return fCode;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2014 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Matthew Khouzam - Initial implementation and API
+ * Marc-Andre Laperle - Initial implementation and API
+ **********************************************************************/
+
+package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands;
+
+/**
+ * Instruction to send to relayd
+ *
+ * @author Matthew Khouzam
+ */
+public interface IBaseCommand {
+
+ /**
+ * gets the numerical value of the command
+ *
+ * @return the numerical value of the command
+ */
+ int getCommand();
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2014 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Matthew Khouzam - Initial implementation and API
+ * Marc-Andre Laperle - Initial implementation and API
+ **********************************************************************/
+
+package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands;
+
+
+/**
+ * Command sent, needs a getBytes to stream the data
+ *
+ * @author Matthew Khouzam
+ */
+public interface IRelayCommand {
+
+ /**
+ * Gets a byte array of the command so that it may be streamed
+ *
+ * @return the byte array of the command
+ */
+ byte[] serialize();
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2014 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Matthew Khouzam - Initial implementation and API
+ * Marc-Andre Laperle - Initial implementation and API
+ **********************************************************************/
+
+package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands;
+
+/**
+ * Command response, this will allow sorting commands easier
+ *
+ * @author Matthew Khouzam
+ */
+public interface IRelayResponse {
+
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2014 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Matthew Khouzam - Initial implementation and API
+ * Marc-Andre Laperle - Initial implementation and API
+ **********************************************************************/
+
+package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands;
+
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+
+/**
+ * An Lttng packet index
+ *
+ * @author Matthew Khouzam
+ */
+public class IndexResponse implements IRelayResponse {
+
+ /**
+ * Command size
+ *
+ * Sum of the field sizes / 8 ( 7 longs and 2 ints):
+ * fOffset + fPacketSize + fContentSize + fTimestampBegin + fTimestampEnd +
+ * fEventsDiscarded + fStreamId + fStatus + fFlags
+ */
+ public static final int SIZE =
+ (Long.SIZE * 7 + Integer.SIZE * 2) / 8;
+
+ /** the offset */
+ private final long fOffset;
+ /** packet_size */
+ private final long fPacketSize;
+ /** the content size - how much of the packet is used */
+ private final long fContentSize;
+ /** timestamp of the beginning of the packet */
+ private final long fTimestampBegin;
+ /** timestamp of the end of the packet */
+ private final long fTimestampEnd;
+ /** number of discarded events BEFORE this packet */
+ private final long fEventsDiscarded;
+ /** the CTF stream id */
+ private final long fStreamId;
+ /** the status of the getNextIndex request */
+ private final NextIndexReturnCode fStatus;
+ /** whether there are new streams or metadata */
+ private final int fFlags;
+
+ /**
+ * IndexResposne from network
+ *
+ * @param inNet
+ * data input stream
+ * @throws IOException
+ * network error
+ */
+ public IndexResponse(DataInputStream inNet) throws IOException {
+ byte[] data = new byte[SIZE];
+ inNet.readFully(data);
+ ByteBuffer bb = ByteBuffer.wrap(data);
+ bb.order(ByteOrder.BIG_ENDIAN);
+ fOffset = bb.getLong();
+ fPacketSize = bb.getLong();
+ fContentSize = bb.getLong();
+ fTimestampBegin = bb.getLong();
+ fTimestampEnd = bb.getLong();
+ fEventsDiscarded = bb.getLong();
+ fStreamId = bb.getLong();
+ fStatus = NextIndexReturnCode.values()[bb.getInt() - 1];
+ fFlags = bb.getInt();
+ }
+
+ /**
+ * Gets the offset
+ *
+ * @return the offset
+ */
+ public long getOffset() {
+ return fOffset;
+ }
+
+ /**
+ * Gets the packet size
+ *
+ * @return the packet size
+ */
+ public long getPacketSize() {
+ return fPacketSize;
+ }
+
+ /**
+ * Gets the content size - how much of the packet is used
+ *
+ * @return the content size
+ */
+ public long getContentSize() {
+ return fContentSize;
+ }
+
+ /**
+ * Gets the timestamp of the beginning of the packet
+ *
+ * @return the timestamp of the beginning of the packet
+ */
+ public long getTimestampBegin() {
+ return fTimestampBegin;
+ }
+
+ /**
+ * Gets the timestamp of the end of the packet
+ *
+ * @return the timestamp of the end of the packet
+ */
+ public long getTimestampEnd() {
+ return fTimestampEnd;
+ }
+
+ /**
+ * Gets the number of discarded events BEFORE this packet
+ *
+ * @return the number of discarded events BEFORE this packet
+ */
+ public long getEventsDiscarded() {
+ return fEventsDiscarded;
+ }
+
+ /**
+ * Gets the CTF stream id
+ *
+ * @return the CTF stream id
+ */
+ public long getStreamId() {
+ return fStreamId;
+ }
+
+ /**
+ * Gets the status
+ *
+ * @return the status
+ */
+ public NextIndexReturnCode getStatus() {
+ return fStatus;
+ }
+
+ /**
+ * Gets the flags that describe whether there are new streams or metadata
+ *
+ * @return the flags
+ */
+ public int getFlags() {
+ return fFlags;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2014 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Matthew Khouzam - Initial implementation and API
+ * Marc-Andre Laperle - Initial implementation and API
+ **********************************************************************/
+
+package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands;
+
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.util.List;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableList.Builder;
+
+/**
+ * VIEWER_LIST_SESSIONS payload.
+ *
+ * @author Matthew Khouzam
+ */
+public class ListSessionsResponse implements IRelayResponse {
+
+ /**
+ * Response size (nbSessions)
+ */
+ public static final int PACKET_FIXED_SIZE = Integer.SIZE / 8;
+
+ /** the list of sessions */
+ private final List<SessionResponse> fSessionList;
+
+ /**
+ * List Sessions response from network
+ *
+ * @param inNet
+ * the network stream
+ * @throws IOException
+ * network error
+ */
+ public ListSessionsResponse(DataInputStream inNet) throws IOException {
+ byte[] data = new byte[PACKET_FIXED_SIZE];
+ inNet.readFully(data);
+ ByteBuffer bb = ByteBuffer.wrap(data);
+ bb.order(ByteOrder.BIG_ENDIAN);
+ int nbSessions = bb.getInt();
+ Builder<SessionResponse> sl = new ImmutableList.Builder<>();
+ for (int session = 0; session < nbSessions; session++) {
+ sl.add(new SessionResponse(inNet));
+ }
+ fSessionList = sl.build();
+ }
+
+ /**
+ * Gets the session list
+ *
+ * @return the sessions list
+ */
+ public List<SessionResponse> getSessionsList() {
+ return fSessionList;
+ }
+
+
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2014 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Matthew Khouzam - Initial implementation
+ **********************************************************************/
+
+package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands;
+
+/**
+ * LTTng Relay Daemon API. needs a TCP connection, API is defined from
+ * BSD-licensed implementation in Lttng tools: <a href=
+ * "http://git.lttng.org/?p=lttng-tools.git;a=blob;f=src/bin/lttng-relayd/lttng-viewer-abi.h"
+ * > src/bin/lttng-relayd/lttng-viewer-abi.h</a>
+ *
+ * @author Matthew Khouzam
+ */
+public interface LttngViewerCommands {
+
+ /** Maximum path name length */
+ static final int LTTNG_VIEWER_PATH_MAX = 4096;
+ /** Maximum name length */
+ static final int LTTNG_VIEWER_NAME_MAX = 255;
+ /** Maximum host name length */
+ static final int LTTNG_VIEWER_HOST_NAME_MAX = 64;
+ /** New stream in the trace */
+ static final int NEW_STREAM = (1 << 1);
+ /** New metadata in the trace */
+ static final int NEW_METADATA = (1 << 0);
+
+}
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2014 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Matthew Khouzam - Initial implementation and API
+ * Marc-Andre Laperle - Initial implementation and API
+ **********************************************************************/
+
+package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands;
+
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+
+/**
+ * Metadata packet response containing a packet of metadata
+ *
+ * @author Matthew Khouzam
+ */
+public class MetadataPacketResponse implements IRelayResponse {
+
+ /**
+ * Response size
+ *
+ * fData.length + fStatus
+ */
+ private static final int SIZE = (Long.SIZE + Integer.SIZE) / 8;
+ /** status of the metadata request */
+ private final GetMetadataReturnCode fStatus;
+ /** the packet */
+ private final byte fData[];
+
+ /**
+ * Read new metadata packet from the network
+ *
+ * @param inNet
+ * network input reader
+ * @throws IOException
+ * network error
+ */
+ public MetadataPacketResponse(DataInputStream inNet) throws IOException {
+ byte[] data = new byte[SIZE];
+ inNet.readFully(data);
+ ByteBuffer bb = ByteBuffer.wrap(data);
+ bb.order(ByteOrder.BIG_ENDIAN);
+ long length = bb.getLong();
+ fStatus = GetMetadataReturnCode.values()[bb.getInt() - 1];
+ if (length >= Integer.MAX_VALUE) {
+ throw new IOException("Metadata Packet too big " + length); //$NON-NLS-1$
+ }
+ fData = new byte[(int) length];
+ inNet.readFully(fData);
+ }
+
+ /**
+ * Get the packet
+ *
+ * @return the packet
+ */
+ public byte[] getData() {
+ return fData;
+ }
+
+ /**
+ * Gets the status
+ *
+ * @return the status
+ */
+ public GetMetadataReturnCode getStatus() {
+ return fStatus;
+ }
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2014 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Matthew Khouzam - Initial implementation and API
+ * Marc-Andre Laperle - Initial implementation and API
+ **********************************************************************/
+
+package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands;
+
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+
+/**
+ * LTTNG_VIEWER_GET_NEW_STREAMS payload.
+ *
+ * @author Matthew Khouzam
+ */
+public class NewStreamsRequest implements IRelayCommand {
+
+ /**
+ * Command size (fSessionId)
+ */
+ public static final int SIZE = Long.SIZE / 8;
+
+ /** session ID */
+ private final long fSessionId;
+
+ /**
+ * Constructor
+ *
+ * @param sessionId
+ * the session id we want
+ */
+ public NewStreamsRequest(long sessionId) {
+ fSessionId = sessionId;
+ }
+
+ @Override
+ public byte[] serialize() {
+ byte data[] = new byte[SIZE];
+ ByteBuffer bb = ByteBuffer.wrap(data);
+ bb.order(ByteOrder.BIG_ENDIAN);
+ bb.putLong(fSessionId);
+ return data;
+ }
+}
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2014 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Matthew Khouzam - Initial implementation and API
+ * Marc-Andre Laperle - Initial implementation and API
+ **********************************************************************/
+
+package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands;
+
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.util.List;
+
+import com.google.common.collect.ImmutableList;
+
+/**
+ * Response to a "new streams" command
+ *
+ * @author Matthew Khouzam
+ */
+public class NewStreamsResponse implements IRelayResponse {
+
+ /**
+ * Response size
+ *
+ * fStatus + fNbStreams
+ */
+ private static final int SIZE = (Integer.SIZE + Integer.SIZE) / 8;
+ /** status of the request */
+ private final NewStreamsReturnCode fStatus;
+ /** the number of streams */
+ private final int fNbStreams;
+ /** the list of streams in the response */
+ private final List<StreamResponse> fStreamList;
+
+ /**
+ * New stream response network constructor
+ *
+ * @param inNet
+ * network stream
+ * @throws IOException
+ * network error
+ */
+ public NewStreamsResponse(DataInputStream inNet) throws IOException {
+ byte[] data = new byte[SIZE];
+ inNet.readFully(data);
+ ByteBuffer bb = ByteBuffer.wrap(data);
+ bb.order(ByteOrder.BIG_ENDIAN);
+ fStatus = NewStreamsReturnCode.values()[bb.getInt() - 1];
+ fNbStreams = bb.getInt();
+ ImmutableList.Builder<StreamResponse> sl = new ImmutableList.Builder<>();
+ if (getStatus().equals(NewStreamsReturnCode.LTTNG_VIEWER_NEW_STREAMS_OK)) {
+ for (int stream = 0; stream < fNbStreams; stream++) {
+ sl.add(new StreamResponse(inNet));
+ }
+ }
+ fStreamList = sl.build();
+ }
+
+ /**
+ * Gets the status
+ *
+ * @return the status
+ */
+ public NewStreamsReturnCode getStatus() {
+ return fStatus;
+ }
+
+ /**
+ * gets the stream list
+ *
+ * @return the stream list
+ */
+ public List<StreamResponse> getStreamList() {
+ return fStreamList;
+ }
+
+ /**
+ * The number of streams
+ *
+ * @return the number of streams
+ */
+ public int getNbStreams() {
+ return fNbStreams;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2014 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Matthew Khouzam - Initial implementation and API
+ * Marc-Andre Laperle - Initial implementation and API
+ **********************************************************************/
+
+package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands;
+
+/**
+ * Return codes for "new streams" command
+ *
+ * @author Matthew Khouzam
+ */
+public enum NewStreamsReturnCode implements IBaseCommand {
+
+ /** If new streams are being sent. */
+ LTTNG_VIEWER_NEW_STREAMS_OK(1),
+ /** If no new streams are available. */
+ LTTNG_VIEWER_NEW_STREAMS_NO_NEW(2),
+ /** Error. */
+ LTTNG_VIEWER_NEW_STREAMS_ERR(3),
+ /** Session closed. */
+ LTTNG_VIEWER_NEW_STREAMS_HUP(4);
+
+ private final int fCode;
+
+ private NewStreamsReturnCode(int c) {
+ fCode = c;
+ }
+
+ @Override
+ public int getCommand() {
+ return fCode;
+ }
+}
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2014 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Matthew Khouzam - Initial implementation and API
+ * Marc-Andre Laperle - Initial implementation and API
+ **********************************************************************/
+
+package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands;
+
+/**
+ * Get next index return code (hope it's viewer_index_ok)
+ *
+ * @author Matthew Khouzam
+ */
+public enum NextIndexReturnCode implements IBaseCommand {
+
+ /** Index is available. */
+ VIEWER_INDEX_OK(1),
+ /** Index not yet available. */
+ VIEWER_INDEX_RETRY(2),
+ /** Index closed (trace destroyed). */
+ VIEWER_INDEX_HUP(3),
+ /** Unknown error. */
+ VIEWER_INDEX_ERR(4),
+ /** Inactive stream beacon. */
+ VIEWER_INDEX_INACTIVE(5),
+ /** End of index file. */
+ VIEWER_INDEX_EOF(6);
+
+ private final int fCode;
+
+ private NextIndexReturnCode(int c) {
+ fCode = c;
+ }
+
+ @Override
+ public int getCommand() {
+ return fCode;
+ }
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2014 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Matthew Khouzam - Initial implementation and API
+ * Marc-Andre Laperle - Initial implementation and API
+ **********************************************************************/
+
+package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands;
+
+/**
+ * Seek command
+ *
+ * @author Matthew Khouzam
+ */
+public enum SeekCommand implements IBaseCommand {
+
+ /** Receive the trace packets from the beginning. */
+ VIEWER_SEEK_BEGINNING(1),
+ /** Receive the trace packets from now. */
+ VIEWER_SEEK_LAST(2);
+
+ private final int fCode;
+
+ /**
+ * Command size (fCode)
+ */
+ public static final int SIZE = Integer.SIZE / 8;
+
+ private SeekCommand(int c) {
+ fCode = c;
+ }
+
+ @Override
+ public int getCommand() {
+ return fCode;
+ }
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2014 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Matthew Khouzam - Initial implementation and API
+ * Marc-Andre Laperle - Initial implementation and API
+ **********************************************************************/
+
+package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands;
+
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+
+/**
+ * Get viewer session response to command
+ *
+ * @author Matthew Khouzam
+ */
+public class SessionResponse implements IRelayResponse {
+
+ /**
+ * Response size
+ *
+ * fHostname + fSessionName + fId + fLiveTimer + fClients + fStreams
+ */
+ public static final int SIZE =
+ LttngViewerCommands.LTTNG_VIEWER_HOST_NAME_MAX + LttngViewerCommands.LTTNG_VIEWER_NAME_MAX + (Long.SIZE + Integer.SIZE + Integer.SIZE + Integer.SIZE) / 8;
+ /** id of the session */
+ private final long fId;
+ /** live timer */
+ private final int fLiveTimer;
+ /** number of clients */
+ private final int fClients;
+ /** number streams */
+ private final int fStreams;
+ /** Hostname, like 'localhost' */
+ private final String fHostname;
+ /** Session name, like 'streaming session' */
+ private final String fSessionName;
+
+ /**
+ * Session response network constructor
+ *
+ * @param inNet
+ * input network stream
+ * @throws IOException
+ * network error
+ */
+ public SessionResponse(DataInputStream inNet) throws IOException {
+ byte[] data = new byte[SIZE];
+ inNet.readFully(data);
+ ByteBuffer bb = ByteBuffer.wrap(data);
+ bb.order(ByteOrder.BIG_ENDIAN);
+ fId = bb.getLong();
+ fLiveTimer = bb.getInt();
+ fClients = bb.getInt();
+ fStreams = bb.getInt();
+ byte[] hostName = new byte[LttngViewerCommands.LTTNG_VIEWER_HOST_NAME_MAX];
+ byte[] sessionName = new byte[LttngViewerCommands.LTTNG_VIEWER_NAME_MAX];
+ bb.get(hostName, 0, hostName.length);
+ bb.get(sessionName, 0, sessionName.length);
+ fHostname = new String(hostName);
+ fSessionName = new String(sessionName);
+ }
+
+ /**
+ * Gets the id of the session
+ *
+ * @return the id of the session
+ */
+ public long getId() {
+ return fId;
+ }
+
+ /**
+ * Gets the live timer
+ *
+ * @return the live timer
+ */
+ public int getLiveTimer() {
+ return fLiveTimer;
+ }
+
+ /**
+ * Gets the number of clients
+ *
+ * @return the number of clients
+ */
+ public int getClients() {
+ return fClients;
+ }
+
+ /**
+ * Gets the number streams
+ *
+ * @return the number streams
+ */
+ public int getStreams() {
+ return fStreams;
+ }
+
+ /**
+ * Gets the Hostname
+ *
+ * @return the Hostname
+ */
+ public String getHostname() {
+ return fHostname;
+ }
+
+ /**
+ * Gets the session name
+ *
+ * @return the session name
+ */
+ public String getSessionName() {
+ return fSessionName;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2014 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Matthew Khouzam - Initial implementation and API
+ * Marc-Andre Laperle - Initial implementation and API
+ **********************************************************************/
+
+package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands;
+
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+
+/**
+ * Get response of viewer stream
+ *
+ * @author Matthew Khouzam
+ */
+public class StreamResponse implements IRelayResponse {
+
+ /**
+ * Response size
+ *
+ * fId + fCtfTraceId + fMetadataFlag + fPathName + fChannelName
+ */
+ public static final int SIZE = (Long.SIZE + Long.SIZE + Integer.SIZE) / 8 + LttngViewerCommands.LTTNG_VIEWER_PATH_MAX + LttngViewerCommands.LTTNG_VIEWER_NAME_MAX;
+
+ /**
+ * id of the stream
+ */
+ private final long fId;
+ /**
+ * It is guaranteed to be unique, because the value is assigned sequentially
+ * by the relay.
+ */
+ private final long fCtfTraceId;
+ /**
+ * if the stream is a metadata stream
+ */
+ private final int fMetadataFlag;
+ /**
+ * the path
+ */
+ private final String fPathName;
+ /**
+ * The channel, traditionally channel0
+ */
+ private final String fChannelName;
+
+ /**
+ * Stream response
+ *
+ * @param inNet
+ * input data stream
+ * @throws IOException
+ * network time
+ */
+ public StreamResponse(DataInputStream inNet) throws IOException {
+ byte[] streamData = new byte[SIZE];
+ inNet.readFully(streamData, 0, SIZE);
+ ByteBuffer bb = ByteBuffer.wrap(streamData);
+ bb.order(ByteOrder.BIG_ENDIAN);
+ fId = (bb.getLong());
+ fCtfTraceId = bb.getLong();
+ fMetadataFlag = bb.getInt();
+ byte pathName[] = new byte[LttngViewerCommands.LTTNG_VIEWER_PATH_MAX];
+ byte channelName[] = new byte[LttngViewerCommands.LTTNG_VIEWER_NAME_MAX];
+ bb.get(pathName, 0, LttngViewerCommands.LTTNG_VIEWER_PATH_MAX);
+ bb.get(channelName, 0, LttngViewerCommands.LTTNG_VIEWER_NAME_MAX);
+ fPathName = new String(pathName);
+ fChannelName = new String(channelName);
+ }
+
+ /**
+ * Get the id
+ *
+ * @return the Id
+ */
+ public long getId() {
+ return fId;
+ }
+
+ /**
+ * Get the CtfTraceId
+ *
+ * @return the CtfTraceId
+ */
+ public long getCtfTraceId() {
+ return fCtfTraceId;
+ }
+
+ /**
+ * Get the metadata flag
+ *
+ * @return the MetadataFlag
+ */
+ public int getMetadataFlag() {
+ return fMetadataFlag;
+ }
+
+ /**
+ * Get the path name
+ *
+ * @return the PathName
+ */
+ public String getPathName() {
+ return fPathName;
+ }
+
+ /**
+ * get the Channel name
+ *
+ * @return the ChannelName
+ */
+ public String getChannelName() {
+ return fChannelName;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2014 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Matthew Khouzam - Initial implementation and API
+ * Marc-Andre Laperle - Initial implementation and API
+ **********************************************************************/
+
+package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands;
+
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+
+/**
+ * Response to getpacket command
+ *
+ * @author Matthew Khouzam
+ */
+public class TracePacketResponse implements IRelayResponse {
+
+ /**
+ * Command size
+ *
+ * fStatus + fData.length + fFlags
+ */
+ private static final int SIZE = (Integer.SIZE + Integer.SIZE + Integer.SIZE) / 8;
+ /** Enum lttng_viewer_get_packet_return_code */
+ private final GetPacketReturnCode fStatus;
+ /** flags: is there new metadata or new streams? */
+ private final int fFlags;
+ /** the packet */
+ private final byte[] fData;
+
+ /**
+ * Trace packet response network constructor
+ *
+ * @param inNet
+ * network input stream
+ * @throws IOException
+ * network error
+ */
+ public TracePacketResponse(DataInputStream inNet) throws IOException {
+ byte[] data = new byte[SIZE];
+ inNet.readFully(data);
+ ByteBuffer bb = ByteBuffer.wrap(data);
+ bb.order(ByteOrder.BIG_ENDIAN);
+ fStatus = GetPacketReturnCode.values()[bb.getInt() - 1];
+ int length = bb.getInt();
+ fFlags = bb.getInt();
+ if (fStatus.equals(GetPacketReturnCode.VIEWER_GET_PACKET_OK)) {
+ fData = new byte[length];
+ inNet.readFully(fData);
+ } else {
+ fData = new byte[0];
+ }
+ }
+
+ /**
+ * Get the status
+ *
+ * @return the Status
+ */
+ public GetPacketReturnCode getStatus() {
+ return fStatus;
+ }
+
+ /**
+ * Get the flags
+ *
+ * @return the Flags
+ */
+ public int getFlags() {
+ return fFlags;
+ }
+
+ /**
+ * Get the packet data, please do not modify the data
+ *
+ * @return the Data
+ */
+ public byte[] getData() {
+ return fData;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**********************************************************************
+ * Copyright (c) 2014 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Matthew Khouzam - Initial implementation and API
+ * Marc-Andre Laperle - Initial implementation and API
+ **********************************************************************/
+
+package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands;
+
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+
+/**
+ * The LTTng command
+ *
+ * @author Matthew Khouzam
+ */
+public class ViewerCommand implements IRelayCommand {
+
+ /**
+ * Command size
+ *
+ * fDataSize + fCmdVersion + fCmd
+ */
+ public static final int SIZE = (Long.SIZE + Integer.SIZE) / 8 + Command.SIZE;
+ /**
+ * data size following this header, you normally attach a payload that one,
+ * in bytes
+ */
+ private final long fDataSize;
+ /** enum lttcomm_relayd_command */
+ private final Command fCmd;
+ /** command version */
+ private final int fCmdVersion;
+
+ /**
+ * Sets the packet command
+ *
+ * @param viewerConnect
+ * the command
+ * @param size size of the command
+ * @param version the version number
+ */
+ public ViewerCommand(Command viewerConnect, long size, int version) {
+ fCmd = viewerConnect;
+ fDataSize = size;
+ fCmdVersion = version;
+ }
+
+ /**
+ * Get the data size
+ *
+ * @return the DataSize
+ */
+ public long getDataSize() {
+ return fDataSize;
+ }
+
+ /**
+ * Get the command
+ *
+ * @return the Cmd
+ */
+ public Command getCmd() {
+ return fCmd;
+ }
+
+ /**
+ * Get the command version
+ *
+ * @return the CmdVersion
+ */
+ public int getCmdVersion() {
+ return fCmdVersion;
+ }
+
+ @Override
+ public byte[] serialize() {
+ byte data[] = new byte[SIZE];
+ ByteBuffer bb = ByteBuffer.wrap(data);
+ bb.order(ByteOrder.BIG_ENDIAN);
+ bb.putLong(getDataSize());
+ bb.putInt(getCmd().getCommand());
+ bb.putInt(fCmdVersion);
+ return data;
+ }
+
+
+}
\ No newline at end of file
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.ILttngRelaydConnector;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.AttachSessionRequest;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.AttachSessionResponse;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.Command;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.ConnectResponse;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.CreateSessionResponse;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.GetMetadata;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.GetNextIndex;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.GetPacket;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.IndexResponse;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.ListSessionsResponse;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.MetadataPacketResponse;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.NewStreamsResponse;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.NextIndexReturnCode;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.SeekCommand;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.SessionResponse;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.StreamResponse;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.TracePacketResponse;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.ViewerCommand;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.AttachSessionRequest;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.AttachSessionResponse;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.Command;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.ConnectResponse;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.CreateSessionResponse;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.GetMetadata;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.GetNextIndex;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.GetPacket;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.IndexResponse;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.ListSessionsResponse;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.MetadataPacketResponse;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.NewStreamsResponse;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.NextIndexReturnCode;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.SeekCommand;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.SessionResponse;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.StreamResponse;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.TracePacketResponse;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.ViewerCommand;
/**
* Lttng 2.4 implementation
import java.util.List;
import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.ILttngRelaydConnector;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.AttachSessionResponse;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.CreateSessionResponse;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.IndexResponse;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.SessionResponse;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.StreamResponse;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.TracePacketResponse;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.AttachSessionResponse;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.CreateSessionResponse;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.IndexResponse;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.SessionResponse;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.StreamResponse;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.TracePacketResponse;
/**
* Unsupported version of the relay daemon
+++ /dev/null
-/**********************************************************************
- * Copyright (c) 2014 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Matthew Khouzam - Initial implementation and API
- * Marc-Andre Laperle - Initial implementation and API
- **********************************************************************/
-
-package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands;
-
-/**
- * Return codes for "viewer attach" command
- *
- * @author Matthew Khouzam
- */
-public enum AttachReturnCode implements IBaseCommand {
-
- /** If the attach command succeeded. */
- VIEWER_ATTACH_OK(1),
- /** If a viewer is already attached. */
- VIEWER_ATTACH_ALREADY(2),
- /** If the session ID is unknown. */
- VIEWER_ATTACH_UNK(3),
- /** If the session is not live. */
- VIEWER_ATTACH_NOT_LIVE(4),
- /** Seek error. */
- VIEWER_ATTACH_SEEK_ERR(5),
- /** No session */
- VIEWER_ATTACH_NO_SESSION(6);
-
- private final int fCode;
-
- private AttachReturnCode(int c) {
- fCode = c;
- }
-
- @Override
- public int getCommand() {
- return fCode;
- }
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * Copyright (c) 2014 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Matthew Khouzam - Initial implementation and API
- * Marc-Andre Laperle - Initial implementation and API
- **********************************************************************/
-
-package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands;
-
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-/**
- * VIEWER_ATTACH_SESSION payload.
- *
- * @author Matthew Khouzam
- */
-public class AttachSessionRequest implements IRelayCommand {
-
- /**
- * Command size
- *
- * fSessionId + fOffset + fSeek
- */
- public static final int SIZE = (Long.SIZE + Long.SIZE) / 8 + SeekCommand.SIZE;
- /** the id of a session */
- private final long fSessionId;
- /** unused for now */
- private final long fOffset;
- /** enum lttng_viewer_seek */
- private final SeekCommand fSeek;
-
- /**
- * Attach session request constructor
- *
- * @param id
- * the session id
- * @param seekCommand
- * the seek command
- */
- public AttachSessionRequest(long id, SeekCommand seekCommand) {
- this(id, 0, seekCommand);
- }
-
- /**
- * Attach session request constructor
- *
- * @param id
- * the session id
- * @param offset
- * unused for now
- * @param seekCommand
- * the seek command
- */
-
- public AttachSessionRequest(long id, int offset, SeekCommand seekCommand) {
- fSessionId = id;
- fOffset = offset;
- fSeek = seekCommand;
-
- }
-
- @Override
- public byte[] serialize() {
- byte data[] = new byte[SIZE];
- ByteBuffer bb = ByteBuffer.wrap(data);
- bb.order(ByteOrder.BIG_ENDIAN);
- bb.putLong(fSessionId);
- bb.putLong(fOffset);
- bb.putInt(fSeek.getCommand());
- return data;
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * Copyright (c) 2014 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Matthew Khouzam - Initial implementation and API
- * Marc-Andre Laperle - Initial implementation and API
- **********************************************************************/
-
-package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands;
-
-import java.io.DataInputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.util.List;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableList.Builder;
-
-/**
- * Attach session response
- *
- * @author Matthew Khouzam
- */
-public class AttachSessionResponse implements IRelayResponse {
-
- /**
- * Response size
- *
- * fStatus + fStreamsCount (first half of a packet) */
- private static final int SIZE = (Integer.SIZE + Integer.SIZE) / 8;
- /** enum lttng_viewer_attach_return_code */
- private final AttachReturnCode fStatus;
- /** how many streams are there */
- private final int fStreamsCount;
- /** public class lttng_viewer_stream */
- private final List<StreamResponse> fStreamList;
-
- /**
- * Attach session response network constructor
- *
- * @param inNet
- * network input stream
- * @throws IOException
- * network error
- */
- public AttachSessionResponse(DataInputStream inNet) throws IOException {
- byte[] data = new byte[SIZE];
- inNet.readFully(data, 0, SIZE);
- ByteBuffer bb = ByteBuffer.wrap(data);
- bb.order(ByteOrder.BIG_ENDIAN);
- fStatus = AttachReturnCode.values()[bb.getInt() - 1];
- fStreamsCount = bb.getInt();
- Builder<StreamResponse> streamResponses = ImmutableList.builder();
- for (int i = 0; i < getNbStreams(); i++) {
- streamResponses.add(new StreamResponse(inNet));
- }
- fStreamList = streamResponses.build();
-
- }
-
- /**
- * Gets the Status
- *
- * @return the Status
- */
- public AttachReturnCode getStatus() {
- return fStatus;
- }
-
- /**
- * Gets the StreamsCount
- *
- * @return the StreamsCount
- */
- public int getNbStreams() {
- return fStreamsCount;
- }
-
- /**
- * Gets the StreamList
- *
- * @return the StreamList
- */
- public List<StreamResponse> getStreamList() {
- return fStreamList;
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * Copyright (c) 2014 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Matthew Khouzam - Initial implementation and API
- * Marc-Andre Laperle - Initial implementation and API
- **********************************************************************/
-
-package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands;
-
-/**
- * Viewer commands
- *
- * @author Matthew Khouzam
- */
-public enum Command implements IBaseCommand {
-
- /** get version */
- VIEWER_CONNECT(1),
- /** list all lttng sessions */
- VIEWER_LIST_SESSIONS(2),
- /** attach to a session */
- VIEWER_ATTACH_SESSION(3),
- /** get the next index */
- VIEWER_GET_NEXT_INDEX(4),
- /** get packet */
- VIEWER_GET_PACKET(5),
- /** get metadata */
- VIEWER_GET_METADATA(6),
- /** get new streams */
- VIEWER_GET_NEW_STREAMS(7),
- /** create a new session */
- VIEWER_CREATE_SESSION(8);
-
- /**
- * Command size (fCode)
- */
- public static final int SIZE = Integer.SIZE / 8;
-
- private final int fCode;
-
- private Command(int c) {
- fCode = c;
- }
-
- @Override
- public int getCommand() {
- return fCode;
- }
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * Copyright (c) 2014 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Matthew Khouzam - Initial implementation and API
- * Marc-Andre Laperle - Initial implementation and API
- **********************************************************************/
-
-package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands;
-
-import java.io.DataInputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-/**
- * CONNECT payload.
- *
- * @author Matthew Khouzam
- */
-public class ConnectResponse implements IRelayResponse, IRelayCommand {
-
- /**
- * Response or command size
- *
- * fViewerSessionId + fMajor + fMinor + fType
- */
- public static final int SIZE = (Long.SIZE + Integer.SIZE + Integer.SIZE + Integer.SIZE) / 8;
- /** session id, counts from 1 and increments by session */
- private final long fViewerSessionId;
- /**
- * Major version, hint, it's at least 2
- */
- private final int fMajor;
- /**
- * Minor version, hint, it's at least 4
- */
- private final int fMinor;
- /**
- * type of connect to {@link ConnectionType}
- */
- private final ConnectionType fType;
-
- /**
- * Connection response reply constructor
- *
- * @param inStream
- * the data input stream
- * @throws IOException
- * a network error
- */
- public ConnectResponse(DataInputStream inStream) throws IOException {
- byte data[] = new byte[SIZE];
- inStream.readFully(data);
- ByteBuffer bb = ByteBuffer.wrap(data);
- bb.order(ByteOrder.BIG_ENDIAN);
- fViewerSessionId = bb.getLong();
- fMajor = bb.getInt();
- fMinor = bb.getInt();
- bb.getInt(); // Should not be used, see http://bugs.lttng.org/issues/728
- fType = ConnectionType.VIEWER_CLIENT_COMMAND;
- }
-
- /**
- * Constructor for command
- *
- * @param sessionID
- * session id
- * @param major
- * the major version
- * @param minor
- * the minor version
- * @param connection
- * the connection type, typically VIEWER_CLIENT_COMMAND
- */
- public ConnectResponse(long sessionID, int major, int minor, ConnectionType connection) {
- fViewerSessionId = sessionID;
- fMajor = major;
- fMinor = minor;
- fType = connection;
- }
-
- /**
- * get the major version
- *
- * @return the major version
- */
- public int getMajor() {
- return fMajor;
- }
-
- /**
- * get the minor version
- *
- * @return the minor version
- */
- public int getMinor() {
- return fMinor;
- }
-
- @Override
- public byte[] serialize() {
- byte data[] = new byte[SIZE];
- ByteBuffer bb = ByteBuffer.wrap(data);
- bb.order(ByteOrder.BIG_ENDIAN);
- bb.putLong(fViewerSessionId);
- bb.putInt(fMajor);
- bb.putInt(fMinor);
- bb.putInt(fType.getCommand());
- return data;
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * Copyright (c) 2014 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Matthew Khouzam - Initial implementation and API
- * Marc-Andre Laperle - Initial implementation and API
- **********************************************************************/
-
-package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands;
-
-/**
- * Get viewer connection type
- *
- * @author Matthew Khouzam
- */
-public enum ConnectionType implements IBaseCommand {
-
- /** Command sent */
- VIEWER_CLIENT_COMMAND(1),
- /** Notification sent */
- VIEWER_CLIENT_NOTIFICATION(2);
-
- private final int fCode;
-
- private ConnectionType(int c) {
- fCode = c;
- }
-
- @Override
- public int getCommand() {
- return fCode;
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * Copyright (c) 2014 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Matthew Khouzam - Initial implementation and API
- * Marc-Andre Laperle - Initial implementation and API
- **********************************************************************/
-
-package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands;
-
-import java.io.DataInputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-/**
- * Response to a "create session" command
- *
- * @author Matthew Khouzam
- */
-public class CreateSessionResponse implements IRelayResponse {
-
- /**
- * Response size (fStatus)
- */
- public static final int SIZE = Integer.SIZE / 8;
-
- /** enum lttng_viewer_create_session_return_code */
- private final CreateSessionReturnCode fStatus;
-
- /**
- * Create session response network constructor
- *
- * @param inNet
- * network input stream
- * @throws IOException
- * network error
- */
- public CreateSessionResponse(DataInputStream inNet) throws IOException {
- byte[] data = new byte[SIZE];
- inNet.readFully(data);
- ByteBuffer bb = ByteBuffer.wrap(data);
- bb.order(ByteOrder.BIG_ENDIAN);
- fStatus = (CreateSessionReturnCode.values()[bb.getInt() - 1]);
- }
-
- /**
- * Get status
- *
- * @return the status
- */
- public CreateSessionReturnCode getStatus() {
- return fStatus;
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * Copyright (c) 2014 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Matthew Khouzam - Initial implementation and API
- * Marc-Andre Laperle - Initial implementation and API
- **********************************************************************/
-
-package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands;
-
-/**
- * Create new session return code
- *
- * @author Matthew Khouzam
- */
-public enum CreateSessionReturnCode implements IBaseCommand {
-
- /** If new streams are being sent. */
- LTTNG_VIEWER_CREATE_SESSION_OK(1),
- /** Fatal error on the server-side. */
- LTTNG_VIEWER_CREATE_SESSION_ERR(2);
-
- private final int fCode;
-
- private CreateSessionReturnCode(int c) {
- fCode = c;
- }
-
- @Override
- public int getCommand() {
- return fCode;
- }
-}
+++ /dev/null
-/**********************************************************************
- * Copyright (c) 2014 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Matthew Khouzam - Initial implementation and API
- * Marc-Andre Laperle - Initial implementation and API
- **********************************************************************/
-
-package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands;
-
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-/**
- * VIEWER_GET_METADATA payload.
- *
- * @author Matthew Khouzam
- */
-public class GetMetadata implements IRelayCommand {
-
- /**
- * Command size (fStreamId)
- */
- public static final int SIZE = Long.SIZE / 8;
-
- /**
- * The stream id
- */
- private final long fStreamId;
-
- /**
- * Set the stream id
- *
- * @param streamId
- * the stream id
- */
- public GetMetadata(long streamId) {
- fStreamId = streamId;
- }
-
- /**
- * Get the stream id
- *
- * @return the stream id
- */
- public long getStreamId() {
- return fStreamId;
- }
-
- @Override
- public byte[] serialize() {
- byte data[] = new byte[SIZE];
- ByteBuffer bb = ByteBuffer.wrap(data);
- bb.order(ByteOrder.BIG_ENDIAN);
- bb.putLong(getStreamId());
- return data;
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * Copyright (c) 2014 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Matthew Khouzam - Initial implementation and API
- * Marc-Andre Laperle - Initial implementation and API
- **********************************************************************/
-
-package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands;
-
-/**
- * Get metadata return code
- *
- * @author Matthew Khouzam
- */
-public enum GetMetadataReturnCode implements IBaseCommand {
-
- /** Response was OK */
- VIEWER_METADATA_OK(1),
- /** Response was nothing new */
- VIEWER_NO_NEW_METADATA(2),
- /** Response was Error */
- VIEWER_METADATA_ERR(3);
-
- private final int fCode;
-
- private GetMetadataReturnCode(int c) {
- fCode = c;
- }
-
- @Override
- public int getCommand() {
- return fCode;
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * Copyright (c) 2014 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Matthew Khouzam - Initial implementation and API
- * Marc-Andre Laperle - Initial implementation and API
- **********************************************************************/
-
-package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands;
-
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-/**
- * VIEWER_GET_NEXT_INDEX payload.
- *
- * @author Matthew Khouzam
- */
-public class GetNextIndex implements IRelayCommand {
-
- /**
- * Command size (fStreamId)
- */
- public static final int SIZE = Long.SIZE / 8;
- /**
- * the id of the stream
- */
- private final long fStreamId;
-
- /**
- * Constructor
- *
- * @param streamId
- * the index stream id
- */
- public GetNextIndex(long streamId) {
- fStreamId = streamId;
- }
-
- /**
- * Gets the stream id
- *
- * @return the stream id
- */
- public long getStreamId() {
- return fStreamId;
- }
-
- @Override
- public byte[] serialize() {
- byte data[] = new byte[SIZE];
- ByteBuffer bb = ByteBuffer.wrap(data);
- bb.order(ByteOrder.BIG_ENDIAN);
- bb.putLong(getStreamId());
- return data;
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * Copyright (c) 2014 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Matthew Khouzam - Initial implementation and API
- * Marc-Andre Laperle - Initial implementation and API
- **********************************************************************/
-
-package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands;
-
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-/**
- * VIEWER_GET_PACKET payload.
- *
- * @author Matthew Khouzam
- */
-public class GetPacket implements IRelayCommand {
-
- /**
- * Command size
- *
- * fStreamId + fOffset + fLength
- */
- public static final int SIZE = (Long.SIZE + Long.SIZE + Integer.SIZE) / 8;
- /** the stream Id */
- private final long fStreamId;
- /** the offset */
- private final long fOffset;
- /** the length of the packet */
- private final int fLength;
-
- /**
- * Get packet constructor
- *
- * @param streamId
- * the stream id
- * @param offset
- * the offset
- * @param length
- * the packet length
- */
- public GetPacket(long streamId, long offset, int length) {
- fStreamId = streamId;
- fOffset = offset;
- fLength = length;
- }
-
- /**
- * Get the length of the packet
- *
- * @return the length of the packet in bytes
- */
- public int getLength() {
- return fLength;
- }
-
- /**
- * Gets the offset of the packet
- *
- * @return the offset
- */
- public long getOffset() {
- return fOffset;
- }
-
- /**
- * Gets the stream id
- *
- * @return the stream id
- */
- public long getStreamId() {
- return fStreamId;
- }
-
- @Override
- public byte[] serialize() {
- byte data[] = new byte[SIZE];
- ByteBuffer bb = ByteBuffer.wrap(data);
- bb.order(ByteOrder.BIG_ENDIAN);
- bb.putLong(getStreamId());
- bb.putLong(getOffset());
- bb.putInt(getLength());
- return data;
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * Copyright (c) 2014 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Matthew Khouzam - Initial implementation and API
- * Marc-Andre Laperle - Initial implementation and API
- **********************************************************************/
-
-package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands;
-
-/**
- * Get packet return code
- *
- * @author Matthew Khouzam
- */
-public enum GetPacketReturnCode implements IBaseCommand {
-
- /** Response was OK */
- VIEWER_GET_PACKET_OK(1),
- /** Response was RETRY */
- VIEWER_GET_PACKET_RETRY(2),
- /** Response was ERROR */
- VIEWER_GET_PACKET_ERR(3),
- /** Response was End of File */
- VIEWER_GET_PACKET_EOF(4);
-
- private final int fCode;
-
- private GetPacketReturnCode(int c) {
- fCode = c;
- }
-
- @Override
- public int getCommand() {
- return fCode;
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * Copyright (c) 2014 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Matthew Khouzam - Initial implementation and API
- * Marc-Andre Laperle - Initial implementation and API
- **********************************************************************/
-
-package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands;
-
-/**
- * Instruction to send to relayd
- *
- * @author Matthew Khouzam
- */
-public interface IBaseCommand {
-
- /**
- * gets the numerical value of the command
- *
- * @return the numerical value of the command
- */
- int getCommand();
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * Copyright (c) 2014 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Matthew Khouzam - Initial implementation and API
- * Marc-Andre Laperle - Initial implementation and API
- **********************************************************************/
-
-package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands;
-
-
-/**
- * Command sent, needs a getBytes to stream the data
- *
- * @author Matthew Khouzam
- */
-public interface IRelayCommand {
-
- /**
- * Gets a byte array of the command so that it may be streamed
- *
- * @return the byte array of the command
- */
- byte[] serialize();
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * Copyright (c) 2014 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Matthew Khouzam - Initial implementation and API
- * Marc-Andre Laperle - Initial implementation and API
- **********************************************************************/
-
-package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands;
-
-/**
- * Command response, this will allow sorting commands easier
- *
- * @author Matthew Khouzam
- */
-public interface IRelayResponse {
-
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * Copyright (c) 2014 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Matthew Khouzam - Initial implementation and API
- * Marc-Andre Laperle - Initial implementation and API
- **********************************************************************/
-
-package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands;
-
-import java.io.DataInputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-/**
- * An Lttng packet index
- *
- * @author Matthew Khouzam
- */
-public class IndexResponse implements IRelayResponse {
-
- /**
- * Command size
- *
- * Sum of the field sizes / 8 ( 7 longs and 2 ints):
- * fOffset + fPacketSize + fContentSize + fTimestampBegin + fTimestampEnd +
- * fEventsDiscarded + fStreamId + fStatus + fFlags
- */
- public static final int SIZE =
- (Long.SIZE * 7 + Integer.SIZE * 2) / 8;
-
- /** the offset */
- private final long fOffset;
- /** packet_size */
- private final long fPacketSize;
- /** the content size - how much of the packet is used */
- private final long fContentSize;
- /** timestamp of the beginning of the packet */
- private final long fTimestampBegin;
- /** timestamp of the end of the packet */
- private final long fTimestampEnd;
- /** number of discarded events BEFORE this packet */
- private final long fEventsDiscarded;
- /** the CTF stream id */
- private final long fStreamId;
- /** the status of the getNextIndex request */
- private final NextIndexReturnCode fStatus;
- /** whether there are new streams or metadata */
- private final int fFlags;
-
- /**
- * IndexResposne from network
- *
- * @param inNet
- * data input stream
- * @throws IOException
- * network error
- */
- public IndexResponse(DataInputStream inNet) throws IOException {
- byte[] data = new byte[SIZE];
- inNet.readFully(data);
- ByteBuffer bb = ByteBuffer.wrap(data);
- bb.order(ByteOrder.BIG_ENDIAN);
- fOffset = bb.getLong();
- fPacketSize = bb.getLong();
- fContentSize = bb.getLong();
- fTimestampBegin = bb.getLong();
- fTimestampEnd = bb.getLong();
- fEventsDiscarded = bb.getLong();
- fStreamId = bb.getLong();
- fStatus = NextIndexReturnCode.values()[bb.getInt() - 1];
- fFlags = bb.getInt();
- }
-
- /**
- * Gets the offset
- *
- * @return the offset
- */
- public long getOffset() {
- return fOffset;
- }
-
- /**
- * Gets the packet size
- *
- * @return the packet size
- */
- public long getPacketSize() {
- return fPacketSize;
- }
-
- /**
- * Gets the content size - how much of the packet is used
- *
- * @return the content size
- */
- public long getContentSize() {
- return fContentSize;
- }
-
- /**
- * Gets the timestamp of the beginning of the packet
- *
- * @return the timestamp of the beginning of the packet
- */
- public long getTimestampBegin() {
- return fTimestampBegin;
- }
-
- /**
- * Gets the timestamp of the end of the packet
- *
- * @return the timestamp of the end of the packet
- */
- public long getTimestampEnd() {
- return fTimestampEnd;
- }
-
- /**
- * Gets the number of discarded events BEFORE this packet
- *
- * @return the number of discarded events BEFORE this packet
- */
- public long getEventsDiscarded() {
- return fEventsDiscarded;
- }
-
- /**
- * Gets the CTF stream id
- *
- * @return the CTF stream id
- */
- public long getStreamId() {
- return fStreamId;
- }
-
- /**
- * Gets the status
- *
- * @return the status
- */
- public NextIndexReturnCode getStatus() {
- return fStatus;
- }
-
- /**
- * Gets the flags that describe whether there are new streams or metadata
- *
- * @return the flags
- */
- public int getFlags() {
- return fFlags;
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * Copyright (c) 2014 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Matthew Khouzam - Initial implementation and API
- * Marc-Andre Laperle - Initial implementation and API
- **********************************************************************/
-
-package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands;
-
-import java.io.DataInputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.util.List;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableList.Builder;
-
-/**
- * VIEWER_LIST_SESSIONS payload.
- *
- * @author Matthew Khouzam
- */
-public class ListSessionsResponse implements IRelayResponse {
-
- /**
- * Response size (nbSessions)
- */
- public static final int PACKET_FIXED_SIZE = Integer.SIZE / 8;
-
- /** the list of sessions */
- private final List<SessionResponse> fSessionList;
-
- /**
- * List Sessions response from network
- *
- * @param inNet
- * the network stream
- * @throws IOException
- * network error
- */
- public ListSessionsResponse(DataInputStream inNet) throws IOException {
- byte[] data = new byte[PACKET_FIXED_SIZE];
- inNet.readFully(data);
- ByteBuffer bb = ByteBuffer.wrap(data);
- bb.order(ByteOrder.BIG_ENDIAN);
- int nbSessions = bb.getInt();
- Builder<SessionResponse> sl = new ImmutableList.Builder<>();
- for (int session = 0; session < nbSessions; session++) {
- sl.add(new SessionResponse(inNet));
- }
- fSessionList = sl.build();
- }
-
- /**
- * Gets the session list
- *
- * @return the sessions list
- */
- public List<SessionResponse> getSessionsList() {
- return fSessionList;
- }
-
-
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * Copyright (c) 2014 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Matthew Khouzam - Initial implementation
- **********************************************************************/
-
-package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands;
-
-/**
- * LTTng Relay Daemon API. needs a TCP connection, API is defined from
- * BSD-licensed implementation in Lttng tools: <a href=
- * "http://git.lttng.org/?p=lttng-tools.git;a=blob;f=src/bin/lttng-relayd/lttng-viewer-abi.h"
- * > src/bin/lttng-relayd/lttng-viewer-abi.h</a>
- *
- * @author Matthew Khouzam
- */
-public interface LttngViewerCommands {
-
- /** Maximum path name length */
- static final int LTTNG_VIEWER_PATH_MAX = 4096;
- /** Maximum name length */
- static final int LTTNG_VIEWER_NAME_MAX = 255;
- /** Maximum host name length */
- static final int LTTNG_VIEWER_HOST_NAME_MAX = 64;
- /** New stream in the trace */
- static final int NEW_STREAM = (1 << 1);
- /** New metadata in the trace */
- static final int NEW_METADATA = (1 << 0);
-
-}
+++ /dev/null
-/**********************************************************************
- * Copyright (c) 2014 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Matthew Khouzam - Initial implementation and API
- * Marc-Andre Laperle - Initial implementation and API
- **********************************************************************/
-
-package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands;
-
-import java.io.DataInputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-/**
- * Metadata packet response containing a packet of metadata
- *
- * @author Matthew Khouzam
- */
-public class MetadataPacketResponse implements IRelayResponse {
-
- /**
- * Response size
- *
- * fData.length + fStatus
- */
- private static final int SIZE = (Long.SIZE + Integer.SIZE) / 8;
- /** status of the metadata request */
- private final GetMetadataReturnCode fStatus;
- /** the packet */
- private final byte fData[];
-
- /**
- * Read new metadata packet from the network
- *
- * @param inNet
- * network input reader
- * @throws IOException
- * network error
- */
- public MetadataPacketResponse(DataInputStream inNet) throws IOException {
- byte[] data = new byte[SIZE];
- inNet.readFully(data);
- ByteBuffer bb = ByteBuffer.wrap(data);
- bb.order(ByteOrder.BIG_ENDIAN);
- long length = bb.getLong();
- fStatus = GetMetadataReturnCode.values()[bb.getInt() - 1];
- if (length >= Integer.MAX_VALUE) {
- throw new IOException("Metadata Packet too big " + length); //$NON-NLS-1$
- }
- fData = new byte[(int) length];
- inNet.readFully(fData);
- }
-
- /**
- * Get the packet
- *
- * @return the packet
- */
- public byte[] getData() {
- return fData;
- }
-
- /**
- * Gets the status
- *
- * @return the status
- */
- public GetMetadataReturnCode getStatus() {
- return fStatus;
- }
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * Copyright (c) 2014 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Matthew Khouzam - Initial implementation and API
- * Marc-Andre Laperle - Initial implementation and API
- **********************************************************************/
-
-package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands;
-
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-/**
- * LTTNG_VIEWER_GET_NEW_STREAMS payload.
- *
- * @author Matthew Khouzam
- */
-public class NewStreamsRequest implements IRelayCommand {
-
- /**
- * Command size (fSessionId)
- */
- public static final int SIZE = Long.SIZE / 8;
-
- /** session ID */
- private final long fSessionId;
-
- /**
- * Constructor
- *
- * @param sessionId
- * the session id we want
- */
- public NewStreamsRequest(long sessionId) {
- fSessionId = sessionId;
- }
-
- @Override
- public byte[] serialize() {
- byte data[] = new byte[SIZE];
- ByteBuffer bb = ByteBuffer.wrap(data);
- bb.order(ByteOrder.BIG_ENDIAN);
- bb.putLong(fSessionId);
- return data;
- }
-}
+++ /dev/null
-/**********************************************************************
- * Copyright (c) 2014 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Matthew Khouzam - Initial implementation and API
- * Marc-Andre Laperle - Initial implementation and API
- **********************************************************************/
-
-package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands;
-
-import java.io.DataInputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.util.List;
-
-import com.google.common.collect.ImmutableList;
-
-/**
- * Response to a "new streams" command
- *
- * @author Matthew Khouzam
- */
-public class NewStreamsResponse implements IRelayResponse {
-
- /**
- * Response size
- *
- * fStatus + fNbStreams
- */
- private static final int SIZE = (Integer.SIZE + Integer.SIZE) / 8;
- /** status of the request */
- private final NewStreamsReturnCode fStatus;
- /** the number of streams */
- private final int fNbStreams;
- /** the list of streams in the response */
- private final List<StreamResponse> fStreamList;
-
- /**
- * New stream response network constructor
- *
- * @param inNet
- * network stream
- * @throws IOException
- * network error
- */
- public NewStreamsResponse(DataInputStream inNet) throws IOException {
- byte[] data = new byte[SIZE];
- inNet.readFully(data);
- ByteBuffer bb = ByteBuffer.wrap(data);
- bb.order(ByteOrder.BIG_ENDIAN);
- fStatus = NewStreamsReturnCode.values()[bb.getInt() - 1];
- fNbStreams = bb.getInt();
- ImmutableList.Builder<StreamResponse> sl = new ImmutableList.Builder<>();
- if (getStatus().equals(NewStreamsReturnCode.LTTNG_VIEWER_NEW_STREAMS_OK)) {
- for (int stream = 0; stream < fNbStreams; stream++) {
- sl.add(new StreamResponse(inNet));
- }
- }
- fStreamList = sl.build();
- }
-
- /**
- * Gets the status
- *
- * @return the status
- */
- public NewStreamsReturnCode getStatus() {
- return fStatus;
- }
-
- /**
- * gets the stream list
- *
- * @return the stream list
- */
- public List<StreamResponse> getStreamList() {
- return fStreamList;
- }
-
- /**
- * The number of streams
- *
- * @return the number of streams
- */
- public int getNbStreams() {
- return fNbStreams;
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * Copyright (c) 2014 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Matthew Khouzam - Initial implementation and API
- * Marc-Andre Laperle - Initial implementation and API
- **********************************************************************/
-
-package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands;
-
-/**
- * Return codes for "new streams" command
- *
- * @author Matthew Khouzam
- */
-public enum NewStreamsReturnCode implements IBaseCommand {
-
- /** If new streams are being sent. */
- LTTNG_VIEWER_NEW_STREAMS_OK(1),
- /** If no new streams are available. */
- LTTNG_VIEWER_NEW_STREAMS_NO_NEW(2),
- /** Error. */
- LTTNG_VIEWER_NEW_STREAMS_ERR(3),
- /** Session closed. */
- LTTNG_VIEWER_NEW_STREAMS_HUP(4);
-
- private final int fCode;
-
- private NewStreamsReturnCode(int c) {
- fCode = c;
- }
-
- @Override
- public int getCommand() {
- return fCode;
- }
-}
+++ /dev/null
-/**********************************************************************
- * Copyright (c) 2014 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Matthew Khouzam - Initial implementation and API
- * Marc-Andre Laperle - Initial implementation and API
- **********************************************************************/
-
-package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands;
-
-/**
- * Get next index return code (hope it's viewer_index_ok)
- *
- * @author Matthew Khouzam
- */
-public enum NextIndexReturnCode implements IBaseCommand {
-
- /** Index is available. */
- VIEWER_INDEX_OK(1),
- /** Index not yet available. */
- VIEWER_INDEX_RETRY(2),
- /** Index closed (trace destroyed). */
- VIEWER_INDEX_HUP(3),
- /** Unknown error. */
- VIEWER_INDEX_ERR(4),
- /** Inactive stream beacon. */
- VIEWER_INDEX_INACTIVE(5),
- /** End of index file. */
- VIEWER_INDEX_EOF(6);
-
- private final int fCode;
-
- private NextIndexReturnCode(int c) {
- fCode = c;
- }
-
- @Override
- public int getCommand() {
- return fCode;
- }
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * Copyright (c) 2014 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Matthew Khouzam - Initial implementation and API
- * Marc-Andre Laperle - Initial implementation and API
- **********************************************************************/
-
-package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands;
-
-/**
- * Seek command
- *
- * @author Matthew Khouzam
- */
-public enum SeekCommand implements IBaseCommand {
-
- /** Receive the trace packets from the beginning. */
- VIEWER_SEEK_BEGINNING(1),
- /** Receive the trace packets from now. */
- VIEWER_SEEK_LAST(2);
-
- private final int fCode;
-
- /**
- * Command size (fCode)
- */
- public static final int SIZE = Integer.SIZE / 8;
-
- private SeekCommand(int c) {
- fCode = c;
- }
-
- @Override
- public int getCommand() {
- return fCode;
- }
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * Copyright (c) 2014 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Matthew Khouzam - Initial implementation and API
- * Marc-Andre Laperle - Initial implementation and API
- **********************************************************************/
-
-package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands;
-
-import java.io.DataInputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-/**
- * Get viewer session response to command
- *
- * @author Matthew Khouzam
- */
-public class SessionResponse implements IRelayResponse {
-
- /**
- * Response size
- *
- * fHostname + fSessionName + fId + fLiveTimer + fClients + fStreams
- */
- public static final int SIZE =
- LttngViewerCommands.LTTNG_VIEWER_HOST_NAME_MAX + LttngViewerCommands.LTTNG_VIEWER_NAME_MAX + (Long.SIZE + Integer.SIZE + Integer.SIZE + Integer.SIZE) / 8;
- /** id of the session */
- private final long fId;
- /** live timer */
- private final int fLiveTimer;
- /** number of clients */
- private final int fClients;
- /** number streams */
- private final int fStreams;
- /** Hostname, like 'localhost' */
- private final String fHostname;
- /** Session name, like 'streaming session' */
- private final String fSessionName;
-
- /**
- * Session response network constructor
- *
- * @param inNet
- * input network stream
- * @throws IOException
- * network error
- */
- public SessionResponse(DataInputStream inNet) throws IOException {
- byte[] data = new byte[SIZE];
- inNet.readFully(data);
- ByteBuffer bb = ByteBuffer.wrap(data);
- bb.order(ByteOrder.BIG_ENDIAN);
- fId = bb.getLong();
- fLiveTimer = bb.getInt();
- fClients = bb.getInt();
- fStreams = bb.getInt();
- byte[] hostName = new byte[LttngViewerCommands.LTTNG_VIEWER_HOST_NAME_MAX];
- byte[] sessionName = new byte[LttngViewerCommands.LTTNG_VIEWER_NAME_MAX];
- bb.get(hostName, 0, hostName.length);
- bb.get(sessionName, 0, sessionName.length);
- fHostname = new String(hostName);
- fSessionName = new String(sessionName);
- }
-
- /**
- * Gets the id of the session
- *
- * @return the id of the session
- */
- public long getId() {
- return fId;
- }
-
- /**
- * Gets the live timer
- *
- * @return the live timer
- */
- public int getLiveTimer() {
- return fLiveTimer;
- }
-
- /**
- * Gets the number of clients
- *
- * @return the number of clients
- */
- public int getClients() {
- return fClients;
- }
-
- /**
- * Gets the number streams
- *
- * @return the number streams
- */
- public int getStreams() {
- return fStreams;
- }
-
- /**
- * Gets the Hostname
- *
- * @return the Hostname
- */
- public String getHostname() {
- return fHostname;
- }
-
- /**
- * Gets the session name
- *
- * @return the session name
- */
- public String getSessionName() {
- return fSessionName;
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * Copyright (c) 2014 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Matthew Khouzam - Initial implementation and API
- * Marc-Andre Laperle - Initial implementation and API
- **********************************************************************/
-
-package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands;
-
-import java.io.DataInputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-/**
- * Get response of viewer stream
- *
- * @author Matthew Khouzam
- */
-public class StreamResponse implements IRelayResponse {
-
- /**
- * Response size
- *
- * fId + fCtfTraceId + fMetadataFlag + fPathName + fChannelName
- */
- public static final int SIZE = (Long.SIZE + Long.SIZE + Integer.SIZE) / 8 + LttngViewerCommands.LTTNG_VIEWER_PATH_MAX + LttngViewerCommands.LTTNG_VIEWER_NAME_MAX;
-
- /**
- * id of the stream
- */
- private final long fId;
- /**
- * It is guaranteed to be unique, because the value is assigned sequentially
- * by the relay.
- */
- private final long fCtfTraceId;
- /**
- * if the stream is a metadata stream
- */
- private final int fMetadataFlag;
- /**
- * the path
- */
- private final String fPathName;
- /**
- * The channel, traditionally channel0
- */
- private final String fChannelName;
-
- /**
- * Stream response
- *
- * @param inNet
- * input data stream
- * @throws IOException
- * network time
- */
- public StreamResponse(DataInputStream inNet) throws IOException {
- byte[] streamData = new byte[SIZE];
- inNet.readFully(streamData, 0, SIZE);
- ByteBuffer bb = ByteBuffer.wrap(streamData);
- bb.order(ByteOrder.BIG_ENDIAN);
- fId = (bb.getLong());
- fCtfTraceId = bb.getLong();
- fMetadataFlag = bb.getInt();
- byte pathName[] = new byte[LttngViewerCommands.LTTNG_VIEWER_PATH_MAX];
- byte channelName[] = new byte[LttngViewerCommands.LTTNG_VIEWER_NAME_MAX];
- bb.get(pathName, 0, LttngViewerCommands.LTTNG_VIEWER_PATH_MAX);
- bb.get(channelName, 0, LttngViewerCommands.LTTNG_VIEWER_NAME_MAX);
- fPathName = new String(pathName);
- fChannelName = new String(channelName);
- }
-
- /**
- * Get the id
- *
- * @return the Id
- */
- public long getId() {
- return fId;
- }
-
- /**
- * Get the CtfTraceId
- *
- * @return the CtfTraceId
- */
- public long getCtfTraceId() {
- return fCtfTraceId;
- }
-
- /**
- * Get the metadata flag
- *
- * @return the MetadataFlag
- */
- public int getMetadataFlag() {
- return fMetadataFlag;
- }
-
- /**
- * Get the path name
- *
- * @return the PathName
- */
- public String getPathName() {
- return fPathName;
- }
-
- /**
- * get the Channel name
- *
- * @return the ChannelName
- */
- public String getChannelName() {
- return fChannelName;
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * Copyright (c) 2014 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Matthew Khouzam - Initial implementation and API
- * Marc-Andre Laperle - Initial implementation and API
- **********************************************************************/
-
-package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands;
-
-import java.io.DataInputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-/**
- * Response to getpacket command
- *
- * @author Matthew Khouzam
- */
-public class TracePacketResponse implements IRelayResponse {
-
- /**
- * Command size
- *
- * fStatus + fData.length + fFlags
- */
- private static final int SIZE = (Integer.SIZE + Integer.SIZE + Integer.SIZE) / 8;
- /** Enum lttng_viewer_get_packet_return_code */
- private final GetPacketReturnCode fStatus;
- /** flags: is there new metadata or new streams? */
- private final int fFlags;
- /** the packet */
- private final byte[] fData;
-
- /**
- * Trace packet response network constructor
- *
- * @param inNet
- * network input stream
- * @throws IOException
- * network error
- */
- public TracePacketResponse(DataInputStream inNet) throws IOException {
- byte[] data = new byte[SIZE];
- inNet.readFully(data);
- ByteBuffer bb = ByteBuffer.wrap(data);
- bb.order(ByteOrder.BIG_ENDIAN);
- fStatus = GetPacketReturnCode.values()[bb.getInt() - 1];
- int length = bb.getInt();
- fFlags = bb.getInt();
- if (fStatus.equals(GetPacketReturnCode.VIEWER_GET_PACKET_OK)) {
- fData = new byte[length];
- inNet.readFully(fData);
- } else {
- fData = new byte[0];
- }
- }
-
- /**
- * Get the status
- *
- * @return the Status
- */
- public GetPacketReturnCode getStatus() {
- return fStatus;
- }
-
- /**
- * Get the flags
- *
- * @return the Flags
- */
- public int getFlags() {
- return fFlags;
- }
-
- /**
- * Get the packet data, please do not modify the data
- *
- * @return the Data
- */
- public byte[] getData() {
- return fData;
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/**********************************************************************
- * Copyright (c) 2014 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Matthew Khouzam - Initial implementation and API
- * Marc-Andre Laperle - Initial implementation and API
- **********************************************************************/
-
-package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands;
-
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-/**
- * The LTTng command
- *
- * @author Matthew Khouzam
- */
-public class ViewerCommand implements IRelayCommand {
-
- /**
- * Command size
- *
- * fDataSize + fCmdVersion + fCmd
- */
- public static final int SIZE = (Long.SIZE + Integer.SIZE) / 8 + Command.SIZE;
- /**
- * data size following this header, you normally attach a payload that one,
- * in bytes
- */
- private final long fDataSize;
- /** enum lttcomm_relayd_command */
- private final Command fCmd;
- /** command version */
- private final int fCmdVersion;
-
- /**
- * Sets the packet command
- *
- * @param viewerConnect
- * the command
- * @param size size of the command
- * @param version the version number
- */
- public ViewerCommand(Command viewerConnect, long size, int version) {
- fCmd = viewerConnect;
- fDataSize = size;
- fCmdVersion = version;
- }
-
- /**
- * Get the data size
- *
- * @return the DataSize
- */
- public long getDataSize() {
- return fDataSize;
- }
-
- /**
- * Get the command
- *
- * @return the Cmd
- */
- public Command getCmd() {
- return fCmd;
- }
-
- /**
- * Get the command version
- *
- * @return the CmdVersion
- */
- public int getCmdVersion() {
- return fCmdVersion;
- }
-
- @Override
- public byte[] serialize() {
- byte data[] = new byte[SIZE];
- ByteBuffer bb = ByteBuffer.wrap(data);
- bb.order(ByteOrder.BIG_ENDIAN);
- bb.putLong(getDataSize());
- bb.putInt(getCmd().getCommand());
- bb.putInt(fCmdVersion);
- return data;
- }
-
-
-}
\ No newline at end of file
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.ILttngRelaydConnector;
import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.LttngRelaydConnectorFactory;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.AttachReturnCode;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.AttachSessionResponse;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.CreateSessionResponse;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.CreateSessionReturnCode;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.IndexResponse;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.NextIndexReturnCode;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.SessionResponse;
-import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands.StreamResponse;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.AttachReturnCode;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.AttachSessionResponse;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.CreateSessionResponse;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.CreateSessionReturnCode;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.IndexResponse;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.NextIndexReturnCode;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.SessionResponse;
+import org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands.StreamResponse;
import org.eclipse.tracecompass.internal.lttng2.control.ui.Activator;
import org.eclipse.tracecompass.tmf.core.signal.TmfTraceRangeUpdatedSignal;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;