1 /**********************************************************************
2 * Copyright (c) 2014 Ericsson
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
10 * Matthew Khouzam - Initial implementation and API
11 * Marc-Andre Laperle - Initial implementation and API
12 **********************************************************************/
14 package org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.relayd
.lttngviewerCommands
;
16 import java
.io
.DataInputStream
;
17 import java
.io
.IOException
;
18 import java
.nio
.ByteBuffer
;
19 import java
.nio
.ByteOrder
;
22 * An Lttng packet index
24 * @author Matthew Khouzam
27 public class IndexResponse
implements IRelayResponse
{
32 * Sum of the field sizes / 8 ( 7 longs and 2 ints):
33 * fOffset + fPacketSize + fContentSize + fTimestampBegin + fTimestampEnd +
34 * fEventsDiscarded + fStreamId + fStatus + fFlags
36 public final static int SIZE
=
37 (Long
.SIZE
* 7 + Integer
.SIZE
* 2) / 8;
40 private final long fOffset
;
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
;
59 * IndexResposne from network
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];
87 public long getOffset() {
92 * Gets the packet size
94 * @return the packet size
96 public long getPacketSize() {
101 * Gets the content size - how much of the packet is used
103 * @return the content size
105 public long getContentSize() {
110 * Gets the timestamp of the beginning of the packet
112 * @return the timestamp of the beginning of the packet
114 public long getTimestampBegin() {
115 return fTimestampBegin
;
119 * Gets the timestamp of the end of the packet
121 * @return the timestamp of the end of the packet
123 public long getTimestampEnd() {
124 return fTimestampEnd
;
128 * Gets the number of discarded events BEFORE this packet
130 * @return the number of discarded events BEFORE this packet
132 public long getEventsDiscarded() {
133 return fEventsDiscarded
;
137 * Gets the CTF stream id
139 * @return the CTF stream id
141 public long getStreamId() {
150 public NextIndexReturnCode
getStatus() {
155 * Gets the flags that describe whether there are new streams or metadata
159 public int getFlags() {