lttng: Remove capital letter in package name
[deliverable/tracecompass.git] / org.eclipse.tracecompass.lttng2.control.core / src / org / eclipse / tracecompass / internal / lttng2 / control / core / relayd / commands / 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.tracecompass.internal.lttng2.control.core.relayd.commands;
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 */
30 public class AttachSessionResponse implements IRelayResponse {
31
32 /**
33 * Response size
34 *
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;
43
44 /**
45 * Attach session response network constructor
46 *
47 * @param inNet
48 * network input stream
49 * @throws IOException
50 * network error
51 */
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));
62 }
63 fStreamList = streamResponses.build();
64
65 }
66
67 /**
68 * Gets the Status
69 *
70 * @return the Status
71 */
72 public AttachReturnCode getStatus() {
73 return fStatus;
74 }
75
76 /**
77 * Gets the StreamsCount
78 *
79 * @return the StreamsCount
80 */
81 public int getNbStreams() {
82 return fStreamsCount;
83 }
84
85 /**
86 * Gets the StreamList
87 *
88 * @return the StreamList
89 */
90 public List<StreamResponse> getStreamList() {
91 return fStreamList;
92 }
93
94 }
This page took 0.039362 seconds and 5 git commands to generate.