ctf: Move plugins to their own sub-directory
[deliverable/tracecompass.git] / org.eclipse.tracecompass.lttng2.control.core / src / org / eclipse / tracecompass / internal / lttng2 / control / core / relayd / commands / SessionResponse.java
CommitLineData
8e15b929
MK
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
41b4bff4 14package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands;
8e15b929
MK
15
16import java.io.DataInputStream;
17import java.io.IOException;
18import java.nio.ByteBuffer;
19import java.nio.ByteOrder;
20
21/**
22 * Get viewer session response to command
23 *
24 * @author Matthew Khouzam
8e15b929
MK
25 */
26public class SessionResponse implements IRelayResponse {
27
28 /**
29 * Response size
8adfbb73
MAL
30 *
31 * fHostname + fSessionName + fId + fLiveTimer + fClients + fStreams
8e15b929
MK
32 */
33 public static final int SIZE =
34 LttngViewerCommands.LTTNG_VIEWER_HOST_NAME_MAX + LttngViewerCommands.LTTNG_VIEWER_NAME_MAX + (Long.SIZE + Integer.SIZE + Integer.SIZE + Integer.SIZE) / 8;
35 /** id of the session */
36 private final long fId;
37 /** live timer */
38 private final int fLiveTimer;
39 /** number of clients */
40 private final int fClients;
41 /** number streams */
42 private final int fStreams;
43 /** Hostname, like 'localhost' */
44 private final String fHostname;
45 /** Session name, like 'streaming session' */
46 private final String fSessionName;
47
48 /**
49 * Session response network constructor
50 *
51 * @param inNet
52 * input network stream
53 * @throws IOException
54 * network error
55 */
56 public SessionResponse(DataInputStream inNet) throws IOException {
57 byte[] data = new byte[SIZE];
58 inNet.readFully(data);
59 ByteBuffer bb = ByteBuffer.wrap(data);
60 bb.order(ByteOrder.BIG_ENDIAN);
61 fId = bb.getLong();
62 fLiveTimer = bb.getInt();
63 fClients = bb.getInt();
64 fStreams = bb.getInt();
65 byte[] hostName = new byte[LttngViewerCommands.LTTNG_VIEWER_HOST_NAME_MAX];
66 byte[] sessionName = new byte[LttngViewerCommands.LTTNG_VIEWER_NAME_MAX];
67 bb.get(hostName, 0, hostName.length);
68 bb.get(sessionName, 0, sessionName.length);
69 fHostname = new String(hostName);
70 fSessionName = new String(sessionName);
71 }
72
73 /**
74 * Gets the id of the session
75 *
76 * @return the id of the session
77 */
78 public long getId() {
79 return fId;
80 }
81
82 /**
83 * Gets the live timer
84 *
85 * @return the live timer
86 */
87 public int getLiveTimer() {
88 return fLiveTimer;
89 }
90
91 /**
92 * Gets the number of clients
93 *
94 * @return the number of clients
95 */
96 public int getClients() {
97 return fClients;
98 }
99
100 /**
101 * Gets the number streams
102 *
103 * @return the number streams
104 */
105 public int getStreams() {
106 return fStreams;
107 }
108
109 /**
110 * Gets the Hostname
111 *
112 * @return the Hostname
113 */
114 public String getHostname() {
115 return fHostname;
116 }
117
118 /**
119 * Gets the session name
120 *
121 * @return the session name
122 */
123 public String getSessionName() {
124 return fSessionName;
125 }
126
127}
This page took 0.111658 seconds and 5 git commands to generate.