Search in sources :

Example 11 with IndexException

use of org.molgenis.data.index.exception.IndexException 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);
    RefreshRequestBuilder refreshRequest = client.admin().indices().prepareRefresh(indexNames);
    RefreshResponse refreshResponse;
    try {
        refreshResponse = refreshRequest.get();
    } catch (ResourceNotFoundException e) {
        LOG.debug("", e);
        throw new UnknownIndexException(toIndexNames(indexes));
    } catch (ElasticsearchException e) {
        LOG.error("", e);
        throw new IndexException(format("Error refreshing index(es) '%s'.", toString(indexes)));
    }
    if (refreshResponse.getFailedShards() > 0) {
        LOG.error(stream(refreshResponse.getShardFailures()).map(ShardOperationFailedException::toString).collect(joining("\n")));
        throw new IndexException(format("Error refreshing index(es) '%s'.", toString(indexes)));
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("Refreshed index(es) '{}'", toString(indexes));
    }
}
Also used : RefreshResponse(org.elasticsearch.action.admin.indices.refresh.RefreshResponse) IndexException(org.molgenis.data.index.exception.IndexException) UnknownIndexException(org.molgenis.data.index.exception.UnknownIndexException) UnknownIndexException(org.molgenis.data.index.exception.UnknownIndexException) ElasticsearchException(org.elasticsearch.ElasticsearchException) ShardOperationFailedException(org.elasticsearch.action.ShardOperationFailedException) ResourceNotFoundException(org.elasticsearch.ResourceNotFoundException) RefreshRequestBuilder(org.elasticsearch.action.admin.indices.refresh.RefreshRequestBuilder)

Aggregations

IndexException (org.molgenis.data.index.exception.IndexException)11 UnknownIndexException (org.molgenis.data.index.exception.UnknownIndexException)11 ElasticsearchException (org.elasticsearch.ElasticsearchException)10 ResourceNotFoundException (org.elasticsearch.ResourceNotFoundException)7 ShardSearchFailure (org.elasticsearch.action.search.ShardSearchFailure)4 SearchRequestBuilder (org.elasticsearch.action.search.SearchRequestBuilder)3 SearchResponse (org.elasticsearch.action.search.SearchResponse)3 CreateIndexRequestBuilder (org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder)2 CreateIndexResponse (org.elasticsearch.action.admin.indices.create.CreateIndexResponse)2 DeleteIndexRequestBuilder (org.elasticsearch.action.admin.indices.delete.DeleteIndexRequestBuilder)2 DeleteIndexResponse (org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse)2 XContentBuilder (org.elasticsearch.common.xcontent.XContentBuilder)2 ResourceAlreadyExistsException (org.elasticsearch.ResourceAlreadyExistsException)1 DocWriteRequest (org.elasticsearch.action.DocWriteRequest)1 ShardOperationFailedException (org.elasticsearch.action.ShardOperationFailedException)1 IndicesExistsRequestBuilder (org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequestBuilder)1 IndicesExistsResponse (org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse)1 RefreshRequestBuilder (org.elasticsearch.action.admin.indices.refresh.RefreshRequestBuilder)1 RefreshResponse (org.elasticsearch.action.admin.indices.refresh.RefreshResponse)1 DeleteRequestBuilder (org.elasticsearch.action.delete.DeleteRequestBuilder)1