usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sfeld...@apache.org
Subject [1/2] incubator-usergrid git commit: add write consistency
Date Tue, 03 Mar 2015 19:13:20 GMT
Repository: incubator-usergrid
Updated Branches:
  refs/heads/USERGRID-432 44c098942 -> 2b3101581


add write consistency


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

Branch: refs/heads/USERGRID-432
Commit: 5e578d5c7a85df521968678b3fa9df1d4241c065
Parents: 44c0989
Author: Shawn Feldman <sfeldman@apache.org>
Authored: Tue Mar 3 10:34:55 2015 -0700
Committer: Shawn Feldman <sfeldman@apache.org>
Committed: Tue Mar 3 10:34:55 2015 -0700

----------------------------------------------------------------------
 .../usergrid/corepersistence/CpEntityManagerFactory.java      | 4 ++--
 .../org/apache/usergrid/persistence/EntityManagerFactory.java | 3 ++-
 .../persistence/cassandra/EntityManagerFactoryImpl.java       | 2 +-
 .../org/apache/usergrid/persistence/index/EntityIndex.java    | 3 ++-
 .../usergrid/persistence/index/impl/EsEntityIndexImpl.java    | 7 ++++---
 .../usergrid/persistence/index/impl/EntityIndexTest.java      | 4 ++--
 .../src/main/java/org/apache/usergrid/rest/IndexResource.java | 4 +++-
 7 files changed, 16 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5e578d5c/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
index 8272d7d..84fad36 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
@@ -826,9 +826,9 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
     }
 
     @Override
-    public void addIndex(final UUID applicationId,final String indexSuffix,final int shards,final
int replicas){
+    public void addIndex(final UUID applicationId,final String indexSuffix,final int shards,final
int replicas, final String writeConsistency){
         EntityIndex entityIndex = managerCache.getEntityIndex(CpNamingUtils.getApplicationScope(applicationId));
-        entityIndex.addIndex(indexSuffix, shards, replicas);
+        entityIndex.addIndex(indexSuffix, shards, replicas,writeConsistency);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5e578d5c/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
index b668e24..880fe89 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
@@ -165,8 +165,9 @@ public interface EntityManagerFactory {
      * @param suffix unique indentifier for additional index
      * @param shards number of shards
      * @param replicas number of replicas
+     * @param writeConsistency only "one, quorum, or all"
      */
-    public void addIndex(final UUID appId,final String suffix,final int shards,final int
replicas);
+    public void addIndex(final UUID appId,final String suffix,final int shards,final int
replicas, final String writeConsistency);
 
     public Health getEntityStoreHealth();
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5e578d5c/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
index 9a90e59..af1eabc 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
@@ -466,7 +466,7 @@ public class EntityManagerFactoryImpl implements EntityManagerFactory,
Applicati
     }
 
     @Override
-    public void addIndex(UUID appId, String suffix,final int shards,final int replicas) {
+    public void addIndex(UUID appId, String suffix,final int shards,final int replicas,final
String consistency) {
         throw new UnsupportedOperationException("Not supported in v1");
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5e578d5c/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java
b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java
index b888e09..3edde4d 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java
@@ -52,8 +52,9 @@ public interface EntityIndex {
      * @param indexSuffix index name
      * @param shards
      * @param replicas
+     * @param writeConsistency
      */
-    public void addIndex(final String indexSuffix, final int shards, final int replicas);
+    public void addIndex(final String indexSuffix, final int shards, final int replicas,
final String writeConsistency);
 
     /**
      * Create the index batch.

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5e578d5c/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
index a8b0cc4..1910cdc 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
@@ -140,11 +140,11 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
     public void initializeIndex() {
         final int numberOfShards = config.getNumberOfShards();
         final int numberOfReplicas = config.getNumberOfReplicas();
-        addIndex(null, numberOfShards, numberOfReplicas);
+        addIndex(null, numberOfShards, numberOfReplicas,config.getWriteConsistencyLevel());
     }
 
     @Override
-    public void addIndex(final String indexSuffix,final int numberOfShards, final int numberOfReplicas)
{
+    public void addIndex(final String indexSuffix,final int numberOfShards, final int numberOfReplicas,
final String writeConsistency) {
         String normalizedSuffix =  StringUtils.isNotEmpty(indexSuffix) ? indexSuffix : null;
         try {
 
@@ -161,7 +161,8 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
                 Settings settings = ImmutableSettings.settingsBuilder()
                         .put("index.number_of_shards", numberOfShards)
                         .put("index.number_of_replicas", numberOfReplicas)
-                        .build();
+                        .put("action.write_consistency", writeConsistency)
+                    .build();
                 final CreateIndexResponse cir = admin.indices().prepareCreate(indexName)
                         .setSettings(settings)
                         .execute()

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5e578d5c/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
index 7bfbb52..22aadc0 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
@@ -169,7 +169,7 @@ public class EntityIndexTest extends BaseIT {
 
         testQueries( indexScope, searchTypes,  entityIndex );
 
-        entityIndex.addIndex("v2", 1,0);
+        entityIndex.addIndex("v2", 1,0,"one");
 
         insertJsonBlob(entityIndex, entityType, indexScope, "/sample-large.json",101,100);
 
@@ -199,7 +199,7 @@ public class EntityIndexTest extends BaseIT {
 
         entityIndex.refresh();
 
-        entityIndex.addIndex("v2", 1, 0);
+        entityIndex.addIndex("v2", 1, 0, "one");
 
         insertJsonBlob(entityIndex, entityType, indexScope, "/sample-large.json", 1, 0);
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5e578d5c/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 f5338c5..f4ebf23 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
@@ -250,8 +250,10 @@ public class IndexResource extends AbstractContextResource {
             throw new IllegalArgumentException("Please add an indexSuffix to your post");
         }
 
+        String writeConsistency = config.get("writeConsistency") != null ? (String)config.get("writeConsistency")
: "one" ;
+
         emf.addIndex(appId, config.get("indexSuffix").toString(),
-            (int) config.get("shards"),(int) config.get("replicas"));
+            (int) config.get("shards"),(int) config.get("replicas"),writeConsistency);
         response.setAction("Add index to alias");
 
         return new JSONWithPadding(response, callback);


Mime
View raw message