Use new thread pool for handling gateway requests
This commit is contained in:
parent
162bf8a1f2
commit
3b8c6869bd
@ -192,7 +192,7 @@ public class DefaultTransportApiService implements TransportApiService {
|
||||
final String certChain = msg.getCertificateChain();
|
||||
result = handlerExecutor.submit(() -> validateOrCreateDeviceX509Certificate(certChain));
|
||||
} else if (transportApiRequestMsg.hasGetOrCreateDeviceRequestMsg()) {
|
||||
result = handle(transportApiRequestMsg.getGetOrCreateDeviceRequestMsg());
|
||||
result = handlerExecutor.submit(() -> handle(transportApiRequestMsg.getGetOrCreateDeviceRequestMsg()));
|
||||
} else if (transportApiRequestMsg.hasEntityProfileRequestMsg()) {
|
||||
result = handle(transportApiRequestMsg.getEntityProfileRequestMsg());
|
||||
} else if (transportApiRequestMsg.hasLwM2MRequestMsg()) {
|
||||
@ -223,7 +223,6 @@ public class DefaultTransportApiService implements TransportApiService {
|
||||
}
|
||||
|
||||
private TransportApiResponseMsg validateCredentials(String credentialsId, DeviceCredentialsType credentialsType) {
|
||||
//TODO: Make async and enable caching
|
||||
DeviceCredentials credentials = deviceCredentialsService.findDeviceCredentialsByCredentialsId(credentialsId);
|
||||
if (credentials != null && credentials.getCredentialsType() == credentialsType) {
|
||||
return getDeviceInfo(credentials);
|
||||
@ -336,10 +335,9 @@ public class DefaultTransportApiService implements TransportApiService {
|
||||
return VALID;
|
||||
}
|
||||
|
||||
private ListenableFuture<TransportApiResponseMsg> handle(GetOrCreateDeviceFromGatewayRequestMsg requestMsg) {
|
||||
private TransportApiResponseMsg handle(GetOrCreateDeviceFromGatewayRequestMsg requestMsg) {
|
||||
DeviceId gatewayId = new DeviceId(new UUID(requestMsg.getGatewayIdMSB(), requestMsg.getGatewayIdLSB()));
|
||||
ListenableFuture<Device> gatewayFuture = deviceService.findDeviceByIdAsync(TenantId.SYS_TENANT_ID, gatewayId);
|
||||
return Futures.transform(gatewayFuture, gateway -> {
|
||||
Device gateway = deviceService.findDeviceById(TenantId.SYS_TENANT_ID, gatewayId);
|
||||
Lock deviceCreationLock = deviceCreationLocks.computeIfAbsent(requestMsg.getDeviceName(), id -> new ReentrantLock());
|
||||
deviceCreationLock.lock();
|
||||
try {
|
||||
@ -405,7 +403,6 @@ public class DefaultTransportApiService implements TransportApiService {
|
||||
} finally {
|
||||
deviceCreationLock.unlock();
|
||||
}
|
||||
}, dbCallbackExecutorService);
|
||||
}
|
||||
|
||||
private ListenableFuture<TransportApiResponseMsg> handle(ProvisionDeviceRequestMsg requestMsg) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user