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 * Metadata packet response containing a packet of metadata
24 * @author Matthew Khouzam
27 public class MetadataPacketResponse
implements IRelayResponse
{
32 * fData.length + fStatus
34 private static final int SIZE
= (Long
.SIZE
+ Integer
.SIZE
) / 8;
35 /** status of the metadata request */
36 private final GetMetadataReturnCode fStatus
;
38 private final byte fData
[];
41 * Read new metadata packet from the network
44 * network input reader
48 public MetadataPacketResponse(DataInputStream inNet
) throws IOException
{
49 byte[] data
= new byte[SIZE
];
50 inNet
.readFully(data
);
51 ByteBuffer bb
= ByteBuffer
.wrap(data
);
52 bb
.order(ByteOrder
.BIG_ENDIAN
);
53 long length
= bb
.getLong();
54 fStatus
= GetMetadataReturnCode
.values()[bb
.getInt() - 1];
55 if (length
>= Integer
.MAX_VALUE
) {
56 throw new IOException("Metadata Packet too big " + length
); //$NON-NLS-1$
58 fData
= new byte[(int) length
];
59 inNet
.readFully(fData
);
67 public byte[] getData() {
76 public GetMetadataReturnCode
getStatus() {