use of org.opendaylight.controller.cluster.datastore.exceptions.UnknownMessageException in project controller by opendaylight.
the class ActorContext method findPrimaryShardAsync.
public Future<PrimaryShardInfo> findPrimaryShardAsync(final String shardName) {
Future<PrimaryShardInfo> ret = primaryShardInfoCache.getIfPresent(shardName);
if (ret != null) {
return ret;
}
Future<Object> future = executeOperationAsync(shardManager, new FindPrimary(shardName, true), shardInitializationTimeout);
return future.transform(new Mapper<Object, PrimaryShardInfo>() {
@Override
public PrimaryShardInfo checkedApply(Object response) throws UnknownMessageException {
if (response instanceof RemotePrimaryShardFound) {
LOG.debug("findPrimaryShardAsync received: {}", response);
RemotePrimaryShardFound found = (RemotePrimaryShardFound) response;
return onPrimaryShardFound(shardName, found.getPrimaryPath(), found.getPrimaryVersion(), null);
} else if (response instanceof LocalPrimaryShardFound) {
LOG.debug("findPrimaryShardAsync received: {}", response);
LocalPrimaryShardFound found = (LocalPrimaryShardFound) response;
return onPrimaryShardFound(shardName, found.getPrimaryPath(), DataStoreVersions.CURRENT_VERSION, found.getLocalShardDataTree());
} else if (response instanceof NotInitializedException) {
throw (NotInitializedException) response;
} else if (response instanceof PrimaryNotFoundException) {
throw (PrimaryNotFoundException) response;
} else if (response instanceof NoShardLeaderException) {
throw (NoShardLeaderException) response;
}
throw new UnknownMessageException(String.format("FindPrimary returned unkown response: %s", response));
}
}, FIND_PRIMARY_FAILURE_TRANSFORMER, getClientDispatcher());
}
Aggregations