Search in sources :

Example 11 with RemotePrimaryShardFound

use of org.opendaylight.controller.cluster.datastore.messages.RemotePrimaryShardFound 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

RemotePrimaryShardFound (org.opendaylight.controller.cluster.datastore.messages.RemotePrimaryShardFound)11 ActorRef (akka.actor.ActorRef)6 TestActorRef (akka.testkit.TestActorRef)6 Test (org.junit.Test)6 FindPrimary (org.opendaylight.controller.cluster.datastore.messages.FindPrimary)6 LocalPrimaryShardFound (org.opendaylight.controller.cluster.datastore.messages.LocalPrimaryShardFound)6 TestKit (akka.testkit.javadsl.TestKit)5 AddressFromURIString (akka.actor.AddressFromURIString)4 AbstractShardManagerTest (org.opendaylight.controller.cluster.datastore.AbstractShardManagerTest)4 ActorInitialized (org.opendaylight.controller.cluster.datastore.messages.ActorInitialized)4 ShardLeaderStateChanged (org.opendaylight.controller.cluster.datastore.messages.ShardLeaderStateChanged)4 UpdateSchemaContext (org.opendaylight.controller.cluster.datastore.messages.UpdateSchemaContext)4 RoleChangeNotification (org.opendaylight.controller.cluster.notifications.RoleChangeNotification)4 ActorSystem (akka.actor.ActorSystem)3 ClusterWrapperImpl (org.opendaylight.controller.cluster.datastore.ClusterWrapperImpl)3 PrimaryShardInfo (org.opendaylight.controller.cluster.datastore.messages.PrimaryShardInfo)3 MockConfiguration (org.opendaylight.controller.cluster.datastore.utils.MockConfiguration)3 Timeout (akka.util.Timeout)2 AbstractActorTest (org.opendaylight.controller.cluster.datastore.AbstractActorTest)2 ClusterWrapper (org.opendaylight.controller.cluster.datastore.ClusterWrapper)2