Search in sources :

Example 1 with DOMDataTreeShard

use of org.opendaylight.mdsal.dom.api.DOMDataTreeShard 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)

Aggregations

ActorRef (akka.actor.ActorRef)1 DataStoreClient (org.opendaylight.controller.cluster.databroker.actors.dds.DataStoreClient)1 AbstractDataStore (org.opendaylight.controller.cluster.datastore.AbstractDataStore)1 DOMDataTreeProducer (org.opendaylight.mdsal.dom.api.DOMDataTreeProducer)1 DOMDataTreeProducerException (org.opendaylight.mdsal.dom.api.DOMDataTreeProducerException)1 DOMDataTreeShard (org.opendaylight.mdsal.dom.api.DOMDataTreeShard)1 DOMDataTreeShardingConflictException (org.opendaylight.mdsal.dom.api.DOMDataTreeShardingConflictException)1