I just tried upgrading my project to ElasticSearch 0.13 and the unit tests are throwing out:
org.elasticsearch.cluster.block.ClusterBlockException: blocked by: [1/not recovered from gateway];
I read the thread from this form entitled "Search failures on server restarts" (which discusses ClusterBlockException) and tried the following advice from it without success:
).node().start();
elasticSearchClient = hostNode.client();
elasticSearchClient.admin().indices().create(Requests.createIndexRequest("index0")).actionGet();
String json = (new FileUtil()).readTextFileFromClasspath("mail_mappings.json");
elasticSearchClient.admin().indices().putMapping(Requests.putMappingRequest("index0").source(json)).actionGet();
json = (new FileUtil()).readTextFileFromClasspath("attachment_mappings.json");
elasticSearchClient.admin().indices().putMapping(Requests.putMappingRequest("index0").source(json)).actionGet();
At the end of each test, I do this:
elasticSearchClient.close();
hostNode.close();
(I tried taking this last part out, and it doesn't to help; I just get different a different error (IndexAlreadyExistsException) when the next tests run.)
Thanks in advance for any help you can afford.
-john
Seems I've found something that gets the job done. I took this part out of the end of the test class:
elasticSearchClient.close();
hostNode.close();
And then when I create the index at the beginning of the next test class, I wrap the index creation in a try/catch and ignore and keep going if I catch:
try {
elasticSearchClient.admin().indices().create(Requests.createIndexRequest("index0")).actionGet();
} catch (ElasticSearchException e) {
e.printStackTrace();
}
This way, my tests can be run in any order or one at a time, as they create the index but don't fail if another has already created it.
Anyway, seems to be working; let me know if this is a bad way of doing things, but it looks ok to me.
In case of none gateway, there shouldn't be the block created (for a very
short time) if it not being recovered from the gateway. You can try and
prepare a cluster health but wait for nodes and not on a specific index, it
should help.
Seems I've found something that gets the job done. I took this part out of
the end of the test class:
elasticSearchClient.close();
hostNode.close();
And then when I create the index at the beginning of the next test class, I
wrap the index creation in a try/catch and ignore and keep going if I
catch:
try {
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.