use of org.molgenis.data.index.exception.IndexRefreshException in project molgenis by molgenis.
the class ClientFacade method refreshIndexes.
private void refreshIndexes(List<Index> indexes) {
if (LOG.isTraceEnabled()) {
LOG.trace("Refreshing index(es) '{}' ...", toString(indexes));
}
String[] indexNames = toIndexNames(indexes);
RefreshRequest refreshRequest = new RefreshRequest(indexNames);
RefreshResponse refreshResponse;
try {
refreshResponse = client.indices().refresh(refreshRequest, DEFAULT);
} catch (ElasticsearchException e) {
if (e.status().getStatus() == 404) {
throw new UnknownIndexException(indexes.stream().map(Index::getName).toList(), e);
}
throw new IndexRefreshException(indexes.stream().map(Index::getName).toList());
} catch (IOException e) {
throw new IndexRefreshException(indexes.stream().map(Index::getName).toList(), e);
}
if (refreshResponse.getFailedShards() > 0) {
if (LOG.isErrorEnabled()) {
LOG.error(stream(refreshResponse.getShardFailures()).map(ShardOperationFailedException::toString).collect(joining("\n")));
}
throw new IndexRefreshException(indexes.stream().map(Index::getName).toList());
}
if (LOG.isDebugEnabled()) {
LOG.debug("Refreshed index(es) '{}'", toString(indexes));
}
}
Aggregations