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/06/15 17:56:29 UTC
incubator-usergrid git commit: adding index initialization step
Repository: incubator-usergrid
Updated Branches:
refs/heads/reindex-init-indexes [created] 7a264c4fe
adding index initialization step
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/7a264c4f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/7a264c4f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/7a264c4f
Branch: refs/heads/reindex-init-indexes
Commit: 7a264c4fe9e621e7c539b03a3399f32795e7341a
Parents: 0620c68
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Jun 15 09:56:08 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Jun 15 09:56:08 2015 -0600
----------------------------------------------------------------------
.../index/ReIndexServiceImpl.java | 29 ++++++++++++++------
1 file changed, 21 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/7a264c4f/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/ReIndexServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/ReIndexServiceImpl.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/ReIndexServiceImpl.java
index 957a29f..8275757 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/ReIndexServiceImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/ReIndexServiceImpl.java
@@ -23,6 +23,7 @@ package org.apache.usergrid.corepersistence.index;
import java.util.List;
+import org.apache.usergrid.persistence.index.EntityIndexFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -70,17 +71,24 @@ public class ReIndexServiceImpl implements ReIndexService {
private final AllApplicationsObservable allApplicationsObservable;
+ private final IndexLocationStrategyFactory indexLocationStrategyFactory;
private final AllEntityIdsObservable allEntityIdsObservable;
private final IndexProcessorFig indexProcessorFig;
private final MapManager mapManager;
private final AsyncEventService indexService;
+ private final EntityIndexFactory entityIndexFactory;
@Inject
- public ReIndexServiceImpl( final AllEntityIdsObservable allEntityIdsObservable,
+ public ReIndexServiceImpl( final EntityIndexFactory entityIndexFactory,
+ final IndexLocationStrategyFactory indexLocationStrategyFactory,
+ final AllEntityIdsObservable allEntityIdsObservable,
final MapManagerFactory mapManagerFactory,
final AllApplicationsObservable allApplicationsObservable,
- final IndexProcessorFig indexProcessorFig, final AsyncEventService indexService ) {
+ final IndexProcessorFig indexProcessorFig,
+ final AsyncEventService indexService ) {
+ this.entityIndexFactory = entityIndexFactory;
+ this.indexLocationStrategyFactory = indexLocationStrategyFactory;
this.allEntityIdsObservable = allEntityIdsObservable;
this.allApplicationsObservable = allApplicationsObservable;
this.indexProcessorFig = indexProcessorFig;
@@ -102,7 +110,6 @@ public class ReIndexServiceImpl implements ReIndexService {
final Optional<ApplicationScope> appId = reIndexRequestBuilder.getApplicationScope();
-
Preconditions.checkArgument( !(cursor.isPresent() && appId.isPresent()),
"You cannot specify an app id and a cursor. When resuming with cursor you must omit the appid" );
@@ -208,19 +215,25 @@ public class ReIndexServiceImpl implements ReIndexService {
private Observable<ApplicationScope> getApplications( final Optional<EdgeScope> cursor,
final Optional<ApplicationScope> appId ) {
//cursor is present use it and skip until we hit that app
- if ( cursor.isPresent() ) {
+ if (cursor.isPresent()) {
final EdgeScope cursorValue = cursor.get();
//we have a cursor and an application scope that was used.
return allApplicationsObservable.getData().skipWhile(
- applicationScope -> !cursorValue.getApplicationScope().equals( applicationScope ) );
+ applicationScope -> !cursorValue.getApplicationScope().equals(applicationScope));
}
//this is intentional. If
- else if ( appId.isPresent() ) {
- return Observable.just( appId.get() );
+ else if (appId.isPresent()) {
+ return Observable.just(appId.get());
}
- return allApplicationsObservable.getData();
+ return allApplicationsObservable.getData()
+ .doOnNext(appScope -> {
+ //make sure index is initialized on rebuild
+ entityIndexFactory.createEntityIndex(
+ indexLocationStrategyFactory.getIndexLocationStrategy(appScope)
+ ).initialize();
+ });
}