Search in sources :

Example 1 with PersistenceService

use of org.onosproject.persistence.PersistenceService in project onos by opennetworkinglab.

the class CoordinationManager method eventuallyConsistentMapBuilder.

@Override
public <K, V> EventuallyConsistentMapBuilder<K, V> eventuallyConsistentMapBuilder() {
    checkPermission(STORAGE_WRITE);
    final NodeId localNodeId = clusterService.getLocalNode().id();
    Supplier<List<NodeId>> peersSupplier = () -> clusterService.getNodes().stream().map(ControllerNode::id).filter(nodeId -> !nodeId.equals(localNodeId)).filter(id -> clusterService.getState(id).isActive()).collect(Collectors.toList());
    Supplier<List<NodeId>> bootstrapPeersSupplier = () -> clusterService.getNodes().stream().map(ControllerNode::id).filter(id -> !localNodeId.equals(id)).filter(id -> clusterService.getState(id).isActive()).collect(Collectors.toList());
    return new EventuallyConsistentMapBuilderImpl<>(localNodeId, clusterCommunicator, persistenceService, peersSupplier, bootstrapPeersSupplier);
}
Also used : WorkQueue(org.onosproject.store.service.WorkQueue) STORAGE_WRITE(org.onosproject.security.AppPermission.Type.STORAGE_WRITE) PersistenceService(org.onosproject.persistence.PersistenceService) TopicBuilder(org.onosproject.store.service.TopicBuilder) AppGuard.checkPermission(org.onosproject.security.AppGuard.checkPermission) EventuallyConsistentMapBuilder(org.onosproject.store.service.EventuallyConsistentMapBuilder) CoordinationService(org.onosproject.store.service.CoordinationService) AtomixManager(org.onosproject.store.atomix.impl.AtomixManager) Supplier(java.util.function.Supplier) ControllerNode(org.onosproject.cluster.ControllerNode) Atomix(io.atomix.core.Atomix) AtomicCounterMapBuilder(org.onosproject.store.service.AtomicCounterMapBuilder) Component(org.osgi.service.component.annotations.Component) AtomicValueBuilder(org.onosproject.store.service.AtomicValueBuilder) ConsistentMultimapBuilder(org.onosproject.store.service.ConsistentMultimapBuilder) Activate(org.osgi.service.component.annotations.Activate) AtomicCounterBuilder(org.onosproject.store.service.AtomicCounterBuilder) NodeId(org.onosproject.cluster.NodeId) Serializer(org.onosproject.store.service.Serializer) LeaderElectorBuilder(org.onosproject.store.service.LeaderElectorBuilder) AsyncDocumentTree(org.onosproject.store.service.AsyncDocumentTree) DocumentTreeBuilder(org.onosproject.store.service.DocumentTreeBuilder) WorkQueueBuilder(org.onosproject.store.service.WorkQueueBuilder) Logger(org.slf4j.Logger) Topic(org.onosproject.store.service.Topic) AsyncConsistentMultimap(org.onosproject.store.service.AsyncConsistentMultimap) Deactivate(org.osgi.service.component.annotations.Deactivate) ConsistentMapBuilder(org.onosproject.store.service.ConsistentMapBuilder) PartitionGroup(io.atomix.primitive.partition.PartitionGroup) Collectors(java.util.stream.Collectors) ConsistentTreeMapBuilder(org.onosproject.store.service.ConsistentTreeMapBuilder) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) List(java.util.List) TransactionContextBuilder(org.onosproject.store.service.TransactionContextBuilder) AsyncConsistentTreeMap(org.onosproject.store.service.AsyncConsistentTreeMap) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) ClusterCommunicationService(org.onosproject.store.cluster.messaging.ClusterCommunicationService) ClusterService(org.onosproject.cluster.ClusterService) DistributedSetBuilder(org.onosproject.store.service.DistributedSetBuilder) AtomicIdGeneratorBuilder(org.onosproject.store.service.AtomicIdGeneratorBuilder) Reference(org.osgi.service.component.annotations.Reference) NodeId(org.onosproject.cluster.NodeId) List(java.util.List)

