本文整理汇总了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();
}
}
示例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();
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}