feat(ft546): adapt legacy shuttle PLC protocol
This commit is contained in:
@@ -17,6 +17,8 @@ public final class DeviceSnapshot {
|
||||
private final Instant observedAt;
|
||||
private final boolean connected;
|
||||
private final String deviceBootId;
|
||||
private final boolean orderedDeviceSequence;
|
||||
private final boolean deviceBootSession;
|
||||
private final long topologyVersion;
|
||||
private final long fencingToken;
|
||||
private final String currentNodeId;
|
||||
@@ -34,7 +36,8 @@ public final class DeviceSnapshot {
|
||||
this(snapshotId, deviceId, commandKey, taskNumber, deviceSequence,
|
||||
observedAt, connected, deviceBootId, topologyVersion,
|
||||
fencingToken, currentNodeId, remainingRouteNodes,
|
||||
commandCompleted, Collections.<String, String>emptyMap());
|
||||
commandCompleted, Collections.<String, String>emptyMap(),
|
||||
true, true);
|
||||
}
|
||||
|
||||
public DeviceSnapshot(String snapshotId, String deviceId, String commandKey,
|
||||
@@ -44,17 +47,38 @@ public final class DeviceSnapshot {
|
||||
long fencingToken, String currentNodeId,
|
||||
List<String> remainingRouteNodes,
|
||||
boolean commandCompleted, Map<String, String> facts) {
|
||||
this(snapshotId, deviceId, commandKey, taskNumber, deviceSequence,
|
||||
observedAt, connected, deviceBootId, topologyVersion,
|
||||
fencingToken, currentNodeId, remainingRouteNodes,
|
||||
commandCompleted, facts, true, true);
|
||||
}
|
||||
|
||||
private DeviceSnapshot(String snapshotId, String deviceId,
|
||||
String commandKey, String taskNumber,
|
||||
long deviceSequence, Instant observedAt,
|
||||
boolean connected, String deviceBootId,
|
||||
long topologyVersion, long fencingToken,
|
||||
String currentNodeId,
|
||||
List<String> remainingRouteNodes,
|
||||
boolean commandCompleted, Map<String, String> facts,
|
||||
boolean orderedDeviceSequence,
|
||||
boolean deviceBootSession) {
|
||||
this.snapshotId = requireText(snapshotId, "snapshotId");
|
||||
this.deviceId = requireText(deviceId, "deviceId");
|
||||
this.commandKey = requireText(commandKey, "commandKey");
|
||||
this.taskNumber = requireText(taskNumber, "taskNumber");
|
||||
if (deviceSequence < 0L || topologyVersion <= 0L || fencingToken <= 0L) {
|
||||
if ((orderedDeviceSequence && deviceSequence < 0L)
|
||||
|| (!orderedDeviceSequence && deviceSequence != 0L)
|
||||
|| topologyVersion <= 0L || fencingToken <= 0L) {
|
||||
throw new IllegalArgumentException("snapshot versions are invalid");
|
||||
}
|
||||
this.deviceSequence = deviceSequence;
|
||||
this.orderedDeviceSequence = orderedDeviceSequence;
|
||||
this.observedAt = Objects.requireNonNull(observedAt, "observedAt");
|
||||
this.connected = connected;
|
||||
this.deviceBootId = requireText(deviceBootId, "deviceBootId");
|
||||
this.deviceBootSession = deviceBootSession;
|
||||
this.deviceBootId = deviceBootSession
|
||||
? requireText(deviceBootId, "deviceBootId") : null;
|
||||
this.topologyVersion = topologyVersion;
|
||||
this.fencingToken = fencingToken;
|
||||
this.currentNodeId = requireText(currentNodeId, "currentNodeId");
|
||||
@@ -63,6 +87,18 @@ public final class DeviceSnapshot {
|
||||
this.facts = immutableFacts(facts);
|
||||
}
|
||||
|
||||
public static DeviceSnapshot unorderedWithoutBootSession(
|
||||
String snapshotId, String deviceId, String commandKey,
|
||||
String taskNumber, Instant observedAt, boolean connected,
|
||||
long topologyVersion, long fencingToken, String currentNodeId,
|
||||
List<String> remainingRouteNodes, boolean commandCompleted,
|
||||
Map<String, String> facts) {
|
||||
return new DeviceSnapshot(snapshotId, deviceId, commandKey,
|
||||
taskNumber, 0L, observedAt, connected, null,
|
||||
topologyVersion, fencingToken, currentNodeId,
|
||||
remainingRouteNodes, commandCompleted, facts, false, false);
|
||||
}
|
||||
|
||||
public String getSnapshotId() { return snapshotId; }
|
||||
public String getDeviceId() { return deviceId; }
|
||||
public String getCommandKey() { return commandKey; }
|
||||
@@ -71,6 +107,10 @@ public final class DeviceSnapshot {
|
||||
public Instant getObservedAt() { return observedAt; }
|
||||
public boolean isConnected() { return connected; }
|
||||
public String getDeviceBootId() { return deviceBootId; }
|
||||
public boolean hasOrderedDeviceSequence() {
|
||||
return orderedDeviceSequence;
|
||||
}
|
||||
public boolean hasDeviceBootSession() { return deviceBootSession; }
|
||||
public long getTopologyVersion() { return topologyVersion; }
|
||||
public long getFencingToken() { return fencingToken; }
|
||||
public String getCurrentNodeId() { return currentNodeId; }
|
||||
|
||||
Reference in New Issue
Block a user