import org.opendaylight.transportpce.olm.power.PowerMgmtImpl;
import org.opendaylight.transportpce.olm.service.OlmPowerServiceImpl;
import org.opendaylight.transportpce.pce.gnpy.consumer.GnpyConsumerImpl;
-import org.opendaylight.transportpce.pce.impl.PceProvider;
import org.opendaylight.transportpce.pce.impl.PceServiceRPCImpl;
import org.opendaylight.transportpce.pce.service.PathComputationService;
import org.opendaylight.transportpce.pce.service.PathComputationServiceImpl;
// because implementation has additional public methods ...
private final DeviceTransactionManagerImpl deviceTransactionManager;
private final NetworkTransactionService networkTransaction;
- // pce beans
- private final PceProvider pceProvider;
// network model beans
private final NetworkModelProvider networkModelProvider;
// service-handler beans
new GnpyConsumerImpl(
"http://127.0.0.1:8008", "gnpy", "gnpy", lightyServices.getAdapterContext().currentSerializer()),
portMapping);
- pceProvider = new PceProvider(lgServRPS, pathComputationService, new PceServiceRPCImpl(pathComputationService));
-
+ rpcRegistrations.add(
+ new PceServiceRPCImpl(lgServRPS, pathComputationService)
+ .getRegisteredRpc());
LOG.info("Creating OLM beans ...");
MappingUtils mappingUtils = new MappingUtilsImpl(lgServBDB);
CrossConnect crossConnect = initCrossConnect(mappingUtils);
servicehandlerProvider.close();
LOG.info("Shutting down network-model provider ...");
networkModelProvider.close();
- LOG.info("Shutting down PCE provider ...");
- pceProvider.close();
LOG.info("Shutting down transaction providers ...");
deviceTransactionManager.preDestroy();
LOG.info("Closing registered RPCs...");
+++ /dev/null
-/*
- * Copyright © 2017 AT&T, 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.pce.impl;
-
-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.rev220808.TransportpcePceService;
-import org.opendaylight.yangtools.concepts.ObjectRegistration;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/*
- * Class to register
- * Pce Service & Notification.
- */
-@Component
-public class PceProvider {
-
- private static final Logger LOG = LoggerFactory.getLogger(PceProvider.class);
-
- private final RpcProviderService rpcService;
- private ObjectRegistration<TransportpcePceService> rpcRegistration;
-
- @Activate
- public PceProvider(@Reference RpcProviderService rpcProviderService,
- @Reference PathComputationService pathComputationService,
- @Reference TransportpcePceService pceServiceRPCImpl) {
- this.rpcService = rpcProviderService;
- rpcRegistration = rpcService.registerRpcImplementation(TransportpcePceService.class, pceServiceRPCImpl);
- LOG.info("PceProvider Session Initiated");
- }
-
- /*
- * Method called when the blueprint container is destroyed.
- */
- @Deactivate
- public void close() {
- LOG.info("PceProvider Closed");
- rpcRegistration.close();
- }
-}
*/
package org.opendaylight.transportpce.pce.impl;
+import com.google.common.collect.ImmutableClassToInstanceMap;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.concurrent.ExecutionException;
+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.rev220808.CancelResourceReserve;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.CancelResourceReserveInput;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.CancelResourceReserveOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRequest;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRequestInput;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRequestOutput;
+import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRerouteRequest;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRerouteRequestInput;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.PathComputationRerouteRequestOutput;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.TransportpcePceService;
+import org.opendaylight.yangtools.concepts.Registration;
+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;
import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Reference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* PceService implementation.
*/
-@Component
+@Component(immediate = true)
public class PceServiceRPCImpl implements TransportpcePceService {
private static final Logger LOG = LoggerFactory.getLogger(PceServiceRPCImpl.class);
private final PathComputationService pathComputationService;
+ private Registration reg;
@Activate
- public PceServiceRPCImpl(@Reference PathComputationService pathComputationService) {
+ public PceServiceRPCImpl(@Reference RpcProviderService rpcProviderService,
+ @Reference PathComputationService pathComputationService) {
this.pathComputationService = pathComputationService;
+ this.reg = rpcProviderService.registerRpcImplementations(ImmutableClassToInstanceMap.<Rpc<?, ?>>builder()
+ .put(CancelResourceReserve.class, this::cancelResourceReserve)
+ .put(PathComputationRequest.class, this::pathComputationRequest)
+ .put(PathComputationRerouteRequest.class, this::pathComputationRerouteRequest)
+ .build());
+
LOG.info("PceServiceRPCImpl instantiated");
}
+ @Deactivate
+ public void close() {
+ this.reg.close();
+ LOG.info("PceServiceRPCImpl Closed");
+ }
+
@Override
- public ListenableFuture<RpcResult<CancelResourceReserveOutput>>
+ public final ListenableFuture<RpcResult<CancelResourceReserveOutput>>
cancelResourceReserve(CancelResourceReserveInput input) {
LOG.info("RPC cancelResourceReserve request received");
try {
}
@Override
- public ListenableFuture<RpcResult<PathComputationRequestOutput>>
+ public final ListenableFuture<RpcResult<PathComputationRequestOutput>>
pathComputationRequest(PathComputationRequestInput input) {
LOG.info("RPC path computation request received");
LOG.debug("input parameters are : input = {}", input);
}
@Override
- public ListenableFuture<RpcResult<PathComputationRerouteRequestOutput>> pathComputationRerouteRequest(
+ public final ListenableFuture<RpcResult<PathComputationRerouteRequestOutput>> pathComputationRerouteRequest(
PathComputationRerouteRequestInput input) {
LOG.info("RPC path computation reroute request received");
LOG.debug("input parameters are : input = {}", input);
return RpcResultBuilder.success((PathComputationRerouteRequestOutput) null).buildFuture();
}
}
+
+ public Registration getRegisteredRpc() {
+ return reg;
+ }
}
this.executor = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(5));
this.gnpyConsumer = gnpyConsumer;
this.portMapping = portMapping;
- LOG.debug("PathComputationServiceImpl instantiated");
+ LOG.info("PathComputationServiceImpl instantiated");
}
@SuppressFBWarnings(
+++ /dev/null
-/*
- * Copyright © 2020 Orange Labs, 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.pce.impl;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-
-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.RpcProviderService;
-import org.opendaylight.transportpce.pce.service.PathComputationService;
-import org.opendaylight.transportpce.test.AbstractTest;
-import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.TransportpcePceService;
-
-@ExtendWith(MockitoExtension.class)
-public class PceProviderTest extends AbstractTest {
-
- @Mock
- private RpcProviderService rpcService;
- @Mock
- private PathComputationService pathComputationService;
- @Mock
- private TransportpcePceService pceServiceRPCImpl;
-
- @Test
- void testInit() {
- new PceProvider(rpcService, pathComputationService, pceServiceRPCImpl);
- verify(rpcService, times(1)).registerRpcImplementation(any(), any(TransportpcePceService.class));
- }
-}
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
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.NotificationPublishService;
+import org.opendaylight.mdsal.binding.api.RpcProviderService;
import org.opendaylight.transportpce.common.mapping.PortMapping;
import org.opendaylight.transportpce.common.network.NetworkTransactionImpl;
import org.opendaylight.transportpce.pce.service.PathComputationService;
import org.opendaylight.transportpce.test.AbstractTest;
import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev220808.CancelResourceReserveInputBuilder;
-
+@ExtendWith(MockitoExtension.class)
public class PceServiceRPCImplTest extends AbstractTest {
private PathComputationService pathComputationService;
private PceServiceRPCImpl pceServiceRPC;
@Mock
private PortMapping portMapping;
+ @Mock
+ private RpcProviderService rpcProviderService;
+
@BeforeEach
void setUp() throws ExecutionException, InterruptedException {
networkTransaction = new NetworkTransactionImpl(getDataBroker());
pathComputationService = new PathComputationServiceImpl(networkTransaction, notificationPublishService,
null, portMapping);
- pceServiceRPC = new PceServiceRPCImpl(pathComputationService);
+ pceServiceRPC = new PceServiceRPCImpl(rpcProviderService, pathComputationService);
+ }
+
+ @Test
+ void testRpcRegistration() {
+ verify(rpcProviderService, times(1)).registerRpcImplementations(any());
}
@Test