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


Java AtomixLeaderElector類代碼示例

本文整理匯總了Java中org.onosproject.store.primitives.resources.impl.AtomixLeaderElector的典型用法代碼示例。如果您正苦於以下問題:Java AtomixLeaderElector類的具體用法?Java AtomixLeaderElector怎麽用?Java AtomixLeaderElector使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AtomixLeaderElector類屬於org.onosproject.store.primitives.resources.impl包,在下文中一共展示了AtomixLeaderElector類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: newAsyncLeaderElector

import org.onosproject.store.primitives.resources.impl.AtomixLeaderElector; //導入依賴的package包/類
@Override
public AsyncLeaderElector newAsyncLeaderElector(String name, long leaderTimeout, TimeUnit timeUnit) {
    AtomixLeaderElector leaderElector = new AtomixLeaderElector(client.newProxyBuilder()
            .withName(name)
            .withServiceType(DistributedPrimitive.Type.LEADER_ELECTOR.name())
            .withReadConsistency(ReadConsistency.LINEARIZABLE)
            .withCommunicationStrategy(CommunicationStrategy.LEADER)
            .withMinTimeout(Duration.ofMillis(timeUnit.toMillis(leaderTimeout)))
            .withMaxTimeout(Duration.ofSeconds(5))
            .withMaxRetries(MAX_RETRIES)
            .build()
            .open()
            .join());
    leaderElector.setupCache().join();
    return leaderElector;
}
 
開發者ID:opennetworkinglab,項目名稱:onos,代碼行數:17,代碼來源:StoragePartitionClient.java

示例2: newAsyncLeaderElector

import org.onosproject.store.primitives.resources.impl.AtomixLeaderElector; //導入依賴的package包/類
@Override
public AsyncLeaderElector newAsyncLeaderElector(String name) {
    AtomixLeaderElector leaderElector = client.getResource(name, AtomixLeaderElector.class)
                                              .thenCompose(AtomixLeaderElector::setupCache)
                                              .join();
    Consumer<State> statusListener = state -> {
        leaderElector.statusChangeListeners()
                     .forEach(listener -> listener.accept(mapper.apply(state)));
    };
    resourceClient.client().onStateChange(statusListener);
    return leaderElector;
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:13,代碼來源:StoragePartitionClient.java


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