ctf: Move plugins to their own sub-directory
[deliverable/tracecompass.git] / org.eclipse.tracecompass.lttng2.control.core / src / org / eclipse / tracecompass / internal / lttng2 / control / core / relayd / commands / AttachSessionRequest.java
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
14 package org.eclipse.tracecompass.internal.lttng2.control.core.relayd.commands;
15
16 import java.nio.ByteBuffer;
17 import java.nio.ByteOrder;
18
19 /**
20 * VIEWER_ATTACH_SESSION payload.
21 *
22 * @author Matthew Khouzam
23 */
24 public class AttachSessionRequest implements IRelayCommand {
25
26 /**
27 * Command size
28 *
29 * fSessionId + fOffset + fSeek
30 */
31 public static final int SIZE = (Long.SIZE + Long.SIZE) / 8 + SeekCommand.SIZE;
32 /** the id of a session */
33 private final long fSessionId;
34 /** unused for now */
35 private final long fOffset;
36 /** enum lttng_viewer_seek */
37 private final SeekCommand fSeek;
38
39 /**
40 * Attach session request constructor
41 *
42 * @param id
43 * the session id
44 * @param seekCommand
45 * the seek command
46 */
47 public AttachSessionRequest(long id, SeekCommand seekCommand) {
48 this(id, 0, seekCommand);
49 }
50
51 /**
52 * Attach session request constructor
53 *
54 * @param id
55 * the session id
56 * @param offset
57 * unused for now
58 * @param seekCommand
59 * the seek command
60 */
61
62 public AttachSessionRequest(long id, int offset, SeekCommand seekCommand) {
63 fSessionId = id;
64 fOffset = offset;
65 fSeek = seekCommand;
66
67 }
68
69 @Override
70 public byte[] serialize() {
71 byte data[] = new byte[SIZE];
72 ByteBuffer bb = ByteBuffer.wrap(data);
73 bb.order(ByteOrder.BIG_ENDIAN);
74 bb.putLong(fSessionId);
75 bb.putLong(fOffset);
76 bb.putInt(fSeek.getCommand());
77 return data;
78 }
79
80 }
This page took 0.031662 seconds and 5 git commands to generate.