Search in sources :

Example 1 with DOMDataTreeIdentifier

use of org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier in project controller by opendaylight.

the class ShardManager method onPrefixShardRemoved.

private void onPrefixShardRemoved(final PrefixShardRemoved message) {
    LOG.debug("{}: onPrefixShardRemoved : {}", persistenceId(), message);
    final DOMDataTreeIdentifier prefix = message.getPrefix();
    final ShardIdentifier shardId = getShardIdentifier(cluster.getCurrentMemberName(), ClusterUtils.getCleanShardName(prefix.getRootIdentifier()));
    configuration.removePrefixShardConfiguration(prefix);
    removeShard(shardId);
}
Also used : DOMDataTreeIdentifier(org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier) ShardIdentifier(org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier)

Example 2 with DOMDataTreeIdentifier

use of org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier in project controller by opendaylight.

the class ConcurrentDOMDataBrokerTest method testExtensions.

@Test
public void testExtensions() {
    DistributedDataStore mockConfigStore = mock(DistributedDataStore.class);
    DistributedDataStore mockOperStore = mock(DistributedDataStore.class);
    try (ConcurrentDOMDataBroker dataBroker = new ConcurrentDOMDataBroker(ImmutableMap.of(LogicalDatastoreType.OPERATIONAL, mockOperStore, LogicalDatastoreType.CONFIGURATION, mockConfigStore), futureExecutor)) {
        Map<Class<? extends DOMDataBrokerExtension>, DOMDataBrokerExtension> supportedExtensions = dataBroker.getSupportedExtensions();
        assertNotNull(supportedExtensions.get(DOMDataTreeChangeService.class));
        DOMDataTreeCommitCohortRegistry cohortRegistry = (DOMDataTreeCommitCohortRegistry) supportedExtensions.get(DOMDataTreeCommitCohortRegistry.class);
        assertNotNull(cohortRegistry);
        DOMDataTreeCommitCohort mockCohort = mock(DOMDataTreeCommitCohort.class);
        DOMDataTreeIdentifier path = new DOMDataTreeIdentifier(org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.EMPTY);
        cohortRegistry.registerCommitCohort(path, mockCohort);
        verify(mockConfigStore).registerCommitCohort(path, mockCohort);
    }
}
Also used : DOMDataTreeChangeService(org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService) DistributedDataStore(org.opendaylight.controller.cluster.datastore.DistributedDataStore) DOMDataTreeIdentifier(org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier) DOMDataBrokerExtension(org.opendaylight.mdsal.dom.api.DOMDataBrokerExtension) DOMDataTreeCommitCohortRegistry(org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry) DOMDataTreeCommitCohort(org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohort) Test(org.junit.Test)

Example 3 with DOMDataTreeIdentifier

use of org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier in project controller by opendaylight.

the class ShardProxyTransaction method ready.

@Override
public void ready() {
    LOG.debug("Readying transaction for shard {}", shardRoot);
    Preconditions.checkNotNull(modification, "Attempting to ready an empty transaction.");
    cohorts.add(modification.seal());
    for (Entry<DOMDataTreeIdentifier, ForeignShardModificationContext> entry : modification.getChildShards().entrySet()) {
        cohorts.add(new ForeignShardThreePhaseCommitCohort(entry.getKey(), entry.getValue()));
    }
}
Also used : ForeignShardThreePhaseCommitCohort(org.opendaylight.mdsal.dom.store.inmemory.ForeignShardThreePhaseCommitCohort) DOMDataTreeIdentifier(org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier) ForeignShardModificationContext(org.opendaylight.mdsal.dom.spi.shard.ForeignShardModificationContext)

Example 4 with DOMDataTreeIdentifier

use of org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier in project controller by opendaylight.

the class ShardedDataTreeActor method onProducerCreated.

private void onProducerCreated(final ProducerCreated message) {
    LOG.debug("Received ProducerCreated: {}", message);
    // fastpath if we have no peers
    if (resolver.getShardingServicePeerActorAddresses().isEmpty()) {
        getSender().tell(new Status.Success(null), noSender());
    }
    final ActorRef sender = getSender();
    final Collection<DOMDataTreeIdentifier> subtrees = message.getSubtrees();
    final List<CompletableFuture<Object>> futures = new ArrayList<>();
    for (final String address : resolver.getShardingServicePeerActorAddresses()) {
        final ActorSelection actorSelection = actorSystem.actorSelection(address);
        futures.add(FutureConverters.toJava(actorContext.executeOperationAsync(actorSelection, new NotifyProducerCreated(subtrees), DEFAULT_ASK_TIMEOUT)).toCompletableFuture());
    }
    final CompletableFuture<Void> combinedFuture = CompletableFuture.allOf(futures.toArray(new CompletableFuture[futures.size()]));
    combinedFuture.thenRun(() -> sender.tell(new Success(null), noSender())).exceptionally(throwable -> {
        sender.tell(new Status.Failure(throwable), self());
        return null;
    });
}
Also used : Status(akka.actor.Status) ActorRef(akka.actor.ActorRef) DOMDataTreeIdentifier(org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier) ArrayList(java.util.ArrayList) Success(akka.actor.Status.Success) Success(akka.actor.Status.Success) CompletableFuture(java.util.concurrent.CompletableFuture) ActorSelection(akka.actor.ActorSelection) NotifyProducerCreated(org.opendaylight.controller.cluster.sharding.messages.NotifyProducerCreated)

Example 5 with DOMDataTreeIdentifier

use of org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier in project controller by opendaylight.

the class ShardedDataTreeActor method onNotifyProducerCreated.

private void onNotifyProducerCreated(final NotifyProducerCreated message) {
    LOG.debug("Received NotifyProducerCreated: {}", message);
    final Collection<DOMDataTreeIdentifier> subtrees = message.getSubtrees();
    try {
        final ActorProducerRegistration registration = new ActorProducerRegistration(shardingService.localCreateProducer(subtrees), subtrees);
        subtrees.forEach(id -> idToProducer.put(id, registration));
        sender().tell(new Status.Success(null), self());
    } catch (final IllegalArgumentException e) {
        sender().tell(new Status.Failure(e), getSelf());
    }
}
Also used : Status(akka.actor.Status) DOMDataTreeIdentifier(org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier) Success(akka.actor.Status.Success)

Aggregations

DOMDataTreeIdentifier (org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier)24 Test (org.junit.Test)9 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)7 DOMDataTreeProducer (org.opendaylight.mdsal.dom.api.DOMDataTreeProducer)6 ActorRef (akka.actor.ActorRef)5 AbstractTest (org.opendaylight.controller.cluster.datastore.AbstractTest)5 DistributedShardRegistration (org.opendaylight.controller.cluster.sharding.DistributedShardFactory.DistributedShardRegistration)5 DOMDataTreeCursorAwareTransaction (org.opendaylight.mdsal.dom.api.DOMDataTreeCursorAwareTransaction)5 DOMDataTreeWriteCursor (org.opendaylight.mdsal.dom.api.DOMDataTreeWriteCursor)5 MapNode (org.opendaylight.yangtools.yang.data.api.schema.MapNode)4 ArrayList (java.util.ArrayList)3 DOMDataTreeProducerException (org.opendaylight.mdsal.dom.api.DOMDataTreeProducerException)3 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)3 Status (akka.actor.Status)2 Success (akka.actor.Status.Success)2 SimpleEntry (java.util.AbstractMap.SimpleEntry)2 Collection (java.util.Collection)2 ExecutionException (java.util.concurrent.ExecutionException)2 TimeoutException (java.util.concurrent.TimeoutException)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2