usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject [03/50] incubator-usergrid git commit: add alias support
Date Thu, 04 Dec 2014 20:10:38 GMT
add alias support


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

Branch: refs/heads/USERGRID-256-ApiResponseImplementation
Commit: 55110a5d87f33d7e7a1bc7c0752b3a7b4baacf17
Parents: 7b08ea5
Author: Shawn Feldman <sfeldman@apache.org>
Authored: Fri Nov 21 13:57:11 2014 -0700
Committer: Shawn Feldman <sfeldman@apache.org>
Committed: Fri Nov 21 13:57:11 2014 -0700

----------------------------------------------------------------------
 .../index/impl/EsEntityIndexBatchImpl.java      |  2 +-
 .../index/impl/EsEntityIndexImpl.java           |  4 +-
 .../persistence/index/impl/IndexingUtils.java   | 65 +++++++++++---------
 3 files changed, 38 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/55110a5d/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 9f50ccd..3fb3340 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
@@ -98,7 +98,7 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
         this.applicationScope = applicationScope;
         this.client = client;
         this.failureMonitor = failureMonitor;
-        this.aliasName = IndexingUtils.createAliasName(createIndexName( config.getIndexPrefix(),
applicationScope ),config);
+        this.aliasName = IndexingUtils.createAliasName( config, applicationScope );
         this.refresh = config.isForcedRefresh();
         this.autoFlushSize = autoFlushSize;
         initBatch();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/55110a5d/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 7407e49..8555b1c 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
@@ -137,7 +137,7 @@ public class EsEntityIndexImpl implements EntityIndex {
         this.esProvider = provider;
         this.config = config;
         this.cursorTimeout = config.getQueryCursorTimeout();
-        this.aliasName = IndexingUtils.createAliasName(IndexingUtils.createIndexName(config.getIndexPrefix(),
appScope),config);
+        this.aliasName = IndexingUtils.createAliasName(config,appScope);
         this.failureMonitor = new FailureMonitorImpl( config, provider );
     }
 
@@ -178,7 +178,7 @@ public class EsEntityIndexImpl implements EntityIndex {
 
     private void createIndexAndAlias(AdminClient admin, Settings settings) {
         String indexName = IndexingUtils.createIndexName(config.getIndexPrefix(), applicationScope);
-        String indexVersionName =  IndexingUtils.getIndexName(indexName, 0);
+        String indexVersionName =  IndexingUtils.createIndexName(indexName, 0);
         final CreateIndexResponse cir = admin.indices().prepareCreate( indexVersionName ).setSettings(
settings ).execute().actionGet();
         //check if alias exists and get the alias
         admin.indices().prepareAliases().addAlias(indexVersionName,aliasName).execute().actionGet();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/55110a5d/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 dcd496b..3aa4f39 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
@@ -98,15 +98,25 @@ public class IndexingUtils {
      * @param applicationScope
      * @return
      */
-    public static String createIndexName(
-            String prefix, ApplicationScope applicationScope) {
+    public static String createIndexBaseName(String prefix, ApplicationScope applicationScope)
{
         StringBuilder sb = new StringBuilder();
         sb.append( prefix ).append( SEPARATOR );
         idString( sb, applicationScope.getApplication() );
         return sb.toString();
     }
 
+    public static String createIndexName(String indexName, int i) {
+        if(i>0) {
+            return indexName + "_v" + (i + 1);
+        }else{
+            return indexName;
+        }
+    }
 
+    public static String createAliasName( IndexFig config,ApplicationScope applicationScope)
{
+        String indexName =IndexingUtils.createIndexBaseName(config.getIndexPrefix(), applicationScope);
+        return indexName + config.getAliasPostfix();
+    }
 
     /**
      * Create the index doc from the given entity
@@ -155,54 +165,54 @@ public class IndexingUtils {
 
                 .startObject( type )
 
-                    .startArray( "dynamic_templates" )
+                    .startArray("dynamic_templates")
 
                            //we need most specific mappings first since it's a stop on match
algorithm
 
                         .startObject()
-                        .startObject( "context_template" )
-                            .field( "match", IndexingUtils.ENTITYID_ID_FIELDNAME )
-                                 .field( "match_mapping_type", "string" )
-                                        .startObject( "mapping" ).field( "type", "string"
)
-                                             .field( "index", "not_analyzed" )
+                        .startObject("context_template")
+                            .field("match", IndexingUtils.ENTITYID_ID_FIELDNAME)
+                                 .field("match_mapping_type", "string")
+                                        .startObject("mapping").field( "type", "string" )
+                                             .field("index", "not_analyzed")
                                         .endObject()
                                  .endObject()
                              .endObject()
 
 
                         .startObject()
-                        .startObject( "context_template" )
-                            .field( "match", IndexingUtils.ENTITY_CONTEXT_FIELDNAME )
-                            .field( "match_mapping_type", "string" )
-                                .startObject( "mapping" ).field( "type", "string" )
-                                    .field( "index", "not_analyzed" ).endObject()
+                        .startObject("context_template")
+                            .field("match", IndexingUtils.ENTITY_CONTEXT_FIELDNAME)
+                            .field("match_mapping_type", "string")
+                                .startObject("mapping").field( "type", "string" )
+                                    .field("index", "not_analyzed").endObject()
                                 .endObject()
                          .endObject()
 
                         // any string with field name that starts with sa_ gets analyzed
                         .startObject()
-                            .startObject( "template_1" ).field( "match", ANALYZED_STRING_PREFIX
+ "*" )
-                            .field( "match_mapping_type", "string" ).startObject( "mapping"
).field( "type", "string" )
-                            .field( "index", "analyzed" ).endObject().endObject()
+                            .startObject("template_1").field( "match", ANALYZED_STRING_PREFIX
+ "*" )
+                            .field("match_mapping_type", "string").startObject( "mapping"
).field( "type", "string" )
+                            .field("index", "analyzed").endObject().endObject()
                         .endObject()
 
                                 // all other strings are not analyzed
                         .startObject()
-                            .startObject( "template_2" )
+                            .startObject("template_2")
                                     //todo, should be string prefix, remove 2 field mapping
-                                .field( "match", "*" ).field( "match_mapping_type", "string"
).startObject( "mapping" )
-                                .field( "type", "string" )
-                                    .field( "index", "not_analyzed" )
+                                .field("match", "*").field( "match_mapping_type", "string"
).startObject( "mapping" )
+                                .field("type", "string")
+                                    .field("index", "not_analyzed")
                                 .endObject()
                             .endObject()
                         .endObject()
 
                         // fields names starting with go_ get geo-indexed
                         .startObject()
-                            .startObject( "template_3" )
-                                .field( "match", GEO_PREFIX + "location" )
-                                .startObject( "mapping" )
-                                    .field( "type", "geo_point" )
+                            .startObject("template_3")
+                                .field("match", GEO_PREFIX + "location")
+                                .startObject("mapping")
+                                    .field("type", "geo_point")
                                 .endObject()
                             .endObject()
                         .endObject()
@@ -218,11 +228,6 @@ public class IndexingUtils {
         return builder;
     }
 
-    public static String createAliasName(String indexName, IndexFig fig) {
-        return indexName + fig.getAliasPostfix();
-    }
 
-    public static String getIndexName(String indexName, int i) {
-        return indexName+"_v"+(i+1);
-    }
+
 }


Mime
View raw message