Search in sources :

Example 1 with DOMDataTreeProducerException

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

the class DistributedShardedDOMDataTree method createShardFrontend.

private void createShardFrontend(final DOMDataTreeIdentifier prefix) {
    LOG.debug("{}: Creating CDS shard for prefix: {}", memberName, prefix);
    final String shardName = ClusterUtils.getCleanShardName(prefix.getRootIdentifier());
    final AbstractDataStore distributedDataStore = prefix.getDatastoreType().equals(org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATION) ? distributedConfigDatastore : distributedOperDatastore;
    try (DOMDataTreeProducer producer = localCreateProducer(Collections.singletonList(prefix))) {
        final Entry<DataStoreClient, ActorRef> entry = createDatastoreClient(shardName, distributedDataStore.getActorContext());
        final DistributedShardFrontend shard = new DistributedShardFrontend(distributedDataStore, entry.getKey(), prefix);
        final DOMDataTreeShardRegistration<DOMDataTreeShard> reg = shardedDOMDataTree.registerDataTreeShard(prefix, shard, producer);
        synchronized (shards) {
            shards.store(prefix, reg);
        }
    } catch (final DOMDataTreeShardingConflictException e) {
        LOG.error("{}: Prefix {} is already occupied by another shard", distributedConfigDatastore.getActorContext().getClusterWrapper().getCurrentMemberName(), prefix, e);
    } catch (DOMDataTreeProducerException e) {
        LOG.error("Unable to close producer", e);
    } catch (DOMDataTreeShardCreationFailedException e) {
        LOG.error("Unable to create datastore client for shard {}", prefix, e);
    }
}
Also used : DOMDataTreeProducerException(org.opendaylight.mdsal.dom.api.DOMDataTreeProducerException) ActorRef(akka.actor.ActorRef) DOMDataTreeProducer(org.opendaylight.mdsal.dom.api.DOMDataTreeProducer) AbstractDataStore(org.opendaylight.controller.cluster.datastore.AbstractDataStore) DOMDataTreeShard(org.opendaylight.mdsal.dom.api.DOMDataTreeShard) DOMDataTreeShardingConflictException(org.opendaylight.mdsal.dom.api.DOMDataTreeShardingConflictException) DataStoreClient(org.opendaylight.controller.cluster.databroker.actors.dds.DataStoreClient)

Example 2 with DOMDataTreeProducerException

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

the class PrefixShardHandler method ensureListExists.

private ListenableFuture<Void> ensureListExists() {
    final CollectionNodeBuilder<MapEntryNode, MapNode> mapBuilder = ImmutableNodes.mapNodeBuilder(ID_INT);
    // hardcoded initial list population for parallel produce-transactions testing on multiple nodes
    for (int i = 1; i < MAX_PREFIX; i++) {
        mapBuilder.withChild(ImmutableNodes.mapEntryBuilder(ID_INT, ID, PREFIX_TEMPLATE + i).withChild(ImmutableNodes.mapNodeBuilder(ITEM).build()).build());
    }
    final MapNode mapNode = mapBuilder.build();
    final ContainerNode containerNode = ImmutableContainerNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(ID_INTS)).withChild(mapNode).build();
    final DOMDataTreeProducer producer = domDataTreeService.createProducer(Collections.singleton(new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.EMPTY)));
    final DOMDataTreeCursorAwareTransaction tx = producer.createTransaction(false);
    final DOMDataTreeWriteCursor cursor = tx.createCursor(new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.EMPTY));
    cursor.merge(containerNode.getIdentifier(), containerNode);
    cursor.close();
    final ListenableFuture<Void> future = tx.submit();
    Futures.addCallback(future, new FutureCallback<Void>() {

        @Override
        public void onSuccess(@Nullable final Void result) {
            try {
                LOG.debug("Closing producer for initial list.");
                producer.close();
            } catch (DOMDataTreeProducerException e) {
                LOG.warn("Error while closing producer.", e);
            }
        }

        @Override
        public void onFailure(final Throwable throwable) {
        // NOOP handled by the caller of this method.
        }
    }, MoreExecutors.directExecutor());
    return future;
}
Also used : DOMDataTreeProducerException(org.opendaylight.mdsal.dom.api.DOMDataTreeProducerException) DOMDataTreeWriteCursor(org.opendaylight.mdsal.dom.api.DOMDataTreeWriteCursor) DOMDataTreeIdentifier(org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier) MapNode(org.opendaylight.yangtools.yang.data.api.schema.MapNode) MapEntryNode(org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) DOMDataTreeProducer(org.opendaylight.mdsal.dom.api.DOMDataTreeProducer) DOMDataTreeCursorAwareTransaction(org.opendaylight.mdsal.dom.api.DOMDataTreeCursorAwareTransaction)

