improvements
This commit is contained in:
parent
f64ec5ca56
commit
dfb633b8e8
@ -67,10 +67,7 @@ public class GatewayLatencyService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onDeviceDelete(DeviceId deviceId) {
|
public void onDeviceDelete(DeviceId deviceId) {
|
||||||
var state = states.remove(deviceId);
|
states.remove(deviceId);
|
||||||
if (state != null) {
|
|
||||||
state.clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDeviceDisconnect(DeviceId deviceId) {
|
public void onDeviceDisconnect(DeviceId deviceId) {
|
||||||
@ -100,7 +97,6 @@ public class GatewayLatencyService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var result = state.getLatencyStateResult();
|
var result = state.getLatencyStateResult();
|
||||||
state.clear();
|
|
||||||
var kvProto = TransportProtos.KeyValueProto.newBuilder()
|
var kvProto = TransportProtos.KeyValueProto.newBuilder()
|
||||||
.setKey("latencyCheck")
|
.setKey("latencyCheck")
|
||||||
.setType(TransportProtos.KeyValueType.JSON_V)
|
.setType(TransportProtos.KeyValueType.JSON_V)
|
||||||
|
|||||||
@ -54,13 +54,16 @@ public class GatewayLatencyState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clear() {
|
|
||||||
connectors.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, ConnectorLatencyResult> getLatencyStateResult() {
|
public Map<String, ConnectorLatencyResult> getLatencyStateResult() {
|
||||||
Map<String, ConnectorLatencyResult> result = new HashMap<>();
|
Map<String, ConnectorLatencyResult> result = new HashMap<>();
|
||||||
connectors.forEach((name, state) -> result.put(name, state.getResult()));
|
updateLock.lock();
|
||||||
|
try {
|
||||||
|
connectors.forEach((name, state) -> result.put(name, state.getResult()));
|
||||||
|
connectors.clear();
|
||||||
|
} finally {
|
||||||
|
updateLock.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user