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
.tracecompass
.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
;
23 import com
.google
.common
.collect
.ImmutableList
.Builder
;
26 * Attach session response
28 * @author Matthew Khouzam
30 public class AttachSessionResponse
implements IRelayResponse
{
35 * fStatus + fStreamsCount (first half of a packet) */
36 private static final int SIZE
= (Integer
.SIZE
+ Integer
.SIZE
) / 8;
37 /** enum lttng_viewer_attach_return_code */
38 private final AttachReturnCode fStatus
;
39 /** how many streams are there */
40 private final int fStreamsCount
;
41 /** public class lttng_viewer_stream */
42 private final List
<StreamResponse
> fStreamList
;
45 * Attach session response network constructor
48 * network input stream
52 public AttachSessionResponse(DataInputStream inNet
) throws IOException
{
53 byte[] data
= new byte[SIZE
];
54 inNet
.readFully(data
, 0, SIZE
);
55 ByteBuffer bb
= ByteBuffer
.wrap(data
);
56 bb
.order(ByteOrder
.BIG_ENDIAN
);
57 fStatus
= AttachReturnCode
.values()[bb
.getInt() - 1];
58 fStreamsCount
= bb
.getInt();
59 Builder
<StreamResponse
> streamResponses
= ImmutableList
.builder();
60 for (int i
= 0; i
< getNbStreams(); i
++) {
61 streamResponses
.add(new StreamResponse(inNet
));
63 fStreamList
= streamResponses
.build();
72 public AttachReturnCode
getStatus() {
77 * Gets the StreamsCount
79 * @return the StreamsCount
81 public int getNbStreams() {
88 * @return the StreamList
90 public List
<StreamResponse
> getStreamList() {
This page took 0.039434 seconds and 5 git commands to generate.