1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.hadoop.hbase.executor;
21
22 import java.io.DataInput;
23 import java.io.DataOutput;
24 import java.io.IOException;
25
26 import org.apache.hadoop.hbase.HMsg;
27 import org.apache.hadoop.hbase.executor.HBaseEventHandler.HBaseEventType;
28 import org.apache.hadoop.io.Writable;
29
30 public class RegionTransitionEventData implements Writable {
31 private HBaseEventType hbEvent;
32 private String rsName;
33 private long timeStamp;
34 private HMsg hmsg;
35
36 public RegionTransitionEventData() {
37 }
38
39 public RegionTransitionEventData(HBaseEventType hbEvent, String rsName) {
40 this(hbEvent, rsName, null);
41 }
42
43 public RegionTransitionEventData(HBaseEventType hbEvent, String rsName, HMsg hmsg) {
44 this.hbEvent = hbEvent;
45 this.rsName = rsName;
46 this.timeStamp = System.currentTimeMillis();
47 this.hmsg = hmsg;
48 }
49
50 public HBaseEventType getHbEvent() {
51 return hbEvent;
52 }
53
54 public String getRsName() {
55 return rsName;
56 }
57
58 public long getTimeStamp() {
59 return timeStamp;
60 }
61
62 public HMsg getHmsg() {
63 return hmsg;
64 }
65
66 @Override
67 public void readFields(DataInput in) throws IOException {
68
69 hbEvent = HBaseEventType.fromByte(in.readByte());
70
71 rsName = in.readUTF();
72
73 timeStamp = in.readLong();
74 if(in.readBoolean()) {
75
76 hmsg = new HMsg();
77 hmsg.readFields(in);
78 }
79 }
80
81 @Override
82 public void write(DataOutput out) throws IOException {
83 out.writeByte(hbEvent.getByteValue());
84 out.writeUTF(rsName);
85 out.writeLong(System.currentTimeMillis());
86 out.writeBoolean((hmsg != null));
87 if(hmsg != null) {
88 hmsg.write(out);
89 }
90 }
91
92 }