Skip to content

Commit

Permalink
HSEARCH-2520 Log automatic closings and openings of Elasticsearch ind…
Browse files Browse the repository at this point in the history
…exes

This is important information, because it might have side-effects on
other clients of those indexes, so the INFO level is relevant here.

These logs shouldn't be very frequent (only one or two per index on
startup).
  • Loading branch information
yrodiere authored and Sanne committed Jan 22, 2017
1 parent 30cd091 commit 6cd1d62
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Expand Up @@ -372,4 +372,22 @@ BulkRequestFailedException elasticsearchBulkRequestFailed(String request, String
)
SearchException elasticsearchIndexSettingsRetrievalForValidationFailed(@Cause Exception cause);

@LogMessage(level = Level.INFO)
@Message(id = ES_BACKEND_MESSAGES_START_ID + 69,
value = "Closed Elasticsearch index '%1$s' automatically."
)
void closedIndex(String indexName);

@LogMessage(level = Level.INFO)
@Message(id = ES_BACKEND_MESSAGES_START_ID + 70,
value = "Opened Elasticsearch index '%1$s' automatically."
)
void openedIndex(String indexName);

@LogMessage(level = Level.ERROR)
@Message(id = ES_BACKEND_MESSAGES_START_ID + 71,
value = "Failed to open Elasticsearch index '%1$s' ; see the stack trace below."
)
void failedToOpenIndex(String indexName);

}
Expand Up @@ -248,9 +248,17 @@ public void dropIndex(String indexName, ExecutionOptions executionOptions) {

public void closeIndex(String indexName) {
jestClient.executeRequest( new CloseIndex.Builder( indexName ).build() );
LOG.closedIndex( indexName );
}

public void openIndex(String indexName) {
jestClient.executeRequest( new OpenIndex.Builder( indexName ).build() );
try {
jestClient.executeRequest( new OpenIndex.Builder( indexName ).build() );
}
catch (RuntimeException e) {
LOG.openedIndex( indexName );
throw e;
}
LOG.openedIndex( indexName );
}
}

0 comments on commit 6cd1d62

Please sign in to comment.