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