Search in sources :

Example 1 with RefreshRequestBuilder

use of org.elasticsearch.action.admin.indices.refresh.RefreshRequestBuilder in project sonarqube by SonarSource.

the class ProxyRefreshRequestBuilderTest method trace_logs.

@Test
public void trace_logs() {
    logTester.setLevel(LoggerLevel.TRACE);
    RefreshRequestBuilder requestBuilder = esTester.client().prepareRefresh(FakeIndexDefinition.INDEX);
    requestBuilder.get();
    assertThat(logTester.logs(LoggerLevel.TRACE)).hasSize(1);
}
Also used : RefreshRequestBuilder(org.elasticsearch.action.admin.indices.refresh.RefreshRequestBuilder) Test(org.junit.Test)

Example 2 with RefreshRequestBuilder

use of org.elasticsearch.action.admin.indices.refresh.RefreshRequestBuilder in project sonarqube by SonarSource.

the class ProxyRefreshRequestBuilderTest method refresh.

@Test
public void refresh() {
    RefreshRequestBuilder requestBuilder = esTester.client().prepareRefresh(FakeIndexDefinition.INDEX);
    requestBuilder.get();
}
Also used : RefreshRequestBuilder(org.elasticsearch.action.admin.indices.refresh.RefreshRequestBuilder) Test(org.junit.Test)

Example 3 with RefreshRequestBuilder

use of org.elasticsearch.action.admin.indices.refresh.RefreshRequestBuilder 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

RefreshRequestBuilder (org.elasticsearch.action.admin.indices.refresh.RefreshRequestBuilder)3 Test (org.junit.Test)2 ElasticsearchException (org.elasticsearch.ElasticsearchException)1 ResourceNotFoundException (org.elasticsearch.ResourceNotFoundException)1 ShardOperationFailedException (org.elasticsearch.action.ShardOperationFailedException)1 RefreshResponse (org.elasticsearch.action.admin.indices.refresh.RefreshResponse)1 IndexException (org.molgenis.data.index.exception.IndexException)1 UnknownIndexException (org.molgenis.data.index.exception.UnknownIndexException)1