Example 2 with PersistenceService

use of org.onosproject.persistence.PersistenceService in project onos by opennetworkinglab.

the class StorageManager method eventuallyConsistentMapBuilder.

@Override
public <K, V> EventuallyConsistentMapBuilder<K, V> eventuallyConsistentMapBuilder() {
    checkPermission(STORAGE_WRITE);
    // Note: NPE in the usage of ClusterService/MembershipService prevents rebooting the Karaf container.
    // We need to reference these services outside the following peer suppliers.
    final MembershipService membershipService = this.membershipService;
    final ClusterService clusterService = this.clusterService;
    final NodeId localNodeId = clusterService.getLocalNode().id();
    // Use the MembershipService to provide peers for the map that are isolated within the current version.
    Supplier<List<NodeId>> peersSupplier = () -> membershipService.getMembers().stream().map(Member::nodeId).filter(nodeId -> !nodeId.equals(localNodeId)).filter(id -> clusterService.getState(id).isActive()).collect(Collectors.toList());
    // If this is the first node in its version, bootstrap from the previous version. Otherwise, bootstrap the
    // map from members isolated within the current version.
    Supplier<List<NodeId>> bootstrapPeersSupplier = () -> {
        if (membershipService.getMembers().size() == 1) {
            return clusterService.getNodes().stream().map(ControllerNode::id).filter(id -> !localNodeId.equals(id)).filter(id -> clusterService.getState(id).isActive()).collect(Collectors.toList());
        } else {
            return membershipService.getMembers().stream().map(Member::nodeId).filter(id -> !localNodeId.equals(id)).filter(id -> clusterService.getState(id).isActive()).collect(Collectors.toList());
        }
    };
    return new EventuallyConsistentMapBuilderImpl<>(localNodeId, clusterCommunicator, persistenceService, peersSupplier, bootstrapPeersSupplier);
}
Also used : StorageAdminService(org.onosproject.store.service.StorageAdminService) STORAGE_WRITE(org.onosproject.security.AppPermission.Type.STORAGE_WRITE) PersistenceService(org.onosproject.persistence.PersistenceService) Member(org.onosproject.cluster.Member) EventuallyConsistentMapBuilder(org.onosproject.store.service.EventuallyConsistentMapBuilder) Atomix(io.atomix.core.Atomix) AtomicCounterMapBuilder(org.onosproject.store.service.AtomicCounterMapBuilder) StorageService(org.onosproject.store.service.StorageService) MapInfo(org.onosproject.store.service.MapInfo) WorkQueueStats(org.onosproject.store.service.WorkQueueStats) Map(java.util.Map) ConsistentMultimapBuilder(org.onosproject.store.service.ConsistentMultimapBuilder) KryoNamespaces(org.onosproject.store.serializers.KryoNamespaces) AtomicCounterBuilder(org.onosproject.store.service.AtomicCounterBuilder) NodeId(org.onosproject.cluster.NodeId) Serializer(org.onosproject.store.service.Serializer) LeaderElectorBuilder(org.onosproject.store.service.LeaderElectorBuilder) DocumentTreeBuilder(org.onosproject.store.service.DocumentTreeBuilder) Deactivate(org.osgi.service.component.annotations.Deactivate) Collection(java.util.Collection) TransactionId(org.onosproject.store.primitives.TransactionId) PartitionGroup(io.atomix.primitive.partition.PartitionGroup) Collectors(java.util.stream.Collectors) ConsistentTreeMapBuilder(org.onosproject.store.service.ConsistentTreeMapBuilder) List(java.util.List) AtomicCounter(io.atomix.core.counter.AtomicCounter) AsyncConsistentTreeMap(org.onosproject.store.service.AsyncConsistentTreeMap) ClusterCommunicationService(org.onosproject.store.cluster.messaging.ClusterCommunicationService) ClusterService(org.onosproject.cluster.ClusterService) DistributedSetBuilder(org.onosproject.store.service.DistributedSetBuilder) AtomicMapType(io.atomix.core.map.AtomicMapType) DistributedLockBuilder(org.onosproject.store.service.DistributedLockBuilder) AtomicCounterType(io.atomix.core.counter.AtomicCounterType) AtomicIdGeneratorBuilder(org.onosproject.store.service.AtomicIdGeneratorBuilder) WorkQueue(org.onosproject.store.service.WorkQueue) TopicBuilder(org.onosproject.store.service.TopicBuilder) AppGuard.checkPermission(org.onosproject.security.AppGuard.checkPermission) MultiRaftProtocol(io.atomix.protocols.raft.MultiRaftProtocol) AtomixManager(org.onosproject.store.atomix.impl.AtomixManager) Supplier(java.util.function.Supplier) ControllerNode(org.onosproject.cluster.ControllerNode) Component(org.osgi.service.component.annotations.Component) AtomicValueBuilder(org.onosproject.store.service.AtomicValueBuilder) Activate(org.osgi.service.component.annotations.Activate) WorkQueueType(io.atomix.core.workqueue.WorkQueueType) AsyncDocumentTree(org.onosproject.store.service.AsyncDocumentTree) WorkQueueBuilder(org.onosproject.store.service.WorkQueueBuilder) Logger(org.slf4j.Logger) Topic(org.onosproject.store.service.Topic) PartitionAdminService(org.onosproject.store.primitives.PartitionAdminService) AsyncConsistentMultimap(org.onosproject.store.service.AsyncConsistentMultimap) ConsistentMapBuilder(org.onosproject.store.service.ConsistentMapBuilder) Maps(com.google.common.collect.Maps) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) TransactionContextBuilder(org.onosproject.store.service.TransactionContextBuilder) MembershipService(org.onosproject.cluster.MembershipService) LoggerFactory.getLogger(org.slf4j.LoggerFactory.getLogger) Reference(org.osgi.service.component.annotations.Reference) ClusterService(org.onosproject.cluster.ClusterService) MembershipService(org.onosproject.cluster.MembershipService) NodeId(org.onosproject.cluster.NodeId) ControllerNode(org.onosproject.cluster.ControllerNode) List(java.util.List) Member(org.onosproject.cluster.Member)

