use of org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput in project so by onap.
the class CDSProcessingHandler method process.
CountDownLatch process(ExecutionServiceInput request, ManagedChannel channel) {
ActionIdentifiers header = request.getActionIdentifiers();
log.info("Processing blueprint({}:{}) for action({})", header.getBlueprintVersion(), header.getBlueprintName(), header.getActionName());
final CountDownLatch finishLatch = new CountDownLatch(1);
final BluePrintProcessingServiceStub asyncStub = BluePrintProcessingServiceGrpc.newStub(channel);
final StreamObserver<ExecutionServiceOutput> responseObserver = new StreamObserver<ExecutionServiceOutput>() {
@Override
public void onNext(ExecutionServiceOutput output) {
listener.onMessage(output);
}
@Override
public void onError(Throwable t) {
listener.onError(t);
finishLatch.countDown();
}
@Override
public void onCompleted() {
log.info("Completed blueprint({}:{}) for action({})", header.getBlueprintVersion(), header.getBlueprintName(), header.getBlueprintVersion());
finishLatch.countDown();
}
};
final StreamObserver<ExecutionServiceInput> requestObserver = asyncStub.process(responseObserver);
try {
// Send our message to CDS backend for processing
requestObserver.onNext(request);
// Mark the end of requests
requestObserver.onCompleted();
} catch (RuntimeException e) {
requestObserver.onError(e);
}
return finishLatch;
}
use of org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput in project so by onap.
the class GrpcNettyServer method start.
@PostConstruct
public void start() throws IOException {
final BluePrintProcessingServiceImplBase blueprintPrcessorImpl = new BluePrintProcessingServiceImplBase() {
@Override
public StreamObserver<ExecutionServiceInput> process(StreamObserver<ExecutionServiceOutput> responseObserver) {
responseObserverRef.set(responseObserver);
StreamObserver<ExecutionServiceInput> requestObserver = new StreamObserver<ExecutionServiceInput>() {
@Override
public void onNext(ExecutionServiceInput message) {
detailedMessages.add(message);
logger.info("Message received: {}", message);
ExecutionServiceOutput executionServiceOutput = ExecutionServiceOutput.newBuilder().setActionIdentifiers(message.getActionIdentifiers()).setStatus(Status.newBuilder().setEventType(EventType.EVENT_COMPONENT_EXECUTED).build()).build();
responseObserverRef.get().onNext(executionServiceOutput);
logger.info("Message sent: {}", executionServiceOutput);
}
@Override
public void onError(Throwable t) {
responseObserverRef.get().onError(t);
}
@Override
public void onCompleted() {
allRequestsDelivered.countDown();
responseObserverRef.get().onCompleted();
}
};
return requestObserver;
}
};
grpcCleanup.register(ServerBuilder.forPort(Integer.valueOf(port)).directExecutor().addService(blueprintPrcessorImpl).build().start());
}
use of org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput in project so by onap.
the class AbstractCDSProcessingBBUtils method sendRequestToCDSClientBB.
/**
* get the executionServiceInput object from execution and send a request to CDS Client and wait for TIMEOUT period
*
* @param execution BuildingBlockExecution object
*/
public void sendRequestToCDSClientBB(BuildingBlockExecution execution) {
logger.trace("Start AbstractCDSProcessingBBUtils.sendRequestToCDSClient for BuildingBlockExecution object.");
try {
ExecutionServiceInput executionServiceInput = execution.getVariable(EXEC_INPUT);
CDSResponse cdsResponse = getCdsResponse(executionServiceInput);
execution.setVariable(CDS_STATUS, cdsResponse.status);
if (cdsResponse.payload != null) {
String payload = JsonFormat.printer().print(cdsResponse.payload);
execution.setVariable(RESPONSE_PAYLOAD, payload);
}
} catch (Exception ex) {
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
}
}
use of org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput in project so by onap.
the class GenericPnfSWUPDownloadTest method workflow_validInput_expectedOutput.
@Test
public void workflow_validInput_expectedOutput() throws InterruptedException {
mockCatalogDb();
mockAai();
grpcNettyServer.resetList();
final String msoRequestId = UUID.randomUUID().toString();
executionVariables.put(ExecutionVariableNames.MSO_REQUEST_ID, msoRequestId);
final String testBusinessKey = UUID.randomUUID().toString();
logger.info("Test the process instance: {} with business key: {}", TEST_PROCESSINSTANCE_KEY, testBusinessKey);
ProcessInstance pi = runtimeService.startProcessInstanceByKey(TEST_PROCESSINSTANCE_KEY, testBusinessKey, executionVariables);
int waitCount = 10;
while (!isProcessInstanceEnded() && waitCount >= 0) {
Thread.sleep(WORKFLOW_WAIT_TIME);
waitCount--;
}
// Layout is to reflect the bpmn visual layout
assertThat(pi).isStarted().hasPassedInOrder("download_StartEvent", "ServiceTask_1mpt2eq", "ServiceTask_1nl90ao", "ExclusiveGateway_1rj84ne", "ServiceTask_0yavde3", "ExclusiveGateway_1ja7grm", "ServiceTask_1wxo7xz", "ExclusiveGateway_08lusga", "download_EndEvent");
List<ExecutionServiceInput> detailedMessages = grpcNettyServer.getDetailedMessages();
assertEquals(3, detailedMessages.size());
int count = 0;
try {
for (ExecutionServiceInput eSI : detailedMessages) {
for (String action : actionNames) {
if (action.equals(eSI.getActionIdentifiers().getActionName()) && eSI.getCommonHeader().getRequestId().equals(msoRequestId)) {
checkWithActionName(eSI, action, msoRequestId);
count++;
}
}
}
} catch (Exception e) {
e.printStackTrace();
fail("GenericPnfSWUPDownload request exception", e);
}
assertTrue(count == actionNames.length);
}
use of org.onap.ccsdk.cds.controllerblueprints.processing.api.ExecutionServiceInput in project so by onap.
the class PnfHealthCheckTest method workflow_validInput_expectedOutput.
@Test
public void workflow_validInput_expectedOutput() throws InterruptedException {
mockCatalogDb();
mockRequestDb();
mockAai();
final String msoRequestId = UUID.randomUUID().toString();
executionVariables.put(ExecutionVariableNames.MSO_REQUEST_ID, msoRequestId);
final String testBusinessKey = UUID.randomUUID().toString();
logger.info("Test the process instance: {} with business key: {}", TEST_PROCESSINSTANCE_KEY, testBusinessKey);
ProcessInstance pi = runtimeService.startProcessInstanceByKey(TEST_PROCESSINSTANCE_KEY, testBusinessKey, executionVariables);
int waitCount = 10;
while (!isProcessInstanceEnded() && waitCount >= 0) {
Thread.sleep(WORKFLOW_WAIT_TIME);
waitCount--;
}
// Layout is to reflect the bpmn visual layout
assertThat(pi).isEnded().hasPassedInOrder("pnfHealthCheck_startEvent", "ServiceTask_042uz7m", "ScriptTask_10klpg9", "ServiceTask_0slpaht", "ExclusiveGateway_0x6h0yi", "ScriptTask_1igtc83", "CallActivity_0o1mi8u", "pnfHealthCheck_endEvent");
List<ExecutionServiceInput> detailedMessages = grpcNettyServer.getDetailedMessages();
logger.debug("Size of detailedMessage is {}", detailedMessages.size());
assertTrue(detailedMessages.size() == 1);
int count = 0;
try {
for (ExecutionServiceInput eSI : detailedMessages) {
if (ACTION_NAME.equals(eSI.getActionIdentifiers().getActionName()) && eSI.getCommonHeader().getRequestId().equals(msoRequestId)) {
checkWithActionName(eSI, ACTION_NAME);
count++;
}
}
} catch (Exception e) {
e.printStackTrace();
fail("PNFHealthCheck request exception", e);
}
assertTrue(count == 1);
}
Aggregations