Search in sources :

Example 1 with Status

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;
    }
}
Also used : LeadershipEvent(org.onosproject.cluster.LeadershipEvent) ComponentContext(org.osgi.service.component.ComponentContext) Tools.groupedThreads(org.onlab.util.Tools.groupedThreads) Strings.isNullOrEmpty(com.google.common.base.Strings.isNullOrEmpty) CoordinationService(org.onosproject.store.service.CoordinationService) LeadershipStore(org.onosproject.cluster.LeadershipStore) Leadership(org.onosproject.cluster.Leadership) Component(org.osgi.service.component.annotations.Component) VersionService(org.onosproject.core.VersionService) Map(java.util.Map) Version(org.onosproject.core.Version) MANDATORY(org.osgi.service.component.annotations.ReferenceCardinality.MANDATORY) Activate(org.osgi.service.component.annotations.Activate) ExecutorService(java.util.concurrent.ExecutorService) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) NodeId(org.onosproject.cluster.NodeId) UpgradeEventListener(org.onosproject.upgrade.UpgradeEventListener) Tools.get(org.onlab.util.Tools.get) UpgradeService(org.onosproject.upgrade.UpgradeService) Logger(org.slf4j.Logger) Change(org.onosproject.event.Change) Deactivate(org.osgi.service.component.annotations.Deactivate) OsgiPropertyConstants(org.onosproject.store.OsgiPropertyConstants) LeadershipStoreDelegate(org.onosproject.cluster.LeadershipStoreDelegate) Maps(com.google.common.collect.Maps) Collectors(java.util.stream.Collectors) Status(org.onosproject.store.service.DistributedPrimitive.Status) Executors(java.util.concurrent.Executors) Objects(java.util.Objects) Consumer(java.util.function.Consumer) UpgradeEvent(org.onosproject.upgrade.UpgradeEvent) LeaderElector(org.onosproject.store.service.LeaderElector) AbstractStore(org.onosproject.store.AbstractStore) Modified(org.osgi.service.component.annotations.Modified) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) ClusterService(org.onosproject.cluster.ClusterService) LeadershipEvent(org.onosproject.cluster.LeadershipEvent) Reference(org.osgi.service.component.annotations.Reference) Dictionary(java.util.Dictionary) Leadership(org.onosproject.cluster.Leadership)

