mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-10-26 05:41:08 +01:00
ONOS-5816
Change-Id: I595fa04b9083bcbfe275b0342bcda0c4f1ecc8f5
This commit is contained in:
parent
0083a5120d
commit
c884c3eff1
@ -64,6 +64,7 @@ import org.onosproject.store.service.Serializer;
|
|||||||
import org.onosproject.store.service.StorageService;
|
import org.onosproject.store.service.StorageService;
|
||||||
import org.onosproject.store.service.Topic;
|
import org.onosproject.store.service.Topic;
|
||||||
import org.onosproject.store.service.Versioned;
|
import org.onosproject.store.service.Versioned;
|
||||||
|
import org.onosproject.store.service.DistributedPrimitive.Status;
|
||||||
import org.osgi.service.component.ComponentContext;
|
import org.osgi.service.component.ComponentContext;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
@ -85,10 +86,13 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import java.util.function.Consumer;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static com.google.common.base.Strings.isNullOrEmpty;
|
import static com.google.common.base.Strings.isNullOrEmpty;
|
||||||
|
import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor;
|
||||||
import static org.onlab.util.Tools.get;
|
import static org.onlab.util.Tools.get;
|
||||||
import static org.onlab.util.Tools.groupedThreads;
|
import static org.onlab.util.Tools.groupedThreads;
|
||||||
import static org.slf4j.LoggerFactory.getLogger;
|
import static org.slf4j.LoggerFactory.getLogger;
|
||||||
@ -126,6 +130,8 @@ public class DistributedGroupStore
|
|||||||
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
|
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
|
||||||
protected ComponentConfigService cfgService;
|
protected ComponentConfigService cfgService;
|
||||||
|
|
||||||
|
private ScheduledExecutorService executor;
|
||||||
|
private Consumer<Status> statusChangeListener;
|
||||||
// Per device group table with (device id + app cookie) as key
|
// Per device group table with (device id + app cookie) as key
|
||||||
private ConsistentMap<GroupStoreKeyMapKey,
|
private ConsistentMap<GroupStoreKeyMapKey,
|
||||||
StoredGroupEntry> groupStoreEntriesByKey = null;
|
StoredGroupEntry> groupStoreEntriesByKey = null;
|
||||||
@ -204,6 +210,16 @@ public class DistributedGroupStore
|
|||||||
log.debug("Current size of groupstorekeymap:{}",
|
log.debug("Current size of groupstorekeymap:{}",
|
||||||
groupStoreEntriesByKey.size());
|
groupStoreEntriesByKey.size());
|
||||||
|
|
||||||
|
log.debug("Creating GroupStoreId Map From GroupStoreKey Map");
|
||||||
|
matchGroupEntries();
|
||||||
|
executor = newSingleThreadScheduledExecutor(groupedThreads("onos/group", "store", log));
|
||||||
|
statusChangeListener = status -> {
|
||||||
|
if (status == Status.ACTIVE) {
|
||||||
|
executor.execute(this::matchGroupEntries);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
groupStoreEntriesByKey.addStatusChangeListener(statusChangeListener);
|
||||||
|
|
||||||
log.debug("Creating Consistent map pendinggroupkeymap");
|
log.debug("Creating Consistent map pendinggroupkeymap");
|
||||||
|
|
||||||
auditPendingReqQueue = storageService.<GroupStoreKeyMapKey, StoredGroupEntry>consistentMapBuilder()
|
auditPendingReqQueue = storageService.<GroupStoreKeyMapKey, StoredGroupEntry>consistentMapBuilder()
|
||||||
@ -251,6 +267,16 @@ public class DistributedGroupStore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updating values of groupEntriesById.
|
||||||
|
*/
|
||||||
|
private void matchGroupEntries() {
|
||||||
|
for (Entry<GroupStoreKeyMapKey, StoredGroupEntry> entry : groupStoreEntriesByKey.asJavaMap().entrySet()) {
|
||||||
|
StoredGroupEntry group = entry.getValue();
|
||||||
|
getGroupIdTable(entry.getKey().deviceId()).put(group.id(), group);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the group store eventual consistent key map.
|
* Returns the group store eventual consistent key map.
|
||||||
*
|
*
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user