You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by mr...@apache.org on 2016/04/25 20:23:21 UTC

usergrid git commit: Added fixes around caching and changed the endpoint to selective indexing to be /_index instead of /_indexes

Repository: usergrid
Updated Branches:
  refs/heads/release-2.1.1 70da5a2c0 -> 262269082


Added fixes around caching and changed the endpoint to selective indexing to be /_index instead of /_indexes


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

Branch: refs/heads/release-2.1.1
Commit: 262269082e67d24cd1904efe658b7f92db3f9a25
Parents: 70da5a2
Author: George Reyes <gr...@apache.org>
Authored: Fri Apr 22 14:45:07 2016 -0700
Committer: George Reyes <gr...@apache.org>
Committed: Fri Apr 22 14:45:07 2016 -0700

----------------------------------------------------------------------
 .../index/IndexSchemaCacheFig.java              |  2 +-
 .../index/IndexSchemaCacheImpl.java             |  3 +-
 .../rest/applications/CollectionResource.java   |  8 ++---
 .../collection/CollectionsResourceIT.java       | 38 ++++++++++----------
 4 files changed, 24 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/26226908/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexSchemaCacheFig.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexSchemaCacheFig.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexSchemaCacheFig.java
index 0953abd..a99b48e 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexSchemaCacheFig.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexSchemaCacheFig.java
@@ -33,7 +33,7 @@ public interface IndexSchemaCacheFig extends GuicyFig {
     int getCacheSize();
 
     @Key( "usergrid.index_schema_cache_timeout_ms" )
-    @Default( "60000" )
+    @Default( "15000" )
     int getCacheTimeout();
 
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/26226908/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexSchemaCacheImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexSchemaCacheImpl.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexSchemaCacheImpl.java
index fd0b676..d4bade4 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexSchemaCacheImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexSchemaCacheImpl.java
@@ -19,6 +19,7 @@ package org.apache.usergrid.corepersistence.index;
 
 
 import java.util.Map;
+import java.util.concurrent.TimeUnit;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -49,7 +50,7 @@ public class IndexSchemaCacheImpl implements IndexSchemaCache {
         this.mapManager = mapManager;
         indexSchemaCache = CacheBuilder.newBuilder()
             .maximumSize( indexSchemaCacheFig.getCacheSize() )
-            //.expireAfterWrite( indexSchemaCacheFig.getCacheTimeout(), TimeUnit.MILLISECONDS ) <-- I don't think we want this to expire that quickly.
+            .expireAfterWrite( indexSchemaCacheFig.getCacheTimeout(), TimeUnit.MILLISECONDS )
             .build( new CacheLoader<String, Optional<Map>>() {
                 @Override
                 public Optional<Map> load( final String collectionName ) throws Exception {

http://git-wip-us.apache.org/repos/asf/usergrid/blob/26226908/stack/rest/src/main/java/org/apache/usergrid/rest/applications/CollectionResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/CollectionResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/CollectionResource.java
index 5bd895c..1e94832 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/applications/CollectionResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/applications/CollectionResource.java
@@ -91,7 +91,7 @@ public class CollectionResource extends ServiceResource {
      * @throws Exception
      */
     @POST
-    @Path( "{itemName}/_indexes" )
+    @Path( "{itemName}/_index" )
     @Produces({ MediaType.APPLICATION_JSON,"application/javascript"})
     @RequireApplicationAccess
     @JSONP
@@ -153,7 +153,7 @@ public class CollectionResource extends ServiceResource {
     }
 
     @DELETE
-    @Path( "{itemName}/_indexes" )
+    @Path( "{itemName}/_index" )
     @Produces({ MediaType.APPLICATION_JSON,"application/javascript"})
     @RequireApplicationAccess
     @JSONP
@@ -222,10 +222,6 @@ public class CollectionResource extends ServiceResource {
 
         addItemToServiceContext( ui, itemName );
 
-//        final ReIndexRequestBuilder request =
-//            createRequest().withApplicationId( services.getApplicationId() ).withCollection(
-//                String.valueOf( getServiceParameters().get( 0 ) ) ).withDelay( 50, TimeUnit.MILLISECONDS );
-//
         IndexResource indexResource = new IndexResource(injector);
         return indexResource.rebuildIndexesPost( services.getApplicationId().toString(),itemName.getPath(),false,callback );
     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/26226908/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
index 0e682a7..db07c3f 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
@@ -136,7 +136,7 @@ public class CollectionsResourceIT extends AbstractRestIT {
 
         try {
 
-            this.pathResource( getOrgAppPath( "testcollections/_indexes" ) ).post( false, payload,
+            this.pathResource( getOrgAppPath( "testcollections/_index" ) ).post( false, payload,
                 new QueryParameters().addParam( "grant_type", "client_credentials" ).addParam( "client_id",
                     String.valueOf( ( ( Map ) appCredentials.get( "credentials" ) ).get( "client_id" ) ) )
                                      .addParam( "client_secret", String.valueOf(
@@ -167,7 +167,7 @@ public class CollectionsResourceIT extends AbstractRestIT {
         payload.put( "fields", indexingArray);
 
         //Post index to the collection metadata
-        Entity thing = this.app().collection( "testCollections" ).collection( "_indexes" ).post( payload );
+        Entity thing = this.app().collection( "testCollections" ).collection( "_index" ).post( payload );
         refreshIndex();
 
 
@@ -206,7 +206,7 @@ public class CollectionsResourceIT extends AbstractRestIT {
         //to prove that the entity exists
 
         //next part is to delete the schema then reindex it and it should work.
-        this.app().collection( "testCollections" ).collection( "_indexes" ).delete();
+        this.app().collection( "testCollections" ).collection( "_index" ).delete();
         refreshIndex();
 
         this.app().collection( "testCollections" ).collection( "_reindex" )
@@ -245,7 +245,7 @@ public class CollectionsResourceIT extends AbstractRestIT {
 
         //Post index to the collection metadata
         try {
-            this.app().collection( "testCollections" ).collection( "_indexes" ).post( payload );
+            this.app().collection( "testCollections" ).collection( "_index" ).post( payload );
             fail();
         }catch(BadRequestException bre){
             //this is expected.
@@ -259,7 +259,7 @@ public class CollectionsResourceIT extends AbstractRestIT {
         payload.put( "fields", indexingMap);
 
         try {
-            this.app().collection( "testCollections" ).collection( "_indexes" ).post( payload );
+            this.app().collection( "testCollections" ).collection( "_index" ).post( payload );
             fail();
         }catch(BadRequestException bre){
             //this is expected.
@@ -269,7 +269,7 @@ public class CollectionsResourceIT extends AbstractRestIT {
         payload.put( "fields", indexingArray);
 
         try {
-            this.app().collection( "testCollections" ).collection( "_indexes" ).post( payload );
+            this.app().collection( "testCollections" ).collection( "_index" ).post( payload );
         }catch(BadRequestException bre){
             fail( "This shouldn't fail" );
         }
@@ -292,7 +292,7 @@ public class CollectionsResourceIT extends AbstractRestIT {
         payload.put( "fields", indexingArray);
 
         //Post index to the collection metadata
-        Entity thing = this.app().collection( "testCollection" ).collection( "_indexes" ).post( payload );
+        Entity thing = this.app().collection( "testCollection" ).collection( "_index" ).post( payload );
         refreshIndex();
 
 
@@ -366,7 +366,7 @@ public class CollectionsResourceIT extends AbstractRestIT {
         payload.put( "fields", indexingArray);
 
         //Post index to the collection metadata
-        Entity thing = this.app().collection( "testCollection" ).collection( "_indexes" ).post( payload );
+        Entity thing = this.app().collection( "testCollection" ).collection( "_index" ).post( payload );
         refreshIndex();
 
 
@@ -417,7 +417,7 @@ public class CollectionsResourceIT extends AbstractRestIT {
         payload.put( "fields", indexingArray);
 
         //Post index to the collection metadata
-        Entity thing = this.app().collection( "testCollection" ).collection( "_indexes" ).post( payload );
+        Entity thing = this.app().collection( "testCollection" ).collection( "_index" ).post( payload );
         refreshIndex();
 
         Collection collection = this.app().collection( "testCollection" ).collection( "_index" ).get();
@@ -445,7 +445,7 @@ public class CollectionsResourceIT extends AbstractRestIT {
         payload.put( "fields", indexingArray);
 
         //Post index to the collection metadata
-        this.app().collection( "testCollection" ).collection( "_indexes" ).post( payload );
+        this.app().collection( "testCollection" ).collection( "_index" ).post( payload );
 
         collection = this.app().collection( "testCollection" ).collection( "_index" ).get();
 
@@ -497,7 +497,7 @@ public class CollectionsResourceIT extends AbstractRestIT {
         payload.put( "fields", indexingArray);
 
         //Post index to the collection metadata
-        this.app().collection( "testCollection" ).collection( "_indexes" ).post( payload );
+        this.app().collection( "testCollection" ).collection( "_index" ).post( payload );
         refreshIndex();
 
         //Create test collection with a test entity that is partially indexed.
@@ -539,7 +539,7 @@ public class CollectionsResourceIT extends AbstractRestIT {
         payload.put( "fields", indexingArray);
 
         //Post index to the collection metadata
-        this.app().collection( "testCollection" ).collection( "_indexes" ).post( payload );
+        this.app().collection( "testCollection" ).collection( "_index" ).post( payload );
         refreshIndex();
 
         Map<String,Object> arrayFieldsForTesting = new HashMap<>();
@@ -589,7 +589,7 @@ public class CollectionsResourceIT extends AbstractRestIT {
         payload.put( "fields", indexingArray);
 
         //Post index to the collection metadata
-        this.app().collection( "testCollection" ).collection( "_indexes" ).post( payload );
+        this.app().collection( "testCollection" ).collection( "_index" ).post( payload );
         refreshIndex();
 
         Map<String,Object> arrayFieldsForTesting = new HashMap<>();
@@ -632,7 +632,7 @@ public class CollectionsResourceIT extends AbstractRestIT {
         payload.put( "fields", indexingArray);
 
         //Post index to the collection metadata
-        this.app().collection( "testCollection" ).collection( "_indexes" ).post( payload );
+        this.app().collection( "testCollection" ).collection( "_index" ).post( payload );
         refreshIndex();
 
         Map<String,Object> arrayFieldsForTestingSelectiveIndexing = new HashMap<>();
@@ -687,7 +687,7 @@ public class CollectionsResourceIT extends AbstractRestIT {
         payload.put( "fields", indexingArray);
 
         //Post index to the collection metadata
-        this.app().collection( "testCollection" ).collection( "_indexes" ).post( payload );
+        this.app().collection( "testCollection" ).collection( "_index" ).post( payload );
         refreshIndex();
 
         Map<String,Object> arrayFieldsForTestingSelectiveIndexing = new HashMap<>();
@@ -738,7 +738,7 @@ public class CollectionsResourceIT extends AbstractRestIT {
         payload.put( "fields", indexingArray);
 
         //Post index to the collection metadata
-        this.app().collection( "testCollection" ).collection( "_indexes" ).post( payload );
+        this.app().collection( "testCollection" ).collection( "_index" ).post( payload );
         refreshIndex();
 
         //Create test collection with a test entity that is partially indexed.
@@ -961,7 +961,7 @@ public class CollectionsResourceIT extends AbstractRestIT {
 
         String randomizer = RandomStringUtils.randomAlphanumeric(10);
         String collectionName = "col_" + randomizer;
-        app().collection( collectionName ).collection( "_indexes" ).post( payload );
+        app().collection( collectionName ).collection( "_index" ).post( payload );
         refreshIndex();
 
         // was the no-index wildcard saved and others ignored?
@@ -1009,7 +1009,7 @@ public class CollectionsResourceIT extends AbstractRestIT {
 
         String randomizer = RandomStringUtils.randomAlphanumeric(10);
         String unIndexedCollectionName = "col_" + randomizer;
-        app().collection( unIndexedCollectionName ).collection( "_indexes" ).post( payload );
+        app().collection( unIndexedCollectionName ).collection( "_index" ).post( payload );
         refreshIndex();
 
         String entityName1 = "unindexed1";
@@ -1070,7 +1070,7 @@ public class CollectionsResourceIT extends AbstractRestIT {
         payload.put( "fields", indexingArray);
 
         String unIndexedCollectionName = "col_" + randomizer;
-        app().collection( unIndexedCollectionName ).collection( "_indexes" ).post( payload );
+        app().collection( unIndexedCollectionName ).collection( "_index" ).post( payload );
         refreshIndex();
 
         String entityName1 = "unindexed1";