X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=renderer%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Frenderer%2Fprovisiondevice%2FRendererServiceOperationsImpl.java;h=a449876a3aa12bd3d7457041756b63c7a03c06ac;hb=b1b3bafd549bb501937cea5c976d5344608b6ed3;hp=4add60c57d1f78a0964e8299b6d9315718ac0a85;hpb=f49968974e1477d4fd9cfdd87d867c9ad347678e;p=transportpce.git diff --git a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/RendererServiceOperationsImpl.java b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/RendererServiceOperationsImpl.java index 4add60c57..a449876a3 100644 --- a/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/RendererServiceOperationsImpl.java +++ b/renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/RendererServiceOperationsImpl.java @@ -11,6 +11,7 @@ import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.MoreExecutors; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -23,7 +24,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.stream.Collectors; import org.opendaylight.mdsal.binding.api.DataBroker; -import org.opendaylight.mdsal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.RpcService; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.transportpce.common.ResponseCodes; import org.opendaylight.transportpce.common.StringConstants; @@ -32,24 +33,29 @@ import org.opendaylight.transportpce.common.mapping.PortMapping; import org.opendaylight.transportpce.common.service.ServiceTypes; import org.opendaylight.transportpce.renderer.ModelMappingUtils; import org.opendaylight.transportpce.renderer.ServicePathInputData; +import org.opendaylight.transportpce.renderer.provisiondevice.notification.Notification; import org.opendaylight.transportpce.renderer.provisiondevice.servicepath.ServicePathDirection; import org.opendaylight.transportpce.renderer.provisiondevice.tasks.DeviceRenderingRollbackTask; import org.opendaylight.transportpce.renderer.provisiondevice.tasks.DeviceRenderingTask; +import org.opendaylight.transportpce.renderer.provisiondevice.tasks.NetworkDeviceRenderingRollbackTask; import org.opendaylight.transportpce.renderer.provisiondevice.tasks.OlmPowerSetupRollbackTask; import org.opendaylight.transportpce.renderer.provisiondevice.tasks.OlmPowerSetupTask; +import org.opendaylight.transportpce.renderer.provisiondevice.tasks.OlmPowerTurnDownTask; import org.opendaylight.transportpce.renderer.provisiondevice.tasks.OtnDeviceRenderingTask; import org.opendaylight.transportpce.renderer.provisiondevice.tasks.RollbackProcessor; +import org.opendaylight.transportpce.renderer.provisiondevice.tasks.RollbackResultMessage; +import org.opendaylight.transportpce.renderer.provisiondevice.transaction.history.History; +import org.opendaylight.transportpce.renderer.provisiondevice.transaction.history.TransactionHistory; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.Action; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.OtnServicePathInput; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkutils.rev220630.OtnLinkType; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.GetPm; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.GetPmInputBuilder; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.GetPmOutput; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerSetup; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerSetupInput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerTurndownInputBuilder; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerTurndownOutput; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.TransportpceOlmService; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.ServicePowerTurndown; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.get.pm.output.Measurements; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.RendererRpcResultSp; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.RendererRpcResultSpBuilder; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceDeleteInput; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceDeleteOutput; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceImplementationRequestInput; @@ -59,27 +65,29 @@ import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer. import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.renderer.rpc.result.sp.Link; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.renderer.rpc.result.sp.LinkBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.device.types.rev191129.NodeTypes; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev161014.PmGranularity; import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev161014.ResourceTypeEnum; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.format.rev191129.ServiceFormat; -import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev211210.service.list.Services; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev210705.PathDescription; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.service.list.Services; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.pathdescription.rev230501.PathDescription; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.RpcStatusEx; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.ServicePathNotificationTypes; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev171017.ServicePathList; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev171017.service.path.list.ServicePaths; import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.servicepath.rev171017.service.path.list.ServicePathsKey; -import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev210930.link.tp.LinkTp; -import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev210930.olm.get.pm.input.ResourceIdentifierBuilder; -import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev210930.optical.renderer.nodes.Nodes; -import org.opendaylight.yang.gen.v1.http.transportpce.topology.rev220123.OtnLinkType; +import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev220926.PmGranularity; +import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev220926.link.tp.LinkTp; +import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev220926.olm.get.pm.input.ResourceIdentifierBuilder; +import org.opendaylight.yang.gen.v1.http.org.transportpce.common.types.rev220926.optical.renderer.nodes.Nodes; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.Notification; import org.opendaylight.yangtools.yang.common.Uint32; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Reference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +@Component(immediate = true) public class RendererServiceOperationsImpl implements RendererServiceOperations { private static final Logger LOG = LoggerFactory.getLogger(RendererServiceOperationsImpl.class); @@ -89,36 +97,42 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations "OLM power setup was not successful! Rendering and OLM will be rolled back."; private static final String RENDERING_DEVICES_A_Z_MSG = "Rendering devices A-Z"; private static final String RENDERING_DEVICES_Z_A_MSG = "Rendering device Z-A"; - private static final String TURNING_DOWN_POWER_ON_A_TO_Z_PATH_MSG = "Turning down power on A-to-Z path"; - private static final String FAILED = "Failed"; + private static final String ATOZPATH = "A-to-Z"; + private static final String ZTOAPATH = "Z-to-A"; private static final String OPERATION_FAILED = "Operation Failed"; private static final String OPERATION_SUCCESSFUL = "Operation Successful"; private static final int NUMBER_OF_THREADS = 4; private final DeviceRendererService deviceRenderer; private final OtnDeviceRendererService otnDeviceRenderer; - private final TransportpceOlmService olmService; private final DataBroker dataBroker; - private final NotificationPublishService notificationPublishService; + private final Notification notification; private final PortMapping portMapping; + private final RpcService rpcService; private ListeningExecutorService executor; - public RendererServiceOperationsImpl(DeviceRendererService deviceRenderer, - OtnDeviceRendererService otnDeviceRenderer, TransportpceOlmService olmService, - DataBroker dataBroker, NotificationPublishService notificationPublishService, PortMapping portMapping) { + @Activate + public RendererServiceOperationsImpl(@Reference DeviceRendererService deviceRenderer, + @Reference OtnDeviceRendererService otnDeviceRenderer, + @Reference DataBroker dataBroker, + @Reference Notification notification, + @Reference PortMapping portMapping, + @Reference RpcService rpcService) { this.deviceRenderer = deviceRenderer; this.otnDeviceRenderer = otnDeviceRenderer; - this.olmService = olmService; this.dataBroker = dataBroker; - this.notificationPublishService = notificationPublishService; + this.notification = notification; this.portMapping = portMapping; + this.rpcService = rpcService; this.executor = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUMBER_OF_THREADS)); + LOG.debug("RendererServiceOperationsImpl instantiated"); } @Override public ListenableFuture - serviceImplementation(ServiceImplementationRequestInput input) { + serviceImplementation(ServiceImplementationRequestInput input, boolean isTempService) { LOG.info("Calling service impl request {}", input.getServiceName()); + LOG.debug("Check if it is temp-service {}", isTempService); return executor.submit(new Callable() { @Override @@ -130,7 +144,7 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations "Service compliant, submitting service implementation Request ..."); Uint32 serviceRate = getServiceRate(input); LOG.info("Using {}G rate", serviceRate); - org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev220316 + org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev231221 .network.Nodes mappingNode = portMapping.isNodeExist(input.getServiceAEnd().getNodeId()) ? portMapping.getNode(input.getServiceAEnd().getNodeId()) @@ -154,7 +168,8 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations case StringConstants.SERVICE_TYPE_OTUC2: case StringConstants.SERVICE_TYPE_OTUC3: case StringConstants.SERVICE_TYPE_OTUC4: - if (!manageServicePathCreation(input, serviceType)) { + LOG.debug("Check temp service {}", isTempService); + if (!manageServicePathCreation(input, serviceType, isTempService)) { return ModelMappingUtils .createServiceImplResponse(ResponseCodes.RESPONSE_FAILED, OPERATION_FAILED); } @@ -211,21 +226,21 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations return ModelMappingUtils .createServiceDeleteResponse(ResponseCodes.RESPONSE_FAILED, OPERATION_FAILED); } - PathDescription pathDescription = pathDescriptionOpt.get(); + PathDescription pathDescription = pathDescriptionOpt.orElseThrow(); String serviceType = ServiceTypes.getServiceType( service.getServiceAEnd().getServiceFormat().getName(), service.getServiceAEnd().getServiceRate(), service.getServiceAEnd().getTxDirection() == null - || service.getServiceAEnd().getTxDirection().values().stream().findFirst().get() + || service.getServiceAEnd().getTxDirection().values().stream().findFirst().orElseThrow() .getPort() == null - || service.getServiceAEnd().getTxDirection().values().stream().findFirst().get() + || service.getServiceAEnd().getTxDirection().values().stream().findFirst().orElseThrow() .getPort().getPortName() == null ? null : portMapping.getMapping( service.getServiceAEnd().getNodeId().getValue(), - service.getServiceAEnd().getTxDirection().values().stream().findFirst().get() - .getPort().getPortName())); + service.getServiceAEnd().getTxDirection().values().stream().findFirst() + .orElseThrow().getPort().getPortName())); switch (serviceType) { case StringConstants.SERVICE_TYPE_100GE_T: case StringConstants.SERVICE_TYPE_400GE: @@ -262,7 +277,7 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations }); } - @edu.umd.cs.findbugs.annotations.SuppressFBWarnings( + @SuppressFBWarnings( value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "call in call() method") private Uint32 getServiceRate(ServiceImplementationRequestInput input) { @@ -294,8 +309,8 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations } String serviceName = ServiceFormat.OTU.getName().equals(input.getServiceAEnd().getServiceFormat().getName()) - ? input.getServiceAEnd().getOtuServiceRate().getSimpleName() - : input.getServiceAEnd().getOduServiceRate().getSimpleName(); + ? input.getServiceAEnd().getOtuServiceRate().toString().split("\\{")[0] + : input.getServiceAEnd().getOduServiceRate().toString().split("\\{")[0]; if (!formatRateMap.get(input.getServiceAEnd().getServiceFormat()).containsKey(serviceName)) { LOG.warn("Unable to get service-rate for service {} - unsupported service name {}", input.getServiceName(), serviceName); @@ -306,20 +321,7 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations .get(serviceName); } - @edu.umd.cs.findbugs.annotations.SuppressFBWarnings( - value = "UPM_UNCALLED_PRIVATE_METHOD", - justification = "call in call() method") - private ServicePowerTurndownOutput olmPowerTurndown(ServicePathInputData servicePathInputData) - throws InterruptedException, ExecutionException, TimeoutException { - LOG.debug(TURNING_DOWN_POWER_ON_A_TO_Z_PATH_MSG); - return this.olmService - .servicePowerTurndown( - new ServicePowerTurndownInputBuilder(servicePathInputData.getServicePathInput()).build()) - .get(Timeouts.DATASTORE_READ, TimeUnit.MILLISECONDS) - .getResult(); - } - - @edu.umd.cs.findbugs.annotations.SuppressFBWarnings( + @SuppressFBWarnings( value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "call in call() method") private Optional deviceRendering( @@ -358,9 +360,12 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations servicePathDataAtoZ.getServicePathInput().getServiceName(), RpcStatusEx.Pending, RENDERING_DEVICES_A_Z_MSG); + + History transactionHistory = new TransactionHistory(); ListenableFuture atozrenderingFuture = this.executor.submit( - new DeviceRenderingTask(this.deviceRenderer, servicePathDataAtoZ, ServicePathDirection.A_TO_Z)); + new DeviceRenderingTask(this.deviceRenderer, servicePathDataAtoZ, ServicePathDirection.A_TO_Z, + transactionHistory)); LOG.info(RENDERING_DEVICES_Z_A_MSG); sendNotifications( @@ -370,7 +375,8 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations RENDERING_DEVICES_Z_A_MSG); ListenableFuture ztoarenderingFuture = this.executor.submit( - new DeviceRenderingTask(this.deviceRenderer, servicePathDataZtoA, ServicePathDirection.Z_TO_A)); + new DeviceRenderingTask(this.deviceRenderer, servicePathDataZtoA, ServicePathDirection.Z_TO_A, + transactionHistory)); ListenableFuture> renderingCombinedFuture = Futures.allAsList(atozrenderingFuture, ztoarenderingFuture); @@ -391,20 +397,19 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations } rollbackProcessor.addTask( - new DeviceRenderingRollbackTask( - "AtoZDeviceTask", - ! renderingResults.get(0).isSuccess(), - renderingResults.get(0).getRenderedNodeInterfaces(), - this.deviceRenderer)); - rollbackProcessor.addTask( - new DeviceRenderingRollbackTask("ZtoADeviceTask", - ! renderingResults.get(1).isSuccess(), - renderingResults.get(1).getRenderedNodeInterfaces(), - this.deviceRenderer)); + new NetworkDeviceRenderingRollbackTask( + "RollbackTransactionHistoryTask", + transactionHistory, + ! (renderingResults.get(0).isSuccess() && renderingResults.get(1).isSuccess()), + deviceRenderer, + new RollbackResultMessage() + ) + ); + return renderingResults; } - @edu.umd.cs.findbugs.annotations.SuppressFBWarnings( + @SuppressFBWarnings( value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "call in call() method") private List otnDeviceRendering( @@ -462,37 +467,43 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations return otnRenderingResults; } - @edu.umd.cs.findbugs.annotations.SuppressFBWarnings( + @SuppressFBWarnings( value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "call in call() method") private void olmPowerSetup( RollbackProcessor rollbackProcessor, ServicePowerSetupInput powerSetupInputAtoZ, - ServicePowerSetupInput powerSetupInputZtoA) { + ServicePowerSetupInput powerSetupInputZtoA, boolean isTempService) { //TODO olmPowerSetupFutureAtoZ & olmPowerSetupFutureZtoA & olmFutures used only once // Do notifications & LOG.info deserve this ? //TODO use constants for LOG.info & notifications common messages + // if the service create is a temp-service, OLM will be skipped + if (isTempService) { + LOG.info("For temp-service create OLM is not computed and skipped"); + return; + } LOG.info("Olm power setup A-Z"); sendNotifications( - ServicePathNotificationTypes.ServiceImplementationRequest, - powerSetupInputAtoZ.getServiceName(), - RpcStatusEx.Pending, - "Olm power setup A-Z"); + ServicePathNotificationTypes.ServiceImplementationRequest, + powerSetupInputAtoZ.getServiceName(), + RpcStatusEx.Pending, + "Olm power setup A-Z"); ListenableFuture olmPowerSetupFutureAtoZ = - this.executor.submit(new OlmPowerSetupTask(this.olmService, powerSetupInputAtoZ)); + this.executor.submit( + new OlmPowerSetupTask(rpcService.getRpc(ServicePowerSetup.class), powerSetupInputAtoZ)); LOG.info("OLM power setup Z-A"); sendNotifications( - ServicePathNotificationTypes.ServiceImplementationRequest, - powerSetupInputAtoZ.getServiceName(), - RpcStatusEx.Pending, - "Olm power setup Z-A"); + ServicePathNotificationTypes.ServiceImplementationRequest, + powerSetupInputAtoZ.getServiceName(), + RpcStatusEx.Pending, + "Olm power setup Z-A"); ListenableFuture olmPowerSetupFutureZtoA = - this.executor.submit(new OlmPowerSetupTask(this.olmService, powerSetupInputZtoA)); - + this.executor.submit( + new OlmPowerSetupTask(rpcService.getRpc(ServicePowerSetup.class), powerSetupInputZtoA)); ListenableFuture> olmFutures = - Futures.allAsList(olmPowerSetupFutureAtoZ, olmPowerSetupFutureZtoA); + Futures.allAsList(olmPowerSetupFutureAtoZ, olmPowerSetupFutureZtoA); List olmResults; try { @@ -501,32 +512,27 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations } catch (InterruptedException | ExecutionException | TimeoutException e) { LOG.warn(OLM_ROLL_BACK_MSG, e); sendNotifications( - ServicePathNotificationTypes.ServiceImplementationRequest, - powerSetupInputAtoZ.getServiceName(), - RpcStatusEx.Pending, - OLM_ROLL_BACK_MSG); + ServicePathNotificationTypes.ServiceImplementationRequest, + powerSetupInputAtoZ.getServiceName(), + RpcStatusEx.Pending, + OLM_ROLL_BACK_MSG); rollbackProcessor.addTask( - new OlmPowerSetupRollbackTask("AtoZOLMTask", true, this.olmService, powerSetupInputAtoZ)); + new OlmPowerSetupRollbackTask("AtoZOLMTask", true, rpcService.getRpc(ServicePowerTurndown.class), + powerSetupInputAtoZ)); rollbackProcessor.addTask( - new OlmPowerSetupRollbackTask("ZtoAOLMTask", true, this.olmService, powerSetupInputZtoA)); + new OlmPowerSetupRollbackTask("ZtoAOLMTask", true, rpcService.getRpc(ServicePowerTurndown.class), + powerSetupInputZtoA)); return; } - - rollbackProcessor.addTask( - new OlmPowerSetupRollbackTask( - "AtoZOLMTask", - ! olmResults.get(0).isSuccess(), - this.olmService, + rollbackProcessor.addTask(new OlmPowerSetupRollbackTask( + "AtoZOLMTask", !olmResults.get(0).isSuccess(), rpcService.getRpc(ServicePowerTurndown.class), powerSetupInputAtoZ)); - rollbackProcessor.addTask( - new OlmPowerSetupRollbackTask( - "ZtoAOLMTask", - ! olmResults.get(1).isSuccess(), - this.olmService, + rollbackProcessor.addTask(new OlmPowerSetupRollbackTask( + "ZtoAOLMTask", !olmResults.get(1).isSuccess(), rpcService.getRpc(ServicePowerTurndown.class), powerSetupInputZtoA)); } - @edu.umd.cs.findbugs.annotations.SuppressFBWarnings( + @SuppressFBWarnings( value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "call in call() method") private boolean isServiceActivated(String nodeId, String tpId) { @@ -552,9 +558,7 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations private List getMeasurements(String nodeId, String tp) { try { - GetPmOutput getPmOutput = - this.olmService - .getPm( + GetPmOutput getPmOutput = rpcService.getRpc(GetPm.class).invoke( new GetPmInputBuilder() .setNodeId(nodeId) .setGranularity(PmGranularity._15min) @@ -609,10 +613,11 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations return result <= threshold; } - @edu.umd.cs.findbugs.annotations.SuppressFBWarnings( + @SuppressFBWarnings( value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "call in call() method") - private boolean manageServicePathCreation(ServiceImplementationRequestInput input, String serviceType) { + private boolean manageServicePathCreation(ServiceImplementationRequestInput input, String serviceType, + boolean isTempService) { ServicePathInputData servicePathInputDataAtoZ = ModelMappingUtils .rendererCreateServiceInputAToZ(input.getServiceName(), input.getPathDescription(), Action.Create); @@ -636,7 +641,7 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations //olmPowerSetupInputAtoZ, ModelMappingUtils.createServicePowerSetupInput(renderingResults.get(0).getOlmList(), input), //olmPowerSetupInputZtoA - ModelMappingUtils.createServicePowerSetupInput(renderingResults.get(1).getOlmList(), input)); + ModelMappingUtils.createServicePowerSetupInput(renderingResults.get(1).getOlmList(), input), isTempService); if (rollbackProcessor.rollbackAllIfNecessary() > 0) { sendNotifications( ServicePathNotificationTypes.ServiceImplementationRequest, @@ -688,7 +693,7 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations return true; } - @edu.umd.cs.findbugs.annotations.SuppressFBWarnings( + @SuppressFBWarnings( value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "call in call() method") private boolean manageServicePathDeletion(String serviceName, PathDescription pathDescription, String serviceType) @@ -697,48 +702,32 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations ModelMappingUtils.rendererCreateServiceInputAToZ(serviceName, pathDescription, Action.Delete); ServicePathInputData servicePathInputDataZtoA = ModelMappingUtils.rendererCreateServiceInputZToA(serviceName, pathDescription, Action.Delete); + + ListenableFuture olmPowerTurnDownFutureAtoZ = this.executor.submit( + new OlmPowerTurnDownTask(serviceName, ATOZPATH, servicePathInputDataAtoZ, notification, rpcService)); + + ListenableFuture olmPowerTurnDownFutureZtoA = this.executor.submit( + new OlmPowerTurnDownTask(serviceName, ZTOAPATH, servicePathInputDataZtoA, notification, rpcService)); + + ListenableFuture> olmPowerTurnDownFutures = + Futures.allAsList(olmPowerTurnDownFutureAtoZ, olmPowerTurnDownFutureZtoA); + + List olmRenderingResults; // OLM turn down power try { - LOG.debug(TURNING_DOWN_POWER_ON_A_TO_Z_PATH_MSG); - sendNotifications( - ServicePathNotificationTypes.ServiceDelete, - serviceName, - RpcStatusEx.Pending, - TURNING_DOWN_POWER_ON_A_TO_Z_PATH_MSG); - // TODO add some flag rather than string - if (FAILED.equals( - olmPowerTurndown(servicePathInputDataAtoZ) - .getResult())) { - LOG.error("Service power turndown failed on A-to-Z path for service {}!", serviceName); - sendNotifications( - ServicePathNotificationTypes.ServiceDelete, - serviceName, - RpcStatusEx.Failed, - "Service power turndown failed on A-to-Z path for service"); - return false; - } - LOG.debug("Turning down power on Z-to-A path"); - sendNotifications( - ServicePathNotificationTypes.ServiceDelete, - serviceName, - RpcStatusEx.Pending, - "Turning down power on Z-to-A path"); - // TODO add some flag rather than string - if (FAILED.equals( - olmPowerTurndown(servicePathInputDataZtoA) - .getResult())) { - LOG.error("Service power turndown failed on Z-to-A path for service {}!", serviceName); - sendNotifications( - ServicePathNotificationTypes.ServiceDelete, - serviceName, - RpcStatusEx.Failed, - "Service power turndown failed on Z-to-A path for service"); - return false; - } + 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( @@ -765,7 +754,7 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations return true; } - @edu.umd.cs.findbugs.annotations.SuppressFBWarnings( + @SuppressFBWarnings( value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "call in call() method") private boolean manageOtnServicePathCreation( @@ -821,7 +810,7 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations return true; } - @edu.umd.cs.findbugs.annotations.SuppressFBWarnings( + @SuppressFBWarnings( value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "call in call() method") private boolean manageOtnServicePathDeletion( @@ -886,9 +875,13 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations String serviceName, RpcStatusEx rpcStatusEx, String message) { - send( - buildNotification(servicePathNotificationTypes, serviceName, rpcStatusEx, message, - null, null, null, null)); + + notification.send( + servicePathNotificationTypes, + serviceName, + rpcStatusEx, + message + ); } /** @@ -908,60 +901,19 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations Link notifLink, Set supportedLinks, String serviceType) { - send( - buildNotification(servicePathNotificationTypes, serviceName, rpcStatusEx, message, - pathDescription, notifLink, supportedLinks, serviceType)); - } - - /** - * Build notification containing path description information. - * @param servicePathNotificationTypes ServicePathNotificationTypes - * @param serviceName String - * @param rpcStatusEx RpcStatusEx - * @param message String - * @param pathDescription PathDescription - * @return notification with RendererRpcResultSp type. - */ - private RendererRpcResultSp buildNotification( - ServicePathNotificationTypes servicePathNotificationTypes, - String serviceName, - RpcStatusEx rpcStatusEx, - String message, - PathDescription pathDescription, - Link notifLink, - Set supportedLinks, - String serviceType) { - RendererRpcResultSpBuilder builder = - new RendererRpcResultSpBuilder() - .setNotificationType(servicePathNotificationTypes).setServiceName(serviceName).setStatus(rpcStatusEx) - .setStatusMessage(message) - .setServiceType(serviceType); - if (pathDescription != null) { - builder - .setAToZDirection(pathDescription.getAToZDirection()) - .setZToADirection(pathDescription.getZToADirection()); - } - if (notifLink != null) { - builder.setLink(notifLink); - } - if (supportedLinks != null) { - builder.setLinkId(supportedLinks); - } - return builder.build(); - } - /** - * Send renderer notification. - * @param notification Notification - */ - private void send(Notification notification) { - try { - LOG.info("Sending notification {}", notification); - notificationPublishService.putNotification(notification); - } catch (InterruptedException e) { - LOG.info("notification offer rejected: ", e); - Thread.currentThread().interrupt(); - } + notification.send( + notification.buildNotification( + servicePathNotificationTypes, + serviceName, + rpcStatusEx, + message, + pathDescription, + notifLink, + supportedLinks, + serviceType + ) + ); } private Link createLinkForNotif(List otnLinkTerminationPoints) {