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
.linuxtools
.internal
.lttng2
.control
.core
.relayd
.lttngviewerCommands
;
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
27 public class SessionResponse
implements IRelayResponse
{
32 * fHostname + fSessionName + fId + fLiveTimer + fClients + fStreams
34 public static final int SIZE
=
35 LttngViewerCommands
.LTTNG_VIEWER_HOST_NAME_MAX
+ LttngViewerCommands
.LTTNG_VIEWER_NAME_MAX
+ (Long
.SIZE
+ Integer
.SIZE
+ Integer
.SIZE
+ Integer
.SIZE
) / 8;
36 /** id of the session */
37 private final long fId
;
39 private final int fLiveTimer
;
40 /** number of clients */
41 private final int fClients
;
43 private final int fStreams
;
44 /** Hostname, like 'localhost' */
45 private final String fHostname
;
46 /** Session name, like 'streaming session' */
47 private final String fSessionName
;
50 * Session response network constructor
53 * input network stream
57 public SessionResponse(DataInputStream inNet
) throws IOException
{
58 byte[] data
= new byte[SIZE
];
59 inNet
.readFully(data
);
60 ByteBuffer bb
= ByteBuffer
.wrap(data
);
61 bb
.order(ByteOrder
.BIG_ENDIAN
);
63 fLiveTimer
= bb
.getInt();
64 fClients
= bb
.getInt();
65 fStreams
= bb
.getInt();
66 byte[] hostName
= new byte[LttngViewerCommands
.LTTNG_VIEWER_HOST_NAME_MAX
];
67 byte[] sessionName
= new byte[LttngViewerCommands
.LTTNG_VIEWER_NAME_MAX
];
68 bb
.get(hostName
, 0, hostName
.length
);
69 bb
.get(sessionName
, 0, sessionName
.length
);
70 fHostname
= new String(hostName
);
71 fSessionName
= new String(sessionName
);
75 * Gets the id of the session
77 * @return the id of the session
86 * @return the live timer
88 public int getLiveTimer() {
93 * Gets the number of clients
95 * @return the number of clients
97 public int getClients() {
102 * Gets the number streams
104 * @return the number streams
106 public int getStreams() {
113 * @return the Hostname
115 public String
getHostname() {
120 * Gets the session name
122 * @return the session name
124 public String
getSessionName() {