Return-Path: X-Original-To: apmail-usergrid-commits-archive@minotaur.apache.org Delivered-To: apmail-usergrid-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E9EEB10947 for ; Tue, 3 Mar 2015 20:00:57 +0000 (UTC) Received: (qmail 45679 invoked by uid 500); 3 Mar 2015 20:00:42 -0000 Delivered-To: apmail-usergrid-commits-archive@usergrid.apache.org Received: (qmail 45626 invoked by uid 500); 3 Mar 2015 20:00:42 -0000 Mailing-List: contact commits-help@usergrid.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@usergrid.incubator.apache.org Delivered-To: mailing list commits@usergrid.incubator.apache.org Received: (qmail 45028 invoked by uid 99); 3 Mar 2015 20:00:41 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Mar 2015 20:00:41 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 22AA4E104E; Tue, 3 Mar 2015 20:00:41 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: grey@apache.org To: commits@usergrid.apache.org Date: Tue, 03 Mar 2015 20:00:59 -0000 Message-Id: <826556e82ba941a0b9caad006ddff00e@git.apache.org> In-Reply-To: <31613d817b9b4e14abf7adb913ddece6@git.apache.org> References: <31613d817b9b4e14abf7adb913ddece6@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [20/37] incubator-usergrid git commit: Add futures to batch and refresh Add futures to batch and refresh Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/afd22ebf Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/afd22ebf Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/afd22ebf Branch: refs/heads/USERGRID-422 Commit: afd22ebf9fc2095b4f6835d2665cf8b97f10676b Parents: ac55e08 Author: Shawn Feldman Authored: Wed Feb 25 09:36:17 2015 -0700 Committer: Shawn Feldman Committed: Wed Feb 25 09:36:17 2015 -0700 ---------------------------------------------------------------------- .../persistence/index/EntityIndexBatch.java | 2 +- .../index/impl/EsEntityIndexBatchImpl.java | 8 +++----- .../persistence/index/impl/EntityIndexTest.java | 20 ++++++++++---------- 3 files changed, 14 insertions(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/afd22ebf/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndexBatch.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndexBatch.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndexBatch.java index f3f9100..a02d0da 100644 --- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndexBatch.java +++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndexBatch.java @@ -70,5 +70,5 @@ public interface EntityIndexBatch { /** * Execute the batch and force the refresh */ - public void executeAndRefresh(); + public BetterFuture executeAndRefresh(); } http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/afd22ebf/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java index 4fcdeb3..c0ddfdc 100644 --- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java +++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java @@ -215,17 +215,15 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch { public BetterFuture execute() { RequestBuilderContainer tempContainer = container; container = new RequestBuilderContainer(); - BetterFuture future = indexBatchBuffer.put(tempContainer); - return future; + return indexBatchBuffer.put(tempContainer); } @Override - public void executeAndRefresh() { + public BetterFuture executeAndRefresh() { container.setForceRefresh(true); RequestBuilderContainer tempContainer = container; container = new RequestBuilderContainer(); - BetterFuture future = indexBatchBuffer.put(tempContainer); - future.get(); + return indexBatchBuffer.put(tempContainer); } /** http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/afd22ebf/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java index e3eeaf4..e820ce1 100644 --- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java +++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java @@ -203,7 +203,7 @@ public class EntityIndexTest extends BaseIT { EntityIndexBatch entityIndexBatch = entityIndex.createBatch(); entityIndexBatch.deindex(indexScope, crs.get(0)); entityIndexBatch.deindex(indexScope, crs.get(1)); - entityIndexBatch.executeAndRefresh(); + entityIndexBatch.executeAndRefresh().get(); entityIndex.refresh(); //Hilda Youn @@ -239,14 +239,14 @@ public class EntityIndexTest extends BaseIT { batch.index(indexScope, entity); if(count %1000 == 0){ - batch.execute(); + batch.execute().get(); } if ( ++count > max ) { break; } } - batch.executeAndRefresh(); + batch.executeAndRefresh().get(); timer.stop(); log.info( "Total time to index {} entries {}ms, average {}ms/entry", new Object[] { count, timer.getTime(), timer.getTime() / count } ); @@ -277,15 +277,15 @@ public class EntityIndexTest extends BaseIT { EntityUtils.setVersion( entity, UUIDGenerator.newTimeUUID() ); entity.setField(new UUIDField(IndexingUtils.ENTITYID_ID_FIELDNAME, UUID.randomUUID())); - entityIndex.createBatch().index(indexScope , entity ).executeAndRefresh(); + entityIndex.createBatch().index(indexScope , entity ).executeAndRefresh().get(); CandidateResults candidateResults = entityIndex.search( indexScope, SearchTypes.fromTypes(entity.getId().getType()), Query.fromQL( "name contains 'Ferrari*'" ) ); assertEquals( 1, candidateResults.size() ); EntityIndexBatch batch = entityIndex.createBatch(); - batch.deindex(indexScope, entity).execute(); - batch.executeAndRefresh(); + batch.deindex(indexScope, entity).execute().get(); + batch.executeAndRefresh().get(); entityIndex.refresh(); candidateResults = entityIndex.search( indexScope, SearchTypes.fromTypes(entity.getId().getType()), Query.fromQL( "name contains 'Ferrari*'" ) ); @@ -429,7 +429,7 @@ public class EntityIndexTest extends BaseIT { batch.index( indexScope, user ); user.setField( new StringField( "address3", "apt 508" ) ); batch.index( indexScope, user ); - batch.executeAndRefresh(); + batch.executeAndRefresh().get(); CandidateResults results = entityIndex.getEntityVersions(indexScope, user.getId() ); @@ -468,7 +468,7 @@ public class EntityIndexTest extends BaseIT { EntityIndexBatch batch = ei.createBatch(); batch.index( appScope, user ); - batch.executeAndRefresh(); + batch.executeAndRefresh().get(); Query query = new Query(); query.addEqualityFilter( "username", "edanuff" ); @@ -476,7 +476,7 @@ public class EntityIndexTest extends BaseIT { assertEquals( user.getId(), r.get( 0 ).getId() ); batch.deindex(appScope, user.getId(), user.getVersion() ); - batch.executeAndRefresh(); + batch.executeAndRefresh().get(); // EntityRef query = new Query(); @@ -536,7 +536,7 @@ public class EntityIndexTest extends BaseIT { EntityUtils.setVersion( fred, UUIDGenerator.newTimeUUID() ); batch.index( appScope, fred ); - batch.executeAndRefresh(); + batch.executeAndRefresh().get(); final SearchTypes searchTypes = SearchTypes.fromTypes( "user" );