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