当前位置: 首页>>代码示例>>Java>>正文


Java Leader类代码示例

本文整理汇总了Java中org.onosproject.cluster.Leader的典型用法代码示例。如果您正苦于以下问题:Java Leader类的具体用法?Java Leader怎么用?Java Leader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Leader类属于org.onosproject.cluster包,在下文中一共展示了Leader类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUpLeadershipService

import org.onosproject.cluster.Leader; //导入依赖的package包/类
/**
 * Configures a mock leadership service to have the specified number of
 * partitions owned by the local node and all other partitions owned by a
 * (fake) remote node.
 *
 * @param numMine number of partitions that should be owned by the local node
 */
private void setUpLeadershipService(int numMine) {
    List<NodeId> allNodes = Arrays.asList(MY_NODE_ID, OTHER_NODE_ID);
    for (int i = 0; i < numMine; i++) {
        expect(leadershipService.getLeadership(ELECTION_PREFIX + i))
                                .andReturn(new Leadership(ELECTION_PREFIX + i,
                                                          new Leader(MY_NODE_ID, 1, 1000),
                                                          allNodes))
                                .anyTimes();
    }

    for (int i = numMine; i < IntentPartitionManager.NUM_PARTITIONS; i++) {
        expect(leadershipService.getLeadership(ELECTION_PREFIX + i))
                                .andReturn(new Leadership(ELECTION_PREFIX + i,
                                                          new Leader(OTHER_NODE_ID, 1, 1000),
                                                          allNodes))
                                .anyTimes();
    }
    for (int i = 0; i < IntentPartitionManager.NUM_PARTITIONS; i++) {
        expect(leadershipService.getCandidates(ELECTION_PREFIX + i))
        .andReturn(Arrays.asList(MY_NODE_ID, OTHER_NODE_ID))
        .anyTimes();
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:31,代码来源:IntentPartitionManagerTest.java

示例2: setUpLeadershipService

import org.onosproject.cluster.Leader; //导入依赖的package包/类
/**
 * Configures a mock leadership service to have the specified number of
 * partitions owned by the local node and all other partitions owned by a
 * (fake) remote node.
 *
 * @param numMine number of partitions that should be owned by the local node
 */
private void setUpLeadershipService(int numMine) {
    List<NodeId> allNodes = Arrays.asList(MY_NODE_ID, OTHER_NODE_ID);
    for (int i = 0; i < numMine; i++) {
        expect(leadershipService.getLeadership(ELECTION_PREFIX + i))
                                .andReturn(new Leadership(ELECTION_PREFIX + i,
                                                          new Leader(MY_NODE_ID, 1, 1000),
                                                          allNodes))
                                .anyTimes();
    }

    for (int i = numMine; i < WorkPartitionManager.NUM_PARTITIONS; i++) {
        expect(leadershipService.getLeadership(ELECTION_PREFIX + i))
                                .andReturn(new Leadership(ELECTION_PREFIX + i,
                                                          new Leader(OTHER_NODE_ID, 1, 1000),
                                                          allNodes))
                                .anyTimes();
    }
    for (int i = 0; i < WorkPartitionManager.NUM_PARTITIONS; i++) {
        expect(leadershipService.getCandidates(ELECTION_PREFIX + i))
        .andReturn(Arrays.asList(MY_NODE_ID, OTHER_NODE_ID))
        .anyTimes();
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:31,代码来源:WorkPartitionManagerTest.java

示例3: runForLeadership

import org.onosproject.cluster.Leader; //导入依赖的package包/类
@Override
public Leadership runForLeadership(String path) {
    elections.put(path, true);
    Leadership leadership = new Leadership(path, new Leader(localNodeId, 0, 0), Arrays.asList(localNodeId));
    for (LeadershipEventListener listener : listeners) {
        listener.event(new LeadershipEvent(Type.LEADER_AND_CANDIDATES_CHANGED, leadership));
    }
    return leadership;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:10,代码来源:SimpleLeadershipManager.java

示例4: leader

import org.onosproject.cluster.Leader; //导入依赖的package包/类
public Leader leader() {
    if (leader == null) {
        return null;
    } else {
        NodeId leaderNodeId = leader.nodeId();
        return new Leader(leaderNodeId, term, termStartTime);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:9,代码来源:AtomixLeaderElectorState.java

示例5: getLeadership

import org.onosproject.cluster.Leader; //导入依赖的package包/类
@Override
public Leadership getLeadership(String path) {
    checkArgument(path != null);
    return elections.get(path) ?
            new Leadership(path, new Leader(localNodeId, 0, 0), Arrays.asList(localNodeId)) : null;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:7,代码来源:SimpleLeadershipManager.java

示例6: getSerializer

import org.onosproject.cluster.Leader; //导入依赖的package包/类
public static Serializer getSerializer() {
    Serializer serializer = new Serializer();
    TypeSerializerFactory factory =
            new DefaultCatalystTypeSerializerFactory(
                    org.onosproject.store.service.Serializer.using(Arrays.asList((KryoNamespaces.API)),
                            MapEntryUpdateResult.class,
                            MapEntryUpdateResult.Status.class,
                            Transaction.State.class,
                            PrepareResult.class,
                            CommitResult.class,
                            RollbackResult.class));
    // ONOS classes
    serializer.register(Change.class, factory);
    serializer.register(Leader.class, factory);
    serializer.register(Leadership.class, factory);
    serializer.register(NodeId.class, factory);
    serializer.register(Match.class, factory);
    serializer.register(MapEntryUpdateResult.class, factory);
    serializer.register(MapEntryUpdateResult.Status.class, factory);
    serializer.register(Transaction.State.class, factory);
    serializer.register(PrepareResult.class, factory);
    serializer.register(CommitResult.class, factory);
    serializer.register(RollbackResult.class, factory);
    serializer.register(TransactionId.class, factory);
    serializer.register(MapUpdate.class, factory);
    serializer.register(MapUpdate.Type.class, factory);
    serializer.register(MapTransaction.class, factory);
    serializer.register(Versioned.class, factory);
    serializer.register(MapEvent.class, factory);
    serializer.register(Maps.immutableEntry("a", "b").getClass(), factory);

    serializer.resolve(new LongCommands.TypeResolver());
    serializer.resolve(new AtomixConsistentMapCommands.TypeResolver());
    serializer.resolve(new AtomixLeaderElectorCommands.TypeResolver());
    serializer.resolve(new ResourceManagerTypeResolver());

    serializer.registerClassLoader(AtomixConsistentMapFactory.class)
              .registerClassLoader(AtomixLeaderElectorFactory.class);

    return serializer;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:42,代码来源:CatalystSerializers.java


注:本文中的org.onosproject.cluster.Leader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。