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