lttng: Add Lttng relayd connector
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.control.core / src / org / eclipse / linuxtools / internal / lttng2 / control / core / relayd / lttngviewerCommands / GetPacket.java
CommitLineData
8e15b929
MK
1/**********************************************************************
2 * Copyright (c) 2014 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Matthew Khouzam - Initial implementation and API
11 * Marc-Andre Laperle - Initial implementation and API
12 **********************************************************************/
13
14package org.eclipse.linuxtools.internal.lttng2.control.core.relayd.lttngviewerCommands;
15
16import java.nio.ByteBuffer;
17import java.nio.ByteOrder;
18
19/**
20 * VIEWER_GET_PACKET payload.
21 *
22 * @author Matthew Khouzam
23 * @since 3.0
24 */
25public class GetPacket implements IRelayCommand {
26
27 /**
28 * Command size
29 */
30 public static final int SIZE = (Long.SIZE + Long.SIZE + Integer.SIZE) / 8;
31 /** the stream Id */
32 private final long fStreamId;
33 /** the offset */
34 private final long fOffset;
35 /** the length of the packet */
36 private final int fLength;
37
38 /**
39 * Get packet constructor
40 *
41 * @param streamId
42 * the stream id
43 * @param offset
44 * the offset
45 * @param length
46 * the packet length
47 */
48 public GetPacket(long streamId, long offset, int length) {
49 fStreamId = streamId;
50 fOffset = offset;
51 fLength = length;
52 }
53
54 /**
55 * Get the length of the packet
56 *
57 * @return the length of the packet in bytes
58 */
59 public int getLength() {
60 return fLength;
61 }
62
63 /**
64 * Gets the offset of the packet
65 *
66 * @return the offset
67 */
68 public long getOffset() {
69 return fOffset;
70 }
71
72 /**
73 * Gets the stream id
74 *
75 * @return the stream id
76 */
77 public long getStreamId() {
78 return fStreamId;
79 }
80
81 @Override
82 public byte[] serialize() {
83 byte data[] = new byte[SIZE];
84 ByteBuffer bb = ByteBuffer.wrap(data);
85 bb.order(ByteOrder.BIG_ENDIAN);
86 bb.putLong(getStreamId());
87 bb.putLong(getOffset());
88 bb.putInt(getLength());
89 return data;
90 }
91
92}
This page took 0.027907 seconds and 5 git commands to generate.