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
.tracecompass
.internal
.lttng2
.control
.core
.relayd
.commands
;
16 import java
.io
.DataInputStream
;
17 import java
.io
.IOException
;
18 import java
.nio
.ByteBuffer
;
19 import java
.nio
.ByteOrder
;
22 * Get viewer session response to command
24 * @author Matthew Khouzam
26 public class SessionResponse
implements IRelayResponse
{
31 * fHostname + fSessionName + fId + fLiveTimer + fClients + fStreams
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
;
38 private final int fLiveTimer
;
39 /** number of clients */
40 private final int fClients
;
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
;
49 * Session response network constructor
52 * input network stream
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
);
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
);
74 * Gets the id of the session
76 * @return the id of the session
85 * @return the live timer
87 public int getLiveTimer() {
92 * Gets the number of clients
94 * @return the number of clients
96 public int getClients() {
101 * Gets the number streams
103 * @return the number streams
105 public int getStreams() {
112 * @return the Hostname
114 public String
getHostname() {
119 * Gets the session name
121 * @return the session name
123 public String
getSessionName() {