From: Joakim Törnqvist Date: Mon, 19 Feb 2024 11:47:55 +0000 (+0000) Subject: Turn down OLM power AtoZ and ZtoA in parallel X-Git-Tag: 9.0.0~36^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=transportpce.git;a=commitdiff_plain;h=41dd5b8249526ddbc5967134424eacb667722751 Turn down OLM power AtoZ and ZtoA in parallel Use the new task OlmPowerTurnDownTask to delete a service AtoZ and ZtoA in parallel. JIRA: TRNSPRTPCE-616 Change-Id: Ib0dab687ef3f5c4a12ad8a71fa5c78d1f9d72254 Signed-off-by: Joakim Törnqvist --- 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 651aefeb0..0fdf79e04 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 @@ -38,6 +38,7 @@ import org.opendaylight.transportpce.renderer.provisiondevice.tasks.DeviceRender import org.opendaylight.transportpce.renderer.provisiondevice.tasks.DeviceRenderingTask; 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.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.Action; @@ -46,8 +47,6 @@ import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkut 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.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.get.pm.output.Measurements; import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceDeleteInput; @@ -91,8 +90,8 @@ 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; @@ -315,19 +314,6 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations .get(serviceName); } - @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(); - } - @SuppressFBWarnings( value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "call in call() method") @@ -710,48 +696,48 @@ public class RendererServiceOperationsImpl implements RendererServiceOperations ModelMappingUtils.rendererCreateServiceInputAToZ(serviceName, pathDescription, Action.Delete); ServicePathInputData servicePathInputDataZtoA = ModelMappingUtils.rendererCreateServiceInputZToA(serviceName, pathDescription, Action.Delete); - // 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, + + ListenableFuture olmPowerTurnDownFutureAtoZ = + this.executor.submit( + new OlmPowerTurnDownTask( 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, + ATOZPATH, + olmService, + servicePathInputDataAtoZ, + notification + ) + ); + + ListenableFuture olmPowerTurnDownFutureZtoA = + this.executor.submit( + new OlmPowerTurnDownTask( serviceName, - RpcStatusEx.Failed, - "Service power turndown failed on Z-to-A path for service"); - return false; - } + ZTOAPATH, + olmService, + servicePathInputDataZtoA, + notification + ) + ); + + ListenableFuture> olmPowerTurnDownFutures = + Futures.allAsList(olmPowerTurnDownFutureAtoZ, olmPowerTurnDownFutureZtoA); + + List 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(