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