diff --git a/elx-common/src/main/java/org/xbib/elx/common/DefaultBulkProcessor.java b/elx-common/src/main/java/org/xbib/elx/common/DefaultBulkProcessor.java index a0124ec..60267e9 100644 --- a/elx-common/src/main/java/org/xbib/elx/common/DefaultBulkProcessor.java +++ b/elx-common/src/main/java/org/xbib/elx/common/DefaultBulkProcessor.java @@ -150,8 +150,13 @@ public class DefaultBulkProcessor implements BulkProcessor { * @return his bulk processor */ @Override - public DefaultBulkProcessor add(ActionRequest request) { - internalAdd(request); + public synchronized DefaultBulkProcessor add(ActionRequest request) { + ensureOpen(); + bulkRequest.add(request); + if ((bulkActions != -1 && bulkRequest.numberOfActions() >= bulkActions) || + (bulkSize != -1 && bulkRequest.estimatedSizeInBytes() >= bulkSize)) { + execute(); + } return this; } @@ -185,33 +190,13 @@ public class DefaultBulkProcessor implements BulkProcessor { } } - private synchronized void internalAdd(ActionRequest request) { - ensureOpen(); - bulkRequest.add(request); - executeIfNeeded(); - } - - private void executeIfNeeded() { - ensureOpen(); - if (!isOverTheLimit()) { - return; - } - execute(); - } - private void execute() { - final BulkRequest myBulkRequest = this.bulkRequest; - final long executionId = executionIdGen.incrementAndGet(); + BulkRequest myBulkRequest = this.bulkRequest; + long executionId = executionIdGen.incrementAndGet(); this.bulkRequest = new BulkRequest(); this.bulkRequestHandler.execute(myBulkRequest, executionId); } - private boolean isOverTheLimit() { - return bulkActions != -1 && - bulkRequest.numberOfActions() >= bulkActions || - bulkSize != -1 && bulkRequest.estimatedSizeInBytes() >= bulkSize; - } - /** * A builder used to create a build an instance of a bulk processor. */ diff --git a/elx-node/src/test/java/org/xbib/elx/node/test/BulkClientTest.java b/elx-node/src/test/java/org/xbib/elx/node/test/BulkClientTest.java index 4aecc09..b63e72f 100644 --- a/elx-node/src/test/java/org/xbib/elx/node/test/BulkClientTest.java +++ b/elx-node/src/test/java/org/xbib/elx/node/test/BulkClientTest.java @@ -32,7 +32,7 @@ class BulkClientTest { private static final Long ACTIONS = 10000L; - private static final Long MAX_ACTIONS_PER_REQUEST = 10000L; + private static final Long MAX_ACTIONS_PER_REQUEST = 1000L; private final TestExtension.Helper helper; diff --git a/gradle.properties b/gradle.properties index 4f2225c..fb5bf3f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ group = org.xbib name = elx -version = 2.2.1.30 +version = 2.2.1.31 gradle.wrapper.version = 6.6.1 xbib-metrics.version = 2.1.0