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 / AttachSessionResponse.java
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
14 package org.eclipse.linuxtools.internal.lttng2.control.core.relayd.lttngviewerCommands;
15
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;
21
22 import com.google.common.collect.ImmutableList;
23 import com.google.common.collect.ImmutableList.Builder;
24
25 /**
26 * Attach session response
27 *
28 * @author Matthew Khouzam
29 * @since 3.0
30 */
31 public class AttachSessionResponse implements IRelayResponse {
32
33 /**
34 * Response size
35 *
36 * fStatus + fStreamsCount (first half of a packet) */
37 private static final int SIZE = (Integer.SIZE + Integer.SIZE) / 8;
38 /** enum lttng_viewer_attach_return_code */
39 private final AttachReturnCode fStatus;
40 /** how many streams are there */
41 private final int fStreamsCount;
42 /** public class lttng_viewer_stream */
43 private final List<StreamResponse> fStreamList;
44
45 /**
46 * Attach session response network constructor
47 *
48 * @param inNet
49 * network input stream
50 * @throws IOException
51 * network error
52 */
53 public AttachSessionResponse(DataInputStream inNet) throws IOException {
54 byte[] data = new byte[SIZE];
55 inNet.readFully(data, 0, SIZE);
56 ByteBuffer bb = ByteBuffer.wrap(data);
57 bb.order(ByteOrder.BIG_ENDIAN);
58 fStatus = AttachReturnCode.values()[bb.getInt() - 1];
59 fStreamsCount = bb.getInt();
60 Builder<StreamResponse> streamResponses = ImmutableList.builder();
61 for (int i = 0; i < getNbStreams(); i++) {
62 streamResponses.add(new StreamResponse(inNet));
63 }
64 fStreamList = streamResponses.build();
65
66 }
67
68 /**
69 * Gets the Status
70 *
71 * @return the Status
72 */
73 public AttachReturnCode getStatus() {
74 return fStatus;
75 }
76
77 /**
78 * Gets the StreamsCount
79 *
80 * @return the StreamsCount
81 */
82 public int getNbStreams() {
83 return fStreamsCount;
84 }
85
86 /**
87 * Gets the StreamList
88 *
89 * @return the StreamList
90 */
91 public List<StreamResponse> getStreamList() {
92 return fStreamList;
93 }
94
95 }
This page took 0.039454 seconds and 5 git commands to generate.