Aggregations

Atomix (io.atomix.core.Atomix)2 PartitionGroup (io.atomix.primitive.partition.PartitionGroup)2 List (java.util.List)2 Supplier (java.util.function.Supplier)2 Collectors (java.util.stream.Collectors)2 ClusterService (org.onosproject.cluster.ClusterService)2 ControllerNode (org.onosproject.cluster.ControllerNode)2 NodeId (org.onosproject.cluster.NodeId)2 PersistenceService (org.onosproject.persistence.PersistenceService)2 AppGuard.checkPermission (org.onosproject.security.AppGuard.checkPermission)2 STORAGE_WRITE (org.onosproject.security.AppPermission.Type.STORAGE_WRITE)2 AtomixManager (org.onosproject.store.atomix.impl.AtomixManager)2 ClusterCommunicationService (org.onosproject.store.cluster.messaging.ClusterCommunicationService)2 AsyncConsistentMultimap (org.onosproject.store.service.AsyncConsistentMultimap)2 AsyncConsistentTreeMap (org.onosproject.store.service.AsyncConsistentTreeMap)2 AsyncDocumentTree (org.onosproject.store.service.AsyncDocumentTree)2 AtomicCounterBuilder (org.onosproject.store.service.AtomicCounterBuilder)2 AtomicCounterMapBuilder (org.onosproject.store.service.AtomicCounterMapBuilder)2 AtomicIdGeneratorBuilder (org.onosproject.store.service.AtomicIdGeneratorBuilder)2 AtomicValueBuilder (org.onosproject.store.service.AtomicValueBuilder)2