You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sf...@apache.org on 2015/02/18 02:10:44 UTC
incubator-usergrid git commit: add comments
Repository: incubator-usergrid
Updated Branches:
refs/heads/USERGRID-273-indexbuffer bf63116a3 -> e16352f6b
add comments
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/e16352f6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/e16352f6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/e16352f6
Branch: refs/heads/USERGRID-273-indexbuffer
Commit: e16352f6b450854934f1fa4fe505a8677e557fe9
Parents: bf63116
Author: Shawn Feldman <sf...@apache.org>
Authored: Tue Feb 17 17:10:28 2015 -0800
Committer: Shawn Feldman <sf...@apache.org>
Committed: Tue Feb 17 17:10:28 2015 -0800
----------------------------------------------------------------------
.../index/impl/IndexBatchBufferImpl.java | 21 ++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e16352f6/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexBatchBufferImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexBatchBufferImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexBatchBufferImpl.java
index 08ed17b..380499b 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexBatchBufferImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexBatchBufferImpl.java
@@ -37,7 +37,6 @@ import rx.Subscriber;
import rx.Subscription;
import rx.functions.Action1;
-import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
@@ -62,7 +61,7 @@ public class IndexBatchBufferImpl implements IndexBatchBuffer {
private final Counter indexSizeCounter;
private Producer producer;
private Subscription producerObservable;
- private ArrayBlockingQueue blockingQueue;
+ private BlockingQueue blockingQueue;
@Inject
public IndexBatchBufferImpl(final IndexFig config, final EsProvider provider, MetricsFactory metricsFactory){
@@ -131,13 +130,23 @@ public class IndexBatchBufferImpl implements IndexBatchBuffer {
* Execute the request, check for errors, then re-init the batch for future use
*/
private synchronized void execute(boolean refresh ) {
- try {
+ if(blockingQueue.size()==0){
+ return;
+ }
BulkRequestBuilder bulkRequest = client.prepareBulk();
bulkRequest.setRefresh(refresh);
int count = bufferSize;
+ //clear the queue or proceed to buffersize
while (blockingQueue.size() > 0 && count-- > 0) {
- RequestBuilderContainer container = (RequestBuilderContainer)blockingQueue.take();
+ RequestBuilderContainer container;
+ try{
+ container = (RequestBuilderContainer)blockingQueue.take();
+ }catch (InterruptedException ie){
+ log.error("Problem taking messages off of queue",ie);
+ throw new RuntimeException(ie);
+ }
ShardReplicationOperationRequestBuilder builder = container.getBuilder();
+ //only handle two types of requests for now, annoyingly there is no base class implementation on BulkRequest
if (builder instanceof IndexRequestBuilder) {
bulkRequest.add((IndexRequestBuilder) builder);
}
@@ -168,10 +177,6 @@ public class IndexBatchBufferImpl implements IndexBatchBuffer {
+ response.getFailure().getMessage());
}
}
- }catch (InterruptedException ie){
- log.error("Problem taking messages off of queue",ie);
- throw new RuntimeException(ie);
- }
}
private static class Producer implements Observable.OnSubscribe<RequestBuilderContainer> {