use of org.onosproject.cluster.Leadership in project onos by opennetworkinglab.
the class ConsistentDeviceMastershipStore method getRole.
@Override
public MastershipRole getRole(NodeId nodeId, DeviceId deviceId) {
checkArgument(nodeId != null, NODE_ID_NULL);
checkArgument(deviceId != null, DEVICE_ID_NULL);
String leadershipTopic = createDeviceMastershipTopic(deviceId);
Leadership leadership = leadershipService.getLeadership(leadershipTopic);
NodeId leader = leadership == null ? null : leadership.leaderNodeId();
List<NodeId> candidates = leadership == null ? ImmutableList.of() : ImmutableList.copyOf(leadership.candidates());
return Objects.equals(nodeId, leader) ? MastershipRole.MASTER : candidates.contains(nodeId) ? MastershipRole.STANDBY : MastershipRole.NONE;
}
use of org.onosproject.cluster.Leadership in project onos by opennetworkinglab.
the class ConsistentDeviceMastershipStore method getMastership.
@Override
public MastershipInfo getMastership(DeviceId deviceId) {
checkArgument(deviceId != null, DEVICE_ID_NULL);
Leadership leadership = leadershipService.getLeadership(createDeviceMastershipTopic(deviceId));
return buildMastershipFromLeadership(leadership);
}
use of org.onosproject.cluster.Leadership in project onos by opennetworkinglab.
the class ConsistentDeviceMastershipStore method requestRole.
@Override
public CompletableFuture<MastershipRole> requestRole(DeviceId deviceId) {
checkArgument(deviceId != null, DEVICE_ID_NULL);
String leadershipTopic = createDeviceMastershipTopic(deviceId);
Leadership leadership = leadershipService.runForLeadership(leadershipTopic);
NodeId leader = leadership == null ? null : leadership.leaderNodeId();
List<NodeId> candidates = leadership == null ? ImmutableList.of() : ImmutableList.copyOf(leadership.candidates());
MastershipRole role = Objects.equals(localNodeId, leader) ? MastershipRole.MASTER : candidates.contains(localNodeId) ? MastershipRole.STANDBY : MastershipRole.NONE;
return CompletableFuture.completedFuture(role);
}
use of org.onosproject.cluster.Leadership in project onos by opennetworkinglab.
the class ConsistentVirtualDeviceMastershipStore method getMastership.
@Override
public MastershipInfo getMastership(NetworkId networkId, DeviceId deviceId) {
checkArgument(networkId != null, NETWORK_ID_NULL);
checkArgument(deviceId != null, DEVICE_ID_NULL);
Leadership leadership = leadershipService.getLeadership(createDeviceMastershipTopic(networkId, deviceId));
return buildMastershipFromLeadership(leadership);
}
use of org.onosproject.cluster.Leadership in project onos by opennetworkinglab.
the class ConsistentVirtualDeviceMastershipStore method requestRole.
@Override
public CompletableFuture<MastershipRole> requestRole(NetworkId networkId, DeviceId deviceId) {
checkArgument(networkId != null, NETWORK_ID_NULL);
checkArgument(deviceId != null, DEVICE_ID_NULL);
String leadershipTopic = createDeviceMastershipTopic(networkId, deviceId);
Leadership leadership = leadershipService.runForLeadership(leadershipTopic);
return CompletableFuture.completedFuture(localNodeId.equals(leadership.leaderNodeId()) ? MastershipRole.MASTER : MastershipRole.STANDBY);
}
Aggregations