Performance Improvement on start
This commit is contained in:
parent
81e6cccac9
commit
42a15097c6
@ -135,6 +135,8 @@ public class DefaultDeviceStateService implements DeviceStateService {
|
|||||||
@Getter
|
@Getter
|
||||||
private int initFetchPackSize;
|
private int initFetchPackSize;
|
||||||
|
|
||||||
|
private volatile boolean clusterUpdatePending = false;
|
||||||
|
|
||||||
private ListeningScheduledExecutorService queueExecutor;
|
private ListeningScheduledExecutorService queueExecutor;
|
||||||
private ConcurrentMap<TenantId, Set<DeviceId>> tenantDevices = new ConcurrentHashMap<>();
|
private ConcurrentMap<TenantId, Set<DeviceId>> tenantDevices = new ConcurrentHashMap<>();
|
||||||
private ConcurrentMap<DeviceId, DeviceStateData> deviceStates = new ConcurrentHashMap<>();
|
private ConcurrentMap<DeviceId, DeviceStateData> deviceStates = new ConcurrentHashMap<>();
|
||||||
@ -192,8 +194,11 @@ public class DefaultDeviceStateService implements DeviceStateService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClusterUpdate() {
|
public void onClusterUpdate() {
|
||||||
|
if (!clusterUpdatePending) {
|
||||||
|
clusterUpdatePending = true;
|
||||||
queueExecutor.submit(this::onClusterUpdateSync);
|
queueExecutor.submit(this::onClusterUpdateSync);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRemoteMsg(ServerAddress serverAddress, byte[] data) {
|
public void onRemoteMsg(ServerAddress serverAddress, byte[] data) {
|
||||||
@ -220,6 +225,7 @@ public class DefaultDeviceStateService implements DeviceStateService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void onClusterUpdateSync() {
|
private void onClusterUpdateSync() {
|
||||||
|
clusterUpdatePending = false;
|
||||||
List<Tenant> tenants = tenantService.findTenants(new TextPageLink(Integer.MAX_VALUE)).getData();
|
List<Tenant> tenants = tenantService.findTenants(new TextPageLink(Integer.MAX_VALUE)).getData();
|
||||||
for (Tenant tenant : tenants) {
|
for (Tenant tenant : tenants) {
|
||||||
List<ListenableFuture<DeviceStateData>> fetchFutures = new ArrayList<>();
|
List<ListenableFuture<DeviceStateData>> fetchFutures = new ArrayList<>();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user