RestHighLevelClient: Force merge async and SocketTimeoutException

Hi,

I have the following problem after trying to upgrade my Java code to the RestHighLevelClient.

At the end of a big process of reindexation, there is an old piece of code that run a Force Merge.
I have replaced with a call to forcemergeAsync(), and expect that the process will be notified when the merge is finished (takes ~20 minutes for very big indices), but the query seems to wait and the socket die with a SocketTimeoutException (That's normal).

My questions are:
What is the good way to run this kind of long query ?
Is there a problem in Java client or is my code bad ? I can believe it :slight_smile:
Do I have to run it in a task and watch the task (seems to be the good solution) ?

Here is the code:

				logger.info("### Force merge...");

			final CountDownLatch countDownLatch = new CountDownLatch(1);

			ActionListener<ForceMergeResponse> listener = new ActionListener<ForceMergeResponse>() {

				@Override
				public void onResponse(ForceMergeResponse response) {
					isOk.set(true);
			        countDownLatch.countDown();
				}

				@Override
				public void onFailure(Exception e) {
					isOk.set(false);
					logger.severe(ExceptionUtils.getFullStackTrace(e));
					countDownLatch.countDown();
				}
			};

			client.indices().forcemergeAsync(
					new ForceMergeRequest(indexName).maxNumSegments(forceMergeMaxNumSegments) /*.createTask(id, type, action, parentTaskId, headers)*/, 
					RequestOptions.DEFAULT, 
					listener);

			// wait max 1h for async request to perform the merge request
			boolean finishNormaly = countDownLatch.await(1, TimeUnit.HOURS);
			if(!finishNormaly) {
				throw new InterruptedException();
			}

After 30s, the onFailure is called, and that's bad for me :frowning:

Thank you,
Xavier

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.