1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.omid.tso;
19
20 import org.apache.phoenix.thirdparty.com.google.common.base.MoreObjects;
21 import org.apache.phoenix.thirdparty.com.google.common.base.Optional;
22 import org.jboss.netty.channel.Channel;
23
24 public final class PersistEvent {
25
26 private MonitoringContext monCtx;
27
28 enum Type {
29 TIMESTAMP, COMMIT, ABORT, COMMIT_RETRY, FENCE
30 }
31
32 private Type type = null;
33 private Channel channel = null;
34
35 private long startTimestamp = 0L;
36 private long commitTimestamp = 0L;
37 private Optional<Long> newLowWatermark;
38
39 void makePersistCommit(long startTimestamp, long commitTimestamp, Optional<Long> newLowWatermark, Channel c, MonitoringContext monCtx) {
40
41 this.type = Type.COMMIT;
42 this.startTimestamp = startTimestamp;
43 this.commitTimestamp = commitTimestamp;
44 this.channel = c;
45 this.monCtx = monCtx;
46 this.newLowWatermark = newLowWatermark;
47 }
48
49 void makeCommitRetry(long startTimestamp, Channel c, MonitoringContext monCtx) {
50
51 this.type = Type.COMMIT_RETRY;
52 this.startTimestamp = startTimestamp;
53 this.channel = c;
54 this.monCtx = monCtx;
55
56 }
57
58 void makePersistAbort(long startTimestamp, Channel c, MonitoringContext monCtx) {
59
60 this.type = Type.ABORT;
61 this.startTimestamp = startTimestamp;
62 this.channel = c;
63 this.monCtx = monCtx;
64
65 }
66
67 void makePersistTimestamp(long startTimestamp, Channel c, MonitoringContext monCtx) {
68
69 this.type = Type.TIMESTAMP;
70 this.startTimestamp = startTimestamp;
71 this.channel = c;
72 this.monCtx = monCtx;
73
74 }
75
76 void makePersistFence(long tableID, long fenceTimestamp, Channel c, MonitoringContext monCtx) {
77
78 this.type = Type.FENCE;
79 this.startTimestamp = tableID;
80 this.commitTimestamp = fenceTimestamp;
81 this.channel = c;
82 this.monCtx = monCtx;
83
84 }
85
86 MonitoringContext getMonCtx() {
87
88 return monCtx;
89
90 }
91
92 Type getType() {
93
94 return type;
95
96 }
97
98 Channel getChannel() {
99
100 return channel;
101
102 }
103
104 long getStartTimestamp() {
105
106 return startTimestamp;
107
108 }
109
110 long getCommitTimestamp() {
111
112 return commitTimestamp;
113
114 }
115
116 public Optional<Long> getNewLowWatermark() {
117 return newLowWatermark;
118 }
119
120 @Override
121 public String toString() {
122 return MoreObjects.toStringHelper(this)
123 .add("type", type)
124 .add("ST", startTimestamp)
125 .add("CT", commitTimestamp)
126 .toString();
127 }
128
129 }