diff options
author | sourabh_sourabh <sourabh.sourabh@est.tech> | 2024-06-07 19:10:45 +0100 |
---|---|---|
committer | sourabh_sourabh <sourabh.sourabh@est.tech> | 2024-06-13 10:34:42 +0100 |
commit | 04dbe3800a0a9f9809cff2da59a31904a26f17ce (patch) | |
tree | eae0353400a41c1ddd603c1ce5799f739c4d5233 /cps-ncmp-rest/src/main | |
parent | d3e64201a957ca4a1538ea0962c3e5218a5d34e8 (diff) |
#1: Used async version of web client for batch read operation
- Exposed async version of post method into dmi rest client.
- Code change is done to use async web client for batch data
operation.
- Use of CpsNcmpTaskExecutor code is removed.
Issue-ID: CPS-2174
Change-Id: I7840fd8c6d9debe42e50c860f9cf39d64274df72
Signed-off-by: sourabh_sourabh <sourabh.sourabh@est.tech>
Diffstat (limited to 'cps-ncmp-rest/src/main')
-rw-r--r-- | cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpPassthroughResourceRequestHandler.java | 43 |
1 files changed, 6 insertions, 37 deletions
diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpPassthroughResourceRequestHandler.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpPassthroughResourceRequestHandler.java index be5b93c47b..d716877d54 100644 --- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpPassthroughResourceRequestHandler.java +++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/handlers/NcmpPassthroughResourceRequestHandler.java @@ -25,13 +25,11 @@ import static org.onap.cps.ncmp.api.impl.operations.OperationType.READ; import java.util.Map; import java.util.UUID; -import java.util.function.BiConsumer; import java.util.function.Supplier; import org.onap.cps.ncmp.api.NetworkCmProxyDataService; import org.onap.cps.ncmp.api.impl.exception.InvalidDatastoreException; import org.onap.cps.ncmp.api.impl.operations.DatastoreType; import org.onap.cps.ncmp.api.impl.operations.OperationType; -import org.onap.cps.ncmp.api.impl.utils.data.operation.ResourceDataOperationRequestUtils; import org.onap.cps.ncmp.api.models.CmResourceAddress; import org.onap.cps.ncmp.api.models.DataOperationRequest; import org.onap.cps.ncmp.rest.exceptions.OperationNotSupportedException; @@ -45,11 +43,7 @@ import org.springframework.stereotype.Component; public class NcmpPassthroughResourceRequestHandler extends NcmpDatastoreRequestHandler { private final NetworkCmProxyDataService networkCmProxyDataService; - - private static final Object noReturn = null; - private static final int MAXIMUM_CM_HANDLES_PER_OPERATION = 200; - private static final String PAYLOAD_TOO_LARGE_TEMPLATE = "Operation '%s' affects too many (%d) cm handles"; /** @@ -101,10 +95,8 @@ public class NcmpPassthroughResourceRequestHandler extends NcmpDatastoreRequestH final DataOperationRequest dataOperationRequest, final String authorization) { final String requestId = UUID.randomUUID().toString(); - cpsNcmpTaskExecutor.executeTaskWithErrorHandling( - getTaskSupplierForDataOperationRequest(topicParamInQuery, dataOperationRequest, requestId, authorization), - getTaskCompletionHandlerForDataOperationRequest(topicParamInQuery, dataOperationRequest, requestId), - timeOutInMilliSeconds); + networkCmProxyDataService.executeDataOperationForCmHandles(topicParamInQuery, dataOperationRequest, requestId, + authorization); return ResponseEntity.ok(Map.of("requestId", requestId)); } @@ -114,41 +106,18 @@ public class NcmpPassthroughResourceRequestHandler extends NcmpDatastoreRequestH dataOperationRequest.getDataOperationDefinitions().forEach(dataOperationDetail -> { if (OperationType.fromOperationName(dataOperationDetail.getOperation()) != READ) { throw new OperationNotSupportedException( - dataOperationDetail.getOperation() + " operation not yet supported"); + dataOperationDetail.getOperation() + " operation not yet supported"); } if (DatastoreType.fromDatastoreName(dataOperationDetail.getDatastore()) == OPERATIONAL) { throw new InvalidDatastoreException(dataOperationDetail.getDatastore() - + " datastore is not supported"); + + " datastore is not supported"); } if (dataOperationDetail.getCmHandleIds().size() > MAXIMUM_CM_HANDLES_PER_OPERATION) { final String errorMessage = String.format(PAYLOAD_TOO_LARGE_TEMPLATE, - dataOperationDetail.getOperationId(), - dataOperationDetail.getCmHandleIds().size()); + dataOperationDetail.getOperationId(), + dataOperationDetail.getCmHandleIds().size()); throw new PayloadTooLargeException(errorMessage); } }); } - - private Supplier<Object> getTaskSupplierForDataOperationRequest(final String topicParamInQuery, - final DataOperationRequest dataOperationRequest, - final String requestId, - final String authorization) { - return () -> { - networkCmProxyDataService.executeDataOperationForCmHandles(topicParamInQuery, - dataOperationRequest, - requestId, - authorization); - return noReturn; - }; - } - - private static BiConsumer<Object, Throwable> getTaskCompletionHandlerForDataOperationRequest( - final String topicParamInQuery, - final DataOperationRequest dataOperationRequest, - final String requestId) { - return (result, throwable) -> - ResourceDataOperationRequestUtils.handleAsyncTaskCompletionForDataOperationsRequest(topicParamInQuery, - requestId, dataOperationRequest, throwable); - } - } |