Example 2 with Status

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);
            }
        }
    }
}
Also used : ConsistentMap(org.onosproject.store.service.ConsistentMap) DeviceService(org.onosproject.net.device.DeviceService) Tools.groupedThreads(org.onlab.util.Tools.groupedThreads) GroupOperation(org.onosproject.net.group.GroupOperation) DriverService(org.onosproject.net.driver.DriverService) ALLOW_EXTRANEOUS_GROUPS(org.onosproject.store.OsgiPropertyConstants.ALLOW_EXTRANEOUS_GROUPS) Executors.newSingleThreadScheduledExecutor(java.util.concurrent.Executors.newSingleThreadScheduledExecutor) StorageService(org.onosproject.store.service.StorageService) FluentIterable(com.google.common.collect.FluentIterable) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) ApplicationId(org.onosproject.core.ApplicationId) KryoNamespaces(org.onosproject.store.serializers.KryoNamespaces) MastershipService(org.onosproject.mastership.MastershipService) NodeId(org.onosproject.cluster.NodeId) Serializer(org.onosproject.store.service.Serializer) Tools.get(org.onlab.util.Tools.get) ImmutableSet(com.google.common.collect.ImmutableSet) StoredGroupBucketEntry(org.onosproject.net.group.StoredGroupBucketEntry) Deactivate(org.osgi.service.component.annotations.Deactivate) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) GroupEvent(org.onosproject.net.group.GroupEvent) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) Executors(java.util.concurrent.Executors) Objects(java.util.Objects) Versioned(org.onosproject.store.service.Versioned) List(java.util.List) GroupStoreDelegate(org.onosproject.net.group.GroupStoreDelegate) GARBAGE_COLLECT(org.onosproject.store.OsgiPropertyConstants.GARBAGE_COLLECT) GroupBuckets(org.onosproject.net.group.GroupBuckets) Type(org.onosproject.net.group.GroupEvent.Type) Entry(java.util.Map.Entry) ClusterCommunicationService(org.onosproject.store.cluster.messaging.ClusterCommunicationService) Optional(java.util.Optional) ClusterService(org.onosproject.cluster.ClusterService) DeviceId(org.onosproject.net.DeviceId) GARBAGE_COLLECT_THRESH_DEFAULT(org.onosproject.store.OsgiPropertyConstants.GARBAGE_COLLECT_THRESH_DEFAULT) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupDescription(org.onosproject.net.group.GroupDescription) Dictionary(java.util.Dictionary) Iterables(com.google.common.collect.Iterables) ComponentContext(org.osgi.service.component.ComponentContext) Strings.isNullOrEmpty(com.google.common.base.Strings.isNullOrEmpty) HashMap(java.util.HashMap) DefaultGroup(org.onosproject.net.group.DefaultGroup) GroupBucket(org.onosproject.net.group.GroupBucket) KryoNamespace(org.onlab.util.KryoNamespace) GroupKey(org.onosproject.net.group.GroupKey) Group(org.onosproject.net.group.Group) MapEventListener(org.onosproject.store.service.MapEventListener) ArrayList(java.util.ArrayList) ConcurrentMap(java.util.concurrent.ConcurrentMap) HashSet(java.util.HashSet) GroupStore(org.onosproject.net.group.GroupStore) Component(org.osgi.service.component.annotations.Component) StoredGroupEntry(org.onosproject.net.group.StoredGroupEntry) GroupState(org.onosproject.net.group.Group.GroupState) ALLOW_EXTRANEOUS_GROUPS_DEFAULT(org.onosproject.store.OsgiPropertyConstants.ALLOW_EXTRANEOUS_GROUPS_DEFAULT) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Activate(org.osgi.service.component.annotations.Activate) ExecutorService(java.util.concurrent.ExecutorService) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) Logger(org.slf4j.Logger) Properties(java.util.Properties) Iterator(java.util.Iterator) GARBAGE_COLLECT_DEFAULT(org.onosproject.store.OsgiPropertyConstants.GARBAGE_COLLECT_DEFAULT) Topic(org.onosproject.store.service.Topic) MastershipRole(org.onosproject.net.MastershipRole) GARBAGE_COLLECT_THRESH(org.onosproject.store.OsgiPropertyConstants.GARBAGE_COLLECT_THRESH) Status(org.onosproject.store.service.DistributedPrimitive.Status) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) Consumer(java.util.function.Consumer) MultiValuedTimestamp(org.onosproject.store.service.MultiValuedTimestamp) GroupId(org.onosproject.core.GroupId) MapEvent(org.onosproject.store.service.MapEvent) AbstractStore(org.onosproject.store.AbstractStore) Modified(org.osgi.service.component.annotations.Modified) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) Reference(org.osgi.service.component.annotations.Reference) Collections(java.util.Collections) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) GroupDescription(org.onosproject.net.group.GroupDescription) DefaultGroup(org.onosproject.net.group.DefaultGroup) Group(org.onosproject.net.group.Group) NodeId(org.onosproject.cluster.NodeId) DefaultGroupDescription(org.onosproject.net.group.DefaultGroupDescription) StoredGroupEntry(org.onosproject.net.group.StoredGroupEntry)

Aggregations

Strings.isNullOrEmpty (com.google.common.base.Strings.isNullOrEmpty)2 Dictionary (java.util.Dictionary)2 Map (java.util.Map)2 Objects (java.util.Objects)2 ExecutorService (java.util.concurrent.ExecutorService)2 Executors (java.util.concurrent.Executors)2 Consumer (java.util.function.Consumer)2 Collectors (java.util.stream.Collectors)2 Tools.get (org.onlab.util.Tools.get)2 Tools.groupedThreads (org.onlab.util.Tools.groupedThreads)2 ComponentConfigService (org.onosproject.cfg.ComponentConfigService)2 ClusterService (org.onosproject.cluster.ClusterService)2 NodeId (org.onosproject.cluster.NodeId)2 FluentIterable (com.google.common.collect.FluentIterable)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Iterables (com.google.common.collect.Iterables)1 Maps (com.google.common.collect.Maps)1 Sets (com.google.common.collect.Sets)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1