use of org.onosproject.cluster.ControllerNode.State in project onos by opennetworkinglab.
the class SimpleMastershipStore method activate.
@Activate
public void activate() {
if (clusterService == null) {
// just for ease of unit test
final ControllerNode instance = new DefaultControllerNode(new NodeId("local"), IpAddress.valueOf("127.0.0.1"));
clusterService = new ClusterService() {
private final Instant creationTime = Instant.now();
@Override
public ControllerNode getLocalNode() {
return instance;
}
@Override
public Set<ControllerNode> getNodes() {
return ImmutableSet.of(instance);
}
@Override
public Set<Node> getConsensusNodes() {
return ImmutableSet.of();
}
@Override
public ControllerNode getNode(NodeId nodeId) {
if (instance.id().equals(nodeId)) {
return instance;
}
return null;
}
@Override
public State getState(NodeId nodeId) {
if (instance.id().equals(nodeId)) {
return State.ACTIVE;
} else {
return State.INACTIVE;
}
}
@Override
public Version getVersion(NodeId nodeId) {
if (instance.id().equals(nodeId)) {
return versionService.version();
}
return null;
}
@Override
public Instant getLastUpdatedInstant(NodeId nodeId) {
return creationTime;
}
@Override
public void addListener(ClusterEventListener listener) {
}
@Override
public void removeListener(ClusterEventListener listener) {
}
};
}
log.info("Started");
}
Aggregations