summaryrefslogtreecommitdiffstats
path: root/cps-ncmp-rest/src/main
diff options
context:
space:
mode:
authorJosephKeenan <joseph.keenan@est.tech>2022-06-16 16:19:09 +0100
committerToine Siebelink <toine.siebelink@est.tech>2022-06-30 07:44:46 +0000
commit1c90848a0cb078e0249a7dc888ea05390f59a1e6 (patch)
tree141223174873ab237bc9bf7607532ff15dd50b16 /cps-ncmp-rest/src/main
parent529f92c549a16ecd9ead36cc00d6f74f775ca638 (diff)
Kafka consumer can not be turned off
-NOTE: Build will fail until docker-compose version issues on build server are fixed --Ticket raised https://jira.linuxfoundation.org/plugins/servlet/theme/portal/2/IT-24219 -added flag for async -added response if async is triggered without being enabled & associated test -modified to use one global flag for notifications Issue-ID: CPS-1088 Signed-off-by: JosephKeenan <joseph.keenan@est.tech> Change-Id: If9d988b4dcb71bf37c1b1bf9464090782708ffc2
Diffstat (limited to 'cps-ncmp-rest/src/main')
-rwxr-xr-xcps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java38
1 files changed, 19 insertions, 19 deletions
diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
index fb234ef71a..5703d5e86b 100755
--- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
+++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/controller/NetworkCmProxyController.java
@@ -28,7 +28,6 @@ import static org.onap.cps.ncmp.api.impl.operations.DmiRequestBody.OperationEnum
import static org.onap.cps.ncmp.api.impl.operations.DmiRequestBody.OperationEnum.PATCH;
import static org.onap.cps.ncmp.api.impl.operations.DmiRequestBody.OperationEnum.UPDATE;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -75,9 +74,10 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
private final NcmpRestInputMapper ncmpRestInputMapper;
private final RestOutputCmHandleStateMapper restOutputCmHandleStateMapper;
private final CpsNcmpTaskExecutor cpsNcmpTaskExecutor;
-
@Value("${notification.async.executor.time-out-value-in-ms:2000}")
private int timeOutInMilliSeconds;
+ @Value("${notification.enabled:true}")
+ private boolean asyncEnabled;
/**
* Get resource data from operational datastore.
@@ -93,15 +93,18 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
final @NotNull @Valid String resourceIdentifier,
final @Valid String optionsParamInQuery,
final @Valid String topicParamInQuery) {
- if (isValidTopic(topicParamInQuery)) {
+ if (asyncEnabled && isValidTopic(topicParamInQuery)) {
final String requestId = UUID.randomUUID().toString();
+ log.info("Received Async passthrough-operational request with id {}", requestId);
cpsNcmpTaskExecutor.executeTask(() ->
- networkCmProxyDataService.getResourceDataOperationalForCmHandle(
- cmHandle, resourceIdentifier, optionsParamInQuery, topicParamInQuery,
- requestId
- ), timeOutInMilliSeconds
+ networkCmProxyDataService.getResourceDataOperationalForCmHandle(
+ cmHandle, resourceIdentifier, optionsParamInQuery, topicParamInQuery, requestId
+ ), timeOutInMilliSeconds
);
- return acknowledgeAsyncRequest(requestId);
+ return ResponseEntity.ok(Map.of("requestId", requestId));
+ } else {
+ log.warn("Asynchronous messaging is currently disabled for passthrough-operational."
+ + " Will use synchronous operation.");
}
final Object responseObject = networkCmProxyDataService.getResourceDataOperationalForCmHandle(
@@ -124,15 +127,18 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
final @NotNull @Valid String resourceIdentifier,
final @Valid String optionsParamInQuery,
final @Valid String topicParamInQuery) {
- if (isValidTopic(topicParamInQuery)) {
- final String resourceDataRequestId = UUID.randomUUID().toString();
+ if (asyncEnabled && isValidTopic(topicParamInQuery)) {
+ final String requestId = UUID.randomUUID().toString();
+ log.info("Received Async passthrough-running request with id {}", requestId);
cpsNcmpTaskExecutor.executeTask(() ->
networkCmProxyDataService.getResourceDataPassThroughRunningForCmHandle(
- cmHandle, resourceIdentifier, optionsParamInQuery, topicParamInQuery,
- resourceDataRequestId
+ cmHandle, resourceIdentifier, optionsParamInQuery, topicParamInQuery, requestId
), timeOutInMilliSeconds
);
- return acknowledgeAsyncRequest(resourceDataRequestId);
+ return ResponseEntity.ok(Map.of("requestId", requestId));
+ } else {
+ log.warn("Asynchronous messaging is currently disabled for passthrough-running."
+ + " Will use synchronous operation.");
}
final Object responseObject = networkCmProxyDataService.getResourceDataPassThroughRunningForCmHandle(
@@ -301,11 +307,5 @@ public class NetworkCmProxyController implements NetworkCmProxyApi {
throw new InvalidTopicException("Topic name " + topicName + " is invalid", "invalid topic");
}
- private ResponseEntity<Object> acknowledgeAsyncRequest(final String requestId) {
- final Map<String, Object> acknowledgeData = new HashMap<>(1);
- acknowledgeData.put("requestId", requestId);
- return ResponseEntity.ok(acknowledgeData);
- }
-
}