X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=servicehandler%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fservicehandler%2Flisteners%2FServiceListener.java;fp=servicehandler%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fservicehandler%2Flisteners%2FServiceListener.java;h=967cbe4ff08404997ef7ce4c8ff9c5866daea435;hb=b1b3bafd549bb501937cea5c976d5344608b6ed3;hp=bb769efdb2116e6b2624458dcf3904cefa87d055;hpb=49ce2e7166b83268dd637ada6ba5421cd08cf2a1;p=transportpce.git diff --git a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/ServiceListener.java b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/ServiceListener.java index bb769efdb..967cbe4ff 100644 --- a/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/ServiceListener.java +++ b/servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/listeners/ServiceListener.java @@ -9,8 +9,8 @@ package org.opendaylight.transportpce.servicehandler.listeners; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.MoreExecutors; -import java.util.Collection; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Optional; import java.util.concurrent.ExecutionException; @@ -21,6 +21,7 @@ import org.opendaylight.mdsal.binding.api.DataObjectModification; import org.opendaylight.mdsal.binding.api.DataTreeChangeListener; import org.opendaylight.mdsal.binding.api.DataTreeModification; import org.opendaylight.mdsal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.RpcService; import org.opendaylight.transportpce.common.ResponseCodes; import org.opendaylight.transportpce.servicehandler.ServiceInput; import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations; @@ -31,11 +32,13 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev2 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev230526.service.resiliency.ServiceResiliency; import org.opendaylight.yang.gen.v1.http.org.openroadm.common.state.types.rev191129.State; import org.opendaylight.yang.gen.v1.http.org.openroadm.equipment.states.types.rev191129.AdminStates; -import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.OrgOpenroadmServiceService; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreate; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateInputBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateOutput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceDelete; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceDeleteInputBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceDeleteOutput; +import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceReroute; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRerouteInput; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRerouteInputBuilder; import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceRerouteOutput; @@ -58,33 +61,33 @@ public class ServiceListener implements DataTreeChangeListener { private static final Logger LOG = LoggerFactory.getLogger(ServiceListener.class); private static final String PUBLISHER = "ServiceListener"; - private OrgOpenroadmServiceService servicehandlerImpl; + private final RpcService rpcService; private ServiceDataStoreOperations serviceDataStoreOperations; private NotificationPublishService notificationPublishService; private Map mapServiceInputReroute; private final ScheduledExecutorService executor; @Activate - public ServiceListener(@Reference OrgOpenroadmServiceService servicehandlerImpl, + public ServiceListener(@Reference RpcService rpcService, @Reference ServiceDataStoreOperations serviceDataStoreOperations, @Reference NotificationPublishService notificationPublishService) { - this.servicehandlerImpl = servicehandlerImpl; - this.notificationPublishService = notificationPublishService; + this.rpcService = rpcService; this.serviceDataStoreOperations = serviceDataStoreOperations; + this.notificationPublishService = notificationPublishService; this.executor = MoreExecutors.getExitingScheduledExecutorService(new ScheduledThreadPoolExecutor(4)); mapServiceInputReroute = new HashMap<>(); } @Override - public void onDataTreeChanged(Collection> changes) { + public void onDataTreeChanged(List> changes) { LOG.info("onDataTreeChanged - {}", this.getClass().getSimpleName()); for (DataTreeModification change : changes) { DataObjectModification rootService = change.getRootNode(); - if (rootService.getDataBefore() == null) { + if (rootService.dataBefore() == null) { continue; } - String serviceInputName = rootService.getDataBefore().key().getServiceName(); - switch (rootService.getModificationType()) { + String serviceInputName = rootService.dataBefore().key().getServiceName(); + switch (rootService.modificationType()) { case DELETE: LOG.info("Service {} correctly deleted from controller", serviceInputName); if (mapServiceInputReroute.get(serviceInputName) != null) { @@ -92,8 +95,8 @@ public class ServiceListener implements DataTreeChangeListener { } break; case WRITE: - Services inputBefore = rootService.getDataBefore(); - Services inputAfter = rootService.getDataAfter(); + Services inputBefore = rootService.dataBefore(); + Services inputAfter = rootService.dataAfter(); if (inputBefore.getOperationalState() == State.InService && inputAfter.getOperationalState() == State.OutOfService) { LOG.info("Service {} is becoming outOfService", serviceInputName); @@ -153,7 +156,7 @@ public class ServiceListener implements DataTreeChangeListener { } break; default: - LOG.debug("Unknown modification type {}", rootService.getModificationType().name()); + LOG.debug("Unknown modification type {}", rootService.modificationType().name()); break; } } @@ -172,7 +175,7 @@ public class ServiceListener implements DataTreeChangeListener { return; } Services service = serviceOpt.orElseThrow(); - ListenableFuture> res = this.servicehandlerImpl.serviceDelete( + ListenableFuture> res = rpcService.getRpc(ServiceDelete.class).invoke( new ServiceDeleteInputBuilder() .setSdncRequestHeader(new SdncRequestHeaderBuilder(service.getSdncRequestHeader()) .setRpcAction(RpcActions.ServiceDelete) @@ -217,7 +220,7 @@ public class ServiceListener implements DataTreeChangeListener { * @param serviceNameToReroute Name of the service */ private void serviceRerouteStep2(String serviceNameToReroute) { - ListenableFuture> res = this.servicehandlerImpl.serviceCreate( + ListenableFuture> res = rpcService.getRpc(ServiceCreate.class).invoke( mapServiceInputReroute.get(serviceNameToReroute).getServiceCreateInput()); try { String httpResponseCode = res.get().getResult().getConfigurationResponseCommon().getResponseCode(); @@ -249,7 +252,7 @@ public class ServiceListener implements DataTreeChangeListener { .setRpcAction(RpcActions.ServiceReroute) .build()) .build(); - ListenableFuture> res = this.servicehandlerImpl.serviceReroute( + ListenableFuture> res = rpcService.getRpc(ServiceReroute.class).invoke( serviceRerouteInput); try { return res.get().getResult().getConfigurationResponseCommon().getResponseCode() @@ -273,4 +276,5 @@ public class ServiceListener implements DataTreeChangeListener { Thread.currentThread().interrupt(); } } + }