Search in sources :

Example 6 with CreateShard

use of org.opendaylight.controller.cluster.datastore.messages.CreateShard in project controller by opendaylight.

the class DistributedShardedDOMDataTree method createPrefixConfigShard.

private static void createPrefixConfigShard(final AbstractDataStore dataStore) {
    Configuration configuration = dataStore.getActorContext().getConfiguration();
    Collection<MemberName> memberNames = configuration.getUniqueMemberNamesForAllShards();
    CreateShard createShardMessage = new CreateShard(new ModuleShardConfiguration(PrefixShards.QNAME.getNamespace(), "prefix-shard-configuration", ClusterUtils.PREFIX_CONFIG_SHARD_ID, ModuleShardStrategy.NAME, memberNames), Shard.builder(), dataStore.getActorContext().getDatastoreContext());
    dataStore.getActorContext().getShardManager().tell(createShardMessage, noSender());
}
Also used : Configuration(org.opendaylight.controller.cluster.datastore.config.Configuration) ModuleShardConfiguration(org.opendaylight.controller.cluster.datastore.config.ModuleShardConfiguration) MemberName(org.opendaylight.controller.cluster.access.concepts.MemberName) CreateShard(org.opendaylight.controller.cluster.datastore.messages.CreateShard) ModuleShardConfiguration(org.opendaylight.controller.cluster.datastore.config.ModuleShardConfiguration)

Example 7 with CreateShard

use of org.opendaylight.controller.cluster.datastore.messages.CreateShard in project controller by opendaylight.

the class DistributedEntityOwnershipService method start.

public static DistributedEntityOwnershipService start(final ActorContext context, final EntityOwnerSelectionStrategyConfig strategyConfig) {
    ActorRef shardManagerActor = context.getShardManager();
    Configuration configuration = context.getConfiguration();
    Collection<MemberName> entityOwnersMemberNames = configuration.getUniqueMemberNamesForAllShards();
    CreateShard createShard = new CreateShard(new ModuleShardConfiguration(EntityOwners.QNAME.getNamespace(), "entity-owners", ENTITY_OWNERSHIP_SHARD_NAME, ModuleShardStrategy.NAME, entityOwnersMemberNames), newShardBuilder(context, strategyConfig), null);
    Future<Object> createFuture = context.executeOperationAsync(shardManagerActor, createShard, MESSAGE_TIMEOUT);
    createFuture.onComplete(new OnComplete<Object>() {

        @Override
        public void onComplete(final Throwable failure, final Object response) {
            if (failure != null) {
                LOG.error("Failed to create {} shard", ENTITY_OWNERSHIP_SHARD_NAME, failure);
            } else {
                LOG.info("Successfully created {} shard", ENTITY_OWNERSHIP_SHARD_NAME);
            }
        }
    }, context.getClientDispatcher());
    return new DistributedEntityOwnershipService(context);
}
Also used : Configuration(org.opendaylight.controller.cluster.datastore.config.Configuration) ModuleShardConfiguration(org.opendaylight.controller.cluster.datastore.config.ModuleShardConfiguration) ActorRef(akka.actor.ActorRef) MemberName(org.opendaylight.controller.cluster.access.concepts.MemberName) CreateShard(org.opendaylight.controller.cluster.datastore.messages.CreateShard) ModuleShardConfiguration(org.opendaylight.controller.cluster.datastore.config.ModuleShardConfiguration)

Aggregations

ModuleShardConfiguration (org.opendaylight.controller.cluster.datastore.config.ModuleShardConfiguration)7 CreateShard (org.opendaylight.controller.cluster.datastore.messages.CreateShard)7 Test (org.junit.Test)5 ActorRef (akka.actor.ActorRef)4 TestActorRef (akka.testkit.TestActorRef)3 TestKit (akka.testkit.javadsl.TestKit)3 AbstractShardManagerTest (org.opendaylight.controller.cluster.datastore.AbstractShardManagerTest)3 Shard (org.opendaylight.controller.cluster.datastore.Shard)3 ConfigurationImpl (org.opendaylight.controller.cluster.datastore.config.ConfigurationImpl)3 EmptyModuleShardConfigProvider (org.opendaylight.controller.cluster.datastore.config.EmptyModuleShardConfigProvider)3 FindLocalShard (org.opendaylight.controller.cluster.datastore.messages.FindLocalShard)3 UpdateSchemaContext (org.opendaylight.controller.cluster.datastore.messages.UpdateSchemaContext)3 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 MemberName (org.opendaylight.controller.cluster.access.concepts.MemberName)2 MemberNode (org.opendaylight.controller.cluster.datastore.MemberNode)2 Configuration (org.opendaylight.controller.cluster.datastore.config.Configuration)2 SchemaContext (org.opendaylight.yangtools.yang.model.api.SchemaContext)2 Success (akka.actor.Status.Success)1 DatastoreContext (org.opendaylight.controller.cluster.datastore.DatastoreContext)1 DisableElectionsRaftPolicy (org.opendaylight.controller.cluster.raft.policy.DisableElectionsRaftPolicy)1