use of org.onosproject.store.service.DistributedPrimitive.Status in project onos by opennetworkinglab.
the class DistributedLeadershipStore method handleStatusChange.
private void handleStatusChange(Status status) {
// Notify mastership Service of disconnect and reconnect
if (status == Status.ACTIVE) {
// Service Restored
localLeaderCache.forEach((topic, leadership) -> leaderElector.run(topic, localNodeId));
leaderElector.getLeaderships().forEach((topic, leadership) -> notifyDelegate(new LeadershipEvent(LeadershipEvent.Type.SERVICE_RESTORED, new Leadership(parseTopic(leadership.topic()), leadership.leader(), leadership.candidates()))));
} else if (status == Status.SUSPENDED) {
// Service Suspended
localLeaderCache.forEach((topic, leadership) -> notifyDelegate(new LeadershipEvent(LeadershipEvent.Type.SERVICE_DISRUPTED, new Leadership(parseTopic(leadership.topic()), leadership.leader(), leadership.candidates()))));
} else {
// Should be only inactive state
return;
}
}
use of org.onosproject.store.service.DistributedPrimitive.Status in project onos by opennetworkinglab.
the class DistributedGroupStore method deviceInitialAuditCompleted.
@Override
public void deviceInitialAuditCompleted(DeviceId deviceId, boolean completed) {
synchronized (deviceAuditStatus) {
if (completed) {
log.debug("AUDIT completed for device {}", deviceId);
deviceAuditStatus.put(deviceId, true);
// Execute all pending group requests
List<StoredGroupEntry> pendingGroupRequests = getPendingGroupKeyTable().values().stream().filter(g -> g.deviceId().equals(deviceId)).collect(Collectors.toList());
if (log.isDebugEnabled()) {
List<String> pendingIds = pendingGroupRequests.stream().map(GroupDescription::givenGroupId).map(id -> id != null ? "0x" + Integer.toHexString(id) : "N/A").collect(Collectors.toList());
log.debug("processing pending group add requests for device {}: {}", deviceId, pendingIds);
}
NodeId master;
for (Group group : pendingGroupRequests) {
// Mastership change can occur during this iteration
if (!shouldHandle(deviceId)) {
log.warn("Tried to process pending groups while the node was not the master" + " or the device {} was not available", deviceId);
return;
}
GroupDescription tmp = new DefaultGroupDescription(group.deviceId(), group.type(), group.buckets(), group.appCookie(), group.givenGroupId(), group.appId());
storeGroupDescriptionInternal(tmp);
getPendingGroupKeyTable().remove(new GroupStoreKeyMapKey(deviceId, group.appCookie()));
}
} else {
Boolean audited = deviceAuditStatus.get(deviceId);
if (audited != null && audited) {
log.debug("Clearing AUDIT status for device {}", deviceId);
deviceAuditStatus.put(deviceId, false);
}
}
}
}
Aggregations