當前位置: 首頁>>代碼示例>>Java>>正文


Java ClusterSingletonService類代碼示例

本文整理匯總了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);
        }
    }
}
 
開發者ID:opendaylight,項目名稱:bgpcep,代碼行數:34,代碼來源:ClusterSingletonServiceRegistrationHelper.java

示例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();
}
 
開發者ID:opendaylight,項目名稱:bgpcep,代碼行數:22,代碼來源:AbstractRIBTestSetup.java

示例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();
}
 
開發者ID:opendaylight,項目名稱:bgpcep,代碼行數:17,代碼來源:AbstractProgrammingTest.java

示例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));
}
 
開發者ID:opendaylight,項目名稱:bgpcep,代碼行數:39,代碼來源:AbstractAddPathTest.java

示例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;
    });
}
 
開發者ID:opendaylight,項目名稱:bgpcep,代碼行數:75,代碼來源:BmpMonitorImplTest.java

示例6: registerSingletonService

import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService; //導入依賴的package包/類
private ClusterSingletonServiceRegistration registerSingletonService(
        final ClusterSingletonService clusterSingletonService) {
    return ClusterSingletonServiceRegistrationHelper
            .registerSingletonService(this.singletonProvider, clusterSingletonService);
}
 
開發者ID:opendaylight,項目名稱:bgpcep,代碼行數:6,代碼來源:BgpTopologyDeployerImpl.java


注:本文中的org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。