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