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