Commit | Line | Data |
---|---|---|
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 | ||
9bc60be7 | 14 | package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.lttngviewerCommands; |
8e15b929 MK |
15 | |
16 | import java.io.DataInputStream; | |
17 | import java.io.IOException; | |
18 | import java.nio.ByteBuffer; | |
19 | import java.nio.ByteOrder; | |
20 | ||
21 | /** | |
22 | * Get response of viewer stream | |
23 | * | |
24 | * @author Matthew Khouzam | |
8e15b929 MK |
25 | */ |
26 | public class StreamResponse implements IRelayResponse { | |
27 | ||
28 | /** | |
29 | * Response size | |
8adfbb73 MAL |
30 | * |
31 | * fId + fCtfTraceId + fMetadataFlag + fPathName + fChannelName | |
8e15b929 MK |
32 | */ |
33 | public static final int SIZE = (Long.SIZE + Long.SIZE + Integer.SIZE) / 8 + LttngViewerCommands.LTTNG_VIEWER_PATH_MAX + LttngViewerCommands.LTTNG_VIEWER_NAME_MAX; | |
34 | ||
35 | /** | |
36 | * id of the stream | |
37 | */ | |
38 | private final long fId; | |
39 | /** | |
40 | * It is guaranteed to be unique, because the value is assigned sequentially | |
41 | * by the relay. | |
42 | */ | |
43 | private final long fCtfTraceId; | |
44 | /** | |
45 | * if the stream is a metadata stream | |
46 | */ | |
47 | private final int fMetadataFlag; | |
48 | /** | |
49 | * the path | |
50 | */ | |
51 | private final String fPathName; | |
52 | /** | |
53 | * The channel, traditionally channel0 | |
54 | */ | |
55 | private final String fChannelName; | |
56 | ||
57 | /** | |
58 | * Stream response | |
59 | * | |
60 | * @param inNet | |
61 | * input data stream | |
62 | * @throws IOException | |
63 | * network time | |
64 | */ | |
65 | public StreamResponse(DataInputStream inNet) throws IOException { | |
66 | byte[] streamData = new byte[SIZE]; | |
67 | inNet.readFully(streamData, 0, SIZE); | |
68 | ByteBuffer bb = ByteBuffer.wrap(streamData); | |
69 | bb.order(ByteOrder.BIG_ENDIAN); | |
70 | fId = (bb.getLong()); | |
71 | fCtfTraceId = bb.getLong(); | |
72 | fMetadataFlag = bb.getInt(); | |
73 | byte pathName[] = new byte[LttngViewerCommands.LTTNG_VIEWER_PATH_MAX]; | |
74 | byte channelName[] = new byte[LttngViewerCommands.LTTNG_VIEWER_NAME_MAX]; | |
75 | bb.get(pathName, 0, LttngViewerCommands.LTTNG_VIEWER_PATH_MAX); | |
76 | bb.get(channelName, 0, LttngViewerCommands.LTTNG_VIEWER_NAME_MAX); | |
77 | fPathName = new String(pathName); | |
78 | fChannelName = new String(channelName); | |
79 | } | |
80 | ||
81 | /** | |
82 | * Get the id | |
83 | * | |
84 | * @return the Id | |
85 | */ | |
86 | public long getId() { | |
87 | return fId; | |
88 | } | |
89 | ||
90 | /** | |
91 | * Get the CtfTraceId | |
92 | * | |
93 | * @return the CtfTraceId | |
94 | */ | |
95 | public long getCtfTraceId() { | |
96 | return fCtfTraceId; | |
97 | } | |
98 | ||
99 | /** | |
100 | * Get the metadata flag | |
101 | * | |
102 | * @return the MetadataFlag | |
103 | */ | |
104 | public int getMetadataFlag() { | |
105 | return fMetadataFlag; | |
106 | } | |
107 | ||
108 | /** | |
109 | * Get the path name | |
110 | * | |
111 | * @return the PathName | |
112 | */ | |
113 | public String getPathName() { | |
114 | return fPathName; | |
115 | } | |
116 | ||
117 | /** | |
118 | * get the Channel name | |
119 | * | |
120 | * @return the ChannelName | |
121 | */ | |
122 | public String getChannelName() { | |
123 | return fChannelName; | |
124 | } | |
125 | ||
126 | } |