use of org.opendaylight.controller.md.sal.dom.api.DOMRpcService in project controller by opendaylight.
the class DomBrokerImplModule method createInstance.
@Override
@SuppressWarnings("checkstyle:IllegalCatch")
public AutoCloseable createInstance() {
// The services are provided via blueprint so retrieve then from the OSGi service registry for
// backwards compatibility.
final List<AutoCloseable> closeables = new ArrayList<>();
DOMNotificationService domNotificationService = newTracker(DOMNotificationService.class, closeables).waitForService(WaitingServiceTracker.FIVE_MINUTES);
DOMNotificationPublishService domNotificationPublishService = newTracker(DOMNotificationPublishService.class, closeables).waitForService(WaitingServiceTracker.FIVE_MINUTES);
DOMRpcService domRpcService = newTracker(DOMRpcService.class, closeables).waitForService(WaitingServiceTracker.FIVE_MINUTES);
DOMRpcProviderService domRpcProvider = newTracker(DOMRpcProviderService.class, closeables).waitForService(WaitingServiceTracker.FIVE_MINUTES);
DOMMountPointService mountService = newTracker(DOMMountPointService.class, closeables).waitForService(WaitingServiceTracker.FIVE_MINUTES);
SchemaService globalSchemaService = newTracker(SchemaService.class, closeables).waitForService(WaitingServiceTracker.FIVE_MINUTES);
final DOMDataBroker dataBroker = getAsyncDataBrokerDependency();
final ClassToInstanceMap<BrokerService> services = MutableClassToInstanceMap.create();
services.putInstance(DOMNotificationService.class, domNotificationService);
services.putInstance(DOMNotificationPublishService.class, domNotificationPublishService);
final SchemaService schemaService = getSchemaServiceImpl(globalSchemaService);
services.putInstance(SchemaService.class, schemaService);
services.putInstance(DOMDataBroker.class, dataBroker);
services.putInstance(DOMRpcService.class, domRpcService);
services.putInstance(DOMRpcProviderService.class, domRpcProvider);
services.putInstance(DOMMountPointService.class, mountService);
BrokerImpl broker = new BrokerImpl(domRpcService, domRpcProvider, services);
broker.setDeactivator(() -> {
for (AutoCloseable ac : closeables) {
try {
ac.close();
} catch (Exception e) {
LOG.warn("Exception while closing {}", ac, e);
}
}
});
return broker;
}
use of org.opendaylight.controller.md.sal.dom.api.DOMRpcService in project controller by opendaylight.
the class DOMRpcServiceTestBugfix560 method test.
@Test
public void test() throws ExecutionException, InterruptedException {
// FIXME: This is made to only make sure instance identifier codec for path is instantiated.
domMountPointService.createMountPoint(BI_MOUNT_ID).addService(DOMRpcService.class, new DOMRpcService() {
@Override
public <T extends DOMRpcAvailabilityListener> ListenerRegistration<T> registerRpcListener(final T arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(final SchemaPath arg0, final NormalizedNode<?, ?> arg1) {
final DOMRpcResult result = new DefaultDOMRpcResult((NormalizedNode<?, ?>) null);
return Futures.immediateCheckedFuture(result);
}
}).register();
final Optional<MountPoint> mountInstance = bindingMountPointService.getMountPoint(BA_MOUNT_ID);
assertTrue(mountInstance.isPresent());
final Optional<RpcConsumerRegistry> rpcRegistry = mountInstance.get().getService(RpcConsumerRegistry.class);
assertTrue(rpcRegistry.isPresent());
final OpendaylightTestRpcServiceService rpcService = rpcRegistry.get().getRpcService(OpendaylightTestRpcServiceService.class);
assertNotNull(rpcService);
try {
final Future<RpcResult<Void>> result = rpcService.rockTheHouse(new RockTheHouseInputBuilder().build());
assertTrue(result.get().isSuccessful());
} catch (final IllegalStateException ex) {
fail("OpendaylightTestRpcServiceService class doesn't contain rockTheHouse method!");
}
}
use of org.opendaylight.controller.md.sal.dom.api.DOMRpcService in project controller by opendaylight.
the class AbstractInvokableServiceMetadata method retrievedDOMRpcService.
private void retrievedDOMRpcService(final Object service) {
log.debug("{}: retrievedDOMRpcService {}", logName(), service);
final DOMRpcService domRpcService = (DOMRpcService) service;
setDependencyDesc("Available DOM RPC for binding RPC: " + rpcInterface);
rpcListenerReg = domRpcService.registerRpcListener(new DOMRpcAvailabilityListener() {
@Override
public void onRpcAvailable(final Collection<DOMRpcIdentifier> rpcs) {
onRpcsAvailable(rpcs);
}
@Override
public void onRpcUnavailable(final Collection<DOMRpcIdentifier> rpcs) {
}
});
}
Aggregations