Skip to content

Commit

Permalink
Merge branch 'making-BulkRequest-implement-RefCounted' into making-Bu…
Browse files Browse the repository at this point in the history
…lkShardRequest-implement-RefCounted
  • Loading branch information
masseyke committed Jan 3, 2024
2 parents a190c7d + 7c9b19d commit 05e2bac
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,14 @@ public void setupIndex() throws IOException {
.get();

BulkRequestBuilder bulk = client().prepareBulk().setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
for (int i = 0; i < numberOfDocs(); i++) {
bulk.add(prepareIndex("test").setId(Integer.toString(i)).setSource("foo", i));
try {
for (int i = 0; i < numberOfDocs(); i++) {
bulk.add(prepareIndex("test").setId(Integer.toString(i)).setSource("foo", i));
}
bulk.get();
} finally {
bulk.request().decRef();
}
bulk.get();
/*
* forceMerge so we can be sure that we don't bump into tiny
* segments that finish super quickly and cause us to report strange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,14 @@ private void createRemoteIndex(int numDocs) throws Exception {
mapping.endObject();
client(REMOTE_CLUSTER).admin().indices().prepareCreate("test").setMapping(mapping).get();
BulkRequestBuilder bulk = client(REMOTE_CLUSTER).prepareBulk("test").setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
for (int i = 0; i < numDocs; i++) {
bulk.add(new IndexRequest().source("foo", i));
try {
for (int i = 0; i < numDocs; i++) {
bulk.add(new IndexRequest().source("foo", i));
}
bulk.get();
} finally {
bulk.request().decRef();
}
bulk.get();
}

public void testCancel() throws Exception {
Expand Down

0 comments on commit 05e2bac

Please sign in to comment.