本文整理汇总了Java中org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService类的典型用法代码示例。如果您正苦于以下问题:Java ClusterSingletonService类的具体用法?Java ClusterSingletonService怎么用?Java ClusterSingletonService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ClusterSingletonService类属于org.opendaylight.mdsal.singleton.common.api包,在下文中一共展示了ClusterSingletonService类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerSingletonService
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService; //导入依赖的package包/类
/**
* This helper function wraps
* {@link ClusterSingletonServiceProvider#registerClusterSingletonService(ClusterSingletonService)} in order to
* execute repeated registration attempts while catching RuntimeException. If registration is not successful,
* RuntimeException is re-thrown.
*
* @param singletonProvider Cluster Singleton Service Provider
* @param clusterSingletonService Cluster Singleton Service
* @param maxAttempts Upper bound for registration retries count.
* @param sleepTime Sleep time between registration retries in milliseconds.
* @return Registration
*/
@SuppressWarnings("checkstyle:IllegalCatch")
public static ClusterSingletonServiceRegistration registerSingletonService(
final ClusterSingletonServiceProvider singletonProvider,
final ClusterSingletonService clusterSingletonService, final int maxAttempts, final int sleepTime) {
int attempts = maxAttempts;
while (true) {
try {
return singletonProvider.registerClusterSingletonService(clusterSingletonService);
} catch (final RuntimeException e) {
if (attempts == 0) {
LOG.error("Giving up after {} registration attempts for service {}.", maxAttempts,
clusterSingletonService, e);
throw e;
}
attempts--;
LOG.warn("Failed to register {} service to ClusterSingletonServiceProvider. Try again in {} ms. {}",
clusterSingletonService, sleepTime, e);
Uninterruptibles.sleepUninterruptibly(sleepTime, TimeUnit.MILLISECONDS);
}
}
}
示例2: mockRib
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService; //导入依赖的package包/类
public void mockRib() throws Exception {
final RIBExtensionProviderContext context = new SimpleRIBExtensionProviderContext();
final ModuleInfoBackedContext strategy = createClassLoadingStrategy();
final SchemaContext schemaContext = strategy.tryToCreateSchemaContext().get();
this.codecFactory = createCodecFactory(strategy, schemaContext);
final List<BgpTableType> localTables = new ArrayList<>();
localTables.add(new BgpTableTypeImpl(AFI, SAFI));
this.a1 = new RIBActivator();
this.a1.startRIBExtensionProvider(context);
mockedMethods();
doReturn(mock(ClusterSingletonServiceRegistration.class)).when(this.clusterSingletonServiceProvider)
.registerClusterSingletonService(any(ClusterSingletonService.class));
this.rib = new RIBImpl(new RibId("test"), new AsNumber(5L), RIB_ID, CLUSTER_ID, context,
this.dispatcher, this.codecFactory, this.dom, localTables,
Collections.singletonMap(new TablesKey(AFI, SAFI),
BasePathSelectionModeFactory.createBestPathSelectionStrategy()),
GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy());
this.rib.onGlobalContextUpdated(schemaContext);
this.ribSupport = getRib().getRibSupportContext().getRIBSupportContext(KEY).getRibSupport();
}
示例3: setUp
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
initMocks(this);
doAnswer(invocationOnMock -> {
this.singletonService = (ClusterSingletonService) invocationOnMock.getArguments()[0];
return this.singletonServiceRegistration;
}).when(this.cssp).registerClusterSingletonService(any(ClusterSingletonService.class));
doAnswer(invocationOnMock -> {
this.singletonService.closeServiceInstance().get();
return null;
}).when(this.singletonServiceRegistration).close();
doReturn(this.registration).when(this.rpcRegistry).addRpcImplementation(any(), any(ProgrammingService.class));
doNothing().when(this.registration).close();
}
示例4: setUp
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
this.ribActivator = new RIBActivator();
this.ribExtension = new SimpleRIBExtensionProviderContext();
this.ribActivator.startRIBExtensionProvider(this.ribExtension);
this.bgpActivator = new BGPActivator();
this.inetActivator = new org.opendaylight.protocol.bgp.inet.BGPActivator();
this.context = new SimpleBGPExtensionProviderContext();
this.bgpActivator.start(this.context);
this.inetActivator.start(this.context);
this.mappingService = new BindingToNormalizedNodeCodec(
GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(),
new BindingNormalizedNodeCodecRegistry(StreamWriterGenerator.create(
JavassistUtils.forClassPool(ClassPool.getDefault()))));
final ModuleInfoBackedContext moduleInfoBackedContext = ModuleInfoBackedContext.create();
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(BgpParameters.class));
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(MultiprotocolCapability.class));
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(DestinationIpv4Case.class));
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(AdvertizedRoutes.class));
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(BgpRib.class));
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(Attributes1.class));
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(MpReachNlri.class));
this.mappingService.onGlobalContextUpdated(moduleInfoBackedContext.tryToCreateSchemaContext().get());
this.schemaContext = moduleInfoBackedContext.getSchemaContext();
if (!Epoll.isAvailable()) {
this.worker = new NioEventLoopGroup();
this.boss = new NioEventLoopGroup();
}
this.serverRegistry = new StrictBGPPeerRegistry();
this.serverDispatcher = new BGPDispatcherImpl(this.context.getMessageRegistry(), this.boss, this.worker,
this.serverRegistry);
doReturn(Mockito.mock(ClusterSingletonServiceRegistration.class)).when(this.clusterSingletonServiceProvider)
.registerClusterSingletonService(any(ClusterSingletonService.class));
}
示例5: setUp
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
doAnswer(invocationOnMock -> {
BmpMonitorImplTest.this.singletonService = (ClusterSingletonService) invocationOnMock.getArguments()[0];
this.singletonService.instantiateServiceInstance();
return BmpMonitorImplTest.this.singletonServiceRegistration;
}).when(this.clusterSSProv).registerClusterSingletonService(any(ClusterSingletonService.class));
doAnswer(invocationOnMock -> BmpMonitorImplTest.this.singletonService.closeServiceInstance())
.when(this.singletonServiceRegistration).close();
doAnswer(invocationOnMock -> {
this.singletonService2 = (ClusterSingletonService) invocationOnMock.getArguments()[0];
this.singletonService2.instantiateServiceInstance();
return BmpMonitorImplTest.this.singletonServiceRegistration2;
}).when(this.clusterSSProv2).registerClusterSingletonService(any(ClusterSingletonService.class));
doAnswer(invocationOnMock -> BmpMonitorImplTest.this.singletonService2.closeServiceInstance())
.when(this.singletonServiceRegistration2).close();
this.mappingService = new BindingToNormalizedNodeCodec(GeneratedClassLoadingStrategy
.getTCCLClassLoadingStrategy(),
new BindingNormalizedNodeCodecRegistry(StreamWriterGenerator
.create(JavassistUtils.forClassPool(ClassPool.getDefault()))));
final ModuleInfoBackedContext moduleInfoBackedContext = ModuleInfoBackedContext.create();
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(InitiationMessage.class));
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(CParameters1.class));
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(BgpParameters.class));
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(MultiprotocolCapability.class));
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(DestinationIpv4Case.class));
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(AdvertizedRoutes.class));
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(SentOpen.class));
moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(ReceivedOpen.class));
this.mappingService.onGlobalContextUpdated(moduleInfoBackedContext.tryToCreateSchemaContext().get());
this.ribActivator = new RIBActivator();
this.ribExtension = new SimpleRIBExtensionProviderContext();
this.ribActivator.startRIBExtensionProvider(this.ribExtension);
this.bgpActivator = new BGPActivator();
final BGPExtensionProviderContext context = new SimpleBGPExtensionProviderContext();
this.bgpActivator.start(context);
final SimpleBmpExtensionProviderContext ctx = new SimpleBmpExtensionProviderContext();
this.bmpActivator = new BmpActivator(context);
this.bmpActivator.start(ctx);
this.msgRegistry = ctx.getBmpMessageRegistry();
this.dispatcher = new BmpDispatcherImpl(new NioEventLoopGroup(), new NioEventLoopGroup(),
ctx.getBmpMessageRegistry(), new DefaultBmpSessionFactory());
final InetSocketAddress inetAddress = new InetSocketAddress(InetAddresses.forString(MONITOR_LOCAL_ADDRESS),
MONITOR_LOCAL_PORT);
final DOMDataWriteTransaction wTx = getDomBroker().newWriteOnlyTransaction();
final ContainerNode parentNode = Builders.containerBuilder().withNodeIdentifier(
new NodeIdentifier(BmpMonitor.QNAME))
.addChild(ImmutableNodes.mapNodeBuilder(Monitor.QNAME).build()).build();
wTx.merge(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.of(BmpMonitor.QNAME), parentNode);
wTx.submit();
final BmpDeployerDependencies bmpDependecies = new BmpDeployerDependencies(getDataBroker(), getDomBroker(),
this.ribExtension, this.mappingService.getCodecFactory(), getSchemaContext(), this.clusterSSProv);
this.bmpApp = new BmpMonitoringStationImpl(bmpDependecies, this.dispatcher, MONITOR_ID, inetAddress, null);
readDataOperational(getDataBroker(), BMP_II, monitor -> {
assertEquals(1, monitor.getMonitor().size());
final Monitor bmpMonitor = monitor.getMonitor().get(0);
assertEquals(MONITOR_ID, bmpMonitor.getMonitorId());
assertEquals(0, bmpMonitor.getRouter().size());
assertEquals(MONITOR_ID, bmpMonitor.getMonitorId());
assertEquals(0, bmpMonitor.getRouter().size());
return monitor;
});
}
示例6: registerSingletonService
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService; //导入依赖的package包/类
private ClusterSingletonServiceRegistration registerSingletonService(
final ClusterSingletonService clusterSingletonService) {
return ClusterSingletonServiceRegistrationHelper
.registerSingletonService(this.singletonProvider, clusterSingletonService);
}