usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sfeld...@apache.org
Subject [4/5] incubator-usergrid git commit: index tests pass
Date Wed, 18 Mar 2015 21:59:55 GMT
index tests pass


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

Branch: refs/heads/USERGRID-480
Commit: 947f063269cda28c1bb25d55d732adb5c419d5b1
Parents: 346eba9
Author: Shawn Feldman <sfeldman@apache.org>
Authored: Wed Mar 18 15:53:54 2015 -0600
Committer: Shawn Feldman <sfeldman@apache.org>
Committed: Wed Mar 18 15:53:54 2015 -0600

----------------------------------------------------------------------
 .../usergrid/persistence/index/SearchType.java  | 49 ++++++++++++++++++++
 .../index/impl/EsEntityIndexBatchImpl.java      |  9 ++--
 .../index/impl/EsEntityIndexImpl.java           |  4 +-
 .../persistence/index/impl/EntityIndexTest.java |  2 +-
 4 files changed, 56 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/947f0632/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/SearchType.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/SearchType.java
b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/SearchType.java
new file mode 100644
index 0000000..5501c09
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/SearchType.java
@@ -0,0 +1,49 @@
+/*
+ *
+ *  * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  *  contributor license agreements.  The ASF licenses this file to You
+ *  * under the Apache License, Version 2.0 (the "License"); you may not
+ *  * use this file except in compliance with the License.
+ *  * You may obtain a copy of the License at
+ *  *
+ *  *     http://www.apache.org/licenses/LICENSE-2.0
+ *  *
+ *  * Unless required by applicable law or agreed to in writing, software
+ *  * distributed under the License is distributed on an "AS IS" BASIS,
+ *  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  * See the License for the specific language governing permissions and
+ *  * limitations under the License.  For additional information regarding
+ *  * copyright in this work, please see the NOTICE file in the top level
+ *  * directory of this distribution.
+ *
+ */
+package org.apache.usergrid.persistence.index;
+
+import org.apache.usergrid.persistence.core.scope.ApplicationScope;
+import org.apache.usergrid.persistence.index.impl.IndexingUtils;
+import org.apache.usergrid.persistence.model.entity.Id;
+
+/**
+ * Classy class class.
+ */
+public class SearchType{
+    private final String type;
+
+    private SearchType( final String type ) {this.type = type;}
+
+    public static SearchType fromType( final String type ) {
+        return new SearchType( type );
+    }
+
+
+    public static SearchType fromId( final Id id ) {
+        return new SearchType( id.getType() );
+    }
+
+
+
+    public String getTypeName(ApplicationScope applicationScope) {
+        final String typeName =  IndexingUtils.getType(applicationScope, type);
+        return typeName;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/947f0632/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 977fe51..c0d0d1e 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
@@ -117,8 +117,8 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
         String indexId = createIndexDocId( entity, context );
 
         log.debug( "Indexing entity documentId {} data {} ", indexId, entityAsMap );
-        final String entityType =IndexingUtils.getType(applicationScope, entity.getId());
-        container.addIndexRequest(new IndexRequest(alias.getWriteAlias(), entityType, indexId,
entityAsMap));
+        final SearchType entityType =SearchType.fromId(entity.getId());
+        container.addIndexRequest(new IndexRequest(alias.getWriteAlias(), entityType.getTypeName(applicationScope),
indexId, entityAsMap));
 
         return this;
     }
@@ -132,7 +132,7 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
         ValidationUtils.verifyVersion( version );
 
         final String context = createContextName(indexScope);
-        final String entityType =IndexingUtils.getType(applicationScope, id);
+        final SearchType entityType =SearchType.fromId(id);
 
         final String indexId = createIndexDocId( id, version, context );
 
@@ -151,14 +151,13 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
                 } );
         }
 
-
         String[] indexes = entityIndex.getIndexes(AliasedEntityIndex.AliasType.Read);
         //get the default index if no alias exists yet
         if(indexes == null ||indexes.length == 0){
             indexes = new String[]{indexIdentifier.getIndex(null)};
         }
 
-        container.addDeIndexRequest( new DeIndexRequest( indexes, entityType, indexId ) );
+        container.addDeIndexRequest( new DeIndexRequest( indexes, entityType.getTypeName(applicationScope),
indexId ) );
 
         log.debug("Deindexed Entity with index id " + indexId);
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/947f0632/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 110b320..f8415df 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
@@ -199,9 +199,9 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
         final int numberOfShards = config.getNumberOfShards();
         final int numberOfReplicas = config.getNumberOfReplicas();
         String[] indexes = getIndexesFromEs(AliasType.Write);
-//        if(indexes == null || indexes.length==0) {
+        if(indexes == null || indexes.length==0) {
             addIndex(null, numberOfShards, numberOfReplicas, config.getWriteConsistencyLevel());
-//        }
+        }
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/947f0632/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 22ca51f..047fbe8 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
@@ -576,7 +576,7 @@ public class EntityIndexTest extends BaseIT {
         EntityIndex ei = eif.createEntityIndex( applicationScope );
 
         assertNotEquals( "cluster should be ok", Health.RED, ei.getClusterHealth() );
-        assertEquals( "index not be ready yet", Health.RED, ei.getIndexHealth() );
+        assertEquals( "index should be ready", Health.GREEN, ei.getIndexHealth() );
 
         ei.initializeIndex();
         ei.refresh();


Mime
View raw message