import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
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.DataTreeChangeListener;
import org.opendaylight.mdsal.binding.api.DataTreeModification;
import org.opendaylight.mdsal.binding.api.NotificationPublishService;
import org.opendaylight.transportpce.common.ResponseCodes;
import org.opendaylight.transportpce.servicehandler.ServiceInput;
import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
import org.opendaylight.transportpce.common.ResponseCodes;
import org.opendaylight.transportpce.servicehandler.ServiceInput;
import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
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.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.ServiceCreateInputBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceCreateOutput;
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.ServiceDeleteInputBuilder;
import org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev230526.ServiceDeleteOutput;
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.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;
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;
private static final Logger LOG = LoggerFactory.getLogger(ServiceListener.class);
private static final String PUBLISHER = "ServiceListener";
private static final Logger LOG = LoggerFactory.getLogger(ServiceListener.class);
private static final String PUBLISHER = "ServiceListener";
private ServiceDataStoreOperations serviceDataStoreOperations;
private NotificationPublishService notificationPublishService;
private Map<String, ServiceInput> mapServiceInputReroute;
private final ScheduledExecutorService executor;
@Activate
private ServiceDataStoreOperations serviceDataStoreOperations;
private NotificationPublishService notificationPublishService;
private Map<String, ServiceInput> mapServiceInputReroute;
private final ScheduledExecutorService executor;
@Activate
@Reference ServiceDataStoreOperations serviceDataStoreOperations,
@Reference NotificationPublishService notificationPublishService) {
@Reference ServiceDataStoreOperations serviceDataStoreOperations,
@Reference NotificationPublishService notificationPublishService) {
this.executor = MoreExecutors.getExitingScheduledExecutorService(new ScheduledThreadPoolExecutor(4));
mapServiceInputReroute = new HashMap<>();
}
@Override
this.executor = MoreExecutors.getExitingScheduledExecutorService(new ScheduledThreadPoolExecutor(4));
mapServiceInputReroute = new HashMap<>();
}
@Override
LOG.info("onDataTreeChanged - {}", this.getClass().getSimpleName());
for (DataTreeModification<Services> change : changes) {
DataObjectModification<Services> rootService = change.getRootNode();
LOG.info("onDataTreeChanged - {}", this.getClass().getSimpleName());
for (DataTreeModification<Services> change : changes) {
DataObjectModification<Services> rootService = change.getRootNode();
- 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) {
case DELETE:
LOG.info("Service {} correctly deleted from controller", serviceInputName);
if (mapServiceInputReroute.get(serviceInputName) != null) {
- 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);
if (inputBefore.getOperationalState() == State.InService
&& inputAfter.getOperationalState() == State.OutOfService) {
LOG.info("Service {} is becoming outOfService", serviceInputName);
new ServiceDeleteInputBuilder()
.setSdncRequestHeader(new SdncRequestHeaderBuilder(service.getSdncRequestHeader())
.setRpcAction(RpcActions.ServiceDelete)
new ServiceDeleteInputBuilder()
.setSdncRequestHeader(new SdncRequestHeaderBuilder(service.getSdncRequestHeader())
.setRpcAction(RpcActions.ServiceDelete)
* @param serviceNameToReroute Name of the service
*/
private void serviceRerouteStep2(String serviceNameToReroute) {
* @param serviceNameToReroute Name of the service
*/
private void serviceRerouteStep2(String serviceNameToReroute) {
mapServiceInputReroute.get(serviceNameToReroute).getServiceCreateInput());
try {
String httpResponseCode = res.get().getResult().getConfigurationResponseCommon().getResponseCode();
mapServiceInputReroute.get(serviceNameToReroute).getServiceCreateInput());
try {
String httpResponseCode = res.get().getResult().getConfigurationResponseCommon().getResponseCode();