Example 3 with DOMDataTreeProducerException

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

the class ShardedDataTreeActor method onNotifyProducerRemoved.

private void onNotifyProducerRemoved(final NotifyProducerRemoved message) {
    LOG.debug("Received NotifyProducerRemoved: {}", message);
    final ActorProducerRegistration registration = idToProducer.remove(message.getSubtrees().iterator().next());
    if (registration == null) {
        LOG.warn("The notification contained a path on which no producer is registered, throwing away");
        getSender().tell(new Status.Success(null), noSender());
        return;
    }
    try {
        registration.close();
        getSender().tell(new Status.Success(null), noSender());
    } catch (final DOMDataTreeProducerException e) {
        LOG.error("Unable to close producer", e);
        getSender().tell(new Status.Failure(e), noSender());
    }
}
Also used : Status(akka.actor.Status) DOMDataTreeProducerException(org.opendaylight.mdsal.dom.api.DOMDataTreeProducerException) Success(akka.actor.Status.Success)

Example 4 with DOMDataTreeProducerException

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

the class PrefixLeaderHandler method makeLeaderLocal.

public ListenableFuture<RpcResult<Void>> makeLeaderLocal(final BecomePrefixLeaderInput input) {
    final YangInstanceIdentifier yid = serializer.toYangInstanceIdentifier(input.getPrefix());
    final DOMDataTreeIdentifier prefix = new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, yid);
    try (CDSDataTreeProducer producer = (CDSDataTreeProducer) domDataTreeService.createProducer(Collections.singleton(prefix))) {
        final CDSShardAccess shardAccess = producer.getShardAccess(prefix);
        final CompletionStage<Void> completionStage = shardAccess.makeLeaderLocal();
        completionStage.exceptionally(throwable -> {
            LOG.error("Leader movement failed.", throwable);
            return null;
        });
    } catch (final DOMDataTreeProducerException e) {
        LOG.warn("Error while closing producer", e);
    } catch (final TimeoutException e) {
        LOG.warn("Timeout while on producer operation", e);
        Futures.immediateFuture(RpcResultBuilder.failed().withError(RpcError.ErrorType.RPC, "resource-denied-transport", "Timeout while opening producer please retry.", "clustering-it", "clustering-it", e));
    }
    return Futures.immediateFuture(RpcResultBuilder.<Void>success().build());
}
Also used : DOMDataTreeProducerException(org.opendaylight.mdsal.dom.api.DOMDataTreeProducerException) DOMDataTreeIdentifier(org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) CDSShardAccess(org.opendaylight.controller.cluster.dom.api.CDSShardAccess) CDSDataTreeProducer(org.opendaylight.controller.cluster.dom.api.CDSDataTreeProducer) TimeoutException(org.opendaylight.controller.cluster.datastore.exceptions.TimeoutException)

Aggregations

DOMDataTreeProducerException (org.opendaylight.mdsal.dom.api.DOMDataTreeProducerException)4 DOMDataTreeIdentifier (org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier)2 DOMDataTreeProducer (org.opendaylight.mdsal.dom.api.DOMDataTreeProducer)2 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)2 ActorRef (akka.actor.ActorRef)1 Status (akka.actor.Status)1 Success (akka.actor.Status.Success)1 DataStoreClient (org.opendaylight.controller.cluster.databroker.actors.dds.DataStoreClient)1 AbstractDataStore (org.opendaylight.controller.cluster.datastore.AbstractDataStore)1 TimeoutException (org.opendaylight.controller.cluster.datastore.exceptions.TimeoutException)1 CDSDataTreeProducer (org.opendaylight.controller.cluster.dom.api.CDSDataTreeProducer)1 CDSShardAccess (org.opendaylight.controller.cluster.dom.api.CDSShardAccess)1 DOMDataTreeCursorAwareTransaction (org.opendaylight.mdsal.dom.api.DOMDataTreeCursorAwareTransaction)1 DOMDataTreeShard (org.opendaylight.mdsal.dom.api.DOMDataTreeShard)1 DOMDataTreeShardingConflictException (org.opendaylight.mdsal.dom.api.DOMDataTreeShardingConflictException)1 DOMDataTreeWriteCursor (org.opendaylight.mdsal.dom.api.DOMDataTreeWriteCursor)1 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)1 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)1 MapNode (org.opendaylight.yangtools.yang.data.api.schema.MapNode)1