use of org.thingsboard.server.queue.util.AfterStartUp in project thingsboard by thingsboard.
the class SnmpTransportContext method fetchDevicesAndEstablishSessions.
@AfterStartUp(order = Integer.MAX_VALUE)
public void fetchDevicesAndEstablishSessions() {
log.info("Initializing SNMP devices sessions");
int batchIndex = 0;
int batchSize = 512;
boolean nextBatchExists = true;
while (nextBatchExists) {
TransportProtos.GetSnmpDevicesResponseMsg snmpDevicesResponse = protoEntityService.getSnmpDevicesIds(batchIndex, batchSize);
snmpDevicesResponse.getIdsList().stream().map(id -> new DeviceId(UUID.fromString(id))).peek(allSnmpDevicesIds::add).filter(deviceId -> balancingService.isManagedByCurrentTransport(deviceId.getId())).map(protoEntityService::getDeviceById).forEach(device -> getExecutor().execute(() -> establishDeviceSession(device)));
nextBatchExists = snmpDevicesResponse.getHasNextPage();
batchIndex++;
}
log.debug("Found all SNMP devices ids: {}", allSnmpDevicesIds);
}
Aggregations