use of org.molgenis.data.index.exception.IndexAlreadyExistsException in project molgenis by molgenis.
the class ClientFacade method createIndex.
public void createIndex(Index index, IndexSettings indexSettings, Stream<Mapping> mappingStream) {
if (LOG.isTraceEnabled()) {
LOG.trace("Creating index '{}' ...", index.getName());
}
CreateIndexRequestBuilder createIndexRequest = createIndexRequest(index, indexSettings, mappingStream);
CreateIndexResponse createIndexResponse;
try {
createIndexResponse = createIndexRequest.get();
} catch (ResourceAlreadyExistsException e) {
LOG.debug("", e);
throw new IndexAlreadyExistsException(index.getName());
} catch (ElasticsearchException e) {
LOG.error("", e);
throw new IndexException(format("Error creating index '%s'.", index.getName()));
}
// 'acknowledged' indicates whether the index was successfully created in the cluster before the request timeout
if (!createIndexResponse.isAcknowledged()) {
LOG.warn("Index '{}' creation possibly failed (acknowledged=false)", index.getName());
}
// 'shards_acknowledged' indicates whether the requisite number of shard copies were started for each shard in the index before timing out
if (!createIndexResponse.isShardsAcked()) {
LOG.warn("Index '{}' creation possibly failed (shards_acknowledged=false)", index.getName());
}
if (LOG.isDebugEnabled()) {
LOG.debug("Created index '{}'.", index.getName());
}
}
Aggregations