+
+ double numOfBitsPerSecond = 112000000000d;
+ double threshold = 0.00002d;
+ double result = preFecCorrectedErrors / numOfBitsPerSecond;
+ LOG.info("PreFEC value is {}", Double.toString(result));
+ return result <= threshold;
+ }
+
+ @SuppressFBWarnings(
+ value = "UPM_UNCALLED_PRIVATE_METHOD",
+ justification = "call in call() method")
+ private boolean manageServicePathCreation(ServiceImplementationRequestInput input, String serviceType,
+ boolean isTempService) {
+ ServicePathInputData servicePathInputDataAtoZ =
+ ModelMappingUtils
+ .rendererCreateServiceInputAToZ(input.getServiceName(), input.getPathDescription(), Action.Create);
+ ServicePathInputData servicePathInputDataZtoA =
+ ModelMappingUtils
+ .rendererCreateServiceInputZToA(input.getServiceName(), input.getPathDescription(), Action.Create);
+ // Rollback should be same for all conditions, so creating a new one
+ RollbackProcessor rollbackProcessor = new RollbackProcessor();
+ List<DeviceRenderingResult> renderingResults =
+ deviceRendering(rollbackProcessor, servicePathInputDataAtoZ, servicePathInputDataZtoA);
+ if (rollbackProcessor.rollbackAllIfNecessary() > 0 || renderingResults.isEmpty()) {
+ sendNotifications(
+ ServicePathNotificationTypes.ServiceImplementationRequest,
+ input.getServiceName(),
+ RpcStatusEx.Failed,
+ DEVICE_RENDERING_ROLL_BACK_MSG);
+ return false;
+ }
+ olmPowerSetup(
+ rollbackProcessor,
+ //olmPowerSetupInputAtoZ,
+ ModelMappingUtils.createServicePowerSetupInput(renderingResults.get(0).getOlmList(), input),
+ //olmPowerSetupInputZtoA
+ ModelMappingUtils.createServicePowerSetupInput(renderingResults.get(1).getOlmList(), input), isTempService);
+ if (rollbackProcessor.rollbackAllIfNecessary() > 0) {
+ sendNotifications(
+ ServicePathNotificationTypes.ServiceImplementationRequest,
+ input.getServiceName(),
+ RpcStatusEx.Failed,
+ OLM_ROLL_BACK_MSG);
+ return false;
+ }
+ // run service activation test twice - once on source node and once on
+ // destination node
+ List<Nodes> nodes = servicePathInputDataAtoZ.getServicePathInput().getNodes();
+ if ((nodes == null) || (nodes.isEmpty())) {
+ return false;
+ }
+
+ Nodes sourceNode = nodes.get(0);
+ Nodes destNode = nodes.get(nodes.size() - 1);
+ String srcNetworkTp =
+ sourceNode.getDestTp().contains(StringConstants.NETWORK_TOKEN)
+ ? sourceNode.getDestTp()
+ : sourceNode.getSrcTp();
+ String dstNetowrkTp =
+ destNode.getDestTp().contains(StringConstants.NETWORK_TOKEN)
+ ? destNode.getDestTp()
+ : destNode.getSrcTp();
+
+ if (!isServiceActivated(sourceNode.getNodeId(), srcNetworkTp)
+ || !isServiceActivated(destNode.getNodeId(), dstNetowrkTp)) {
+ rollbackProcessor.rollbackAll();
+ sendNotifications(
+ ServicePathNotificationTypes.ServiceImplementationRequest,
+ input.getServiceName(),
+ RpcStatusEx.Failed,
+ "Service activation test failed.");
+ return false;
+ }
+ sendNotificationsWithPathDescription(
+ ServicePathNotificationTypes.ServiceImplementationRequest,
+ input.getServiceName(),
+ RpcStatusEx.Successful,
+ OPERATION_SUCCESSFUL,
+ input.getPathDescription(),
+ createLinkForNotif(
+ renderingResults.stream()
+ .flatMap(rr -> rr.getOtnLinkTps().stream())
+ .collect(Collectors.toList())),
+ null,
+ serviceType);
+ return true;
+ }
+
+ @SuppressFBWarnings(
+ value = "UPM_UNCALLED_PRIVATE_METHOD",
+ justification = "call in call() method")
+ private boolean manageServicePathDeletion(String serviceName, PathDescription pathDescription, String serviceType)
+ throws InterruptedException {
+ ServicePathInputData servicePathInputDataAtoZ =
+ ModelMappingUtils.rendererCreateServiceInputAToZ(serviceName, pathDescription, Action.Delete);
+ ServicePathInputData servicePathInputDataZtoA =
+ ModelMappingUtils.rendererCreateServiceInputZToA(serviceName, pathDescription, Action.Delete);
+
+ ListenableFuture<OLMRenderingResult> olmPowerTurnDownFutureAtoZ =
+ this.executor.submit(
+ new OlmPowerTurnDownTask(
+ serviceName,
+ ATOZPATH,
+ olmService,
+ servicePathInputDataAtoZ,
+ notification
+ )
+ );
+
+ ListenableFuture<OLMRenderingResult> olmPowerTurnDownFutureZtoA =
+ this.executor.submit(
+ new OlmPowerTurnDownTask(
+ serviceName,
+ ZTOAPATH,
+ olmService,
+ servicePathInputDataZtoA,
+ notification
+ )
+ );
+
+ ListenableFuture<List<OLMRenderingResult>> olmPowerTurnDownFutures =
+ Futures.allAsList(olmPowerTurnDownFutureAtoZ, olmPowerTurnDownFutureZtoA);
+
+ List<OLMRenderingResult> olmRenderingResults;
+ // OLM turn down power
+ try {
+ LOG.info("Waiting for A-Z and Z-A OLM power turn down ...");
+ olmRenderingResults = olmPowerTurnDownFutures.get(
+ Timeouts.OLM_TIMEOUT, TimeUnit.MILLISECONDS
+ );
+ } catch (InterruptedException | ExecutionException | TimeoutException e) {
+ LOG.error("Error while turning down power!", e);
+ return false;
+ }
+ if (!olmRenderingResults.get(0).isSuccess() || !olmRenderingResults.get(1).isSuccess()) {
+ LOG.error("Error while turning down power!");
+ return false;
+ }
+ LOG.info("OLM power successfully turned down!");
+ // delete service path with renderer
+ LOG.info("Deleting service path via renderer");
+ sendNotifications(
+ ServicePathNotificationTypes.ServiceDelete,
+ serviceName,
+ RpcStatusEx.Pending,
+ "Deleting service path via renderer");
+ sendNotificationsWithPathDescription(
+ ServicePathNotificationTypes.ServiceDelete,
+ serviceName,
+ RpcStatusEx.Successful,
+ OPERATION_SUCCESSFUL,
+ pathDescription,
+ createLinkForNotif(
+ deviceRendering(
+ new RollbackProcessor(),
+ servicePathInputDataAtoZ,
+ servicePathInputDataZtoA)
+ .stream()
+ .flatMap(rr -> rr.getOtnLinkTps().stream())
+ .collect(Collectors.toList())),
+ null,
+ serviceType);
+ return true;
+ }
+
+ @SuppressFBWarnings(
+ value = "UPM_UNCALLED_PRIVATE_METHOD",
+ justification = "call in call() method")
+ private boolean manageOtnServicePathCreation(
+ ServiceImplementationRequestInput input,
+ String serviceType,
+ Uint32 serviceRate) {
+ // Rollback should be same for all conditions, so creating a new one
+ RollbackProcessor rollbackProcessor = new RollbackProcessor();
+ List<OtnDeviceRenderingResult> renderingResults =
+ otnDeviceRendering(
+ rollbackProcessor,
+ // This is A-Z side
+ ModelMappingUtils
+ .rendererCreateOtnServiceInput(
+ input.getServiceName(),
+ Action.Create,
+ input.getServiceAEnd().getServiceFormat().getName(),
+ serviceRate,
+ input.getPathDescription(),
+ true),
+ // This is Z-A side
+ ModelMappingUtils
+ .rendererCreateOtnServiceInput(
+ input.getServiceName(),
+ Action.Create,
+ input.getServiceZEnd().getServiceFormat().getName(),
+ serviceRate,
+ input.getPathDescription(),
+ false),
+ serviceType);
+ if (rollbackProcessor.rollbackAllIfNecessary() > 0) {
+ rollbackProcessor.rollbackAll();
+ sendNotifications(
+ ServicePathNotificationTypes.ServiceImplementationRequest,
+ input.getServiceName(),
+ RpcStatusEx.Failed,
+ DEVICE_RENDERING_ROLL_BACK_MSG);
+ return false;
+ }
+ sendNotificationsWithPathDescription(
+ ServicePathNotificationTypes.ServiceImplementationRequest,
+ input.getServiceName(),
+ RpcStatusEx.Successful, OPERATION_SUCCESSFUL,
+ input.getPathDescription(),
+ createLinkForNotif(
+ renderingResults.stream()
+ .flatMap(rr -> rr.getOtnLinkTps().stream())
+ .collect(Collectors.toList())),
+ getSupportedLinks(
+ ModelMappingUtils.getLinksFromServicePathDescription(input.getPathDescription()),
+ serviceType),
+ serviceType);
+ return true;