You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2016/06/07 15:27:15 UTC
[1/8] usergrid git commit: Better Shiro cache key logic
Repository: usergrid
Updated Branches:
refs/heads/usergrid-1268-akka-211 bc857e3e6 -> 324ef35c9
Better Shiro cache key logic
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/e2ebc468
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/e2ebc468
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/e2ebc468
Branch: refs/heads/usergrid-1268-akka-211
Commit: e2ebc468b2e72cb9cec98bd8f91ee07d507d1c59
Parents: 7fdca3d
Author: Dave Johnson <sn...@apache.org>
Authored: Thu May 19 22:39:05 2016 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Thu May 19 22:39:05 2016 -0400
----------------------------------------------------------------------
.../usergrid/security/shiro/ShiroCache.java | 22 ++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/e2ebc468/stack/services/src/main/java/org/apache/usergrid/security/shiro/ShiroCache.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/security/shiro/ShiroCache.java b/stack/services/src/main/java/org/apache/usergrid/security/shiro/ShiroCache.java
index 88466bf..e14442c 100644
--- a/stack/services/src/main/java/org/apache/usergrid/security/shiro/ShiroCache.java
+++ b/stack/services/src/main/java/org/apache/usergrid/security/shiro/ShiroCache.java
@@ -182,16 +182,34 @@ public class ShiroCache<K, V> implements Cache<K,V> {
/** key is the user UUID in string form + class name of key */
private String getKeyString( K key ) {
+ // both authc and authz caches use same column family
+ // make sure keys unique to key type
+ String keyClass = key.getClass().getSimpleName();
+
+ // if we can't get a user UUID or access token, then we have a guest
+ String ret = keyClass + "_guest";
+
if ( key instanceof SimplePrincipalCollection) {
SimplePrincipalCollection spc = (SimplePrincipalCollection)key;
+ // principal is a user, use UUID as cache key
if ( spc.getPrimaryPrincipal() instanceof UserPrincipal) {
UserPrincipal p = (UserPrincipal) spc.getPrimaryPrincipal();
- return p.getUser().getUuid().toString();
+ ret = p.getUser().getUuid().toString() + "_" + keyClass;
+ }
+
+ else if ( spc.getPrimaryPrincipal() instanceof PrincipalIdentifier ) {
+ PrincipalIdentifier p = (PrincipalIdentifier)spc.getPrimaryPrincipal();
+
+ // principal is not user, try to get something unique as cache key
+ if ( p.getAccessTokenCredentials() != null ) {
+ ret = p.getAccessTokenCredentials().getToken() + "_" + keyClass;
+
+ }
}
}
- return key.toString() + "_" + key.getClass().getSimpleName();
+ return ret;
}
}
[2/8] usergrid git commit: Account for every type of principal
Posted by sn...@apache.org.
Account for every type of principal
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/5107ccf5
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/5107ccf5
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/5107ccf5
Branch: refs/heads/usergrid-1268-akka-211
Commit: 5107ccf592346cbd0afb65b6a83985bd062ce2dc
Parents: e2ebc46
Author: Dave Johnson <sn...@apache.org>
Authored: Fri May 20 10:07:11 2016 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Fri May 20 10:07:11 2016 -0400
----------------------------------------------------------------------
.../usergrid/security/shiro/ShiroCache.java | 44 +++++++++++++++-----
1 file changed, 33 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/5107ccf5/stack/services/src/main/java/org/apache/usergrid/security/shiro/ShiroCache.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/security/shiro/ShiroCache.java b/stack/services/src/main/java/org/apache/usergrid/security/shiro/ShiroCache.java
index e14442c..b4803b1 100644
--- a/stack/services/src/main/java/org/apache/usergrid/security/shiro/ShiroCache.java
+++ b/stack/services/src/main/java/org/apache/usergrid/security/shiro/ShiroCache.java
@@ -182,31 +182,53 @@ public class ShiroCache<K, V> implements Cache<K,V> {
/** key is the user UUID in string form + class name of key */
private String getKeyString( K key ) {
- // both authc and authz caches use same column family
- // make sure keys unique to key type
- String keyClass = key.getClass().getSimpleName();
+ String ret = null;
- // if we can't get a user UUID or access token, then we have a guest
- String ret = keyClass + "_guest";
+ final String typeName = typeRef.getType().getTypeName();
if ( key instanceof SimplePrincipalCollection) {
+
SimplePrincipalCollection spc = (SimplePrincipalCollection)key;
- // principal is a user, use UUID as cache key
if ( spc.getPrimaryPrincipal() instanceof UserPrincipal) {
+
+ // principal is a user, use UUID as cache key
UserPrincipal p = (UserPrincipal) spc.getPrimaryPrincipal();
- ret = p.getUser().getUuid().toString() + "_" + keyClass;
+ ret = p.getUser().getUuid().toString() + "_" + typeName;
}
else if ( spc.getPrimaryPrincipal() instanceof PrincipalIdentifier ) {
- PrincipalIdentifier p = (PrincipalIdentifier)spc.getPrimaryPrincipal();
// principal is not user, try to get something unique as cache key
- if ( p.getAccessTokenCredentials() != null ) {
- ret = p.getAccessTokenCredentials().getToken() + "_" + keyClass;
-
+ PrincipalIdentifier p = (PrincipalIdentifier) spc.getPrimaryPrincipal();
+ if (p.getAccessTokenCredentials() != null) {
+ ret = p.getAccessTokenCredentials().getToken() + "_" + typeName;
+ } else {
+ ret = p.getApplicationId() + "_" + typeName;
}
}
+
+ } else if ( key instanceof ApplicationGuestPrincipal ) {
+ ApplicationGuestPrincipal agp = (ApplicationGuestPrincipal) key;
+ ret = agp.getApplicationId() + "_" + typeName;
+
+ } else if ( key instanceof ApplicationPrincipal ) {
+ ApplicationPrincipal ap = (ApplicationPrincipal) key;
+ ret = ap.getApplicationId() + "_" + typeName;
+
+ } else if ( key instanceof OrganizationPrincipal ) {
+ OrganizationPrincipal op = (OrganizationPrincipal) key;
+ ret = op.getOrganizationId() + "_" + typeName;
+
+ } else if ( key instanceof UserPrincipal ) {
+ UserPrincipal up = (UserPrincipal)key;
+ ret = up.getUser().getUuid() + "_" + typeName;
+ }
+
+ if ( ret == null) {
+ String msg = "Unknown key type: " + key.getClass().getSimpleName();
+ logger.error(msg);
+ throw new RuntimeException(msg);
}
return ret;
[4/8] usergrid git commit: Merge branch 'release-2.1.1' of
https://git-wip-us.apache.org/repos/asf/usergrid into release-2.1.1
Posted by sn...@apache.org.
Merge branch 'release-2.1.1' of https://git-wip-us.apache.org/repos/asf/usergrid into release-2.1.1
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/aae8fdf8
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/aae8fdf8
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/aae8fdf8
Branch: refs/heads/usergrid-1268-akka-211
Commit: aae8fdf817c59a57ef875ab5f8aa9e7a47a945ab
Parents: ebcc772 5107ccf
Author: Dave Johnson <sn...@apache.org>
Authored: Fri May 20 12:02:02 2016 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Fri May 20 12:02:02 2016 -0400
----------------------------------------------------------------------
.../usergrid/security/shiro/ShiroCache.java | 44 +++++++++++++++++++-
1 file changed, 42 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
[7/8] usergrid git commit: Merge branch 'release-2.1.1' into
usergrid-1268-akka-211
Posted by sn...@apache.org.
Merge branch 'release-2.1.1' into usergrid-1268-akka-211
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/6fadf80b
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/6fadf80b
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/6fadf80b
Branch: refs/heads/usergrid-1268-akka-211
Commit: 6fadf80bcdd71e4bc894b43bf4d19659a89f4bf6
Parents: bc857e3 0970e1d
Author: Dave Johnson <sn...@apache.org>
Authored: Fri May 27 14:08:51 2016 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Fri May 27 14:08:51 2016 -0400
----------------------------------------------------------------------
.../main/resources/usergrid-default.properties | 5 --
.../applications/ApplicationResourceIT.java | 5 +-
.../usergrid/security/shiro/ShiroCache.java | 44 +++++++++++++-
.../usergrid/services/ServiceManager.java | 61 +++-----------------
4 files changed, 52 insertions(+), 63 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/6fadf80b/stack/config/src/main/resources/usergrid-default.properties
----------------------------------------------------------------------
[6/8] usergrid git commit: Revert "Service manager's init() method
now retries if unable to get application."
Posted by sn...@apache.org.
Revert "Service manager's init() method now retries if unable to get application."
This reverts commit 223521e4150e520c92560bbea873b6a024e18a0e.
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/0970e1df
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/0970e1df
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/0970e1df
Branch: refs/heads/usergrid-1268-akka-211
Commit: 0970e1dfa1b7f54204b6ad82e4bf01da84b38618
Parents: b03f6a9
Author: Dave Johnson <sn...@apache.org>
Authored: Tue May 24 14:36:44 2016 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Tue May 24 14:36:44 2016 -0400
----------------------------------------------------------------------
.../main/resources/usergrid-default.properties | 5 --
.../usergrid/services/ServiceManager.java | 52 +++-----------------
2 files changed, 8 insertions(+), 49 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/0970e1df/stack/config/src/main/resources/usergrid-default.properties
----------------------------------------------------------------------
diff --git a/stack/config/src/main/resources/usergrid-default.properties b/stack/config/src/main/resources/usergrid-default.properties
index 35e12ae..4f57cdd 100644
--- a/stack/config/src/main/resources/usergrid-default.properties
+++ b/stack/config/src/main/resources/usergrid-default.properties
@@ -628,11 +628,6 @@ usergrid.auth.cache.inmemory.size=3000
# all (= in + out)'
usergrid.rest.default-connection-param=all
-# In a busy cluster the Service Manager's init() may fail (usually a time-out) on the first
-# attempt to communicate with Cassandra or ElasticSearch so we retry on failure, using an
-# interval that is longer than the default (10s) Cassandra connection time-out.
-service.manager.retry.interval=15000
-service.manager.max.retries=5
############################## Usergrid Testing #############################
http://git-wip-us.apache.org/repos/asf/usergrid/blob/0970e1df/stack/services/src/main/java/org/apache/usergrid/services/ServiceManager.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/ServiceManager.java b/stack/services/src/main/java/org/apache/usergrid/services/ServiceManager.java
index 1ed73d6..a9892f5 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/ServiceManager.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/ServiceManager.java
@@ -50,6 +50,7 @@ import static org.apache.usergrid.utils.InflectionUtils.pluralize;
public class ServiceManager {
+
private static final Logger logger = LoggerFactory.getLogger( ServiceManager.class );
/** A pointer that signals we couldn't find a class */
@@ -68,10 +69,6 @@ public class ServiceManager {
public static final String APPLICATION_REQUESTS_PER = APPLICATION_REQUESTS + ".";
public static final String IMPL = "Impl";
- public static final String SERVICE_MANAGER_RETRY_INTERVAL = "service.manager.retry.interval";
-
- public static final String SERVICE_MANAGER_MAX_RETRIES= "service.manager.max.retries";
-
private Application application;
private UUID applicationId;
@@ -99,60 +96,27 @@ public class ServiceManager {
this.qm = qm;
this.properties = properties;
- Integer retryInterval;
- try {
- Object retryIntervalObject = properties.get( SERVICE_MANAGER_RETRY_INTERVAL ).toString();
- retryInterval = Integer.parseInt( retryIntervalObject.toString() );
- } catch ( NumberFormatException nfe ) {
- retryInterval = 15000;
- }
-
- Integer maxRetries;
- try {
- Object maxRetriesObject = properties.get( SERVICE_MANAGER_MAX_RETRIES ).toString();
- maxRetries = Integer.parseInt( maxRetriesObject.toString() );
- } catch ( NumberFormatException nfe ) {
- maxRetries = 5;
- }
-
if ( em != null ) {
-
try {
- int retryCount = 0;
- boolean appNotFound = true;
-
- while ( appNotFound && retryCount <= maxRetries ) {
-
- application = em.getApplication();
-
- if ( application != null ) {
- appNotFound = false;
- applicationId = application.getUuid();
- } else {
- Thread.sleep( retryInterval );
- retryCount++;
- }
- }
-
- if ( application == null ) {
- Exception e = new RuntimeException( "application id {" + em.getApplicationId() + "} is returning null" );
- logger.error( "Failed to get application", e );
+ application = em.getApplication();
+ if(application == null){
+ Exception e = new RuntimeException("application id {"+em.getApplicationId()+"} is returning null");
+ logger.error("Failed to get application",e);
throw e;
}
-
- } catch ( Exception e ) {
+ applicationId = application.getUuid();
+ }
+ catch ( Exception e ) {
logger.error( "ServiceManager init failure", e );
throw new RuntimeException( e );
}
}
-
if ( properties != null ) {
String packages = properties.getProperty( SERVICE_PACKAGE_PREFIXES );
if ( !StringUtils.isEmpty( packages ) ) {
setServicePackagePrefixes( packages );
}
}
-
return this;
}
[5/8] usergrid git commit: Revert "Adding distinctive logging,
also: no longer wrap RuntimeException in RuntimeException"
Posted by sn...@apache.org.
Revert "Adding distinctive logging, also: no longer wrap RuntimeException in RuntimeException"
This reverts commit 6b195a07b94858deecdc80156d9ab9ebd6ae4a80.
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/b03f6a9e
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/b03f6a9e
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/b03f6a9e
Branch: refs/heads/usergrid-1268-akka-211
Commit: b03f6a9eaee9cd529ff8ca781030415798f32e7d
Parents: aae8fdf
Author: Dave Johnson <sn...@apache.org>
Authored: Tue May 24 14:36:29 2016 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Tue May 24 14:36:29 2016 -0400
----------------------------------------------------------------------
.../org/apache/usergrid/services/ServiceManager.java | 13 ++-----------
1 file changed, 2 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/b03f6a9e/stack/services/src/main/java/org/apache/usergrid/services/ServiceManager.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/ServiceManager.java b/stack/services/src/main/java/org/apache/usergrid/services/ServiceManager.java
index ef1baaf..1ed73d6 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/ServiceManager.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/ServiceManager.java
@@ -128,27 +128,18 @@ public class ServiceManager {
if ( application != null ) {
appNotFound = false;
applicationId = application.getUuid();
-
} else {
- // Cassandra may be alive but responding very slowly, let's wait and retry
- logger.error("STARTUP PROBLEM: Cannot get application by UUID. Will retry in {} seconds #{}",
- retryInterval/1000, retryCount);
Thread.sleep( retryInterval );
retryCount++;
}
}
if ( application == null ) {
- Exception e = new RuntimeException(
- "STARTUP FAILURE: application id {" + em.getApplicationId()
- + "} is returning null after " + retryCount + " retries" );
+ Exception e = new RuntimeException( "application id {" + em.getApplicationId() + "} is returning null" );
+ logger.error( "Failed to get application", e );
throw e;
}
- } catch ( RuntimeException re ) {
- logger.error( "ServiceManager init failure", re );
- throw re;
-
} catch ( Exception e ) {
logger.error( "ServiceManager init failure", e );
throw new RuntimeException( e );
[3/8] usergrid git commit: Now that ShiroCache is working well,
this test is not thread-safe.
Posted by sn...@apache.org.
Now that ShiroCache is working well, this test is not thread-safe.
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/ebcc772f
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/ebcc772f
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/ebcc772f
Branch: refs/heads/usergrid-1268-akka-211
Commit: ebcc772f99d8a85bd20ebd53ebbf49f900a79ce8
Parents: 7fdca3d
Author: Dave Johnson <sn...@apache.org>
Authored: Fri May 20 12:01:28 2016 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Fri May 20 12:01:28 2016 -0400
----------------------------------------------------------------------
.../usergrid/rest/applications/ApplicationResourceIT.java | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/ebcc772f/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
index 2dd5090..06615df 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/ApplicationResourceIT.java
@@ -16,19 +16,17 @@
*/
package org.apache.usergrid.rest.applications;
-import com.fasterxml.jackson.databind.JsonNode;
import junit.framework.Assert;
+import net.jcip.annotations.NotThreadSafe;
import org.apache.commons.lang.RandomStringUtils;
import org.apache.shiro.codec.Base64;
import org.apache.usergrid.cassandra.SpringResource;
import org.apache.usergrid.management.ManagementService;
import org.apache.usergrid.rest.test.resource.AbstractRestIT;
-import org.apache.usergrid.rest.test.resource.endpoints.mgmt.OrganizationResource;
import org.apache.usergrid.rest.test.resource.model.*;
import org.apache.usergrid.setup.ConcurrentProcessSingleton;
import org.apache.usergrid.utils.MapUtils;
import org.glassfish.jersey.client.ClientProperties;
-import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -52,6 +50,7 @@ import static org.junit.Assert.*;
/**
* Invokes methods on ApplicationResource
*/
+@NotThreadSafe
public class ApplicationResourceIT extends AbstractRestIT {
private static final Logger logger = LoggerFactory.getLogger(ApplicationResourceIT.class);
[8/8] usergrid git commit: Add docs for Collection Settings &
Selective Indexing.
Posted by sn...@apache.org.
Add docs for Collection Settings & Selective Indexing.
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/324ef35c
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/324ef35c
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/324ef35c
Branch: refs/heads/usergrid-1268-akka-211
Commit: 324ef35c9087d9557f6b9da4217ee9e8311b0c84
Parents: 6fadf80
Author: Dave Johnson <sn...@apache.org>
Authored: Tue Jun 7 11:27:03 2016 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Tue Jun 7 11:27:03 2016 -0400
----------------------------------------------------------------------
docs/data-storage/collections.md | 144 ++++++++++++++++++++++++++++++++++
1 file changed, 144 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/324ef35c/docs/data-storage/collections.md
----------------------------------------------------------------------
diff --git a/docs/data-storage/collections.md b/docs/data-storage/collections.md
index fa8652e..88ffc55 100644
--- a/docs/data-storage/collections.md
+++ b/docs/data-storage/collections.md
@@ -44,7 +44,150 @@ Response:
"organization" : "your-org",
"applicationName" : "your-app"
}
+
+
+## Collection Settings
+
+Usergrid allows you to specify settings for each of your Collections.
+Collections may have a *_settings* resource with the following URI pattern:
+
+ /{org-identifier}/{app-identifier}/{collection-name}/_settings
+
+If a Collection does not have a _settings resource,
+then doing an HTTP GET on that URI will yield the normal Collection resource.
+For example here a request and respinse for settings for the Collection "battles", which does not yet have _settigs:
+
+ curl "https//api.usergrid.com/test-organization/settingstest/battles/_settings?access_token=YWM..."
+ {
+ "action" : "get",
+ "application" : "7fd6c414-2cb6-11e6-8b07-0a669fe1d66e",
+ "params" : { },
+ "path" : "/battles",
+ "uri" : "https//api.usergrid.com/test-organization/settingstest/battles",
+ "entities" : [ ],
+ "timestamp" : 1465308535753,
+ "duration" : 175,
+ "organization" : "test-organization",
+ "applicationName" : "settingstest"
+ }
+
+Once a Collection has a _settings resource, here's what it might look like:
+
+ curl "0:8080/test-organization/settingstest/battles/_settings?access_token=YWM..."
+ {
+ "action" : "get",
+ "application" : "7fd6c414-2cb6-11e6-8b07-0a669fe1d66e",
+ "params" : { },
+ "path" : "/battles",
+ "uri" : "https//api.usergrid.com/test-organization/settingstest/battles",
+ "entities" : [ ],
+ "data" : {
+ "lastUpdated" : 1465311161543,
+ "lastReindexed" : 0,
+ "fields" : "all",
+ "region" : "us-east-1",
+ "lastUpdateBy" : "super@usergrid.com"
+ },
+ "timestamp" : 1465311177535,
+ "duration" : 6,
+ "organization" : "test-organization",
+ "applicationName" : "settingstest"
+ }
+
+
+Collection settings are useful for setting up Selective Indexing. Let's discuss that next.
+
+## Setting up Selective Indexing via Collection Settings
+
+Indexing is expensive and now it can be done selectively.
+
+In the beginning, Usergrid indexed each and every field of an Entity.
+If a field was an object, the the fields of that object would also be indexed.
+Indexing everything is very convenient because it means you can query on any field,
+but indexing everything is expensive in terms of performance;
+it slows down Entity creation and update.
+Indexing everything is also expensive in terms of storage,
+it takes up space and makes puts strain on the system.
+
+Staring with Usegrid 2.1.1, you can specify a "schema" for each Collection.
+You can tell Usergrid which fields should be indexed or
+you can tell Usergrid to completely skip indexing for a collection.
+
+### Specifying a Schema for a Collection
+
+There are three ways to specify a schema for a Collection.
+You can specify that all fields are to be index, you can specify none or
+you can specify a list of the fields that should be indexed.
+You do this by POSTing or PUTing a _settings resource for the Collection with one field named "fields".
+
+There are three possible values for "fields":
+
+Fields Setting Type Meaning
+-------------- ---- -------
+"fields":"all" String Index all Entity fields
+"fields":"none" String Index no fields; completely skip indexing for this collection.
+"fields":["field1", "field2"] Array Index all fields whose names are listed in the array value.
+
+
+#### Example: Turn off Indexing for a Collection
+
+This example shows how you would use curl to set the schema if you want to turn off indexing for a collection:
+
+ curl -X PUT "0:8080/test-organization/settingstest/_settings?access_token=YWM..." -d '{"fields":"none"}'
+ {
+ "action" : "put",
+ "application" : "7fd6c414-2cb6-11e6-8b07-0a669fe1d66e",
+ "params" : { },
+ "path" : "/_settings",
+ "uri" : "http://localhost:8080/test-organization/settingstest/_settings",
+ "entities" : [ {
+ "uuid" : "6fc783c6-2cc3-11e6-8fce-0a669fe1d66e",
+ "type" : "_setting",
+ "created" : 1465312858697,
+ "modified" : 1465312858697,
+ "fields" : "none",
+ "metadata" : {
+ "path" : "/_settings/6fc783c6-2cc3-11e6-8fce-0a669fe1d66e",
+ "size" : 347
+ }
+ } ],
+ "timestamp" : 1465312858688,
+ "duration" : 63,
+ "organization" : "test-organization",
+ "applicationName" : "settingstest"
+ }
+
+
+#### Example: Index only one field of a Collection
+
+This example shows how you would use curl to set the schema if you only want the "year" field to be indexed:
+
+ curl -X PUT "0:8080/test-organization/settingstest/_settings?access_token=YWM..." -d '{"fields":["year"]}'
+ {
+ "action" : "put",
+ "application" : "7fd6c414-2cb6-11e6-8b07-0a669fe1d66e",
+ "params" : { },
+ "path" : "/_settings",
+ "uri" : "http://localhost:8080/test-organization/settingstest/_settings",
+ "entities" : [ {
+ "uuid" : "6fc783c6-2cc3-11e6-8fce-0a669fe1d66e",
+ "type" : "_setting",
+ "created" : 1465312858697,
+ "modified" : 1465312858697,
+ "fields" : [ "year" ],
+ "metadata" : {
+ "path" : "/_settings/6fc783c6-2cc3-11e6-8fce-0a669fe1d66e",
+ "size" : 347
+ }
+ } ],
+ "timestamp" : 1465312858688,
+ "duration" : 63,
+ "organization" : "test-organization",
+ "applicationName" : "settingstest"
+ }
+
+
## Retrieving Collections
This article describes how to retrieve all of the entities in a collection.
@@ -179,6 +322,7 @@ Response:
"organization" : "your-org",
"applicationName" : "your-app"
}
+
## Deleting Collections
This article describes how to batch delete entities in a collection. Batch deletes require the use of a query string in the request, which specifies a subset of entities to be deleted. For more information on queries, see Querying your data.