+++ /dev/null
-/*
- * Copyright © 2020 Orange, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.transportpce.nbinotifications.impl;
-
-import com.google.common.collect.ImmutableClassToInstanceMap;
-import java.util.Optional;
-import java.util.concurrent.ExecutionException;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.transportpce.common.converter.JsonStringConverter;
-import org.opendaylight.transportpce.common.network.NetworkTransactionService;
-import org.opendaylight.transportpce.nbinotifications.impl.rpc.CreateNotificationSubscriptionServiceImpl;
-import org.opendaylight.transportpce.nbinotifications.impl.rpc.DeleteNotificationSubscriptionServiceImpl;
-import org.opendaylight.transportpce.nbinotifications.impl.rpc.GetNotificationListImpl;
-import org.opendaylight.transportpce.nbinotifications.impl.rpc.GetNotificationSubscriptionServiceDetailsImpl;
-import org.opendaylight.transportpce.nbinotifications.impl.rpc.GetNotificationSubscriptionServiceListImpl;
-import org.opendaylight.transportpce.nbinotifications.impl.rpc.GetNotificationsAlarmServiceImpl;
-import org.opendaylight.transportpce.nbinotifications.impl.rpc.GetNotificationsProcessServiceImpl;
-import org.opendaylight.transportpce.nbinotifications.impl.rpc.GetSupportedNotificationTypesImpl;
-import org.opendaylight.transportpce.nbinotifications.utils.TopicManager;
-import org.opendaylight.yang.gen.v1.nbi.notifications.rev230728.GetNotificationsAlarmService;
-import org.opendaylight.yang.gen.v1.nbi.notifications.rev230728.GetNotificationsProcessService;
-import org.opendaylight.yang.gen.v1.nbi.notifications.rev230728.NotificationAlarmService;
-import org.opendaylight.yang.gen.v1.nbi.notifications.rev230728.NotificationProcessService;
-import org.opendaylight.yang.gen.v1.nbi.notifications.rev230728.NotificationTapiService;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Context;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.Context1;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.CreateNotificationSubscriptionService;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.DeleteNotificationSubscriptionService;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.GetNotificationList;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.GetNotificationSubscriptionServiceDetails;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.GetNotificationSubscriptionServiceList;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.GetSupportedNotificationTypes;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.context.NotificationContext;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.Rpc;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class NbiNotificationsImpl {
- private static final Logger LOG = LoggerFactory.getLogger(NbiNotificationsImpl.class);
- private final JsonStringConverter<NotificationProcessService> converterService;
- private final JsonStringConverter<NotificationAlarmService> converterAlarmService;
- private final JsonStringConverter<NotificationTapiService> converterTapiService;
- private final String server;
- private final NetworkTransactionService networkTransactionService;
- private final TopicManager topicManager;
-
- public NbiNotificationsImpl(JsonStringConverter<NotificationProcessService> converterService,
- JsonStringConverter<NotificationAlarmService> converterAlarmService,
- JsonStringConverter<NotificationTapiService> converterTapiService, String server,
- NetworkTransactionService networkTransactionService, TopicManager topicManager) {
- this.converterService = converterService;
- this.converterAlarmService = converterAlarmService;
- this.converterTapiService = converterTapiService;
- this.server = server;
- this.networkTransactionService = networkTransactionService;
- this.topicManager = topicManager;
- }
-
- public ImmutableClassToInstanceMap<Rpc<?, ?>> registerRPCs() {
- return ImmutableClassToInstanceMap.<Rpc<?, ?>>builder()
- .put(GetNotificationsProcessService.class, new GetNotificationsProcessServiceImpl(converterService, server))
- .put(GetNotificationsAlarmService.class,
- new GetNotificationsAlarmServiceImpl(converterAlarmService, server))
- .put(GetSupportedNotificationTypes.class, new GetSupportedNotificationTypesImpl(this))
- .put(CreateNotificationSubscriptionService.class,
- new CreateNotificationSubscriptionServiceImpl(this, topicManager))
- .put(DeleteNotificationSubscriptionService.class,
- new DeleteNotificationSubscriptionServiceImpl(networkTransactionService, topicManager))
- .put(GetNotificationSubscriptionServiceDetails.class,
- new GetNotificationSubscriptionServiceDetailsImpl(this))
- .put(GetNotificationSubscriptionServiceList.class, new GetNotificationSubscriptionServiceListImpl(this))
- .put(GetNotificationList.class,
- new GetNotificationListImpl(converterTapiService, server, networkTransactionService, topicManager))
- .build();
- }
-
- public NotificationContext getNotificationContext() {
- LOG.info("Getting tapi notification context");
- try {
- InstanceIdentifier<NotificationContext> notificationcontextIID =
- InstanceIdentifier.builder(Context.class).augmentation(Context1.class)
- .child(NotificationContext.class).build();
- Optional<NotificationContext> notificationContextOptional
- = this.networkTransactionService.read(LogicalDatastoreType.OPERATIONAL, notificationcontextIID).get();
- if (!notificationContextOptional.isPresent()) {
- LOG.error("Could not get TAPI notification context");
- return null;
- }
- return notificationContextOptional.orElseThrow();
- } catch (InterruptedException | ExecutionException e) {
- LOG.error("Could not get TAPI notification context");
- }
- return null;
- }
-
- public boolean updateNotificationContext(NotificationContext notificationContext1) {
- try {
- InstanceIdentifier<NotificationContext> notificationcontextIID =
- InstanceIdentifier.builder(Context.class).augmentation(Context1.class)
- .child(NotificationContext.class).build();
- this.networkTransactionService.merge(LogicalDatastoreType.OPERATIONAL, notificationcontextIID,
- notificationContext1);
- this.networkTransactionService.commit().get();
- return true;
- } catch (InterruptedException | ExecutionException e) {
- LOG.error("Could not update TAPI notification context");
- }
- return false;
- }
-
-}
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
+import java.util.concurrent.ExecutionException;
import org.opendaylight.mdsal.binding.api.NotificationService;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
import org.opendaylight.mdsal.binding.dom.codec.spi.BindingDOMCodecServices;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.transportpce.common.converter.JsonStringConverter;
import org.opendaylight.transportpce.common.network.NetworkTransactionService;
+import org.opendaylight.transportpce.nbinotifications.impl.rpc.CreateNotificationSubscriptionServiceImpl;
+import org.opendaylight.transportpce.nbinotifications.impl.rpc.DeleteNotificationSubscriptionServiceImpl;
+import org.opendaylight.transportpce.nbinotifications.impl.rpc.GetNotificationListImpl;
+import org.opendaylight.transportpce.nbinotifications.impl.rpc.GetNotificationSubscriptionServiceDetailsImpl;
+import org.opendaylight.transportpce.nbinotifications.impl.rpc.GetNotificationSubscriptionServiceListImpl;
+import org.opendaylight.transportpce.nbinotifications.impl.rpc.GetNotificationsAlarmServiceImpl;
+import org.opendaylight.transportpce.nbinotifications.impl.rpc.GetNotificationsProcessServiceImpl;
+import org.opendaylight.transportpce.nbinotifications.impl.rpc.GetSupportedNotificationTypesImpl;
import org.opendaylight.transportpce.nbinotifications.listener.NbiNotificationsHandler;
import org.opendaylight.transportpce.nbinotifications.producer.Publisher;
import org.opendaylight.transportpce.nbinotifications.utils.TopicManager;
import org.opendaylight.yang.gen.v1.nbi.notifications.rev230728.NotificationAlarmService;
import org.opendaylight.yang.gen.v1.nbi.notifications.rev230728.NotificationProcessService;
import org.opendaylight.yang.gen.v1.nbi.notifications.rev230728.NotificationTapiService;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Context;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.Context1;
+import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.context.NotificationContext;
import org.opendaylight.yangtools.concepts.Registration;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
private static Map<String, Publisher<NotificationAlarmService>> publishersAlarmMap = new HashMap<>();
private Registration listenerRegistration;
private Registration rpcRegistration;
+ private NetworkTransactionService networkTransactionService;
@Activate
public NbiNotificationsProvider(@Reference RpcProviderService rpcProviderService,
public NbiNotificationsProvider(String subscriberServer, String publisherServer,
RpcProviderService rpcProviderService, NotificationService notificationService,
BindingDOMCodecServices bindingDOMCodecServices, NetworkTransactionService networkTransactionService) {
+ this.networkTransactionService = networkTransactionService;
List<String> publishersServiceList = List.of("PceListener", "ServiceHandlerOperations", "ServiceHandler",
"RendererListener");
TopicManager topicManager = TopicManager.getInstance();
LOG.info("baozhi tapi converter: {}", converterTapiService);
topicManager.setTapiConverter(converterTapiService);
- NbiNotificationsImpl nbiImpl = new NbiNotificationsImpl(converterService, converterAlarmService,
- converterTapiService, subscriberServer, networkTransactionService, topicManager);
- rpcRegistration = rpcProviderService.registerRpcImplementations(nbiImpl.registerRPCs());
+ rpcRegistration = rpcProviderService.registerRpcImplementations(
+ new GetNotificationsProcessServiceImpl(converterService, subscriberServer),
+ new GetNotificationsAlarmServiceImpl(converterAlarmService, subscriberServer),
+ new GetSupportedNotificationTypesImpl(this),
+ new CreateNotificationSubscriptionServiceImpl(this, topicManager),
+ new DeleteNotificationSubscriptionServiceImpl(networkTransactionService, topicManager),
+ new GetNotificationSubscriptionServiceDetailsImpl(this),
+ new GetNotificationSubscriptionServiceListImpl(this),
+ new GetNotificationListImpl(converterTapiService, subscriberServer, networkTransactionService,
+ topicManager));
+
NbiNotificationsHandler notificationsListener = new NbiNotificationsHandler(
topicManager.getProcessTopicMap(), topicManager.getAlarmTopicMap(), topicManager.getTapiTopicMap());
listenerRegistration = notificationService.registerCompositeListener(
listenerRegistration.close();
LOG.info("NbiNotificationsProvider Closed");
}
+
+ public NotificationContext getNotificationContext() {
+ LOG.info("Getting tapi notification context");
+ try {
+ Optional<NotificationContext> notificationContextOptional = this.networkTransactionService.read(
+ LogicalDatastoreType.OPERATIONAL,
+ InstanceIdentifier.builder(Context.class)
+ .augmentation(Context1.class).child(NotificationContext.class)
+ .build())
+ .get();
+ if (notificationContextOptional.isPresent()) {
+ return notificationContextOptional.orElseThrow();
+ }
+ LOG.debug("notification context is empty");
+ } catch (InterruptedException | ExecutionException e) {
+ LOG.error("Caught exception getting Notification Context", e);
+ }
+ LOG.error("Could not get TAPI notification context");
+ return null;
+ }
+
+ public boolean updateNotificationContext(NotificationContext notificationContext1) {
+ try {
+ this.networkTransactionService.merge(
+ LogicalDatastoreType.OPERATIONAL,
+ InstanceIdentifier.builder(Context.class)
+ .augmentation(Context1.class).child(NotificationContext.class)
+ .build(),
+ notificationContext1);
+ this.networkTransactionService.commit().get();
+ return true;
+ } catch (InterruptedException | ExecutionException e) {
+ LOG.error("Could not update TAPI notification context");
+ }
+ return false;
+ }
+
}
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-import org.opendaylight.transportpce.nbinotifications.impl.NbiNotificationsImpl;
+import org.opendaylight.transportpce.nbinotifications.impl.NbiNotificationsProvider;
import org.opendaylight.transportpce.nbinotifications.utils.TopicManager;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Uuid;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.CreateNotificationSubscriptionService;
public class CreateNotificationSubscriptionServiceImpl implements CreateNotificationSubscriptionService {
private static final Logger LOG = LoggerFactory.getLogger(CreateNotificationSubscriptionServiceImpl.class);
- private NbiNotificationsImpl nbiNotifications;
+ private NbiNotificationsProvider nbiNotifications;
private final TopicManager topicManager;
- public CreateNotificationSubscriptionServiceImpl(NbiNotificationsImpl nbiNotifications, TopicManager topicManager) {
+ public CreateNotificationSubscriptionServiceImpl(NbiNotificationsProvider nbiNotifications,
+ TopicManager topicManager) {
this.nbiNotifications = nbiNotifications;
this.topicManager = topicManager;
}
package org.opendaylight.transportpce.nbinotifications.impl.rpc;
import com.google.common.util.concurrent.ListenableFuture;
-import org.opendaylight.transportpce.nbinotifications.impl.NbiNotificationsImpl;
+import org.opendaylight.transportpce.nbinotifications.impl.NbiNotificationsProvider;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Uuid;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.GetNotificationSubscriptionServiceDetails;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.GetNotificationSubscriptionServiceDetailsInput;
public class GetNotificationSubscriptionServiceDetailsImpl implements GetNotificationSubscriptionServiceDetails {
private static final Logger LOG = LoggerFactory.getLogger(GetNotificationSubscriptionServiceDetailsImpl.class);
- private NbiNotificationsImpl nbiNotifications;
+ private NbiNotificationsProvider nbiNotifications;
- public GetNotificationSubscriptionServiceDetailsImpl(NbiNotificationsImpl nbiNotifications) {
+ public GetNotificationSubscriptionServiceDetailsImpl(NbiNotificationsProvider nbiNotifications) {
this.nbiNotifications = nbiNotifications;
}
import com.google.common.util.concurrent.ListenableFuture;
import java.util.HashMap;
import java.util.Map;
-import org.opendaylight.transportpce.nbinotifications.impl.NbiNotificationsImpl;
+import org.opendaylight.transportpce.nbinotifications.impl.NbiNotificationsProvider;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.GetNotificationSubscriptionServiceList;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.GetNotificationSubscriptionServiceListInput;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.GetNotificationSubscriptionServiceListOutput;
public class GetNotificationSubscriptionServiceListImpl implements GetNotificationSubscriptionServiceList {
- private NbiNotificationsImpl nbiNotifications;
+ private NbiNotificationsProvider nbiNotifications;
- public GetNotificationSubscriptionServiceListImpl(NbiNotificationsImpl nbiNotifications) {
+ public GetNotificationSubscriptionServiceListImpl(NbiNotificationsProvider nbiNotifications) {
this.nbiNotifications = nbiNotifications;
}
import com.google.common.util.concurrent.ListenableFuture;
import java.util.HashSet;
import java.util.Set;
-import org.opendaylight.transportpce.nbinotifications.impl.NbiNotificationsImpl;
+import org.opendaylight.transportpce.nbinotifications.impl.NbiNotificationsProvider;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.OBJECTTYPE;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.OBJECTTYPEPROFILE;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.OBJECTTYPESERVICEINTERFACEPOINT;
public class GetSupportedNotificationTypesImpl implements GetSupportedNotificationTypes {
- private NbiNotificationsImpl nbiNotifications;
+ private NbiNotificationsProvider nbiNotifications;
- public GetSupportedNotificationTypesImpl(NbiNotificationsImpl nbiNotifications) {
+ public GetSupportedNotificationTypesImpl(NbiNotificationsProvider nbiNotifications) {
this.nbiNotifications = nbiNotifications;
}
import java.util.concurrent.ExecutionException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.opendaylight.mdsal.binding.api.NotificationService;
+import org.opendaylight.mdsal.binding.api.RpcProviderService;
import org.opendaylight.transportpce.common.converter.JsonStringConverter;
import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
import org.opendaylight.transportpce.common.network.NetworkTransactionService;
import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.GetNotificationListOutput;
import org.opendaylight.yangtools.yang.common.RpcResult;
+@ExtendWith(MockitoExtension.class)
public class NbiNotificationsImplTest extends AbstractTest {
- private NbiNotificationsImpl nbiNotificationsImpl;
+
+ @Mock
+ RpcProviderService rpcProviderRegistry;
+ @Mock
+ private NotificationService notificationService;
+
+ private NbiNotificationsProvider nbiNotifications;
public static NetworkTransactionService networkTransactionService;
private TopicManager topicManager;
private JsonStringConverter<NotificationProcessService> converterProcess;
topicManager.setTapiConverter(converterTapi);
NotificationServiceDataUtils.createTapiContext(networkTransactionService);
- nbiNotificationsImpl = new NbiNotificationsImpl(converterProcess, converterAlarm, converterTapi,
- "localhost:8080", networkTransactionService, topicManager);
+ nbiNotifications = new NbiNotificationsProvider("localhost:8080", "localhost:8080",
+ rpcProviderRegistry, notificationService, getDataStoreContextUtil().getBindingDOMCodecServices(),
+ networkTransactionService);
}
@Test
@Test
void createTapiNotificationSubscriptionServiceTest() throws InterruptedException, ExecutionException {
ListenableFuture<RpcResult<CreateNotificationSubscriptionServiceOutput>> result =
- new CreateNotificationSubscriptionServiceImpl(nbiNotificationsImpl, topicManager)
+ new CreateNotificationSubscriptionServiceImpl(nbiNotifications, topicManager)
.invoke(NotificationServiceDataUtils.buildNotificationSubscriptionServiceInputBuilder().build());
assertNotNull(result.get().getResult().getSubscriptionService().getUuid().toString(),
"Should receive UUID for subscription service");
@Test
void getTapiNotificationsServiceTest() throws InterruptedException, ExecutionException {
ListenableFuture<RpcResult<CreateNotificationSubscriptionServiceOutput>> result =
- new CreateNotificationSubscriptionServiceImpl(nbiNotificationsImpl, topicManager)
+ new CreateNotificationSubscriptionServiceImpl(nbiNotifications, topicManager)
.invoke(NotificationServiceDataUtils.buildNotificationSubscriptionServiceInputBuilder().build());
ListenableFuture<RpcResult<GetNotificationListOutput>> result2 =
new GetNotificationListImpl(converterTapi, "localhost:8080", networkTransactionService, topicManager)
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-import com.google.common.collect.ClassToInstanceMap;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
import org.opendaylight.transportpce.common.network.NetworkTransactionService;
+import org.opendaylight.transportpce.nbinotifications.impl.rpc.CreateNotificationSubscriptionServiceImpl;
+import org.opendaylight.transportpce.nbinotifications.impl.rpc.DeleteNotificationSubscriptionServiceImpl;
+import org.opendaylight.transportpce.nbinotifications.impl.rpc.GetNotificationListImpl;
+import org.opendaylight.transportpce.nbinotifications.impl.rpc.GetNotificationSubscriptionServiceDetailsImpl;
+import org.opendaylight.transportpce.nbinotifications.impl.rpc.GetNotificationSubscriptionServiceListImpl;
+import org.opendaylight.transportpce.nbinotifications.impl.rpc.GetNotificationsAlarmServiceImpl;
+import org.opendaylight.transportpce.nbinotifications.impl.rpc.GetNotificationsProcessServiceImpl;
+import org.opendaylight.transportpce.nbinotifications.impl.rpc.GetSupportedNotificationTypesImpl;
import org.opendaylight.transportpce.test.AbstractTest;
new NbiNotificationsProvider("localhost:8080", "localhost:8080",
rpcProviderRegistry, notificationService, getDataStoreContextUtil().getBindingDOMCodecServices(),
networkTransactionService);
- verify(rpcProviderRegistry, times(1)).registerRpcImplementations(any(ClassToInstanceMap.class));
+ verify(rpcProviderRegistry, times(1)).registerRpcImplementations(
+ any(GetNotificationsProcessServiceImpl.class),
+ any(GetNotificationsAlarmServiceImpl.class),
+ any(GetSupportedNotificationTypesImpl.class),
+ any(CreateNotificationSubscriptionServiceImpl.class),
+ any(DeleteNotificationSubscriptionServiceImpl.class),
+ any(GetNotificationSubscriptionServiceDetailsImpl.class),
+ any(GetNotificationSubscriptionServiceListImpl.class),
+ any(GetNotificationListImpl.class));
verify(notificationService, times(1))
.registerCompositeListener(any(NotificationService.CompositeListener.class));
}
import org.apache.kafka.common.serialization.StringSerializer;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import org.opendaylight.mdsal.binding.api.NotificationService;
+import org.opendaylight.mdsal.binding.api.RpcProviderService;
import org.opendaylight.transportpce.common.converter.JsonStringConverter;
import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
import org.opendaylight.transportpce.common.network.NetworkTransactionService;
-import org.opendaylight.transportpce.nbinotifications.impl.NbiNotificationsImpl;
+import org.opendaylight.transportpce.nbinotifications.impl.NbiNotificationsProvider;
import org.opendaylight.transportpce.nbinotifications.impl.rpc.CreateNotificationSubscriptionServiceImpl;
import org.opendaylight.transportpce.nbinotifications.serialization.ConfigConstants;
import org.opendaylight.transportpce.nbinotifications.serialization.NotificationAlarmServiceSerializer;
import org.opendaylight.yangtools.yang.data.codec.gson.JSONCodecFactorySupplier;
public class PublisherTest extends AbstractTest {
+
private static NetworkTransactionService networkTransactionService;
+ @Mock
+ RpcProviderService rpcProviderRegistry;
+ @Mock
+ private NotificationService notificationService;
+
private JsonStringConverter<NotificationProcessService> converterService;
private JsonStringConverter<NotificationAlarmService> converterAlarm;
private JsonStringConverter<NotificationTapiService> converterTapiService;
private MockProducer<String, NotificationProcessService> mockProducer;
private MockProducer<String, NotificationAlarmService> mockAlarmProducer;
private MockProducer<String, NotificationTapiService> mockTapiProducer;
- private NbiNotificationsImpl nbiNotificationsImpl;
+ private NbiNotificationsProvider nbiNotifications;
private TopicManager topicManager;
networkTransactionService = new NetworkTransactionImpl(getDataBroker());
topicManager.setTapiConverter(converterTapiService);
NotificationServiceDataUtils.createTapiContext(networkTransactionService);
- nbiNotificationsImpl = new NbiNotificationsImpl(converterService, converterAlarm, converterTapiService,
- "localhost:8080", networkTransactionService, topicManager);
+ nbiNotifications = new NbiNotificationsProvider("localhost:8080", "localhost:8080",
+ rpcProviderRegistry, notificationService, getDataStoreContextUtil().getBindingDOMCodecServices(),
+ networkTransactionService);
}
@Test
.build();
builder.setSubscriptionFilter(subscriptionFilter);
- new CreateNotificationSubscriptionServiceImpl(nbiNotificationsImpl, topicManager).invoke(builder.build());
+ new CreateNotificationSubscriptionServiceImpl(nbiNotifications, topicManager).invoke(builder.build());
String json = Files.readString(Paths.get("src/test/resources/tapi_event.json"));
NotificationTapiService notificationTapiService = converterTapiService
.createDataObjectFromJsonString(YangInstanceIdentifier.of(NotificationTapiService.QNAME),
*/
package org.opendaylight.transportpce.networkmodel;
-import com.google.common.collect.ClassToInstanceMap;
-import com.google.common.collect.ImmutableClassToInstanceMap;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.topology.rev180226.networks.network.LinkKey;
import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.Rpc;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.osgi.service.component.annotations.Activate;
@Activate
public NetworkUtilsImpl(@Reference DataBroker dataBroker, @Reference RpcProviderService rpcProvider) {
this.dataBroker = dataBroker;
- rpcReg = rpcProvider.registerRpcImplementations(getRpcClassToInstanceMap());
+ rpcReg = rpcProvider.registerRpcImplementations(
+ (DeleteLink) this::deleteLink,
+ (InitRoadmNodes) this::initRoadmNodes,
+ (InitXpdrRdmLinks) this::initXpdrRdmLinks,
+ (InitRdmXpdrLinks) this::initRdmXpdrLinks
+ );
LOG.info("NetworkUtilsImpl instanciated");
}
+
@Deactivate
public void close() {
rpcReg.close();
return RpcResultBuilder.<InitRdmXpdrLinksOutput>failed().buildFuture();
}
}
-
- public final ClassToInstanceMap<Rpc<?, ?>> getRpcClassToInstanceMap() {
- return ImmutableClassToInstanceMap.<Rpc<?, ?>>builder()
- .put(DeleteLink.class, this::deleteLink)
- .put(InitRoadmNodes.class, this::initRoadmNodes)
- .put(InitXpdrRdmLinks.class, this::initXpdrRdmLinks)
- .put(InitRdmXpdrLinks.class, this::initRdmXpdrLinks)
- .build();
- }
}
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-import com.google.common.collect.ClassToInstanceMap;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkutils.rev220630.DeleteLink;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkutils.rev220630.InitRdmXpdrLinks;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkutils.rev220630.InitRoadmNodes;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.networkutils.rev220630.InitXpdrRdmLinks;
@ExtendWith(MockitoExtension.class)
void networkUtilsInitTest() {
new NetworkUtilsImpl(dataBroker, rpcProvider);
- verify(rpcProvider, times(1)).registerRpcImplementations(any(ClassToInstanceMap.class));
+ verify(rpcProvider, times(1)).registerRpcImplementations(
+ any(DeleteLink.class), any(InitRoadmNodes.class), any(InitXpdrRdmLinks.class),
+ any(InitRdmXpdrLinks.class));
}
}
package org.opendaylight.transportpce.olm;
-import com.google.common.collect.ImmutableClassToInstanceMap;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
import org.opendaylight.transportpce.olm.rpc.impl.CalculateSpanlossBaseImpl;
import org.opendaylight.transportpce.olm.rpc.impl.CalculateSpanlossCurrentImpl;
import org.opendaylight.transportpce.olm.rpc.impl.ServicePowerSetupImpl;
import org.opendaylight.transportpce.olm.rpc.impl.ServicePowerTurndownImpl;
import org.opendaylight.transportpce.olm.service.OlmPowerService;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.CalculateSpanlossBase;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.olm.rev210618.CalculateSpanlossCurrent;
-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.ServicePowerReset;
-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.ServicePowerTurndown;
import org.opendaylight.yangtools.concepts.Registration;
-import org.opendaylight.yangtools.yang.binding.Rpc;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
public OlmPowerServiceRpcImpl(@Reference OlmPowerService olmPowerService,
@Reference RpcProviderService rpcProviderService) {
this.rpcRegistration = rpcProviderService.registerRpcImplementations(
- ImmutableClassToInstanceMap.<Rpc<?, ?>>builder()
- .put(GetPm.class, new GetPmImpl(olmPowerService))
- .put(ServicePowerSetup.class, new ServicePowerSetupImpl(olmPowerService))
- .put(ServicePowerTurndown.class, new ServicePowerTurndownImpl(olmPowerService))
- .put(CalculateSpanlossBase.class, new CalculateSpanlossBaseImpl(olmPowerService))
- .put(CalculateSpanlossCurrent.class, new CalculateSpanlossCurrentImpl(olmPowerService))
- .put(ServicePowerReset.class, new ServicePowerResetImpl(olmPowerService))
- .build());
+ new GetPmImpl(olmPowerService),
+ new ServicePowerSetupImpl(olmPowerService),
+ new ServicePowerTurndownImpl(olmPowerService),
+ new CalculateSpanlossBaseImpl(olmPowerService),
+ new CalculateSpanlossCurrentImpl(olmPowerService),
+ new ServicePowerResetImpl(olmPowerService));
LOG.info("OlmPowerServiceRpcImpl instantiated");
}
*/
package org.opendaylight.transportpce.pce.impl;
-import com.google.common.collect.ImmutableClassToInstanceMap;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
import org.opendaylight.transportpce.pce.service.PathComputationService;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.CancelResourceReserve;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequest;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRerouteRequest;
import org.opendaylight.yangtools.concepts.Registration;
-import org.opendaylight.yangtools.yang.binding.Rpc;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
@Activate
public PceServiceRPCImpl(@Reference RpcProviderService rpcProviderService,
@Reference PathComputationService pathComputationService) {
- this.reg = rpcProviderService.registerRpcImplementations(ImmutableClassToInstanceMap.<Rpc<?, ?>>builder()
- .put(CancelResourceReserve.class, new CancelResourceReserveImpl(pathComputationService))
- .put(PathComputationRequest.class, new PathComputationRequestImpl(pathComputationService))
- .put(PathComputationRerouteRequest.class, new PathComputationRerouteRequestImpl(pathComputationService))
- .build());
+ this.reg = rpcProviderService.registerRpcImplementations(
+ new CancelResourceReserveImpl(pathComputationService),
+ new PathComputationRequestImpl(pathComputationService),
+ new PathComputationRerouteRequestImpl(pathComputationService));
LOG.info("PceServiceRPCImpl instantiated");
}
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-import com.google.common.collect.ClassToInstanceMap;
import java.util.concurrent.ExecutionException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@Test
void testRpcRegistration() {
new PceServiceRPCImpl(rpcProviderService, pathComputationService);
- verify(rpcProviderService, times(1)).registerRpcImplementations(any(ClassToInstanceMap.class));
+ verify(rpcProviderService, times(1)).registerRpcImplementations(
+ any(CancelResourceReserveImpl.class), any(PathComputationRequestImpl.class),
+ any(PathComputationRerouteRequestImpl.class));
}
@Test
package org.opendaylight.transportpce.renderer.rpcs;
-import com.google.common.collect.ImmutableClassToInstanceMap;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
import org.opendaylight.transportpce.renderer.provisiondevice.DeviceRendererService;
import org.opendaylight.transportpce.renderer.provisiondevice.OtnDeviceRendererService;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.CreateOtsOms;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.OtnServicePath;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.RendererRollback;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.device.renderer.rev211004.ServicePath;
import org.opendaylight.yangtools.concepts.Registration;
-import org.opendaylight.yangtools.yang.binding.Rpc;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
public DeviceRendererRPCImpl(@Reference RpcProviderService rpcProviderService,
@Reference DeviceRendererService deviceRenderer,
@Reference OtnDeviceRendererService otnDeviceRendererService) {
- this.reg = rpcProviderService.registerRpcImplementations(ImmutableClassToInstanceMap.<Rpc<?, ?>>builder()
- .put(ServicePath.class, new ServicePathImpl(deviceRenderer))
- .put(OtnServicePath.class, new OtnServicePathImpl(otnDeviceRendererService))
- .put(RendererRollback.class, new RendererRollbackImpl(deviceRenderer))
- .put(CreateOtsOms.class, new CreateOtsOmsImpl(deviceRenderer))
- .build());
+ this.reg = rpcProviderService.registerRpcImplementations(
+ new ServicePathImpl(deviceRenderer),
+ new OtnServicePathImpl(otnDeviceRendererService),
+ new RendererRollbackImpl(deviceRenderer),
+ new CreateOtsOmsImpl(deviceRenderer));
LOG.debug("RPC of DeviceRendererRPCImpl instantiated");
}
*/
package org.opendaylight.transportpce.renderer.rpcs;
-import com.google.common.collect.ImmutableClassToInstanceMap;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
import org.opendaylight.transportpce.renderer.provisiondevice.RendererServiceOperations;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceDelete;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.renderer.rev210915.ServiceImplementationRequest;
import org.opendaylight.yangtools.concepts.Registration;
-import org.opendaylight.yangtools.yang.binding.Rpc;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
@Activate
public RendererRPCImpl(@Reference RendererServiceOperations rendererServiceOperations,
@Reference RpcProviderService rpcProviderService) {
- this.reg = rpcProviderService.registerRpcImplementations(ImmutableClassToInstanceMap.<Rpc<?, ?>>builder()
- .put(ServiceImplementationRequest.class, new ServiceImplementationRequestImpl(rendererServiceOperations))
- .put(ServiceDelete.class, new ServiceDeleteImpl(rendererServiceOperations))
- .build());
+ this.reg = rpcProviderService.registerRpcImplementations(
+ new ServiceImplementationRequestImpl(rendererServiceOperations),
+ new ServiceDeleteImpl(rendererServiceOperations));
LOG.debug("TransportPCEServicePathRPCImpl instantiated");
}
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import com.google.common.collect.ClassToInstanceMap;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.concurrent.ExecutionException;
import org.junit.jupiter.api.BeforeEach;
@Test
void testRpcRegistration() {
new DeviceRendererRPCImpl(rpcProviderService, deviceRenderer, otnDeviceRendererService);
- verify(rpcProviderService, times(1)).registerRpcImplementations(any(ClassToInstanceMap.class));
+ verify(rpcProviderService, times(1)).registerRpcImplementations(
+ any(ServicePathImpl.class), any(OtnServicePathImpl.class), any(RendererRollbackImpl.class),
+ any(CreateOtsOmsImpl.class));
}
@Test
+++ /dev/null
-/*
- * Copyright © 2018 Orange, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.transportpce.tapi.connectivity;
-
-import com.google.common.collect.ImmutableClassToInstanceMap;
-import org.opendaylight.mdsal.binding.api.RpcService;
-import org.opendaylight.transportpce.common.network.NetworkTransactionService;
-import org.opendaylight.transportpce.tapi.impl.rpc.CreateConnectivityServiceImpl;
-import org.opendaylight.transportpce.tapi.impl.rpc.DeleteConnectivityServiceImpl;
-import org.opendaylight.transportpce.tapi.impl.rpc.GetConnectionDetailsImpl;
-import org.opendaylight.transportpce.tapi.impl.rpc.GetConnectivityServiceDetailsImpl;
-import org.opendaylight.transportpce.tapi.impl.rpc.GetConnectivityServiceListImpl;
-import org.opendaylight.transportpce.tapi.listeners.TapiPceNotificationHandler;
-import org.opendaylight.transportpce.tapi.listeners.TapiRendererNotificationHandler;
-import org.opendaylight.transportpce.tapi.utils.TapiContext;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.CreateConnectivityService;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.DeleteConnectivityService;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.GetConnectionDetails;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.GetConnectivityServiceDetails;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.GetConnectivityServiceList;
-import org.opendaylight.yangtools.yang.binding.Rpc;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Top level service interface providing main TAPI Connectivity services.
- */
-public class TapiConnectivityImpl {
- private static final Logger LOG = LoggerFactory.getLogger(TapiConnectivityImpl.class);
-
- private RpcService rpcService;
- private final TapiContext tapiContext;
- private final ConnectivityUtils connectivityUtils;
- private TapiPceNotificationHandler pceListenerImpl;
- private TapiRendererNotificationHandler rendererListenerImpl;
- private final NetworkTransactionService networkTransactionService;
-
- public TapiConnectivityImpl(RpcService rpcService, TapiContext tapiContext,
- ConnectivityUtils connectivityUtils, TapiPceNotificationHandler pceListenerImpl,
- TapiRendererNotificationHandler rendererListenerImpl,
- NetworkTransactionService networkTransactionService) {
- LOG.info("inside TapiImpl constructor");
- this.rpcService = rpcService;
- this.tapiContext = tapiContext;
- this.connectivityUtils = connectivityUtils;
- this.pceListenerImpl = pceListenerImpl;
- this.rendererListenerImpl = rendererListenerImpl;
- this.networkTransactionService = networkTransactionService;
- }
-
-
- public ImmutableClassToInstanceMap<Rpc<?, ?>> registerRPCs() {
- return ImmutableClassToInstanceMap.<Rpc<?, ?>>builder()
- .put(CreateConnectivityService.class, new CreateConnectivityServiceImpl(rpcService, tapiContext,
- connectivityUtils, pceListenerImpl, rendererListenerImpl))
- .put(GetConnectivityServiceDetails.class, new GetConnectivityServiceDetailsImpl(tapiContext))
- .put(GetConnectionDetails.class, new GetConnectionDetailsImpl(tapiContext))
- .put(DeleteConnectivityService.class, new DeleteConnectivityServiceImpl(rpcService, tapiContext,
- networkTransactionService))
- .put(GetConnectivityServiceList.class, new GetConnectivityServiceListImpl(tapiContext))
- .build();
- }
-
-}
import org.opendaylight.transportpce.common.network.NetworkTransactionService;
import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
import org.opendaylight.transportpce.tapi.connectivity.ConnectivityUtils;
-import org.opendaylight.transportpce.tapi.connectivity.TapiConnectivityImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.CreateConnectivityServiceImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.DeleteConnectivityServiceImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetConnectionDetailsImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetConnectivityServiceDetailsImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetConnectivityServiceListImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetLinkDetailsImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetNodeDetailsImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetNodeEdgePointDetailsImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetServiceInterfacePointDetailsImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetServiceInterfacePointListImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetTopologyDetailsImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetTopologyListImpl;
import org.opendaylight.transportpce.tapi.listeners.TapiNetworkModelNotificationHandler;
import org.opendaylight.transportpce.tapi.listeners.TapiPceNotificationHandler;
import org.opendaylight.transportpce.tapi.listeners.TapiRendererNotificationHandler;
import org.opendaylight.transportpce.tapi.topology.TapiNetworkModelService;
import org.opendaylight.transportpce.tapi.topology.TapiOrLinkListener;
import org.opendaylight.transportpce.tapi.topology.TapiPortMappingListener;
-import org.opendaylight.transportpce.tapi.topology.TapiTopologyImpl;
import org.opendaylight.transportpce.tapi.topology.TopologyUtils;
import org.opendaylight.transportpce.tapi.utils.TapiContext;
import org.opendaylight.transportpce.tapi.utils.TapiInitialORMapping;
private final NetworkTransactionService networkTransactionService;
private final ServiceDataStoreOperations serviceDataStoreOperations;
private List<Registration> listeners;
- private List<Registration> rpcRegistrations = new ArrayList<>();
+ private Registration rpcRegistration;
private Registration pcelistenerRegistration;
private Registration rendererlistenerRegistration;
private Registration servicehandlerlistenerRegistration;
TapiRendererNotificationHandler rendererListenerImpl = new TapiRendererNotificationHandler(dataBroker,
notificationPublishService);
- TapiConnectivityImpl tapiConnectivity = new TapiConnectivityImpl(rpcService, tapiContext,
- connectivityUtils, pceListenerImpl, rendererListenerImpl, networkTransactionService);
- rpcRegistrations.add(rpcProviderService.registerRpcImplementations(tapiConnectivity.registerRPCs()));
- TapiTopologyImpl topo = new TapiTopologyImpl(networkTransactionService, tapiContext, topologyUtils, tapiLink);
- rpcRegistrations.add(rpcProviderService.registerRpcImplementations(topo.registerRPCs()));
+ rpcRegistration = rpcProviderService.registerRpcImplementations(
+ new CreateConnectivityServiceImpl(rpcService, tapiContext, connectivityUtils, pceListenerImpl,
+ rendererListenerImpl),
+ new GetConnectivityServiceDetailsImpl(tapiContext),
+ new GetConnectionDetailsImpl(tapiContext),
+ new DeleteConnectivityServiceImpl(rpcService, tapiContext, networkTransactionService),
+ new GetConnectivityServiceListImpl(tapiContext),
+ new GetNodeDetailsImpl(tapiContext),
+ new GetTopologyDetailsImpl(tapiContext, topologyUtils, tapiLink, networkTransactionService),
+ new GetNodeEdgePointDetailsImpl(tapiContext),
+ new GetLinkDetailsImpl(tapiContext),
+ new GetTopologyListImpl(tapiContext),
+ new GetServiceInterfacePointDetailsImpl(tapiContext),
+ new GetServiceInterfacePointListImpl(tapiContext));
this.listeners = new ArrayList<>();
TapiNetconfTopologyListener topologyListener = new TapiNetconfTopologyListener(tapiNetworkModelServiceImpl);
rendererlistenerRegistration.close();
servicehandlerlistenerRegistration.close();
tapinetworkmodellistenerRegistration.close();
- for (Registration reg : rpcRegistrations) {
- reg.close();
- }
+ rpcRegistration.close();
LOG.info("TapiProvider Session Closed");
}
- public List<Registration> getRegisteredRpcs() {
- return rpcRegistrations;
+ public Registration getRegisteredRpcs() {
+ return rpcRegistration;
}
}
+++ /dev/null
-/*
- * Copyright © 2019 Orange, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.transportpce.tapi.topology;
-
-import com.google.common.collect.ImmutableClassToInstanceMap;
-import org.opendaylight.transportpce.common.network.NetworkTransactionService;
-import org.opendaylight.transportpce.tapi.impl.rpc.GetLinkDetailsImpl;
-import org.opendaylight.transportpce.tapi.impl.rpc.GetNodeDetailsImpl;
-import org.opendaylight.transportpce.tapi.impl.rpc.GetNodeEdgePointDetailsImpl;
-import org.opendaylight.transportpce.tapi.impl.rpc.GetServiceInterfacePointDetailsImpl;
-import org.opendaylight.transportpce.tapi.impl.rpc.GetServiceInterfacePointListImpl;
-import org.opendaylight.transportpce.tapi.impl.rpc.GetTopologyDetailsImpl;
-import org.opendaylight.transportpce.tapi.impl.rpc.GetTopologyListImpl;
-import org.opendaylight.transportpce.tapi.utils.TapiContext;
-import org.opendaylight.transportpce.tapi.utils.TapiLink;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.GetServiceInterfacePointDetails;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.GetServiceInterfacePointList;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetLinkDetails;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetNodeDetails;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetNodeEdgePointDetails;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetTopologyDetails;
-import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.GetTopologyList;
-import org.opendaylight.yangtools.yang.binding.Rpc;
-
-public class TapiTopologyImpl {
-
- private final NetworkTransactionService networkTransactionService;
- private final TapiContext tapiContext;
- private final TopologyUtils topologyUtils;
- private final TapiLink tapiLink;
-
- public TapiTopologyImpl(NetworkTransactionService networkTransactionService, TapiContext tapiContext,
- TopologyUtils topologyUtils, TapiLink tapiLink) {
- this.networkTransactionService = networkTransactionService;
- this.tapiContext = tapiContext;
- this.topologyUtils = topologyUtils;
- this.tapiLink = tapiLink;
-
- }
-
- public ImmutableClassToInstanceMap<Rpc<?, ?>> registerRPCs() {
- return ImmutableClassToInstanceMap.<Rpc<?, ?>>builder()
- .put(GetNodeDetails.class, new GetNodeDetailsImpl(tapiContext))
- .put(GetTopologyDetails.class, new GetTopologyDetailsImpl(tapiContext, topologyUtils, tapiLink,
- networkTransactionService))
- .put(GetNodeEdgePointDetails.class, new GetNodeEdgePointDetailsImpl(tapiContext))
- .put(GetLinkDetails.class, new GetLinkDetailsImpl(tapiContext))
- .put(GetTopologyList.class, new GetTopologyListImpl(tapiContext))
- .put(GetServiceInterfacePointDetails.class, new GetServiceInterfacePointDetailsImpl(tapiContext))
- .put(GetServiceInterfacePointList.class, new GetServiceInterfacePointListImpl(tapiContext))
- .build();
- }
-
-}
tapiInitialORMapping = new TapiInitialORMapping(topologyUtils, connectivityUtils,
tapiContext, serviceDataStoreOperations);
tapiInitialORMapping.performTopoInitialMapping();
- new TapiConnectivityImpl(rpcService, tapiContext, connectivityUtils,
- tapipceNotificationHandler, tapirendererNotificationHandler, networkTransactionService);
LOG.info("setup done");
}
import static org.mockito.Mockito.when;
import static org.opendaylight.mdsal.common.api.CommitInfo.emptyFluentFuture;
-import com.google.common.collect.ClassToInstanceMap;
import com.google.common.util.concurrent.Futures;
import java.util.Optional;
import org.junit.jupiter.api.Test;
import org.opendaylight.transportpce.common.network.NetworkTransactionService;
import org.opendaylight.transportpce.servicehandler.service.ServiceDataStoreOperations;
import org.opendaylight.transportpce.tapi.impl.TapiProvider;
+import org.opendaylight.transportpce.tapi.impl.rpc.CreateConnectivityServiceImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.DeleteConnectivityServiceImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetConnectionDetailsImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetConnectivityServiceDetailsImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetConnectivityServiceListImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetLinkDetailsImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetNodeDetailsImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetNodeEdgePointDetailsImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetServiceInterfacePointDetailsImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetServiceInterfacePointListImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetTopologyDetailsImpl;
+import org.opendaylight.transportpce.tapi.impl.rpc.GetTopologyListImpl;
import org.opendaylight.transportpce.tapi.listeners.TapiNetworkModelNotificationHandler;
import org.opendaylight.transportpce.tapi.topology.TapiNetworkModelService;
networkTransactionService, serviceDataStoreOperations,
tapiNetworkModelNotificationHandler, tapiNetworkModelServiceImpl);
- verify(rpcProviderService, times(2)).registerRpcImplementations(any(ClassToInstanceMap.class));
+ verify(rpcProviderService, times(1)).registerRpcImplementations(
+ any(CreateConnectivityServiceImpl.class),
+ any(GetConnectivityServiceDetailsImpl.class),
+ any(GetConnectionDetailsImpl.class),
+ any(DeleteConnectivityServiceImpl.class),
+ any(GetConnectivityServiceListImpl.class),
+ any(GetNodeDetailsImpl.class),
+ any(GetTopologyDetailsImpl.class),
+ any(GetNodeEdgePointDetailsImpl.class),
+ any(GetLinkDetailsImpl.class),
+ any(GetTopologyListImpl.class),
+ any(GetServiceInterfacePointDetailsImpl.class),
+ any(GetServiceInterfacePointListImpl.class));
verify(dataBroker, times(4)).registerTreeChangeListener(any(), any());
}
}
import static org.junit.jupiter.api.Assertions.assertNotNull;
import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
@Mock
private RpcService rpcService;
- private static ListeningExecutorService executorService;
- private static CountDownLatch endSignal;
private static final int NUM_THREADS = 3;
private static NetworkTransactionService networkTransactionService;
private static TapiContext tapiContext;
@BeforeAll
static void setUp() throws InterruptedException, ExecutionException {
- executorService = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUM_THREADS));
- endSignal = new CountDownLatch(1);
+ MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(NUM_THREADS));
+ new CountDownLatch(1);
TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),
TapiTopologyDataUtils.OPENROADM_TOPOLOGY_FILE, InstanceIdentifiers.OVERLAY_NETWORK_II);
TopologyDataUtils.writeTopologyFromFileToDatastore(getDataStoreContextUtil(),