usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From toddn...@apache.org
Subject [47/50] incubator-usergrid git commit: separate calls
Date Tue, 31 Mar 2015 22:58:31 GMT
separate calls


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

Branch: refs/heads/USERGRID-509
Commit: c1643a7fff668abab72026fb2dd714bb9eb6245d
Parents: c12aa17
Author: Shawn Feldman <sfeldman@apache.org>
Authored: Mon Mar 30 17:29:28 2015 -0600
Committer: Shawn Feldman <sfeldman@apache.org>
Committed: Mon Mar 30 17:29:28 2015 -0600

----------------------------------------------------------------------
 .../usergrid/persistence/index/EntityIndex.java |  2 +
 .../impl/EsApplicationEntityIndexImpl.java      |  2 +-
 .../index/impl/EsEntityIndexBatchImpl.java      |  1 +
 .../index/impl/EsEntityIndexImpl.java           | 57 ++++++++------------
 .../index/migration/EsIndexMigrationPlugin.java |  2 +-
 5 files changed, 26 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c1643a7f/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 ff9008e..54a4127 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
@@ -70,6 +70,8 @@ public interface EntityIndex extends CPManager {
 
 
     void initialize();
+
+    boolean shouldInitialize();
 }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c1643a7f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsApplicationEntityIndexImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsApplicationEntityIndexImpl.java
b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsApplicationEntityIndexImpl.java
index 84845d0..eceff90 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsApplicationEntityIndexImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsApplicationEntityIndexImpl.java
@@ -118,7 +118,7 @@ public class EsApplicationEntityIndexImpl implements ApplicationEntityIndex{
     @Override
     public EntityIndexBatch createBatch() {
         EntityIndexBatch batch = new EsEntityIndexBatchImpl(
-            applicationScope, indexBatchBufferProducer, entityIndex, indexIdentifier );
+            applicationScope, indexBatchBufferProducer, entityIndex, indexIdentifier);
         return batch;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c1643a7f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
index f62648d..6fcb5eb 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
@@ -69,6 +69,7 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
         IndexValidationUtils.validateIndexScope( indexScope );
         ValidationUtils.verifyEntityWrite( entity );
         ValidationUtils.verifyVersion( entity.getVersion() );
+
         //add app id for indexing
         container.addIndexRequest(new IndexRequest(alias.getWriteAlias(), applicationScope,indexScope,
entity));
         return this;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c1643a7f/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 993b529..8de4832 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
@@ -77,12 +77,9 @@ public class EsEntityIndexImpl implements AliasedEntityIndex,VersionedData
{
     private final Timer addTimer;
     private final Timer updateAliasTimer;
 
-
     /**
      * We purposefully make this per instance. Some indexes may work, while others may fail
      */
-
-
     private final EsProvider esProvider;
 
     //number of times to wait for the index to refresh properly.
@@ -103,7 +100,6 @@ public class EsEntityIndexImpl implements AliasedEntityIndex,VersionedData
{
     private Timer refreshTimer;
     private Meter refreshIndexMeter;
 
-
 //    private final Timer indexTimer;
 
 
@@ -128,23 +124,30 @@ public class EsEntityIndexImpl implements AliasedEntityIndex,VersionedData
{
         this.refreshTimer = metricsFactory
             .getTimer(EsEntityIndexImpl.class, "refresh.timer");
         this.refreshIndexMeter = metricsFactory.getMeter(EsEntityIndexImpl.class,"refresh.meter");
+        if(shouldInitialize()){
+            initialize();
+        }
 
     }
 
     @Override
-    public void initialize(){
+    public void initialize() {
         final int numberOfShards = indexFig.getNumberOfShards();
         final int numberOfReplicas = indexFig.getNumberOfReplicas();
         aliasCache.invalidate(alias);
-        String[] reads = getIndexes(AliasedEntityIndex.AliasType.Read);
-        String[] writes = getIndexes(AliasedEntityIndex.AliasType.Write);
-
-        if(reads.length==0  || writes.length==0) {
+        if (shouldInitialize()) {
             addIndex(null, numberOfShards, numberOfReplicas, indexFig.getWriteConsistencyLevel());
         }
     }
 
     @Override
+    public boolean shouldInitialize() {
+        String[] reads = getIndexes(AliasedEntityIndex.AliasType.Read);
+        String[] writes = getIndexes(AliasedEntityIndex.AliasType.Write);
+        return reads.length==0  || writes.length==0;
+    }
+
+    @Override
     public void addIndex(final String indexSuffix,final int numberOfShards, final int numberOfReplicas,
final String writeConsistency) {
         try {
             //get index name with suffix attached
@@ -216,33 +219,15 @@ public class EsEntityIndexImpl implements AliasedEntityIndex,VersionedData
{
                 isAck = aliasesRequestBuilder.execute().actionGet().isAcknowledged();
                 logger.info("Removed Index Name from Alias=[{}] ACK=[{}]", alias, isAck);
             }
-            String[] reads = getIndexes(AliasedEntityIndex.AliasType.Read);
-            String[] writes = getIndexes(AliasedEntityIndex.AliasType.Write);
-
-            try {
-                aliasesRequestBuilder = adminClient.indices().prepareAliases();
-                //Added For Graphite Metrics
-                // add read alias
-                aliasesRequestBuilder.addAlias(indexName, alias.getReadAlias());
-                isAck = aliasesRequestBuilder.execute().actionGet().isAcknowledged();
-                logger.info("Created new read aliases ACK=[{}]", isAck);
-            } catch (InvalidAliasNameException ie) {
-                logger.debug("error creating read", ie);
-            }
-            try {
-                aliasesRequestBuilder = adminClient.indices().prepareAliases();
-
-                //Added For Graphite Metrics
-                //add write alias
-                aliasesRequestBuilder.addAlias(indexName, alias.getWriteAlias());
-                isAck = aliasesRequestBuilder.execute().actionGet().isAcknowledged();
-                logger.info("Created new write aliases ACK=[{}]", isAck);
-
-            } catch (InvalidAliasNameException ie) {
-                logger.debug("error creating write", ie);
-            }
-
-
+            aliasesRequestBuilder = adminClient.indices().prepareAliases();
+            //Added For Graphite Metrics
+            // add read alias
+            aliasesRequestBuilder.addAlias(indexName, alias.getReadAlias());
+            //Added For Graphite Metrics
+            //add write alias
+            aliasesRequestBuilder.addAlias(indexName, alias.getWriteAlias());
+            isAck = aliasesRequestBuilder.execute().actionGet().isAcknowledged();
+            logger.info("Created new read and write aliases ACK=[{}]", isAck);
             aliasCache.invalidate(alias);
 
         } catch (Exception e) {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c1643a7f/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/EsIndexMigrationPlugin.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/EsIndexMigrationPlugin.java
b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/EsIndexMigrationPlugin.java
index a28c701..9ece73b 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/EsIndexMigrationPlugin.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/migration/EsIndexMigrationPlugin.java
@@ -41,6 +41,6 @@ public class EsIndexMigrationPlugin  extends AbstractMigrationPlugin<Application
 
     @Override
     public PluginPhase getPhase() {
-        return PluginPhase.MIGRATE;
+        return PluginPhase.BOOTSTRAP;
     }
 }


Mime
View raw message