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/25 17:36:18 UTC
incubator-usergrid git commit: Add futures to batch and refresh
Repository: incubator-usergrid
Updated Branches:
refs/heads/USERGRID-273-indexbuffer ac55e0878 -> afd22ebf9
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-273-indexbuffer
Commit: afd22ebf9fc2095b4f6835d2665cf8b97f10676b
Parents: ac55e08
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Feb 25 09:36:17 2015 -0700
Committer: Shawn Feldman <sf...@apache.org>
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" );