You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by gr...@apache.org on 2015/05/21 01:00:37 UTC

[07/10] incubator-usergrid git commit: Updates REST api calls. POST is used to create a re-index job, PUT is used to resume.

Updates REST api calls.  POST is used to create a re-index job, PUT is used to resume.

Also fixes transitive dependency issue with clouds


Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/5a7f9c09
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/5a7f9c09
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/5a7f9c09

Branch: refs/heads/two-dot-o-dev
Commit: 5a7f9c096b5d79950b5df658070ae0bd9bdc77da
Parents: 48be894
Author: Todd Nine <tn...@apigee.com>
Authored: Fri May 15 19:24:17 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Fri May 15 19:24:17 2015 -0600

----------------------------------------------------------------------
 .../index/IndexServiceRequestBuilder.java       |  88 -----
 .../index/IndexServiceRequestBuilderImpl.java   | 122 -------
 .../index/ReIndexRequestBuilder.java            |  86 +++++
 .../index/ReIndexRequestBuilderImpl.java        | 122 +++++++
 .../corepersistence/index/ReIndexService.java   |   6 +-
 .../index/ReIndexServiceImpl.java               |  14 +-
 .../PerformanceEntityRebuildIndexTest.java      |   6 +-
 .../persistence/index/impl/IndexingUtils.java   |   2 +
 stack/pom.xml                                   |  13 +
 .../org/apache/usergrid/rest/IndexResource.java | 342 +++++++++----------
 .../main/resources/usergrid-rest-context.xml    |   3 -
 .../resources/usergrid-rest-deploy-context.xml  |   1 -
 12 files changed, 401 insertions(+), 404 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5a7f9c09/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexServiceRequestBuilder.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexServiceRequestBuilder.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexServiceRequestBuilder.java
