public ForceMergeRequestBuilder prepareForceMerge(String indexName) { // TODO add proxy for profiling return nativeClient().admin().indices().prepareForceMerge(indexName) .setMaxNumSegments(1); }
@Override public void optimize(String indexName) { client.admin().indices().prepareForceMerge(indexName).get(); }
public ForceMergeRequestBuilder prepareForceMerge(String indexName) { // TODO add proxy for profiling return nativeClient().admin().indices().prepareForceMerge(indexName) .setMaxNumSegments(1); }
public ForceMergeResponse forceMerge( final BuilderCallback<ForceMergeRequestBuilder> builder) { waitForRelocation(); final ForceMergeResponse actionGet = builder .apply(client().admin().indices().prepareForceMerge()).execute() .actionGet(); final ShardOperationFailedException[] shardFailures = actionGet .getShardFailures(); if (shardFailures != null && shardFailures.length != 0) { final StringBuilder buf = new StringBuilder(100); for (final ShardOperationFailedException shardFailure : shardFailures) { buf.append(shardFailure.toString()).append('\n'); } onFailure(buf.toString(), actionGet); } return actionGet; }
/** * Waits for all relocations and force merge all indices in the cluster to 1 segment. */ protected ForceMergeResponse forceMerge() { waitForRelocation(); ForceMergeResponse actionGet = client().admin().indices().prepareForceMerge().setMaxNumSegments(1).execute().actionGet(); assertNoFailures(actionGet); return actionGet; }
/** * Maybe refresh, force merge, or flush then always make sure there aren't too many in flight async operations. */ private void postIndexAsyncActions(String[] indices, List<CountDownLatch> inFlightAsyncOperations, boolean maybeFlush) throws InterruptedException { if (rarely()) { if (rarely()) { client().admin().indices().prepareRefresh(indices).setIndicesOptions(IndicesOptions.lenientExpandOpen()).execute( new LatchedActionListener<>(newLatch(inFlightAsyncOperations))); } else if (maybeFlush && rarely()) { if (randomBoolean()) { client().admin().indices().prepareFlush(indices).setIndicesOptions(IndicesOptions.lenientExpandOpen()).execute( new LatchedActionListener<>(newLatch(inFlightAsyncOperations))); } else { client().admin().indices().syncedFlush(syncedFlushRequest(indices).indicesOptions(IndicesOptions.lenientExpandOpen()), new LatchedActionListener<>(newLatch(inFlightAsyncOperations))); } } else if (rarely()) { client().admin().indices().prepareForceMerge(indices).setIndicesOptions(IndicesOptions.lenientExpandOpen()).setMaxNumSegments(between(1, 10)).setFlush(maybeFlush && randomBoolean()).execute( new LatchedActionListener<>(newLatch(inFlightAsyncOperations))); } } while (inFlightAsyncOperations.size() > MAX_IN_FLIGHT_ASYNC_INDEXES) { int waitFor = between(0, inFlightAsyncOperations.size() - 1); inFlightAsyncOperations.remove(waitFor).await(); } }