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=refs%2Fchanges%2F09%2F110209%2F5;hp=0fdf79e0493878256a95c632da61127a0014fec9;hpb=41dd5b8249526ddbc5967134424eacb667722751;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 0fdf79e04..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 @@ -24,6 +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.RpcService; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.transportpce.common.ResponseCodes; import org.opendaylight.transportpce.common.StringConstants; @@ -36,18 +37,24 @@ import org.opendaylight.transportpce.renderer.provisiondevice.notification.Notif 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.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.ServiceDeleteInput; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceDeleteOutput; @@ -98,25 +105,25 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations private final DeviceRendererService deviceRenderer; private final OtnDeviceRendererService otnDeviceRenderer; - private final TransportpceOlmService olmService; private final DataBroker dataBroker; private final Notification notification; private final PortMapping portMapping; + private final RpcService rpcService; private ListeningExecutorService executor; @Activate public RendererServiceOperationsImpl(@Reference DeviceRendererService deviceRenderer, @Reference OtnDeviceRendererService otnDeviceRenderer, - @Reference TransportpceOlmService olmService, @Reference DataBroker dataBroker, @Reference Notification notification, - @Reference PortMapping portMapping) { + @Reference PortMapping portMapping, + @Reference RpcService rpcService) { this.deviceRenderer = deviceRenderer; this.otnDeviceRenderer = otnDeviceRenderer; - this.olmService = olmService; this.dataBroker = dataBroker; this.notification = notification; this.portMapping = portMapping; + this.rpcService = rpcService; this.executor = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUMBER_OF_THREADS)); LOG.debug("RendererServiceOperationsImpl instantiated"); } @@ -353,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( @@ -365,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); @@ -386,16 +397,15 @@ 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; } @@ -480,7 +490,8 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations 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( @@ -489,7 +500,8 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations 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); @@ -505,23 +517,19 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations 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, - powerSetupInputAtoZ)); - rollbackProcessor.addTask( - new OlmPowerSetupRollbackTask( - "ZtoAOLMTask", - !olmResults.get(1).isSuccess(), - this.olmService, - powerSetupInputZtoA)); + rollbackProcessor.addTask(new OlmPowerSetupRollbackTask( + "AtoZOLMTask", !olmResults.get(0).isSuccess(), rpcService.getRpc(ServicePowerTurndown.class), + powerSetupInputAtoZ)); + rollbackProcessor.addTask(new OlmPowerSetupRollbackTask( + "ZtoAOLMTask", !olmResults.get(1).isSuccess(), rpcService.getRpc(ServicePowerTurndown.class), + powerSetupInputZtoA)); } @SuppressFBWarnings( @@ -550,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) @@ -697,27 +703,11 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations ServicePathInputData servicePathInputDataZtoA = ModelMappingUtils.rendererCreateServiceInputZToA(serviceName, pathDescription, Action.Delete); - ListenableFuture olmPowerTurnDownFutureAtoZ = - this.executor.submit( - new OlmPowerTurnDownTask( - serviceName, - ATOZPATH, - olmService, - servicePathInputDataAtoZ, - notification - ) - ); + ListenableFuture olmPowerTurnDownFutureAtoZ = this.executor.submit( + new OlmPowerTurnDownTask(serviceName, ATOZPATH, servicePathInputDataAtoZ, notification, rpcService)); - ListenableFuture olmPowerTurnDownFutureZtoA = - this.executor.submit( - new OlmPowerTurnDownTask( - serviceName, - ZTOAPATH, - olmService, - servicePathInputDataZtoA, - notification - ) - ); + ListenableFuture olmPowerTurnDownFutureZtoA = this.executor.submit( + new OlmPowerTurnDownTask(serviceName, ZTOAPATH, servicePathInputDataZtoA, notification, rpcService)); ListenableFuture> olmPowerTurnDownFutures = Futures.allAsList(olmPowerTurnDownFutureAtoZ, olmPowerTurnDownFutureZtoA);