deleted file mode 100644
index 07160d8..0000000
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexServiceRequestBuilder.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.usergrid.corepersistence.index;
-
-
-import java.util.UUID;
-
-import org.elasticsearch.action.index.IndexRequestBuilder;
-
-import org.apache.usergrid.persistence.core.scope.ApplicationScope;
-
-import com.google.common.base.Optional;
-
-
-/**
- * A builder interface to build our re-index request
- */
-public interface IndexServiceRequestBuilder {
-
-    /**
-     * Set the application id
-     */
-    IndexServiceRequestBuilder withApplicationId( final UUID applicationId );
-
-    /**
-     * Set the collection name.  If not set, every collection will be reindexed
-     * @param collectionName
-     * @return
-     */
-    IndexServiceRequestBuilder withCollection( final String collectionName );
-
-    /**
-     * Set our cursor to resume processing
-     * @param cursor
-     * @return
-     */
-    IndexServiceRequestBuilder withCursor(final String cursor);
-
-
-    /**
-     * Set the timestamp to re-index entities updated >= this timestamp
-     * @param timestamp
-     * @return
-     */
-    IndexServiceRequestBuilder withStartTimestamp(final Long timestamp);
-
-
-    /**
-     * Get the application scope
-     * @return
-     */
-    Optional<ApplicationScope> getApplicationScope();
-
-    /**
-     * Get the collection name
-     * @return
-     */
-    Optional<String> getCollectionName();
-
-    /**
-     * Get the cursor
-     * @return
-     */
-    Optional<String> getCursor();
-
-    /**
-     * Get the updated since timestamp
-     * @return
-     */
-    Optional<Long> getUpdateTimestamp();
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5a7f9c09/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexServiceRequestBuilderImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexServiceRequestBuilderImpl.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexServiceRequestBuilderImpl.java
deleted file mode 100644
index 4017b6e..0000000
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexServiceRequestBuilderImpl.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.usergrid.corepersistence.index;
-
-
-import java.util.UUID;
-
-import org.apache.usergrid.corepersistence.util.CpNamingUtils;
-import org.apache.usergrid.persistence.core.scope.ApplicationScope;
-
-import com.google.common.base.Optional;
-
-
-/**
- * Index service request builder
- */
-public class IndexServiceRequestBuilderImpl implements IndexServiceRequestBuilder {
-
-    private Optional<UUID> withApplicationId = Optional.absent();
-    private Optional<String> withCollectionName = Optional.absent();
-    private Optional<String> cursor = Optional.absent();
-    private Optional<Long> updateTimestamp = Optional.absent();
-
-
-    /***
-     *
-     * @param applicationId The application id
-     * @return
-     */
-    @Override
-    public IndexServiceRequestBuilder withApplicationId( final UUID applicationId ) {
-        this.withApplicationId = Optional.fromNullable( applicationId );
-        return this;
-    }
-
-
-    /**
-     * the colleciton name
-     * @param collectionName
-     * @return
-     */
-    @Override
-    public IndexServiceRequestBuilder withCollection( final String collectionName ) {
-        if(collectionName == null){
-            this.withCollectionName = Optional.absent();
-        }
-        else {
-            this.withCollectionName = Optional.fromNullable( CpNamingUtils.getEdgeTypeFromCollectionName( collectionName ) );
-        }
-        return this;
-    }
-
-
-    /**
-     * The cursor
-     * @param cursor
-     * @return
-     */
-    @Override
-    public IndexServiceRequestBuilder withCursor( final String cursor ) {
-        this.cursor = Optional.fromNullable( cursor );
-        return this;
-    }
-
-
-    /**
-     * Set start timestamp in epoch time.  Only entities updated since this time will be processed for indexing
-     * @param timestamp
-     * @return
-     */
-    @Override
-    public IndexServiceRequestBuilder withStartTimestamp( final Long timestamp ) {
-        this.updateTimestamp = Optional.fromNullable( timestamp );
-        return this;
-    }
-
-
-    @Override
-    public Optional<ApplicationScope> getApplicationScope() {
-
-        if ( this.withApplicationId.isPresent() ) {
-            return Optional.of( CpNamingUtils.getApplicationScope( withApplicationId.get() ) );
-        }
-
-        return Optional.absent();
-    }
-
-
-    @Override
-    public Optional<String> getCollectionName() {
-        return withCollectionName;
-    }
-
-
-    @Override
-    public Optional<String> getCursor() {
-        return cursor;
-    }
-
-
-    @Override
-    public Optional<Long> getUpdateTimestamp() {
-        return updateTimestamp;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5a7f9c09/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/ReIndexRequestBuilder.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/ReIndexRequestBuilder.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/ReIndexRequestBuilder.java
new file mode 100644
index 0000000..0863a63
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/ReIndexRequestBuilder.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.usergrid.corepersistence.index;
+
+
+import java.util.UUID;
+
+import org.apache.usergrid.persistence.core.scope.ApplicationScope;
+
+import com.google.common.base.Optional;
+
+
+/**
+ * A builder interface to build our re-index request
+ */
+public interface ReIndexRequestBuilder {
+
+    /**
+     * Set the application id
+     */
+    ReIndexRequestBuilder withApplicationId( final UUID applicationId );
+
+    /**
+     * Set the collection name.  If not set, every collection will be reindexed
+     * @param collectionName
+     * @return
+     */
+    ReIndexRequestBuilder withCollection( final String collectionName );
+
+    /**
+     * Set our cursor to resume processing
+     * @param cursor
+     * @return
+     */
+    ReIndexRequestBuilder withCursor(final String cursor);
+
+
+    /**
+     * Set the timestamp to re-index entities updated >= this timestamp
+     * @param timestamp
+     * @return
+     */
+    ReIndexRequestBuilder withStartTimestamp(final Long timestamp);
+
+
+    /**
+     * Get the application scope
+     * @return
+     */
+    Optional<ApplicationScope> getApplicationScope();
+
+    /**
+     * Get the collection name
+     * @return
+     */
+    Optional<String> getCollectionName();
+
+    /**
+     * Get the cursor
+     * @return
+     */
+    Optional<String> getCursor();
+
+    /**
+     * Get the updated since timestamp
+     * @return
+     */
+    Optional<Long> getUpdateTimestamp();
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5a7f9c09/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/ReIndexRequestBuilderImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/ReIndexRequestBuilderImpl.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/ReIndexRequestBuilderImpl.java
new file mode 100644
index 0000000..25e71e6
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/ReIndexRequestBuilderImpl.java
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.usergrid.corepersistence.index;
+
+
+import java.util.UUID;
+
+import org.apache.usergrid.corepersistence.util.CpNamingUtils;
+import org.apache.usergrid.persistence.core.scope.ApplicationScope;
+
+import com.google.common.base.Optional;
+
+
+/**
+ * Index service request builder
+ */
+public class ReIndexRequestBuilderImpl implements ReIndexRequestBuilder {
+
+    private Optional<UUID> withApplicationId = Optional.absent();
+    private Optional<String> withCollectionName = Optional.absent();
+    private Optional<String> cursor = Optional.absent();
+    private Optional<Long> updateTimestamp = Optional.absent();
+
+
+    /***
+     *
+     * @param applicationId The application id
+     * @return
+     */
+    @Override
+    public ReIndexRequestBuilder withApplicationId( final UUID applicationId ) {
+        this.withApplicationId = Optional.fromNullable( applicationId );
+        return this;
+    }
+
+
+    /**
+     * the colleciton name
+     * @param collectionName
+     * @return
+     */
+    @Override
+    public ReIndexRequestBuilder withCollection( final String collectionName ) {
+        if(collectionName == null){
+            this.withCollectionName = Optional.absent();
+        }
+        else {
+            this.withCollectionName = Optional.fromNullable( CpNamingUtils.getEdgeTypeFromCollectionName( collectionName ) );
+        }
+        return this;
+    }
+
+
+    /**
+     * The cursor
+     * @param cursor
+     * @return
+     */
+    @Override
+    public ReIndexRequestBuilder withCursor( final String cursor ) {
+        this.cursor = Optional.fromNullable( cursor );
+        return this;
+    }
+
+
+    /**
+     * Set start timestamp in epoch time.  Only entities updated since this time will be processed for indexing
+     * @param timestamp
+     * @return
+     */
+    @Override
+    public ReIndexRequestBuilder withStartTimestamp( final Long timestamp ) {
+        this.updateTimestamp = Optional.fromNullable( timestamp );
+        return this;
+    }
+
+
+    @Override
+    public Optional<ApplicationScope> getApplicationScope() {
+
+        if ( this.withApplicationId.isPresent() ) {
+            return Optional.of( CpNamingUtils.getApplicationScope( withApplicationId.get() ) );
+        }
+
+        return Optional.absent();
+    }
+
+
+    @Override
+    public Optional<String> getCollectionName() {
+        return withCollectionName;
+    }
+
+
+    @Override
+    public Optional<String> getCursor() {
+        return cursor;
+    }
+
+
+    @Override
+    public Optional<Long> getUpdateTimestamp() {
+        return updateTimestamp;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5a7f9c09/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/ReIndexService.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/ReIndexService.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/ReIndexService.java
index af3615e..bae8d1f 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/ReIndexService.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/ReIndexService.java
@@ -29,15 +29,15 @@ public interface ReIndexService {
     /**
      * Perform an index rebuild
      *
-     * @param indexServiceRequestBuilder The builder to build the request
+     * @param reIndexRequestBuilder The builder to build the request
      */
-    ReIndexStatus rebuildIndex( final IndexServiceRequestBuilder indexServiceRequestBuilder );
+    ReIndexStatus rebuildIndex( final ReIndexRequestBuilder reIndexRequestBuilder );
 
 
     /**
      * Generate a build for the index
      */
-    IndexServiceRequestBuilder getBuilder();
+    ReIndexRequestBuilder getBuilder();
 
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5a7f9c09/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 f44113b..ef03866 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
@@ -91,16 +91,16 @@ public class ReIndexServiceImpl implements ReIndexService {
 
 
     @Override
-    public ReIndexStatus rebuildIndex( final IndexServiceRequestBuilder indexServiceRequestBuilder ) {
+    public ReIndexStatus rebuildIndex( final ReIndexRequestBuilder reIndexRequestBuilder ) {
 
         //load our last emitted Scope if a cursor is present
 
-        final Optional<EdgeScope> cursor = parseCursor( indexServiceRequestBuilder.getCursor() );
+        final Optional<EdgeScope> cursor = parseCursor( reIndexRequestBuilder.getCursor() );
 
 
         final CursorSeek<Edge> cursorSeek = getResumeEdge( cursor );
 
-        final Optional<ApplicationScope> appId = indexServiceRequestBuilder.getApplicationScope();
+        final Optional<ApplicationScope> appId = reIndexRequestBuilder.getApplicationScope();
 
 
         Preconditions.checkArgument( !(cursor.isPresent() && appId.isPresent()),
@@ -111,11 +111,11 @@ public class ReIndexServiceImpl implements ReIndexService {
 
         final String jobId = StringUtils.sanitizeUUID( UUIDGenerator.newTimeUUID() );
 
-        final long modifiedSince = indexServiceRequestBuilder.getUpdateTimestamp().or( Long.MIN_VALUE );
+        final long modifiedSince = reIndexRequestBuilder.getUpdateTimestamp().or( Long.MIN_VALUE );
 
         //create an observable that loads each entity and indexes it, start it running with publish
         final Observable<EdgeScope> runningReIndex = allEntityIdsObservable.getEdgesToEntities( applicationScopes,
-            indexServiceRequestBuilder.getCollectionName(), cursorSeek.getSeekValue() )
+            reIndexRequestBuilder.getCollectionName(), cursorSeek.getSeekValue() )
 
             //for each edge, create our scope and index on it
             .doOnNext( edge -> {
@@ -143,8 +143,8 @@ public class ReIndexServiceImpl implements ReIndexService {
 
 
     @Override
-    public IndexServiceRequestBuilder getBuilder() {
-        return new IndexServiceRequestBuilderImpl();
+    public ReIndexRequestBuilder getBuilder() {
+        return new ReIndexRequestBuilderImpl();
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5a7f9c09/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
index 8d54043..06eb060 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
@@ -33,7 +33,7 @@ import org.apache.commons.lang.RandomStringUtils;
 
 import org.apache.usergrid.AbstractCoreIT;
 import org.apache.usergrid.cassandra.SpringResource;
-import org.apache.usergrid.corepersistence.index.IndexServiceRequestBuilder;
+import org.apache.usergrid.corepersistence.index.ReIndexRequestBuilder;
 import org.apache.usergrid.corepersistence.index.ReIndexService;
 import org.apache.usergrid.persistence.core.scope.ApplicationScope;
 import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
@@ -153,7 +153,7 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
         logger.debug( "Preparing to rebuild all indexes" );
 
 
-        final IndexServiceRequestBuilder builder =
+        final ReIndexRequestBuilder builder =
             reIndexService.getBuilder().withApplicationId( em.getApplicationId() ).withCollection( "catherders" );
 
         ReIndexService.ReIndexStatus status = reIndexService.rebuildIndex( builder );
@@ -270,7 +270,7 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
 
         try {
 
-            final IndexServiceRequestBuilder builder =
+            final ReIndexRequestBuilder builder =
                 reIndexService.getBuilder().withApplicationId( em.getApplicationId() );
 
             ReIndexService.ReIndexStatus status = reIndexService.rebuildIndex( builder );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5a7f9c09/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexingUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexingUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexingUtils.java
index 8b248aa..bc15149 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexingUtils.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/IndexingUtils.java
@@ -99,6 +99,8 @@ public class IndexingUtils {
 
     /**
      * Create our sub scope.  This is the ownerUUID + type
+     *
+     * TODO make this format more readable and parsable
      */
     public static String createContextName( final ApplicationScope applicationScope, final SearchEdge scope ) {
         StringBuilder sb = new StringBuilder();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5a7f9c09/stack/pom.xml
----------------------------------------------------------------------
diff --git a/stack/pom.xml b/stack/pom.xml
index 762607d..4559db2 100644
--- a/stack/pom.xml
+++ b/stack/pom.xml
@@ -1241,6 +1241,13 @@
         <groupId>org.apache.jclouds</groupId>
         <artifactId>jclouds-blobstore</artifactId>
         <version>${jclouds.version}</version>
+          <exclusions>
+              <!-- blows up our version of guice-->
+                          <exclusion>
+                              <groupId>com.google.inject.extensions</groupId>
+                              <artifactId>guice-assistedinject</artifactId>
+                          </exclusion>
+          </exclusions>
       </dependency>
 
       <dependency>
@@ -1262,6 +1269,12 @@
             <groupId>aopalliance</groupId>
             <artifactId>aopalliance</artifactId>
           </exclusion>
+
+            <!-- blows up our version of guice-->
+            <exclusion>
+                <groupId>com.google.inject.extensions</groupId>
+                <artifactId>guice-assistedinject</artifactId>
+            </exclusion>
         </exclusions>
       </dependency>
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5a7f9c09/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
index 668c05c..ffb9700 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
@@ -20,25 +20,34 @@
 
 package org.apache.usergrid.rest;
 
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.sun.jersey.api.json.JSONWithPadding;
-import org.apache.usergrid.persistence.EntityManagerFactory;
-import org.apache.usergrid.persistence.EntityRef;
-import org.apache.usergrid.persistence.index.utils.UUIDUtils;
-import org.apache.usergrid.rest.security.annotations.RequireSystemAccess;
+
+import java.util.Map;
+import java.util.UUID;
+
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriInfo;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Component;
 
-import javax.ws.rs.*;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.UriInfo;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
+import org.apache.usergrid.corepersistence.index.ReIndexRequestBuilder;
+import org.apache.usergrid.corepersistence.index.ReIndexService;
+import org.apache.usergrid.persistence.index.utils.UUIDUtils;
+import org.apache.usergrid.rest.security.annotations.RequireSystemAccess;
+
+import com.google.common.base.Preconditions;
+import com.sun.jersey.api.json.JSONWithPadding;
+
 
 /**
  * Classy class class.
@@ -46,260 +55,239 @@ import java.util.UUID;
 @Component
 @Scope( "singleton" )
 @Produces( {
-        MediaType.APPLICATION_JSON, "application/javascript", "application/x-javascript", "text/ecmascript",
-        "application/ecmascript", "text/jscript"
+    MediaType.APPLICATION_JSON, "application/javascript", "application/x-javascript", "text/ecmascript",
+    "application/ecmascript", "text/jscript"
 } )
 public class IndexResource extends AbstractContextResource {
 
-    private static final Logger logger = LoggerFactory.getLogger(IndexResource.class);
+    private static final Logger logger = LoggerFactory.getLogger( IndexResource.class );
+    private static final String UPDATED_FIELD = "updated";
 
-    public IndexResource(){
+
+    public IndexResource() {
         super();
     }
 
+
     @RequireSystemAccess
-    @PUT
+    @POST
     @Path( "rebuild" )
-    public JSONWithPadding rebuildIndexes( @Context UriInfo ui,
-                                           @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
-            throws Exception {
+    public JSONWithPadding rebuildIndexesPost( @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
+        throws Exception {
 
-        ApiResponse response = createApiResponse();
-        response.setAction( "rebuild indexes" );
 
+        logger.info( "Rebuilding all applications" );
 
-        final EntityManagerFactory.ProgressObserver po = new EntityManagerFactory.ProgressObserver() {
+        final ReIndexRequestBuilder request = createRequest();
 
+        return executeAndCreateResponse( request, callback );
+    }
 
-            @Override
-            public void onProgress( final EntityRef entity ) {
-                logger.info( "Indexing entity {}:{} ", entity.getType(), entity.getUuid() );
-            }
 
-        };
+    @RequireSystemAccess
+    @PUT
+    @Path( "rebuild" )
+    public JSONWithPadding rebuildIndexesPut( final Map<String, Object> payload,
+                                              @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
+        throws Exception {
 
 
-        final Thread rebuild = new Thread() {
+        logger.info( "Resuming rebuilding all applications" );
+        final ReIndexRequestBuilder request = createRequest();
 
-            @Override
-            public void run() {
-                logger.info( "Rebuilding all indexes" );
+        return executeResumeAndCreateResponse( payload, request, callback );
+    }
 
-                try {
-                    emf.rebuildAllIndexes( po );
-                }
-                catch ( Exception e ) {
-                    logger.error( "Unable to rebuild indexes", e );
-                }
 
-                logger.info( "Completed all indexes" );
-            }
-        };
+    @RequireSystemAccess
+    @POST
+    @Path( "rebuild/" + RootResource.APPLICATION_ID_PATH )
+    public JSONWithPadding rebuildIndexesPut( @PathParam( "applicationId" ) String applicationIdStr,
+                                              @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback,
+                                              @QueryParam( "delay" ) @DefaultValue( "10" ) final long delay )
 
-        rebuild.setName( "Index rebuild all usergrid" );
-        rebuild.setDaemon( true );
-        rebuild.start();
+        throws Exception {
 
 
-        response.setSuccess();
+        logger.info( "Rebuilding application {}", applicationIdStr );
 
-        return new JSONWithPadding( response, callback );
+
+        final UUID appId = UUIDUtils.tryExtractUUID( applicationIdStr );
+
+        final ReIndexRequestBuilder request = createRequest().withApplicationId( appId );
+
+        return executeAndCreateResponse( request, callback );
     }
 
 
     @RequireSystemAccess
     @PUT
     @Path( "rebuild/" + RootResource.APPLICATION_ID_PATH )
-    public JSONWithPadding rebuildIndexes( @Context UriInfo ui, @PathParam( "applicationId" ) String applicationIdStr,
-                                           @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback,
-                                           @QueryParam( "delay" ) @DefaultValue( "10" ) final long delay )
-
-            throws Exception {
-
-        final UUID appId = UUIDUtils.tryExtractUUID(applicationIdStr);
-        ApiResponse response = createApiResponse();
-        response.setAction( "rebuild indexes started" );
+    public JSONWithPadding rebuildIndexesPut( final Map<String, Object> payload,
+                                              @PathParam( "applicationId" ) String applicationIdStr,
+                                              @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback,
+                                              @QueryParam( "delay" ) @DefaultValue( "10" ) final long delay )
 
-        final EntityManagerFactory.ProgressObserver po = new EntityManagerFactory.ProgressObserver() {
+        throws Exception {
 
-            @Override
-            public void onProgress( final EntityRef entity ) {
-                logger.info( "Indexing entity {}:{}", entity.getType(), entity.getUuid() );
-            }
+        logger.info( "Resuming rebuilding application {}", applicationIdStr );
 
+        final UUID appId = UUIDUtils.tryExtractUUID( applicationIdStr );
 
-        };
-
-
-        final Thread rebuild = new Thread() {
-
-            @Override
-            public void run() {
-
+        final ReIndexRequestBuilder request = createRequest().withApplicationId( appId );
 
-                logger.info( "Started rebuilding application {} in collection ", appId );
+        return executeResumeAndCreateResponse( payload, request, callback );
+    }
 
 
-                try {
-                    emf.rebuildApplicationIndexes( appId, po );
-                }
-                catch ( Exception e ) {
-                    logger.error( "Unable to re-index application", e );
-                }
+    @RequireSystemAccess
+    @POST
+    @Path( "rebuild/" + RootResource.APPLICATION_ID_PATH + "/{collectionName}" )
+    public JSONWithPadding rebuildIndexesPost( @PathParam( "applicationId" ) final String applicationIdStr,
+                                               @PathParam( "collectionName" ) final String collectionName,
+                                               @QueryParam( "reverse" ) @DefaultValue( "false" ) final Boolean reverse,
+                                               @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
+        throws Exception {
 
 
-                logger.info( "Completed rebuilding application {} in collection ", appId );
-            }
-        };
+        logger.info( "Rebuilding collection {} in  application {}", collectionName, applicationIdStr );
 
-        rebuild.setName( String.format( "Index rebuild for app %s", appId ) );
-        rebuild.setDaemon( true );
-        rebuild.start();
+        final UUID appId = UUIDUtils.tryExtractUUID( applicationIdStr );
 
-        response.setSuccess();
+        final ReIndexRequestBuilder request =
+            createRequest().withApplicationId( appId ).withCollection( collectionName );
 
-        return new JSONWithPadding( response, callback );
+        return executeAndCreateResponse( request, callback );
     }
 
 
     @RequireSystemAccess
     @PUT
     @Path( "rebuild/" + RootResource.APPLICATION_ID_PATH + "/{collectionName}" )
-    public JSONWithPadding rebuildIndexes(
-        @Context UriInfo ui,
-        @PathParam( "applicationId" ) final String applicationIdStr,
-        @PathParam( "collectionName" ) final String collectionName,
-        @QueryParam( "reverse" ) @DefaultValue( "false" ) final Boolean reverse,
-        @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback) throws Exception {
+    public JSONWithPadding rebuildIndexesPut( final Map<String, Object> payload,
+                                              @PathParam( "applicationId" ) final String applicationIdStr,
+                                              @PathParam( "collectionName" ) final String collectionName,
+                                              @QueryParam( "reverse" ) @DefaultValue( "false" ) final Boolean reverse,
+                                              @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
+        throws Exception {
 
-        final UUID appId = UUIDUtils.tryExtractUUID( applicationIdStr );
-        ApiResponse response = createApiResponse();
-        response.setAction( "rebuild indexes" );
+        logger.info( "Resuming rebuilding collection {} in  application {}", collectionName, applicationIdStr );
 
-        final Thread rebuild = new Thread() {
+        final UUID appId = UUIDUtils.tryExtractUUID( applicationIdStr );
 
-            public void run() {
+        final ReIndexRequestBuilder request =
+            createRequest().withApplicationId( appId ).withCollection( collectionName );
 
-                logger.info( "Started rebuilding application {} in collection {}", appId, collectionName );
+        return executeResumeAndCreateResponse( payload, request, callback );
+    }
 
-                try {
-                    rebuildCollection( appId, collectionName, reverse );
-                } catch (Exception e) {
 
-                    // TODO: handle this in rebuildCollection() instead
-                    throw new RuntimeException("Error rebuilding collection");
-                }
+    @RequireSystemAccess
+    @POST
+    @Path( "rebuild/management" )
+    public JSONWithPadding rebuildInternalIndexesPost(
+        @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback ) throws Exception {
 
-                logger.info( "Completed rebuilding application {} in collection {}", appId, collectionName );
-            }
-        };
 
-        rebuild.setName( String.format( "Index rebuild for app %s and collection %s", appId, collectionName ) );
-        rebuild.setDaemon( true );
-        rebuild.start();
+        final UUID managementAppId = emf.getManagementAppId();
 
-        response.setSuccess();
+        logger.info( "Rebuilding management application with id {} ", managementAppId );
+        final ReIndexRequestBuilder request = createRequest().withApplicationId( managementAppId );
 
-        return new JSONWithPadding( response, callback );
+        return executeAndCreateResponse( request, callback );
     }
 
+
     @RequireSystemAccess
-    @PUT
-    @Path( "rebuildinternal" )
-    public JSONWithPadding rebuildInternalIndexes(
-        @Context UriInfo ui,
-        @PathParam( "applicationId" ) String applicationIdStr,
-        @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback,
-        @QueryParam( "delay" ) @DefaultValue( "10" ) final long delay )  throws Exception {
+    @POST
+    @Path( "rebuild/management" )
+    public JSONWithPadding rebuildInternalIndexesPut( final Map<String, Object> payload,
+                                                      @QueryParam( "callback" ) @DefaultValue( "callback" )
+                                                      String callback ) throws Exception {
 
 
-        final UUID appId = UUIDUtils.tryExtractUUID(applicationIdStr);
-        ApiResponse response = createApiResponse();
-        response.setAction( "rebuild indexes started" );
+        final UUID managementAppId = emf.getManagementAppId();
 
-        final EntityManagerFactory.ProgressObserver po = new EntityManagerFactory.ProgressObserver() {
+        logger.info( "Resuming rebuilding management application with id {} ", managementAppId );
+        final ReIndexRequestBuilder request = createRequest().withApplicationId( managementAppId );
 
-            @Override
-            public void onProgress( final EntityRef entity ) {
-                logger.info( "Indexing entity {}:{}", entity.getType(), entity.getUuid() );
-            }
+        return executeResumeAndCreateResponse( payload, request, callback );
+    }
 
-        };
 
-        final Thread rebuild = new Thread() {
+    @RequireSystemAccess
+    @POST
+    public JSONWithPadding addIndex( @Context UriInfo ui, Map<String, Object> config,
+                                     @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback )
+        throws Exception {
 
-            @Override
-            public void run() {
+        Preconditions
+            .checkNotNull( config, "Payload for config is null, please pass {replicas:int, shards:int} in body" );
 
-                logger.info( "Started rebuilding internal indexes", appId );
+        ApiResponse response = createApiResponse();
 
-                try {
-                    emf.rebuildInternalIndexes( po );
-                }
-                catch ( Exception e ) {
-                    logger.error( "Unable to re-index internals", e );
-                }
+        if ( !config.containsKey( "replicas" ) || !config.containsKey( "shards" ) ||
+            !( config.get( "replicas" ) instanceof Integer ) || !( config.get( "shards" ) instanceof Integer ) ) {
+            throw new IllegalArgumentException( "body must contains 'replicas' of type int and 'shards' of type int" );
+        }
 
-                logger.info( "Completed rebuilding internal indexes" );
-            }
-        };
+        if ( !config.containsKey( "indexSuffix" ) ) {
+            throw new IllegalArgumentException( "Please add an indexSuffix to your post" );
+        }
 
-        rebuild.setName( String.format( "Index rebuild for app %s", appId ) );
-        rebuild.setDaemon( true );
-        rebuild.start();
 
-        response.setSuccess();
+        emf.addIndex( config.get( "indexSuffix" ).toString(), ( int ) config.get( "shards" ),
+            ( int ) config.get( "replicas" ), ( String ) config.get( "writeConsistency" ) );
+        response.setAction( "Add index to alias" );
 
         return new JSONWithPadding( response, callback );
     }
 
-    @RequireSystemAccess
-    @POST
-    @Path( RootResource.APPLICATION_ID_PATH )
-    public JSONWithPadding addIndex(@Context UriInfo ui,
-            Map<String, Object> config,
-            @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback)  throws Exception{
 
-        Preconditions.checkNotNull(config,"Payload for config is null, please pass {replicas:int, shards:int} in body");
+    private ReIndexService getReIndexService() {
+        return injector.getInstance( ReIndexService.class );
+    }
 
-        ApiResponse response = createApiResponse();
 
-        if (!config.containsKey("replicas") || !config.containsKey("shards") ||
-                !(config.get("replicas") instanceof Integer) || !(config.get("shards") instanceof Integer)){
-            throw new IllegalArgumentException("body must contains 'replicas' of type int and 'shards' of type int");
-        }
+    private ReIndexRequestBuilder createRequest() {
+        return createRequest();
+    }
 
-        if(!config.containsKey("indexSuffix")) {
-            throw new IllegalArgumentException("Please add an indexSuffix to your post");
-        }
 
+    private JSONWithPadding executeResumeAndCreateResponse( final Map<String, Object> payload,
+                                                            final ReIndexRequestBuilder request,
+                                                            final String callback ) {
 
-        emf.addIndex( config.get("indexSuffix").toString(),
-            (int) config.get("shards"),(int) config.get("replicas"),(String)config.get("writeConsistency"));
-        response.setAction("Add index to alias");
+        Preconditions.checkArgument( payload.containsKey( UPDATED_FIELD ),
+            "You must specified the field \"updated\" in the payload" );
 
-        return new JSONWithPadding(response, callback);
+        //add our updated timestamp to the request
+        if ( !payload.containsKey( UPDATED_FIELD ) ) {
+            final long timestamp = ( long ) payload.get( UPDATED_FIELD );
+            request.withStartTimestamp( timestamp );
+        }
 
+        return executeAndCreateResponse( request, callback );
     }
 
-    private void rebuildCollection(
-        final UUID applicationId,
-        final String collectionName,
-        final boolean reverse) throws Exception {
 
-        EntityManagerFactory.ProgressObserver po = new EntityManagerFactory.ProgressObserver() {
+    /**
+     * Execute the request and return the response.
+     */
+    private JSONWithPadding executeAndCreateResponse( final ReIndexRequestBuilder request, final String callback ) {
 
-            @Override
-            public void onProgress( final EntityRef entity ) {
-                logger.info( "Indexing entity {}:{}", entity.getType(), entity.getUuid() );
-            }
 
-        };
+        final ReIndexService.ReIndexStatus status = getReIndexService().rebuildIndex( request );
 
-        logger.info( "Reindexing for app id: {} and collection {}", applicationId, collectionName );
+        final ApiResponse response = createApiResponse();
 
-        emf.rebuildCollectionIndex(Optional.of(applicationId),Optional.of(collectionName));
-        getEntityIndex().refreshAsync().toBlocking().first();
-    }
+        response.setAction( "rebuild indexes" );
+        response.setProperty( "jobId", status.getJobId() );
+        response.setProperty( "status", status.getStatus() );
+        response.setProperty( "lastUpdatedEpoch", status.getLastUpdated() );
+        response.setProperty( "numberQueued", status.getNumberProcessed() );
+        response.setSuccess();
 
+        return new JSONWithPadding( response, callback );
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5a7f9c09/stack/rest/src/main/resources/usergrid-rest-context.xml
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/resources/usergrid-rest-context.xml b/stack/rest/src/main/resources/usergrid-rest-context.xml
index 5c63e72..16f4541 100644
--- a/stack/rest/src/main/resources/usergrid-rest-context.xml
+++ b/stack/rest/src/main/resources/usergrid-rest-context.xml
@@ -47,9 +47,6 @@
 		<property name="securityManager" ref="securityManager" />
 	</bean>
 
-	<bean id="mongoServer" class="org.apache.usergrid.mongo.MongoServer"
-		init-method="startServer" destroy-method="stopServer" />
-
 	<!-- override the security manager -->
 	<bean id="securityManager" class="org.apache.usergrid.rest.security.shiro.RestSecurityManager">
 		<property name="cacheManager" ref="cacheManager" />

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5a7f9c09/stack/rest/src/main/resources/usergrid-rest-deploy-context.xml
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/resources/usergrid-rest-deploy-context.xml b/stack/rest/src/main/resources/usergrid-rest-deploy-context.xml
index 9965dbc..e9b7ccd 100644
--- a/stack/rest/src/main/resources/usergrid-rest-deploy-context.xml
+++ b/stack/rest/src/main/resources/usergrid-rest-deploy-context.xml
@@ -33,7 +33,6 @@
 		<property name="locations">
 			<list>
 				<value>classpath:/usergrid-default.properties</value>
-                <value>${usergrid-custom-spring-properties}</value>
 			</list>
 		</property>
 	</bean>