@Override public void flush(String indexName) { client.admin().indices().prepareFlush(indexName).get(); }
@Override public void flush() { client.admin().indices().prepareFlush(getIndexNamesAsArray()).execute().actionGet(); }
@Override public void flush() { client.admin().indices().prepareFlush(getIndexNamesAsArray()).execute().actionGet(); }
protected final void flush(final String index) { final IndicesAdminClient indices = elasticClient().admin().indices(); indices.prepareFlush(index).execute().actionGet(); indices.prepareRefresh(index).execute().actionGet(); } }
protected final void flush(final String index) { final IndicesAdminClient indices = elasticClient().admin().indices(); indices.prepareFlush(index).execute().actionGet(); indices.prepareRefresh(index).execute().actionGet(); } }
@Override public void flush() { client.admin().indices().prepareFlush(getIndexNamesAsArray()).execute().actionGet(); }
public FlushResponse flush( final BuilderCallback<FlushRequestBuilder> builder) { waitForRelocation(); final FlushResponse actionGet = builder .apply(client().admin().indices().prepareFlush()).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; }
/** * Flush some or all indices in the cluster. */ protected final FlushResponse flush(String... indices) { waitForRelocation(); FlushResponse actionGet = client().admin().indices().prepareFlush(indices).execute().actionGet(); for (ShardOperationFailedException failure : actionGet.getShardFailures()) { assertThat("unexpected flush failure " + failure.reason(), failure.status(), equalTo(RestStatus.SERVICE_UNAVAILABLE)); } return actionGet; }
@Override protected void loadData() throws Exception { client.prepareIndex("test", "type1") .setSource( jsonBuilder().startObject().field("tag", "green") .endObject()).execute().actionGet(); client.admin().indices().prepareFlush().setRefresh(true).execute() .actionGet(); client.prepareIndex("test", "type1") .setSource( jsonBuilder().startObject().field("tag", "blue") .endObject()).execute().actionGet(); client.admin().indices().prepareRefresh().execute().actionGet(); }
@Override protected void loadData() throws Exception { client.admin().indices().preparePutMapping("test").setType("type1").setSource("{\"type1\":{"+ " \"properties\" : { "+ " \"tag\" : {\"type\" : \"string\", \"analyzer\" : \"hsf_analyzer\"} "+ " } "+ "}}" ).execute().actionGet(); client.prepareIndex("test", "type1") .setSource("{ \"tag\" : \"1s2s3\"}").execute().actionGet(); client.admin().indices().prepareFlush().setRefresh(true).execute() .actionGet(); client.prepareIndex("test", "type1") .setSource("{ \"tag\" : \"2s4\"}").execute().actionGet(); client.admin().indices().prepareRefresh().execute().actionGet(); }
@Override protected void loadData() throws Exception { client.prepareIndex("test", "type1") .setSource( jsonBuilder().startObject().field("tag", "week1").field("date","2012-07-03T10:00:00.000Z") .endObject()).execute().actionGet(); client.admin().indices().prepareFlush().setRefresh(true).execute() .actionGet(); documentCount++; client.prepareIndex("test", "type1") .setSource( jsonBuilder().startObject().field("tag", "week2").field("date","2012-07-10T10:00:00.000Z") .endObject()).execute().actionGet(); client.admin().indices().prepareRefresh().execute().actionGet(); documentCount++; }
/** * 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(); } }