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));
}
Aggregations