Thanks for the suggestion. I replaced the codes with High level rest client
RestHighLevelClient client = new RestHighLevelClient(
RestClient.builder(new HttpHost("10.169.149.134", 9200, "http"))
.setRequestConfigCallback(new RestClientBuilder.RequestConfigCallback() {
public RequestConfig.Builder customizeRequestConfig(RequestConfig.Builder requestConfigBuilder) {
return requestConfigBuilder.setConnectTimeout(5000)
.setSocketTimeout(100000);
}
})
.setMaxRetryTimeoutMillis(100000)
);
IndexRequest indexRequest = new IndexRequest("event-index", "event-log")
.source(builder);
IndexResponse indexResponse = client.index(indexRequest);
But this time I see the following error after inserting two records ....
Exception in thread "main" ElasticsearchStatusException[Elasticsearch exception [type=unavailable_shards_exception, reason=[event-index][0] primary shard is not active Timeout: [1m], request: [BulkShardRequest [[event-index][0]] containing [index {[event-index][event-log][SHo5bGQBSnIrxdlC0Dps], source[{"alert_type":"EVENTType1ALERT2","incident_category":"health","event_category":"heartbeat","component_category":"monstor_client","source_timestamp":"2018-07-05T20:54:45.594Z","source_eventtype":"EVENTType1","criticality":2,"dimensions.app_name":"APP10","dimensions.colo":"PHX","dimensions.monstor":true,"dimensions.host":"HOST1","dimensions.pool":"POOL3","dimensions.env":"ENV1"}]}]]]]
at org.elasticsearch.rest.BytesRestResponse.errorFromXContent(BytesRestResponse.java:177)
at org.elasticsearch.client.RestHighLevelClient.parseEntity(RestHighLevelClient.java:653)
at org.elasticsearch.client.RestHighLevelClient.parseResponseException(RestHighLevelClient.java:628)
at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:535)
at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:508)
at org.elasticsearch.client.RestHighLevelClient.index(RestHighLevelClient.java:348)
at UMPHeartbeatGenerator.generateEvent(UMPHeartbeatGenerator.java:198)
at UMPHeartbeatGenerator.main(UMPHeartbeatGenerator.java:75)
Suppressed: org.elasticsearch.client.ResponseException: method [POST], host [http://10.169.149.134:9200], URI [/event-index/event-log?timeout=1m], status line [HTTP/1.1 503 Service Unavailable]
{"error":{"root_cause":[{"type":"unavailable_shards_exception","reason":"[event-index][0] primary shard is not active Timeout: [1m], request: [BulkShardRequest [[event-index][0]] containing [index {[event-index][event-log][SHo5bGQBSnIrxdlC0Dps], source[{\"alert_type\":\"EVENTType1ALERT2\",\"incident_category\":\"health\",\"event_category\":\"heartbeat\",\"component_category\":\"monstor_client\",\"source_timestamp\":\"2018-07-05T20:54:45.594Z\",\"source_eventtype\":\"EVENTType1\",\"criticality\":2,\"dimensions.app_name\":\"APP10\",\"dimensions.colo\":\"PHX\",\"dimensions.monstor\":true,\"dimensions.host\":\"HOST1\",\"dimensions.pool\":\"POOL3\",\"dimensions.env\":\"ENV1\"}]}]]"}],"type":"unavailable_shards_exception","reason":"[event-index][0] primary shard is not active Timeout: [1m], request: [BulkShardRequest [[event-index][0]] containing [index {[event-index][event-log][SHo5bGQBSnIrxdlC0Dps], source[{\"alert_type\":\"EVENTType1ALERT2\",\"incident_category\":\"health\",\"event_category\":\"heartbeat\",\"component_category\":\"monstor_client\",\"source_timestamp\":\"2018-07-05T20:54:45.594Z\",\"source_eventtype\":\"EVENTType1\",\"criticality\":2,\"dimensions.app_name\":\"APP10\",\"dimensions.colo\":\"PHX\",\"dimensions.monstor\":true,\"dimensions.host\":\"HOST1\",\"dimensions.pool\":\"POOL3\",\"dimensions.env\":\"ENV1\"}]}]]"},"status":503}
at org.elasticsearch.client.RestClient$SyncResponseListener.get(RestClient.java:705)
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:235)
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:198)
at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:522)
... 4 more
Caused by: org.elasticsearch.client.ResponseException: method [POST], host [http://10.169.149.134:9200], URI [/event-index/event-log?timeout=1m], status line [HTTP/1.1 503 Service Unavailable]
at org.elasticsearch.client.RestClient$1.completed(RestClient.java:377)
at org.elasticsearch.client.RestClient$1.completed(RestClient.java:366)
at org.apache.http.concurrent.BasicFuture.completed(BasicFuture.java:119)
at org.apache.http.impl.nio.client.DefaultClientExchangeHandlerImpl.responseCompleted(DefaultClientExchangeHandlerImpl.java:177)
at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.processResponse(HttpAsyncRequestExecutor.java:436)
at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.inputReady(HttpAsyncRequestExecutor.java:326)
at org.apache.http.impl.nio.DefaultNHttpClientConnection.consumeInput(DefaultNHttpClientConnection.java:265)
at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:81)
at org.apache.http.impl.nio.client.InternalIODispatch.onInputReady(InternalIODispatch.java:39)
at org.apache.http.impl.nio.reactor.AbstractIODispatch.inputReady(AbstractIODispatch.java:114)
at org.apache.http.impl.nio.reactor.BaseIOReactor.readable(BaseIOReactor.java:162)
at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent(AbstractIOReactor.java:337)
at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents(AbstractIOReactor.java:315)
at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:276)
at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:104)
at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:588)
at java.lang.Thread.run(Thread.java:748)
When I try the same code in my locally running Elasticsearch everything seems to be fine.