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
;
20 import java
.util
.List
;
22 import com
.google
.common
.collect
.ImmutableList
;
25 * Response to a "new streams" command
27 * @author Matthew Khouzam
30 public class NewStreamsResponse
implements IRelayResponse
{
35 * fStatus + fNbStreams
37 private static final int SIZE
= (Integer
.SIZE
+ Integer
.SIZE
) / 8;
38 /** status of the request */
39 private final NewStreamsReturnCode fStatus
;
40 /** the number of streams */
41 private final int fNbStreams
;
42 /** the list of streams in the response */
43 private final List
<StreamResponse
> fStreamList
;
46 * New stream response network constructor
53 public NewStreamsResponse(DataInputStream inNet
) throws IOException
{
54 byte[] data
= new byte[SIZE
];
55 inNet
.readFully(data
);
56 ByteBuffer bb
= ByteBuffer
.wrap(data
);
57 bb
.order(ByteOrder
.BIG_ENDIAN
);
58 fStatus
= NewStreamsReturnCode
.values()[bb
.getInt() - 1];
59 fNbStreams
= bb
.getInt();
60 ImmutableList
.Builder
<StreamResponse
> sl
= new ImmutableList
.Builder
<>();
61 if (getStatus().equals(NewStreamsReturnCode
.LTTNG_VIEWER_NEW_STREAMS_OK
)) {
62 for (int stream
= 0; stream
< fNbStreams
; stream
++) {
63 sl
.add(new StreamResponse(inNet
));
66 fStreamList
= sl
.build();
74 public NewStreamsReturnCode
getStatus() {
79 * gets the stream list
81 * @return the stream list
83 public List
<StreamResponse
> getStreamList() {
88 * The number of streams
90 * @return the number of streams
92 public int getNbStreams() {