X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=servicehandler%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fservicehandler%2Flisteners%2FRendererListenerImpl.java;h=0669f842c3827c882e2acc4898b10290fc330c68;hb=a07392226a2e30930323959a5f6925812f5192ae;hp=6a4a199358d520059afab10b4bef3f1792ca36eb;hpb=2ef6a7a4d8d7aaac99fe8f34d25ed1d5e23cb3c7;p=transportpce.git diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/RendererListenerImpl.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/RendererListenerImpl.java index 6a4a19935..0669f842c 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/RendererListenerImpl.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/RendererListenerImpl.java @@ -7,17 +7,19 @@ */ package org.opendaylight.transportpce.servicehandler.listeners; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; import org.opendaylight.transportpce.common.OperationResult; import org.opendaylight.transportpce.pce.service.PathComputationService; import org.opendaylight.transportpce.servicehandler.ServiceInput; import org.opendaylight.transportpce.servicehandler.service.PCEServiceWrapper; import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.ServiceRpcResultSp; -import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev171017.TransportpceRendererListener; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ServiceNotificationTypes; -import org.opendaylight.yang.gen.v1.http.org.openroadm.common.types.rev161014.State; -import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev171016.RpcStatusEx; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev200520.ServiceRpcResultSp; +import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev200520.TransportpceRendererListener; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev190531.ServiceNotificationTypes; +import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev181130.State; +import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev181130.AdminStates; +import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev200128.RpcStatusEx; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -54,61 +56,11 @@ public class RendererListenerImpl implements TransportpceRendererListener { switch (notifType) { /* service-implementation-request. */ case 3 : - if (serviceRpcResultSp.getStatus() == RpcStatusEx.Successful) { - LOG.info("Service implemented !"); - OperationResult operationResult = null; - if (tempService) { - operationResult = this.serviceDataStoreOperations.modifyTempService( - serviceRpcResultSp.getServiceName(), - State.InService, State.InService); - if (!operationResult.isSuccess()) { - LOG.warn("Temp Service status not updated in datastore !"); - } - } else { - operationResult = this.serviceDataStoreOperations.modifyService( - serviceRpcResultSp.getServiceName(), - State.InService, State.InService); - if (!operationResult.isSuccess()) { - LOG.warn("Service status not updated in datastore !"); - } - } - } else if (serviceRpcResultSp.getStatus() == RpcStatusEx.Failed) { - LOG.error("Renderer implementation failed !"); - OperationResult deleteServicePathOperationResult = - this.serviceDataStoreOperations.deleteServicePath(serviceName); - if (!deleteServicePathOperationResult.isSuccess()) { - LOG.warn("Service path was not removed from datastore!"); - } - if (tempService) { - OperationResult deleteServiceOperationResult = - this.serviceDataStoreOperations.deleteTempService(serviceName); - if (!deleteServiceOperationResult.isSuccess()) { - LOG.warn("Temp Service was not removed from datastore!"); - } - } else { - OperationResult deleteServiceOperationResult = - this.serviceDataStoreOperations.deleteService(serviceName); - if (!deleteServiceOperationResult.isSuccess()) { - LOG.warn("Service was not removed from datastore!"); - } - } - } + onServiceImplementationResult(serviceName); break; /* service-delete. */ case 4 : - if (serviceRpcResultSp.getStatus() == RpcStatusEx.Successful) { - LOG.info("Service '{}' deleted !", serviceName); - if (this.input != null) { - LOG.info("sending PCE cancel resource reserve for '{}'", this.input.getServiceName()); - this.pceServiceWrapper.cancelPCEResource(this.input.getServiceName(), - ServiceNotificationTypes.ServiceDeleteResult); - } else { - LOG.error("ServiceInput parameter is null !"); - } - } else if (serviceRpcResultSp.getStatus() == RpcStatusEx.Failed) { - LOG.error("Renderer service delete failed !"); - return; - } + onServiceDeleteResult(serviceName); break; default: break; @@ -118,6 +70,91 @@ public class RendererListenerImpl implements TransportpceRendererListener { } } + /** + * Process service delete result for serviceName. + * @param serviceName String + */ + private void onServiceDeleteResult(String serviceName) { + if (serviceRpcResultSp.getStatus() == RpcStatusEx.Successful) { + LOG.info("Service '{}' deleted !", serviceName); + if (this.input != null) { + LOG.info("sending PCE cancel resource reserve for '{}'", this.input.getServiceName()); + this.pceServiceWrapper.cancelPCEResource(this.input.getServiceName(), + ServiceNotificationTypes.ServiceDeleteResult); + } else { + LOG.error("ServiceInput parameter is null !"); + } + } else if (serviceRpcResultSp.getStatus() == RpcStatusEx.Failed) { + LOG.error("Renderer service delete failed !"); + } + } + + /** + * Process service implementation result for serviceName. + * @param serviceName String + * @param serviceName String + */ + private void onServiceImplementationResult(String serviceName) { + if (serviceRpcResultSp.getStatus() == RpcStatusEx.Successful) { + onSuccededServiceImplementation(); + } else if (serviceRpcResultSp.getStatus() == RpcStatusEx.Failed) { + onFailedServiceImplementation(serviceName); + } + } + + /** + * Process succeeded service implementation for service. + */ + private void onSuccededServiceImplementation() { + LOG.info("Service implemented !"); + if (serviceDataStoreOperations != null) { + OperationResult operationResult = null; + if (tempService) { + operationResult = this.serviceDataStoreOperations.modifyTempService( + serviceRpcResultSp.getServiceName(), State.InService, AdminStates.InService); + if (!operationResult.isSuccess()) { + LOG.warn("Temp Service status not updated in datastore !"); + } + } else { + operationResult = this.serviceDataStoreOperations + .modifyService(serviceRpcResultSp.getServiceName(), + State.InService, AdminStates.InService); + if (!operationResult.isSuccess()) { + LOG.warn("Service status not updated in datastore !"); + } + } + } + } + + /** + * Process failed service implementation for serviceName. + * @param serviceName String + */ + private void onFailedServiceImplementation(String serviceName) { + LOG.error("Renderer implementation failed !"); + OperationResult deleteServicePathOperationResult = + this.serviceDataStoreOperations.deleteServicePath(serviceName); + if (!deleteServicePathOperationResult.isSuccess()) { + LOG.warn("Service path was not removed from datastore!"); + } + if (tempService) { + OperationResult deleteServiceOperationResult = + this.serviceDataStoreOperations.deleteTempService(serviceName); + if (!deleteServiceOperationResult.isSuccess()) { + LOG.warn("Temp Service was not removed from datastore!"); + } + } else { + OperationResult deleteServiceOperationResult = + this.serviceDataStoreOperations.deleteService(serviceName); + if (!deleteServiceOperationResult.isSuccess()) { + LOG.warn("Service was not removed from datastore!"); + } + } + } + + @SuppressFBWarnings( + value = "ES_COMPARING_STRINGS_WITH_EQ", + justification = "false positives, not strings but real object references comparisons") private Boolean compareServiceRpcResultSp(ServiceRpcResultSp notification) { Boolean result = true; if (serviceRpcResultSp == null) {