-
Notifications
You must be signed in to change notification settings - Fork 221
/
NodeCommunication.java
211 lines (169 loc) · 5.58 KB
/
NodeCommunication.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
/**
* Licensed to JumpMind Inc under one or more contributor
* license agreements. See the NOTICE file distributed
* with this work for additional information regarding
* copyright ownership. JumpMind Inc licenses this file
* to you under the GNU General Public License, version 3.0 (GPLv3)
* (the "License"); you may not use this file except in compliance
* with the License.
*
* You should have received a copy of the GNU General Public License,
* version 3.0 (GPLv3) along with this library; if not, see
* <http://www.gnu.org/licenses/>.
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.jumpmind.symmetric.model;
import java.io.Serializable;
import java.util.Date;
public class NodeCommunication implements Serializable {
private static final long serialVersionUID = 1L;
public enum CommunicationType {
PULL, PUSH, FILE_PUSH, FILE_PULL, OFFLN_PULL, OFFLN_PUSH, EXTRACT, FILE_XTRCT, OFF_FSPULL, OFF_FSPUSH, ROUTE;
public static boolean isPullType(CommunicationType communicationType) {
return communicationType == PULL || communicationType == CommunicationType.FILE_PULL
|| communicationType == OFFLN_PULL || communicationType == CommunicationType.OFF_FSPULL;
}
};
private transient Node node;
private String nodeId;
private String queue = "default";
private CommunicationType communicationType;
private Date lockTime;
private Date lastLockTime = new Date();
private long lastLockMillis;
private String lockingServerId;
private long successCount;
private long failCount;
private long totalSuccessCount;
private long totalFailCount;
private long totalSuccessMillis;
private long totalFailMillis;
private long batchToSendCount;
private int nodePriority;
public String getNodeId() {
return nodeId;
}
public void setNodeId(String nodeId) {
this.nodeId = nodeId;
}
public String getQueue() {
return queue;
}
public void setQueue(String queue) {
this.queue = queue;
}
public CommunicationType getCommunicationType() {
return communicationType;
}
public void setCommunicationType(CommunicationType communicationType) {
this.communicationType = communicationType;
}
public Date getLockTime() {
return lockTime;
}
public void setLockTime(Date startTime) {
this.lockTime = startTime;
}
public String getLockingServerId() {
return lockingServerId;
}
public void setLockingServerId(String lockingServerId) {
this.lockingServerId = lockingServerId;
}
public long getSuccessCount() {
return successCount;
}
public void setSuccessCount(long successCount) {
this.successCount = successCount;
}
public long getFailCount() {
return failCount;
}
public void setFailCount(long failCount) {
this.failCount = failCount;
}
public long getTotalSuccessCount() {
return totalSuccessCount;
}
public void setTotalSuccessCount(long totalSuccessCount) {
this.totalSuccessCount = totalSuccessCount;
}
public long getTotalFailCount() {
return totalFailCount;
}
public void setTotalFailCount(long totalFailCount) {
this.totalFailCount = totalFailCount;
}
public long getTotalSuccessMillis() {
return totalSuccessMillis;
}
public void setTotalSuccessMillis(long totalSuccessMillis) {
this.totalSuccessMillis = totalSuccessMillis;
}
public long getTotalFailMillis() {
return totalFailMillis;
}
public void setTotalFailMillis(long totalFailMillis) {
this.totalFailMillis = totalFailMillis;
}
public void setLastLockMillis(long lastLockMillis) {
this.lastLockMillis = lastLockMillis;
}
public long getLastLockMillis() {
return lastLockMillis;
}
public void setLastLockTime(Date lastLockTime) {
this.lastLockTime = lastLockTime;
}
public Date getLastLockTime() {
return lastLockTime;
}
public long getBatchToSendCount() {
return batchToSendCount;
}
public void setBatchToSendCount(long batchToSendCount) {
this.batchToSendCount = batchToSendCount;
}
public int getNodePriority() {
return nodePriority;
}
public void setNodePriority(int nodePriority) {
this.nodePriority = nodePriority;
}
public void setNode(Node node) {
this.node = node;
}
public Node getNode() {
return node;
}
public boolean isLocked() {
return lockTime != null;
}
public long getAverageSuccessPeriod() {
if (totalSuccessCount > 0 && totalSuccessMillis > 0) {
return totalSuccessMillis / totalSuccessCount;
} else {
return 0l;
}
}
public long getAverageFailurePeriod() {
if (totalFailCount > 0 && totalFailMillis > 0) {
return totalFailMillis / totalFailCount;
} else {
return 0l;
}
}
public String getIdentifier() {
return getNodeId() + "-" + getQueue();
}
@Override
public String toString() {
return "NodeCommunication [nodeId=" + nodeId + ", queue=" + queue + ", communicationType=" + communicationType + "]";
}
}