Search in sources :

Example 11 with LocalPrimaryShardFound

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

the class ShardManager method findPrimary.

private void findPrimary(final String shardName, final FindPrimaryResponseHandler handler) {
    Timeout findPrimaryTimeout = new Timeout(datastoreContextFactory.getBaseDatastoreContext().getShardInitializationTimeout().duration().$times(2));
    Future<Object> futureObj = ask(getSelf(), new FindPrimary(shardName, true), findPrimaryTimeout);
    futureObj.onComplete(new OnComplete<Object>() {

        @Override
        public void onComplete(final Throwable failure, final Object response) {
            if (failure != null) {
                handler.onFailure(failure);
            } else {
                if (response instanceof RemotePrimaryShardFound) {
                    handler.onRemotePrimaryShardFound((RemotePrimaryShardFound) response);
                } else if (response instanceof LocalPrimaryShardFound) {
                    handler.onLocalPrimaryFound((LocalPrimaryShardFound) response);
                } else {
                    handler.onUnknownResponse(response);
                }
            }
        }
    }, new Dispatchers(context().system().dispatchers()).getDispatcher(Dispatchers.DispatcherType.Client));
}
Also used : FindPrimary(org.opendaylight.controller.cluster.datastore.messages.FindPrimary) RemoteFindPrimary(org.opendaylight.controller.cluster.datastore.messages.RemoteFindPrimary) LocalPrimaryShardFound(org.opendaylight.controller.cluster.datastore.messages.LocalPrimaryShardFound) Timeout(akka.util.Timeout) RemotePrimaryShardFound(org.opendaylight.controller.cluster.datastore.messages.RemotePrimaryShardFound) Dispatchers(org.opendaylight.controller.cluster.common.actor.Dispatchers)

Aggregations

LocalPrimaryShardFound (org.opendaylight.controller.cluster.datastore.messages.LocalPrimaryShardFound)11 FindPrimary (org.opendaylight.controller.cluster.datastore.messages.FindPrimary)7 ActorRef (akka.actor.ActorRef)6 TestActorRef (akka.testkit.TestActorRef)6 Test (org.junit.Test)6 RemotePrimaryShardFound (org.opendaylight.controller.cluster.datastore.messages.RemotePrimaryShardFound)6 AddressFromURIString (akka.actor.AddressFromURIString)5 TestKit (akka.testkit.javadsl.TestKit)5 AbstractShardManagerTest (org.opendaylight.controller.cluster.datastore.AbstractShardManagerTest)5 ActorInitialized (org.opendaylight.controller.cluster.datastore.messages.ActorInitialized)5 ShardLeaderStateChanged (org.opendaylight.controller.cluster.datastore.messages.ShardLeaderStateChanged)5 UpdateSchemaContext (org.opendaylight.controller.cluster.datastore.messages.UpdateSchemaContext)5 RoleChangeNotification (org.opendaylight.controller.cluster.notifications.RoleChangeNotification)5 PrimaryShardInfo (org.opendaylight.controller.cluster.datastore.messages.PrimaryShardInfo)4 DataTree (org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree)4 ActorSystem (akka.actor.ActorSystem)2 Timeout (akka.util.Timeout)2 ClusterWrapperImpl (org.opendaylight.controller.cluster.datastore.ClusterWrapperImpl)2 PrimaryNotFoundException (org.opendaylight.controller.cluster.datastore.exceptions.PrimaryNotFoundException)2 ShardIdentifier (org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier)2