Remove all existing @since annotations
[deliverable/tracecompass.git] / org.eclipse.tracecompass.lttng2.control.core / src / org / eclipse / tracecompass / internal / lttng2 / control / core / relayd / lttngviewerCommands / IndexResponse.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
9bc60be7 14package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands;
8e15b929
MK
15
16import java.io.DataInputStream;
17import java.io.IOException;
18import java.nio.ByteBuffer;
19import java.nio.ByteOrder;
20
21/**
22 * An Lttng packet index
23 *
24 * @author Matthew Khouzam
8e15b929
MK
25 */
26public class IndexResponse implements IRelayResponse {
27
8e15b929
MK
28 /**
29 * Command size
8adfbb73
MAL
30 *
31 * Sum of the field sizes / 8 ( 7 longs and 2 ints):
32 * fOffset + fPacketSize + fContentSize + fTimestampBegin + fTimestampEnd +
33 * fEventsDiscarded + fStreamId + fStatus + fFlags
8e15b929
MK
34 */
35 public final static int SIZE =
36 (Long.SIZE * 7 + Integer.SIZE * 2) / 8;
37
38 /** the offset */
39 private final long fOffset;
40 /** packet_size */
41 private final long fPacketSize;
42 /** the content size - how much of the packet is used */
43 private final long fContentSize;
44 /** timestamp of the beginning of the packet */
45 private final long fTimestampBegin;
46 /** timestamp of the end of the packet */
47 private final long fTimestampEnd;
48 /** number of discarded events BEFORE this packet */
49 private final long fEventsDiscarded;
50 /** the CTF stream id */
51 private final long fStreamId;
52 /** the status of the getNextIndex request */
53 private final NextIndexReturnCode fStatus;
54 /** whether there are new streams or metadata */
55 private final int fFlags;
56
57 /**
58 * IndexResposne from network
59 *
60 * @param inNet
61 * data input stream
62 * @throws IOException
63 * network error
64 */
65 public IndexResponse(DataInputStream inNet) throws IOException {
66 byte[] data = new byte[SIZE];
67 inNet.readFully(data);
68 ByteBuffer bb = ByteBuffer.wrap(data);
69 bb.order(ByteOrder.BIG_ENDIAN);
70 fOffset = bb.getLong();
71 fPacketSize = bb.getLong();
72 fContentSize = bb.getLong();
73 fTimestampBegin = bb.getLong();
74 fTimestampEnd = bb.getLong();
75 fEventsDiscarded = bb.getLong();
76 fStreamId = bb.getLong();
77 fStatus = NextIndexReturnCode.values()[bb.getInt() - 1];
78 fFlags = bb.getInt();
79 }
80
81 /**
82 * Gets the offset
83 *
84 * @return the offset
85 */
86 public long getOffset() {
87 return fOffset;
88 }
89
90 /**
91 * Gets the packet size
92 *
93 * @return the packet size
94 */
95 public long getPacketSize() {
96 return fPacketSize;
97 }
98
99 /**
100 * Gets the content size - how much of the packet is used
101 *
102 * @return the content size
103 */
104 public long getContentSize() {
105 return fContentSize;
106 }
107
108 /**
109 * Gets the timestamp of the beginning of the packet
110 *
111 * @return the timestamp of the beginning of the packet
112 */
113 public long getTimestampBegin() {
114 return fTimestampBegin;
115 }
116
117 /**
118 * Gets the timestamp of the end of the packet
119 *
120 * @return the timestamp of the end of the packet
121 */
122 public long getTimestampEnd() {
123 return fTimestampEnd;
124 }
125
126 /**
127 * Gets the number of discarded events BEFORE this packet
128 *
129 * @return the number of discarded events BEFORE this packet
130 */
131 public long getEventsDiscarded() {
132 return fEventsDiscarded;
133 }
134
135 /**
136 * Gets the CTF stream id
137 *
138 * @return the CTF stream id
139 */
140 public long getStreamId() {
141 return fStreamId;
142 }
143
144 /**
145 * Gets the status
146 *
147 * @return the status
148 */
149 public NextIndexReturnCode getStatus() {
150 return fStatus;
151 }
152
153 /**
154 * Gets the flags that describe whether there are new streams or metadata
155 *
156 * @return the flags
157 */
158 public int getFlags() {
159 return fFlags;
160 }
161
162}
This page took 0.044012 seconds and 5 git commands to generate.