use of org.onosproject.cluster.ControllerNode in project onos by opennetworkinglab.
the class AtomixClusterStore method removeNode.
@Override
public void removeNode(NodeId nodeId) {
checkNotNull(nodeId, INSTANCE_ID_NULL);
ControllerNode node = nodes.remove(nodeId);
if (node != null) {
states.remove(nodeId);
notifyDelegate(clusterEvent(ClusterEvent.Type.INSTANCE_REMOVED, membershipService.getMember(node.id().id()), node));
}
}
use of org.onosproject.cluster.ControllerNode in project onos by opennetworkinglab.
the class NetconfControllerImpl method activate.
@Activate
public void activate(ComponentContext context) {
cfgService.registerProperties(getClass());
modified(context);
Security.addProvider(new BouncyCastleProvider());
clusterCommunicator.<NetconfProxyMessage>addSubscriber(SEND_REQUEST_SUBJECT_STRING, SERIALIZER::decode, this::handleProxyMessage, remoteRequestExecutor);
clusterCommunicator.<NetconfProxyMessage>addSubscriber(SEND_REQUEST_SUBJECT_SET_STRING, SERIALIZER::decode, this::handleProxyMessage, remoteRequestExecutor);
clusterCommunicator.<NetconfProxyMessage>addSubscriber(SEND_REPLY_SUBJECT_STRING, SERIALIZER::decode, this::handleProxyReplyMessage, remoteRequestExecutor);
clusterCommunicator.<NetconfProxyMessage>addSubscriber(SEND_REPLY_SUBJECT_SET_STRING, SERIALIZER::decode, this::handleProxyReplyMessage, remoteRequestExecutor);
localNodeId = Optional.ofNullable(clusterService.getLocalNode()).map(ControllerNode::id).orElseGet(() -> new NodeId("nullNodeId"));
log.info("Started");
}
use of org.onosproject.cluster.ControllerNode in project onos by opennetworkinglab.
the class ClusterMetadataManager method getLocalNode.
@Override
public ControllerNode getLocalNode() {
checkPermission(CLUSTER_READ);
if (localNode == null) {
ClusterMetadata metadata = getProvider().getClusterMetadata().value();
ControllerNode localNode = metadata.getLocalNode();
try {
if (localNode != null) {
this.localNode = new DefaultControllerNode(localNode.id(), localNode.ip() != null ? localNode.ip() : findLocalIp(), localNode.tcpPort());
} else {
IpAddress ip = findLocalIp();
localNode = metadata.getControllerNodes().stream().filter(node -> node.ip().equals(ip)).findFirst().orElse(null);
if (localNode != null) {
this.localNode = localNode;
} else {
this.localNode = new DefaultControllerNode(NodeId.nodeId(ip.toString()), ip);
}
}
} catch (SocketException e) {
throw new IllegalStateException(e);
}
}
return localNode;
}
use of org.onosproject.cluster.ControllerNode in project onos by opennetworkinglab.
the class MastershipManager method findBucket.
/**
* Finds node with the minimum/maximum devices from a list of nodes.
*
* @param min true: minimum, false: maximum
* @param controllerDevices controller nodes to devices map
* @return controller node with minimum/maximum devices
*/
private ControllerNode findBucket(boolean min, Map<ControllerNode, Set<DeviceId>> controllerDevices) {
int xSize = min ? Integer.MAX_VALUE : -1;
ControllerNode xNode = null;
for (ControllerNode node : controllerDevices.keySet()) {
int size = controllerDevices.get(node).size();
if ((min && size < xSize) || (!min && size > xSize)) {
xSize = size;
xNode = node;
}
}
return xNode;
}
use of org.onosproject.cluster.ControllerNode in project onos by opennetworkinglab.
the class MastershipManager method balanceControllerNodes.
/**
* Balances the nodes specified in controllerDevices.
*
* @param controllerDevices controller nodes to devices map
* @param deviceCount number of devices mastered by controller nodes
* @param futures list of setRole futures for "moved" devices
*/
private void balanceControllerNodes(Map<ControllerNode, Set<DeviceId>> controllerDevices, int deviceCount, List<CompletableFuture<Void>> futures) {
// Now re-balance the buckets until they are roughly even.
int rounds = controllerDevices.keySet().size();
for (int i = 0; i < rounds; i++) {
// Iterate over the buckets and find the smallest and the largest.
ControllerNode smallest = findBucket(true, controllerDevices);
ControllerNode largest = findBucket(false, controllerDevices);
futures.add(balanceBuckets(smallest, largest, controllerDevices, deviceCount));
}
}
Aggregations