You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by to...@apache.org on 2015/03/20 22:32:34 UTC
[01/31] incubator-usergrid git commit: latest
Repository: incubator-usergrid
Updated Branches:
refs/heads/USERGRID-486 bab5ba7f0 -> a40fb8d57
latest
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/98bc9a42
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/98bc9a42
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/98bc9a42
Branch: refs/heads/USERGRID-486
Commit: 98bc9a4254f23cc07d437a1e818fa9438c0d04f7
Parents: b53cb07
Author: Shawn Feldman <sf...@apache.org>
Authored: Tue Mar 17 21:13:32 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Tue Mar 17 21:13:32 2015 -0600
----------------------------------------------------------------------
.../index/impl/EsEntityIndexBatchImpl.java | 27 ++---
.../index/impl/EsEntityIndexImpl.java | 20 ++--
.../persistence/index/impl/EsQueryVistor.java | 88 +++++++++-------
.../persistence/index/impl/IndexingUtils.java | 104 +++++++++++--------
4 files changed, 135 insertions(+), 104 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/98bc9a42/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 92312d2..34e7702 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
@@ -56,15 +56,7 @@ import com.codahale.metrics.Timer;
import rx.Observable;
import rx.functions.Func1;
-import static org.apache.usergrid.persistence.index.impl.IndexingUtils.ANALYZED_STRING_PREFIX;
-import static org.apache.usergrid.persistence.index.impl.IndexingUtils.BOOLEAN_PREFIX;
-import static org.apache.usergrid.persistence.index.impl.IndexingUtils.ENTITYID_ID_FIELDNAME;
-import static org.apache.usergrid.persistence.index.impl.IndexingUtils.ENTITY_CONTEXT_FIELDNAME;
-import static org.apache.usergrid.persistence.index.impl.IndexingUtils.GEO_PREFIX;
-import static org.apache.usergrid.persistence.index.impl.IndexingUtils.NUMBER_PREFIX;
-import static org.apache.usergrid.persistence.index.impl.IndexingUtils.STRING_PREFIX;
-import static org.apache.usergrid.persistence.index.impl.IndexingUtils.createContextName;
-import static org.apache.usergrid.persistence.index.impl.IndexingUtils.createIndexDocId;
+import static org.apache.usergrid.persistence.index.impl.IndexingUtils.*;
public class EsEntityIndexBatchImpl implements EntityIndexBatch {
@@ -243,7 +235,7 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
if ( f instanceof ListField ) {
List list = ( List ) field.getValue();
- entityMap.put( field.getName().toLowerCase(),
+ entityMap.put( ARRAY_PREFIX+ field.getName().toLowerCase(),
new ArrayList( processCollectionForMap( list ) ) );
if ( !list.isEmpty() ) {
@@ -255,7 +247,7 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
}
else if ( f instanceof ArrayField ) {
List list = ( List ) field.getValue();
- entityMap.put( field.getName().toLowerCase(),
+ entityMap.put( ARRAY_PREFIX+ field.getName().toLowerCase(),
new ArrayList( processCollectionForMap( list ) ) );
}
else if ( f instanceof SetField ) {
@@ -265,7 +257,7 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
}
else if ( f instanceof EntityObjectField ) {
EntityObject eo = ( EntityObject ) field.getValue();
- entityMap.put( field.getName().toLowerCase(), entityToMap( eo ) ); // recursion
+ entityMap.put( field.getName().toLowerCase(), entityToMap(eo) ); // recursion
}
else if ( f instanceof StringField ) {
@@ -284,12 +276,11 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
locMap.put( "lon", locField.getValue().getLongitude() );
entityMap.put( GEO_PREFIX + field.getName().toLowerCase(), locMap );
}
- else if ( f instanceof DoubleField
- || f instanceof FloatField
- || f instanceof IntegerField
- || f instanceof LongField ) {
-
- entityMap.put( NUMBER_PREFIX + field.getName().toLowerCase(), field.getValue() );
+ else if( f instanceof DoubleField || f instanceof FloatField){
+ entityMap.put( DOUBLE_PREFIX + field.getName().toLowerCase(), field.getValue() );
+ }
+ else if( f instanceof LongField || f instanceof IntegerField){
+ entityMap.put( LONG_PREFIX + field.getName().toLowerCase(), field.getValue() );
}
else if ( f instanceof BooleanField ) {
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/98bc9a42/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 16f4b3f..598c8d9 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
@@ -457,11 +457,19 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
logger.debug( " Sort: {} order by {}", stringFieldName, order.toString() );
- final String numberFieldName = NUMBER_PREFIX + sp.getPropertyName();
- final FieldSortBuilder numberSort = SortBuilders.fieldSort( numberFieldName )
+ final String longFieldName = LONG_PREFIX + sp.getPropertyName();
+ final FieldSortBuilder longSort = SortBuilders.fieldSort( longFieldName )
.order( order ).ignoreUnmapped( true );
- srb.addSort( numberSort );
- logger.debug( " Sort: {} order by {}", numberFieldName, order.toString() );
+ srb.addSort( longSort );
+ logger.debug( " Sort: {} order by {}", longFieldName, order.toString() );
+
+
+ final String doubleFieldName = DOUBLE_PREFIX + sp.getPropertyName();
+ final FieldSortBuilder doubleSort = SortBuilders.fieldSort( doubleFieldName )
+ .order( order ).ignoreUnmapped( true );
+ srb.addSort( doubleSort );
+ logger.debug( " Sort: {} order by {}", doubleFieldName, order.toString() );
+
final String booleanFieldName = BOOLEAN_PREFIX + sp.getPropertyName();
final FieldSortBuilder booleanSort = SortBuilders.fieldSort( booleanFieldName )
@@ -613,7 +621,7 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
}
};
- doInRetry( retryOperation );
+ doInRetry(retryOperation);
}
@@ -741,7 +749,7 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
new ClusterHealthRequest( new String[] { indexIdentifier.getIndex( null ) } ) );
//only wait 2 seconds max
- ClusterHealthResponse chr = future.actionGet( 2000 );
+ ClusterHealthResponse chr = future.actionGet(2000);
return Health.valueOf( chr.getStatus().name() );
}
catch ( Exception ex ) {
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/98bc9a42/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java
index f012bab..8e8b43c 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsQueryVistor.java
@@ -50,15 +50,11 @@ import org.apache.usergrid.persistence.index.query.tree.WithinOperand;
import com.google.common.base.Joiner;
-import static org.apache.usergrid.persistence.index.impl.IndexingUtils.ANALYZED_STRING_PREFIX;
-import static org.apache.usergrid.persistence.index.impl.IndexingUtils.BOOLEAN_PREFIX;
-import static org.apache.usergrid.persistence.index.impl.IndexingUtils.GEO_PREFIX;
-import static org.apache.usergrid.persistence.index.impl.IndexingUtils.NUMBER_PREFIX;
-import static org.apache.usergrid.persistence.index.impl.IndexingUtils.STRING_PREFIX;
+import static org.apache.usergrid.persistence.index.impl.IndexingUtils.*;
/**
- * Visits tree of parsed Query operands and populates
+ * Visits tree of parsed Query operands and populates
* ElasticSearch QueryBuilder that represents the query.
*/
public class EsQueryVistor implements QueryVisitor {
@@ -67,7 +63,7 @@ public class EsQueryVistor implements QueryVisitor {
Stack<QueryBuilder> stack = new Stack<QueryBuilder>();
List<FilterBuilder> filterBuilders = new ArrayList<FilterBuilder>();
-
+
@Override
public void visit( AndOperand op ) throws IndexException {
@@ -157,14 +153,14 @@ public class EsQueryVistor implements QueryVisitor {
Object value = op.getLiteral().getValue();
BoolQueryBuilder qb = QueryBuilders.boolQuery(); // let's do a boolean OR
- qb.minimumNumberShouldMatch(1);
+ qb.minimumNumberShouldMatch(1);
// field is an entity/array that needs no name prefix
qb = qb.should( QueryBuilders.matchQuery( name, value ) );
// OR field is a string and needs the prefix on the name
qb = qb.should( QueryBuilders.matchQuery( addPrefix( value.toString(), name, true), value));
-
+
stack.push( qb );
}
@@ -186,7 +182,7 @@ public class EsQueryVistor implements QueryVisitor {
FilterBuilder fb = FilterBuilders.geoDistanceFilter( name )
.lat( lat ).lon( lon ).distance( distance, DistanceUnit.METERS );
filterBuilders.add( fb );
- }
+ }
@Override
@@ -222,19 +218,19 @@ public class EsQueryVistor implements QueryVisitor {
qb.minimumNumberShouldMatch(1);
// field is an entity/array that does not need a prefix on its name
- // TODO is this right now that we've updated our doc structure?
+ // TODO is this right now that we've updated our doc structure?
// Should this be "must" instead of should?
qb = qb.should( QueryBuilders.wildcardQuery( name, svalue ) );
-
+
// or field is just a string that does need a prefix
if ( svalue.indexOf("*") != -1 ) {
qb = qb.should( QueryBuilders.wildcardQuery( addPrefix( value, name ), svalue ) );
} else {
qb = qb.should( QueryBuilders.termQuery( addPrefix( value, name ), value ));
- }
+ }
stack.push( qb );
return;
- }
+ }
// assume all other types need prefix
stack.push( QueryBuilders.termQuery( addPrefix( value, name ), value ));
@@ -276,29 +272,38 @@ public class EsQueryVistor implements QueryVisitor {
if ( parts.length > 1 ) {
name = parts[ parts.length - 1 ];
}
-
+
if ( value instanceof String && analyzed ) {
name = addAnalyzedStringPrefix( name );
} else if ( value instanceof String ) {
name = addStringPrefix( name );
- } else if ( value instanceof Number ) {
- name = addNumberPrefix( name );
+ }else if ( value instanceof Integer ) {
+ name = addLongPrefix(name);
+
+ }else if ( value instanceof Long ) {
+ name = addLongPrefix(name);
+
+ } else if ( value instanceof Float ) {
+ name = addDoublePrefix(name);
+
+ }else if ( value instanceof Float ) {
+ name = addDoublePrefix(name);
} else if ( value instanceof Boolean ) {
- name = addBooleanPrefix( name );
+ name = addBooleanPrefix(name);
} else if ( value instanceof UUID ) {
- name = addStringPrefix( name );
+ name = addStringPrefix(name);
}
- // re-create nested property name
+ // re-create nested property name
if ( parts.length > 1 ) {
parts[parts.length - 1] = name;
Joiner joiner = Joiner.on(".").skipNulls();
return joiner.join(parts);
- }
+ }
return name;
}
@@ -307,34 +312,41 @@ public class EsQueryVistor implements QueryVisitor {
private String addAnalyzedStringPrefix( String name ) {
if ( name.startsWith( ANALYZED_STRING_PREFIX ) ) {
return name;
- }
+ }
return ANALYZED_STRING_PREFIX + name;
- }
-
+ }
+
private String addStringPrefix( String name ) {
if ( name.startsWith( STRING_PREFIX ) ) {
return name;
- }
+ }
return STRING_PREFIX + name;
- }
-
+ }
- private String addNumberPrefix( String name ) {
- if ( name.startsWith( NUMBER_PREFIX ) ) {
+
+ private String addDoublePrefix( String name ) {
+ if ( name.startsWith( DOUBLE_PREFIX ) ) {
return name;
- }
- return NUMBER_PREFIX + name;
- }
-
+ }
+ return DOUBLE_PREFIX + name;
+ }
+
+ private String addLongPrefix( String name ) {
+ if ( name.startsWith( LONG_PREFIX ) ) {
+ return name;
+ }
+ return LONG_PREFIX + name;
+ }
+
private String addBooleanPrefix( String name ) {
if ( name.startsWith( BOOLEAN_PREFIX ) ) {
return name;
- }
+ }
return BOOLEAN_PREFIX + name;
- }
-
+ }
+
@Override
public QueryBuilder getQueryBuilder() {
@@ -354,10 +366,10 @@ public class EsQueryVistor implements QueryVisitor {
for ( FilterBuilder fb : filterBuilders ) {
if ( andFilter == null ) {
andFilter = FilterBuilders.andFilter( fb );
- } else {
+ } else {
andFilter = FilterBuilders.andFilter( andFilter, fb );
}
- }
+ }
} else if ( !filterBuilders.isEmpty() ) {
return filterBuilders.get(0);
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/98bc9a42/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 ffd98e9..0df3a2c 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
@@ -35,8 +35,11 @@ public class IndexingUtils {
public static final String STRING_PREFIX = "su_";
public static final String ANALYZED_STRING_PREFIX = "sa_";
public static final String GEO_PREFIX = "go_";
- public static final String NUMBER_PREFIX = "nu_";
+ public static final String LONG_PREFIX = "long_";
+ public static final String DOUBLE_PREFIX = "long_";
+
public static final String BOOLEAN_PREFIX = "bu_";
+ public static final String ARRAY_PREFIX = "ar_";
public static final String SPLITTER = "\\__";
@@ -54,6 +57,7 @@ public class IndexingUtils {
public static final String ENTITY_VERSION_FIELDNAME = "ug_entityVersion";
+ public static final String DOC_VALUES_KEY = "doc_values";
/**
* Create our sub scope. This is the ownerUUID + type
@@ -151,78 +155,94 @@ public class IndexingUtils {
.startObject()
- /** add routing "_routing":{ "required":false, "path":"ug_entityId" **/
- .startObject("_routing").field("required",true).field("path",ENTITYID_ID_FIELDNAME).endObject()
- .startArray("dynamic_templates")
+ /** add routing "_routing":{ "required":true, "path":"ug_entityId" **/
+ .startObject("_routing")
+ .field("required", true)
+ .field("path", ENTITYID_ID_FIELDNAME)
+ .endObject()
+ .startArray("dynamic_templates")
// we need most specific mappings first since it's a stop on match algorithm
-
.startObject()
-
- .startObject( "entity_id_template" )
- .field( "match", IndexingUtils.ENTITYID_ID_FIELDNAME )
- .field( "match_mapping_type", "string" )
- .startObject( "mapping" ).field( "type", "string" )
- .field( "index", "not_analyzed" )
+ .startObject("entity_id_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( "entity_context_template" )
- .field( "match", IndexingUtils.ENTITY_CONTEXT_FIELDNAME )
- .field( "match_mapping_type", "string" )
- .startObject( "mapping" )
- .field( "type", "string" )
- .field( "index", "not_analyzed" ).endObject()
- .endObject()
+ .startObject("entity_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()
.startObject()
- .startObject( "entity_version_template" )
- .field( "match", IndexingUtils.ENTITY_VERSION_FIELDNAME )
- .field( "match_mapping_type", "string" )
- .startObject( "mapping" ).field( "type", "long" )
- .endObject()
- .endObject()
+ .startObject("entity_version_template")
+ .field("match", IndexingUtils.ENTITY_VERSION_FIELDNAME)
+ .field("match_mapping_type", "string")
+ .startObject("mapping").field("type", "long").field(DOC_VALUES_KEY, true)
.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" )
+ .startObject("template_string_analyzed")
+ .field("match", ANALYZED_STRING_PREFIX + "*")
+ .field("match_mapping_type", "string")
+ .startObject("mapping")
+ .field("type", "string")
+ .field("index", "analyzed")
+ .endObject()
.endObject()
.endObject()
- .endObject()
-
// all other strings are not analyzed
.startObject()
- .startObject( "template_2" )
+ .startObject("template_string_not_analyzed")
//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_geo")
+ .field("match", GEO_PREFIX + "location")
+ .startObject("mapping").field("type", "geo_point")
.endObject()
.endObject()
.endObject()
+ // all other strings are not analyzed
+ .startObject()
+ .startObject("template__long")
+ .field("match", LONG_PREFIX + "*")
+ .field("match_mapping_type", "long")
+ .startObject("mapping").field("type", "long").field("index","not_analyzed").field(DOC_VALUES_KEY, true).endObject()
+ .endObject()
+ .endObject()
- .endArray()
+ .startObject()
+ .startObject("template__double")
+ .field("match", DOUBLE_PREFIX + "*")
+ .field("match_mapping_type", "double")
+ .startObject("mapping").field("type", "double").field("index", "not_analyzed").field(DOC_VALUES_KEY, true).endObject()
+ .endObject()
+ .endObject()
+ .endArray()
.endObject();
return builder;
[14/31] incubator-usergrid git commit: fix collections it
Posted by to...@apache.org.
fix collections it
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/735eedb2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/735eedb2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/735eedb2
Branch: refs/heads/USERGRID-486
Commit: 735eedb2c25d6149f58728cbde74ca0dbf7d9283
Parents: 70fe285
Author: Shawn Feldman <sf...@apache.org>
Authored: Thu Mar 19 17:24:32 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Thu Mar 19 17:24:32 2015 -0600
----------------------------------------------------------------------
.../corepersistence/CpEntityManager.java | 7 ----
.../corepersistence/CpEntityManagerFactory.java | 6 +--
.../usergrid/corepersistence/CpSetup.java | 6 ++-
.../usergrid/persistence/EntityManager.java | 5 ---
.../cassandra/EntityManagerImpl.java | 6 ---
.../corepersistence/StaleIndexCleanupTest.java | 39 ++++++++++++++++----
.../usergrid/persistence/CollectionIT.java | 14 ++++---
.../index/impl/EsEntityIndexImpl.java | 4 ++
8 files changed, 53 insertions(+), 34 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/735eedb2/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
index a9f00b4..64f0257 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
@@ -2893,13 +2893,6 @@ public class CpEntityManager implements EntityManager {
@Override
- public void createIndex() {
- ei.initializeIndex();
- }
-
-
-
- @Override
public void flushManagerCaches() {
managerCache.invalidate();
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/735eedb2/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 f3d18d0..134886f 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
@@ -160,8 +160,8 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
em.getApplication();
}
- em.createIndex();
- em.refreshIndex();
+ entityIndex.initializeIndex();
+ entityIndex.refresh();
} catch (Exception ex) {
@@ -723,7 +723,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
EntityManager em = getEntityManager( appId );
//explicitly invoke create index, we don't know if it exists or not in ES during a rebuild.
- em.createIndex();
+ entityIndex.initializeIndex();
em.reindex(po);
em.reindex( po );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/735eedb2/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
index d70c16c..a9e6cee 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
@@ -19,6 +19,8 @@ package org.apache.usergrid.corepersistence;
import java.util.UUID;
+import com.google.inject.Binding;
+import org.apache.usergrid.persistence.index.EntityIndex;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -64,6 +66,7 @@ public class CpSetup implements Setup {
private final CassandraService cass;
private final EntityManagerFactory emf;
+ private final EntityIndex entityIndex;
/**
@@ -75,6 +78,7 @@ public class CpSetup implements Setup {
this.emf = emf;
this.cass = cassandraService;
this.injector = injector;
+ this.entityIndex = injector.getInstance(EntityIndex.class);
}
@@ -95,7 +99,7 @@ public class CpSetup implements Setup {
setupStaticKeyspace();
//force the EMF creation of indexes before creating the default applications
- emf.refreshIndex();
+ entityIndex.initializeIndex();
injector.getInstance( DataMigrationManager.class ).migrate();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/735eedb2/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
index 71dcd07..89a5384 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
@@ -690,11 +690,6 @@ public interface EntityManager {
*/
void refreshIndex();
- /**
- * Create the index, should ONLY ever be called the first time an application is created
- */
- void createIndex();
-
public void init( EntityManagerFactory emf, EntityIndex entityIndex, UUID applicationId);
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/735eedb2/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
index 803512b..112b684 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
@@ -2890,12 +2890,6 @@ public class EntityManagerImpl implements EntityManager {
}
- @Override
- public void createIndex() {
- //no op
- }
-
-
@Override
public EntityRef getGroupRoleRef( UUID ownerId, String roleName) throws Exception {
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/735eedb2/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
index fdd230c..450f44b 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
@@ -120,7 +120,14 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
assertTrue( "New version is greater than old",
UUIDComparator.staticCompare( newVersion, oldVersion ) > 0 );
- assertEquals( 2, queryCollectionCp( "things", "thing", "select *" ).size() );
+ CandidateResults results;
+ do{
+ results = queryCollectionCp( "things", "thing", "select *" );
+ if(results.size()!=2){
+ Thread.sleep(200);
+ }
+ }while(results.size()!=2);
+ assertEquals( 2, results.size() );
}
@@ -151,24 +158,42 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
UUID newVersion = getCpEntity( thing ).getVersion();
+ CandidateResults candidateResults = null;
+
+ do{
+ candidateResults = queryCollectionCp("things", "thing", "select * order by ordinal desc");
+ if(candidateResults.size()!=2){
+ Thread.sleep(200);
+ }
+ }while(candidateResults.size()<2);
- assertEquals(2, queryCollectionCp("things", "thing", "select * order by ordinal desc").size());
+ assertEquals(2, candidateResults.size());
//now run enable events and ensure we clean up
System.setProperty(EVENTS_DISABLED, "false");
- final Results results = queryCollectionEm("things", "select * order by ordinal desc");
-
+ Results results = null;
+ do{
+ results = queryCollectionEm("things", "select * order by ordinal desc");;
+ if(results.size()!=1){
+ Thread.sleep(200);
+ }
+ }while(results.size()<1);
assertEquals( 1, results.size() );
assertEquals(1, results.getEntities().get( 0 ).getProperty( "ordinal" ));
em.refreshIndex();
//ensure it's actually gone
- final CandidateResults candidates = queryCollectionCp( "things", "thing", "select * order by ordinal desc" );
- assertEquals(1, candidates.size());
+ do{
+ candidateResults = queryCollectionCp( "things", "thing", "select * order by ordinal desc" );
+ if(candidateResults.size()!=1){
+ Thread.sleep(200);
+ }
+ }while(candidateResults.size()!=1);
+ assertEquals(1, candidateResults.size());
- assertEquals(newVersion, candidates.get(0).getVersion());
+ assertEquals(newVersion, candidateResults.get(0).getVersion());
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/735eedb2/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java
index 641d3ad..aa75a9a 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java
@@ -1227,11 +1227,15 @@ public class CollectionIT extends AbstractCoreIT {
Query query = new Query();
query.addEqualityFilter( "rootprop1", "simpleprop" );
-
- Results results = em.searchCollection( em.getApplicationRef(), "tests", query );
-
- Entity entity = results.getEntitiesMap().get( saved.getUuid() );
-
+ Entity entity;
+ Results results;
+ do {
+ results = em.searchCollection(em.getApplicationRef(), "tests", query);
+ entity = results.getEntitiesMap().get(saved.getUuid());
+ if (entity == null) {
+ Thread.sleep(200);
+ }
+ }while(entity == null);
assertNotNull( entity );
// query on the nested int value
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/735eedb2/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 e92e133..04fde6a 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
@@ -18,6 +18,7 @@
package org.apache.usergrid.persistence.index.impl;
+import com.codahale.metrics.Meter;
import com.codahale.metrics.Timer;
import com.google.common.collect.ImmutableMap;
import com.google.inject.Inject;
@@ -105,6 +106,7 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
private EsIndexCache aliasCache;
private Timer mappingTimer;
private Timer refreshTimer;
+ private Meter refreshIndexMeter;
// private final Timer indexTimer;
@@ -131,6 +133,7 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
.getTimer(EsEntityIndexImpl.class, "create.mapping.timer");
this.refreshTimer = metricsFactory
.getTimer(EsEntityIndexImpl.class, "refresh.timer");
+ this.refreshIndexMeter = metricsFactory.getMeter(EsEntityIndexImpl.class,"refresh.meter");
}
@@ -323,6 +326,7 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
public void refresh() {
+ refreshIndexMeter.mark();
BetterFuture future = indexBatchBufferProducer.put(new IndexOperationMessage());
future.get();
[29/31] incubator-usergrid git commit: Merge branch 'USERGRID-480'
into USERGRID-405
Posted by to...@apache.org.
Merge branch 'USERGRID-480' into USERGRID-405
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/2af7489a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/2af7489a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/2af7489a
Branch: refs/heads/USERGRID-486
Commit: 2af7489a6f01ecf9e8dd8ce1c6ce900adcc280fa
Parents: c864ab6 d36689c
Author: Shawn Feldman <sf...@apache.org>
Authored: Fri Mar 20 15:20:33 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Fri Mar 20 15:20:33 2015 -0600
----------------------------------------------------------------------
.../batch/service/SchedulerServiceImpl.java | 17 +-
.../corepersistence/CpEntityManager.java | 41 +-
.../corepersistence/CpEntityManagerFactory.java | 50 +-
.../corepersistence/CpManagerCache.java | 6 +-
.../corepersistence/CpRelationManager.java | 19 +-
.../usergrid/corepersistence/CpSetup.java | 6 +-
.../usergrid/corepersistence/ManagerCache.java | 3 +-
.../events/EntityDeletedHandler.java | 3 +-
.../events/EntityVersionDeletedHandler.java | 4 +-
.../results/FilteringLoader.java | 3 +-
.../usergrid/persistence/EntityManager.java | 19 +-
.../persistence/EntityManagerFactory.java | 2 -
.../cassandra/EntityManagerFactoryImpl.java | 5 -
.../cassandra/EntityManagerImpl.java | 20 +-
.../org/apache/usergrid/CoreApplication.java | 24 +-
.../java/org/apache/usergrid/CoreITSetup.java | 6 +
.../org/apache/usergrid/CoreITSetupImpl.java | 27 +-
.../org/apache/usergrid/TestEntityIndex.java | 27 +
.../corepersistence/StaleIndexCleanupTest.java | 87 ++--
.../usergrid/persistence/CollectionIT.java | 80 +--
.../usergrid/persistence/CountingMutatorIT.java | 4 +-
.../persistence/EntityConnectionsIT.java | 14 +-
.../usergrid/persistence/EntityManagerIT.java | 16 +-
.../org/apache/usergrid/persistence/GeoIT.java | 26 +-
.../persistence/GeoQueryBooleanTest.java | 4 +-
.../apache/usergrid/persistence/IndexIT.java | 14 +-
.../usergrid/persistence/PathQueryIT.java | 6 +-
.../PerformanceEntityRebuildIndexTest.java | 35 +-
.../usergrid/persistence/PermissionsIT.java | 4 +-
.../cassandra/EntityManagerFactoryImplIT.java | 4 +-
.../persistence/query/CollectionIoHelper.java | 2 +-
.../persistence/query/ConnectionHelper.java | 2 +-
.../query/IntersectionTransitivePagingIT.java | 2 +-
.../query/IntersectionUnionPagingIT.java | 2 +-
.../persistence/query/IteratingQueryIT.java | 34 +-
.../resources/usergrid-custom-test.properties | 1 +
.../persistence/index/AliasedEntityIndex.java | 7 +-
.../index/ApplicationEntityIndex.java | 50 ++
.../usergrid/persistence/index/EntityIndex.java | 46 +-
.../persistence/index/EntityIndexFactory.java | 2 +-
.../persistence/index/IndexIdentifier.java | 26 +-
.../usergrid/persistence/index/SearchType.java | 49 ++
.../usergrid/persistence/index/SearchTypes.java | 14 +-
.../persistence/index/guice/IndexModule.java | 5 +-
.../impl/EsApplicationEntityIndexImpl.java | 371 ++++++++++++++
.../index/impl/EsEntityIndexBatchImpl.java | 48 +-
.../index/impl/EsEntityIndexFactoryImpl.java | 27 +-
.../index/impl/EsEntityIndexImpl.java | 490 ++++---------------
.../persistence/index/impl/EsQueryVistor.java | 88 ++--
.../persistence/index/impl/IndexingUtils.java | 140 +++---
.../index/impl/CorePerformanceIT.java | 0
.../impl/EntityConnectionIndexImplTest.java | 0
.../persistence/index/impl/EntityIndexTest.java | 181 +++----
.../index/impl/IndexLoadTestsIT.java | 12 +-
.../usergrid/rest/AbstractContextResource.java | 102 ++--
.../org/apache/usergrid/rest/IndexResource.java | 2 +-
.../rest/test/RefreshIndexResource.java | 17 +-
.../resources/usergrid-custom-test.properties | 2 +
.../org/apache/usergrid/ServiceApplication.java | 18 +-
.../apache/usergrid/management/EmailFlowIT.java | 6 +-
.../usergrid/management/OrganizationIT.java | 10 +-
.../org/apache/usergrid/management/RoleIT.java | 4 +-
.../cassandra/ManagementServiceIT.java | 22 +-
.../management/export/ExportServiceIT.java | 12 +-
.../management/importer/ImportCollectionIT.java | 15 +-
.../usergrid/services/ConnectionsServiceIT.java | 10 +-
.../usergrid/services/GroupServiceIT.java | 6 +-
.../usergrid/services/RolesServiceIT.java | 2 +-
.../usergrid/services/UsersServiceIT.java | 2 +-
.../AbstractServiceNotificationIT.java | 2 +-
.../apns/NotificationsServiceIT.java | 40 +-
.../gcm/NotificationsServiceIT.java | 4 +-
.../resources/usergrid-custom-test.properties | 2 +
73 files changed, 1309 insertions(+), 1144 deletions(-)
----------------------------------------------------------------------
[25/31] incubator-usergrid git commit: add delay on refresh for tests
Posted by to...@apache.org.
add delay on refresh for tests
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/f95a7569
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/f95a7569
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/f95a7569
Branch: refs/heads/USERGRID-486
Commit: f95a7569892adfee191b16745db32c62b9f4be52
Parents: 7002051
Author: Shawn Feldman <sf...@apache.org>
Authored: Fri Mar 20 13:37:37 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Fri Mar 20 13:37:37 2015 -0600
----------------------------------------------------------------------
.../org/apache/usergrid/CoreApplication.java | 2 +-
.../java/org/apache/usergrid/CoreITSetup.java | 2 +-
.../org/apache/usergrid/CoreITSetupImpl.java | 16 +++++++++---
.../org/apache/usergrid/TestEntityIndex.java | 27 ++++++++++++++++++++
4 files changed, 42 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f95a7569/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java b/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
index 00972ea..503da3d 100644
--- a/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
+++ b/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
@@ -217,7 +217,7 @@ public class CoreApplication implements Application, TestRule {
@Override
public void refreshIndex() {
try{
- Thread.sleep(100);
+ Thread.sleep(50);
}catch (InterruptedException ie){
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f95a7569/stack/core/src/test/java/org/apache/usergrid/CoreITSetup.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/CoreITSetup.java b/stack/core/src/test/java/org/apache/usergrid/CoreITSetup.java
index a1db845..3745b49 100644
--- a/stack/core/src/test/java/org/apache/usergrid/CoreITSetup.java
+++ b/stack/core/src/test/java/org/apache/usergrid/CoreITSetup.java
@@ -47,5 +47,5 @@ public interface CoreITSetup extends TestRule {
Injector getInjector();
- EntityIndex getEntityIndex();
+ TestEntityIndex getEntityIndex();
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f95a7569/stack/core/src/test/java/org/apache/usergrid/CoreITSetupImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/CoreITSetupImpl.java b/stack/core/src/test/java/org/apache/usergrid/CoreITSetupImpl.java
index 4996684..3cc0815 100644
--- a/stack/core/src/test/java/org/apache/usergrid/CoreITSetupImpl.java
+++ b/stack/core/src/test/java/org/apache/usergrid/CoreITSetupImpl.java
@@ -38,7 +38,7 @@ import org.apache.usergrid.utils.JsonUtils;
import com.google.inject.Injector;
-public class CoreITSetupImpl implements CoreITSetup {
+public class CoreITSetupImpl implements CoreITSetup, TestEntityIndex {
private static final Logger LOG = LoggerFactory.getLogger( CoreITSetupImpl.class );
private final Injector injector;
@@ -156,7 +156,17 @@ public class CoreITSetupImpl implements CoreITSetup {
}
@Override
- public EntityIndex getEntityIndex(){
- return getInjector().getInstance(EntityIndex.class);
+ public TestEntityIndex getEntityIndex(){
+ return this;
+ }
+
+ @Override
+ public void refresh(){
+ try{
+ Thread.sleep(50);
+ }catch (InterruptedException ie){
+
+ }
+ getEntityIndex().refresh();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f95a7569/stack/core/src/test/java/org/apache/usergrid/TestEntityIndex.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/TestEntityIndex.java b/stack/core/src/test/java/org/apache/usergrid/TestEntityIndex.java
new file mode 100644
index 0000000..cdbae3f
--- /dev/null
+++ b/stack/core/src/test/java/org/apache/usergrid/TestEntityIndex.java
@@ -0,0 +1,27 @@
+/*
+ *
+ * * 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;
+
+/**
+ * abstract refresh implementation
+ */
+public interface TestEntityIndex {
+ void refresh();
+}
[30/31] incubator-usergrid git commit: Merge remote-tracking branch
'origin/USERGRID-405' into USERGRID-486
Posted by to...@apache.org.
Merge remote-tracking branch 'origin/USERGRID-405' into USERGRID-486
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/2195e655
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/2195e655
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/2195e655
Branch: refs/heads/USERGRID-486
Commit: 2195e655c3227355cd5eece51a0b29ce729d6579
Parents: bab5ba7 2af7489
Author: Todd Nine <tn...@apigee.com>
Authored: Fri Mar 20 15:32:09 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Fri Mar 20 15:32:09 2015 -0600
----------------------------------------------------------------------
.../batch/service/SchedulerServiceImpl.java | 17 +-
.../corepersistence/CpEntityManager.java | 41 +-
.../corepersistence/CpEntityManagerFactory.java | 50 +-
.../corepersistence/CpManagerCache.java | 6 +-
.../corepersistence/CpRelationManager.java | 19 +-
.../usergrid/corepersistence/CpSetup.java | 6 +-
.../usergrid/corepersistence/ManagerCache.java | 3 +-
.../events/EntityDeletedHandler.java | 3 +-
.../events/EntityVersionDeletedHandler.java | 4 +-
.../results/FilteringLoader.java | 3 +-
.../usergrid/persistence/EntityManager.java | 19 +-
.../persistence/EntityManagerFactory.java | 2 -
.../cassandra/EntityManagerFactoryImpl.java | 5 -
.../cassandra/EntityManagerImpl.java | 20 +-
.../org/apache/usergrid/CoreApplication.java | 24 +-
.../java/org/apache/usergrid/CoreITSetup.java | 6 +
.../org/apache/usergrid/CoreITSetupImpl.java | 27 +-
.../org/apache/usergrid/TestEntityIndex.java | 27 +
.../corepersistence/StaleIndexCleanupTest.java | 87 ++--
.../usergrid/persistence/CollectionIT.java | 80 +--
.../usergrid/persistence/CountingMutatorIT.java | 4 +-
.../persistence/EntityConnectionsIT.java | 14 +-
.../usergrid/persistence/EntityManagerIT.java | 16 +-
.../org/apache/usergrid/persistence/GeoIT.java | 26 +-
.../persistence/GeoQueryBooleanTest.java | 4 +-
.../apache/usergrid/persistence/IndexIT.java | 14 +-
.../usergrid/persistence/PathQueryIT.java | 6 +-
.../PerformanceEntityRebuildIndexTest.java | 35 +-
.../usergrid/persistence/PermissionsIT.java | 4 +-
.../cassandra/EntityManagerFactoryImplIT.java | 4 +-
.../persistence/query/CollectionIoHelper.java | 2 +-
.../persistence/query/ConnectionHelper.java | 2 +-
.../query/IntersectionTransitivePagingIT.java | 2 +-
.../query/IntersectionUnionPagingIT.java | 2 +-
.../persistence/query/IteratingQueryIT.java | 34 +-
.../resources/usergrid-custom-test.properties | 1 +
.../persistence/index/AliasedEntityIndex.java | 7 +-
.../index/ApplicationEntityIndex.java | 50 ++
.../usergrid/persistence/index/EntityIndex.java | 46 +-
.../persistence/index/EntityIndexFactory.java | 2 +-
.../persistence/index/IndexIdentifier.java | 26 +-
.../usergrid/persistence/index/SearchType.java | 49 ++
.../usergrid/persistence/index/SearchTypes.java | 14 +-
.../persistence/index/guice/IndexModule.java | 5 +-
.../impl/EsApplicationEntityIndexImpl.java | 371 ++++++++++++++
.../index/impl/EsEntityIndexBatchImpl.java | 48 +-
.../index/impl/EsEntityIndexFactoryImpl.java | 27 +-
.../index/impl/EsEntityIndexImpl.java | 490 ++++---------------
.../persistence/index/impl/EsQueryVistor.java | 88 ++--
.../persistence/index/impl/IndexingUtils.java | 140 +++---
.../index/impl/CorePerformanceIT.java | 0
.../impl/EntityConnectionIndexImplTest.java | 0
.../persistence/index/impl/EntityIndexTest.java | 181 +++----
.../index/impl/IndexLoadTestsIT.java | 2 +-
.../usergrid/rest/AbstractContextResource.java | 102 ++--
.../org/apache/usergrid/rest/IndexResource.java | 2 +-
.../rest/test/RefreshIndexResource.java | 17 +-
.../resources/usergrid-custom-test.properties | 2 +
.../org/apache/usergrid/ServiceApplication.java | 18 +-
.../apache/usergrid/management/EmailFlowIT.java | 6 +-
.../usergrid/management/OrganizationIT.java | 10 +-
.../org/apache/usergrid/management/RoleIT.java | 4 +-
.../cassandra/ManagementServiceIT.java | 22 +-
.../management/export/ExportServiceIT.java | 12 +-
.../management/importer/ImportCollectionIT.java | 15 +-
.../usergrid/services/ConnectionsServiceIT.java | 10 +-
.../usergrid/services/GroupServiceIT.java | 6 +-
.../usergrid/services/RolesServiceIT.java | 2 +-
.../usergrid/services/UsersServiceIT.java | 2 +-
.../AbstractServiceNotificationIT.java | 2 +-
.../apns/NotificationsServiceIT.java | 40 +-
.../gcm/NotificationsServiceIT.java | 4 +-
.../resources/usergrid-custom-test.properties | 2 +
73 files changed, 1302 insertions(+), 1141 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2195e655/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/2195e655/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java
----------------------------------------------------------------------
diff --cc stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java
index 057c472,623f9dd..e453a53
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java
@@@ -162,80 -82,15 +162,80 @@@ public class IndexLoadTestsIT extends B
final Id applicationId = new SimpleId( applicationUUID, "application" );
final ApplicationScope scope = new ApplicationScopeImpl( applicationId );
- final EntityIndex index = entityIndexFactory.createEntityIndex( scope );
+ final IndexScope indexScope = new IndexScopeImpl( applicationId, "test" );
+
//create our index if it doesn't exist
index.initializeIndex();
- ApplicationEntityIndex applicationEntityIndex = entityIndexFactory.createApplicationEntityIndex(scope);
- final Observable<Entity> createEntities = createStreamFromWorkers( applicationEntityIndex, applicationId );
++ final Observable<Entity> createEntities = createStreamFromWorkers( index, applicationId );
+
+ //delay our verification for indexing to happen
+ final Observable<DataLoadResult> dataLoadResults =
+ createStreamFromWorkers( index, indexScope, uniqueIdentifier ).buffer( indexTestFig.getBufferSize() )
+ //perform a delay to let ES index from our batches
+ .delay( indexTestFig.getValidateWait(), TimeUnit.MILLISECONDS )
+ //do our search in parallel, otherwise this test will take far too long
+ .flatMap( entitiesToValidate -> {
+ return Observable.from( entitiesToValidate ).map( entityObservable -> {
+
+
+ final int workerIndex = ( int ) entityObservable.getField( FIELD_WORKER_INDEX ).getValue();
+ final int ordinal = ( int ) entityObservable.getField( FIELD_ORDINAL ).getValue();
+
+
+ final Timer.Context queryTimerContext = queryTimer.time();
+
+
+ //execute our search
+ final CandidateResults results = index
+ .search( indexScope, SearchTypes.fromTypes( indexScope.getName() ), Query.fromQLNullSafe(
+ "select * where " + FIELD_WORKER_INDEX + " = " + workerIndex + " AND " + FIELD_ORDINAL
+ + " = " + ordinal + " AND " + FIELD_UNIQUE_IDENTIFIER + " = '" + uniqueIdentifier
+ + "'" ) );
+
+ queryTps.mark();
+ queryTimerContext.stop();
+
+ boolean found;
+
+ if ( !results.isEmpty() && results.get( 0 ).getId().equals( entityObservable.getId() ) ) {
+ found = true;
+ }
+ else {
+ found = false;
+ }
+
+ return new EntitySearchResult( entityObservable, found );
+ } ).subscribeOn( Schedulers.io() );
+ }, indexTestFig.getConcurrentReadThreads() )
+
+ //collect all the results into a single data load result
+ .collect( () -> new DataLoadResult(), ( dataloadResult, entitySearchResult ) -> {
+ if ( entitySearchResult.found ) {
+ dataloadResult.success();
+ return;
+ }
+
+ final int ordinal = ( int ) entitySearchResult.searched.getField( FIELD_ORDINAL ).getValue();
+ final int worker = ( int ) entitySearchResult.searched.getField( FIELD_WORKER_INDEX ).getValue();
+
+ dataloadResult.failed();
- //run them all
- createEntities.toBlocking().last();
+ log.error(
+ "Could not find entity with worker {}, ordinal {}, and Id {} after waiting {} milliseconds",
+ worker, ordinal, entitySearchResult.searched.getId(), indexTestFig.getValidateWait() );
+ } );
+
+
+ //wait for processing to finish
+ final DataLoadResult result = dataLoadResults.toBlocking().last();
+
+ final long expectedCount = indexTestFig.getNumberOfRecords() * indexTestFig.getNumberOfWorkers();
+
+ assertEquals( "Excepted to have no failures", 0, result.getFailCount() );
+
+ assertEquals( "Excepted to find all records", expectedCount, result.getSuccessCount() );
}
[28/31] incubator-usergrid git commit: changing tests to iterate
fewer times
Posted by to...@apache.org.
changing tests to iterate fewer times
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/d36689ca
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/d36689ca
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/d36689ca
Branch: refs/heads/USERGRID-486
Commit: d36689ca8637514f78e0a79d95dec2a8c6641f22
Parents: 00d7aba
Author: Shawn Feldman <sf...@apache.org>
Authored: Fri Mar 20 15:17:25 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Fri Mar 20 15:17:25 2015 -0600
----------------------------------------------------------------------
.../query/IntersectionTransitivePagingIT.java | 2 +-
.../query/IntersectionUnionPagingIT.java | 2 +-
.../persistence/query/IteratingQueryIT.java | 28 ++++++++++----------
.../impl/EsApplicationEntityIndexImpl.java | 1 +
4 files changed, 17 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d36689ca/stack/core/src/test/java/org/apache/usergrid/persistence/query/IntersectionTransitivePagingIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/IntersectionTransitivePagingIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/IntersectionTransitivePagingIT.java
index af7c401..195ccdb 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/query/IntersectionTransitivePagingIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/query/IntersectionTransitivePagingIT.java
@@ -90,7 +90,7 @@ public class IntersectionTransitivePagingIT{
io.doSetup();
- int writeSize =200;
+ int writeSize = 10;
List<UUID> expected = new ArrayList<UUID>(writeSize);
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d36689ca/stack/core/src/test/java/org/apache/usergrid/persistence/query/IntersectionUnionPagingIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/IntersectionUnionPagingIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/IntersectionUnionPagingIT.java
index 146b591..b78bc46 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/query/IntersectionUnionPagingIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/query/IntersectionUnionPagingIT.java
@@ -93,7 +93,7 @@ public class IntersectionUnionPagingIT {
private Set<String> performSetup( final IoHelper io ) throws Exception {
io.doSetup();
- int size = 200;
+ int size =10;
long start = System.currentTimeMillis();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d36689ca/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java
index f4c5c0e..c73b776 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java
@@ -407,7 +407,7 @@ public class IteratingQueryIT {
protected void singleOrderByComplexIntersection( IoHelper io ) throws Exception {
- int size = 200;
+ int size = 10;
int queryLimit = Query.MAX_LIMIT;
// the number of entities that should be written including an intersection
@@ -481,7 +481,7 @@ public class IteratingQueryIT {
protected void singleOrderByNoIntersection( IoHelper io ) throws Exception {
io.doSetup();
- int size = 200;
+ int size = 5;
int queryLimit = Query.MAX_LIMIT;
// the number of entities that should be written including an intersection
@@ -529,7 +529,7 @@ public class IteratingQueryIT {
io.doSetup();
- int size = 200;
+ int size = 10;
int queryLimit = Query.MAX_LIMIT;
// the number of entities that should be written including an intersection
@@ -599,7 +599,7 @@ public class IteratingQueryIT {
io.doSetup();
- int size = 200;
+ int size = 10;
int queryLimit = Query.MAX_LIMIT;
// the number of entities that should be written including an intersection
@@ -669,7 +669,7 @@ public class IteratingQueryIT {
io.doSetup();
- int size = 200;
+ int size = 10;
int queryLimit = Query.MAX_LIMIT;
int matchMax = queryLimit - 1;
@@ -729,7 +729,7 @@ public class IteratingQueryIT {
io.doSetup();
- int size = 200;
+ int size = 10;
int queryLimit = 100;
int startValue = 100;
@@ -791,7 +791,7 @@ public class IteratingQueryIT {
io.doSetup();
- int size = 200;
+ int size = 10;
int queryLimit = 50;
int startValue = 100;
@@ -853,7 +853,7 @@ public class IteratingQueryIT {
io.doSetup();
- int size = 200;
+ int size = 10;
int queryLimit = 100;
int startValue = 100;
@@ -914,7 +914,7 @@ public class IteratingQueryIT {
io.doSetup();
- int size = 200;
+ int size = 10;
int queryLimit = 100;
int startValue = 99;
@@ -975,7 +975,7 @@ public class IteratingQueryIT {
io.doSetup();
- int size = 200;
+ int size = 10;
int queryLimit = 100;
int startValue = 50;
int endValue = 150;
@@ -1038,7 +1038,7 @@ public class IteratingQueryIT {
io.doSetup();
- int size = 200;
+ int size = 10;
int queryLimit = 100;
int startValue = 50;
int endValue = 150;
@@ -1159,7 +1159,7 @@ public class IteratingQueryIT {
io.doSetup();
- int size = 200;
+ int size = 10;
int queryLimit = Query.MAX_LIMIT;
// the number of entities that should be written including an intersection
@@ -1266,7 +1266,7 @@ public class IteratingQueryIT {
io.doSetup();
- int size = 200;
+ int size = 10;
int queryLimit = Query.MAX_LIMIT;
// the number of entities that should be written including an intersection
@@ -1378,7 +1378,7 @@ public class IteratingQueryIT {
/**
* Leave this as a large size. We have to write over 1k to reproduce this issue
*/
- int size = 200;
+ int size = 10;
long start = System.currentTimeMillis();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d36689ca/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 de29e83..56f8030 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
@@ -293,6 +293,7 @@ public class EsApplicationEntityIndexImpl implements ApplicationEntityIndex{
});
return Observable.from(response);
})
+ .doOnError( t -> logger.error("Failed on delete application",t))
.doOnCompleted(() -> timer.stop());
}
[04/31] incubator-usergrid git commit: index tests pass
Posted by to...@apache.org.
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-486
Commit: 947f063269cda28c1bb25d55d732adb5c419d5b1
Parents: 346eba9
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Mar 18 15:53:54 2015 -0600
Committer: Shawn Feldman <sf...@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();
[16/31] incubator-usergrid git commit: compiling
Posted by to...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/services/src/test/java/org/apache/usergrid/management/export/ExportServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/export/ExportServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/management/export/ExportServiceIT.java
index 3a6d8f9..a85ec53 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/export/ExportServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/export/ExportServiceIT.java
@@ -116,7 +116,7 @@ public class ExportServiceIT {
organization = newOrgAppAdminRule.getOrganizationInfo();
applicationId = newOrgAppAdminRule.getApplicationInfo().getId();
- setup.getEmf().refreshIndex();
+ setup.getEntityIndex().refresh();
}
@@ -270,7 +270,7 @@ public class ExportServiceIT {
entity[i] = em.create( "users", userProperties );
}
- em.refreshIndex();
+ setup.getEntityIndex().refresh();
//creates connections
em.createConnection( em.get( new SimpleEntityRef( "user", entity[0].getUuid() ) ), "Vibrations",
em.get( new SimpleEntityRef( "user", entity[1].getUuid() ) ) );
@@ -502,7 +502,7 @@ public class ExportServiceIT {
JobExecution jobExecution = mock( JobExecution.class );
when( jobExecution.getJobData() ).thenReturn( jobData );
- em.refreshIndex();
+ setup.getEntityIndex().refresh();
exportService.doExport( jobExecution );
@@ -573,7 +573,7 @@ public class ExportServiceIT {
JobExecution jobExecution = mock( JobExecution.class );
when( jobExecution.getJobData() ).thenReturn( jobData );
- em.refreshIndex();
+ setup.getEntityIndex().refresh();
exportService.doExport( jobExecution );
@@ -608,7 +608,7 @@ public class ExportServiceIT {
EntityManager em = setup.getEmf().getEntityManager( applicationId );
em.createApplicationCollection( "baconators" );
- em.refreshIndex();
+ setup.getEntityIndex().refresh();
//initialize user object to be posted
Map<String, Object> userProperties = null;
@@ -641,7 +641,7 @@ public class ExportServiceIT {
JobExecution jobExecution = mock( JobExecution.class );
when( jobExecution.getJobData() ).thenReturn( jobData );
- em.refreshIndex();
+ setup.getEntityIndex().refresh();
exportService.doExport( jobExecution );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java b/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java
index d8e104d..8dbc042 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/importer/ImportCollectionIT.java
@@ -239,8 +239,8 @@ public class ImportCollectionIT {
for ( Entity importedThing : importedThings ) {
emApp1.delete( importedThing );
}
- emApp1.refreshIndex();
- emApp2.refreshIndex();
+ setup.getEntityIndex().refresh();
+
importedThings = emApp2.getCollection(
appId2, "things", null, Level.ALL_PROPERTIES).getEntities();
@@ -533,7 +533,8 @@ public class ImportCollectionIT {
if ( retries >= maxRetries ) {
throw new RuntimeException("Max retries reached");
}
- em.refreshIndex();
+ setup.getEntityIndex().refresh();
+
return importEntity.getUuid();
}
@@ -547,8 +548,8 @@ public class ImportCollectionIT {
logger.debug("\n\nExporting {} collection from application {}\n",
collectionName, em.getApplication().getName() );
+ setup.getEntityIndex().refresh();
- em.refreshIndex();
ExportService exportService = setup.getExportService();
UUID exportUUID = exportService.schedule( new HashMap<String, Object>() {{
@@ -591,7 +592,8 @@ public class ImportCollectionIT {
logger.debug("\n\nCreating new {} collection in application {}\n",
type, em.getApplication().getName());
- em.refreshIndex();
+ setup.getEntityIndex().refresh();
+
List<Entity> created = new ArrayList<>();
for (int i = 0; i < 10; i++) {
@@ -612,7 +614,8 @@ public class ImportCollectionIT {
em.createConnection(new SimpleEntityRef(type, created.get(1).getUuid()),
"related", new SimpleEntityRef(type, created.get(0).getUuid()));
- em.refreshIndex();
+ setup.getEntityIndex().refresh();
+
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/services/src/test/java/org/apache/usergrid/services/ConnectionsServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/ConnectionsServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/services/ConnectionsServiceIT.java
index eb8e2dd..57853a6 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/ConnectionsServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/ConnectionsServiceIT.java
@@ -98,14 +98,16 @@ public class ConnectionsServiceIT extends AbstractServiceIT {
Entity bar = app.testRequest( ServiceAction.POST, 1, "bars" ).getEntity();
assertNotNull( bar );
- app.getEntityManager().refreshIndex();
+ setup.getEntityIndex().refresh();
- //POST users/conn-user1/user2/UUID
+
+ //POST users/conn-user1/user2/UUID
app.testRequest( ServiceAction.POST, 1, "foos", "foo", "bars", bar.getUuid() ); // should succeed
- app.getEntityManager().refreshIndex();
+ setup.getEntityIndex().refresh();
+
- try {
+ try {
//POST users/conn-user1/user2/bar
app.testRequest( ServiceAction.POST, 1, "foos", "foo", "bars", "bar" );
Assert.fail();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/services/src/test/java/org/apache/usergrid/services/GroupServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/GroupServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/services/GroupServiceIT.java
index 49ce433..8fd5da3 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/GroupServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/GroupServiceIT.java
@@ -68,13 +68,13 @@ public class GroupServiceIT extends AbstractServiceIT {
app.createGroupRole( group.getUuid(), "admin", 0 );
app.createGroupRole( group.getUuid(), "author", 0 );
- app.getEntityManager().refreshIndex();
+ setup.getEntityIndex().refresh();
+
app.grantGroupRolePermission( group.getUuid(), "admin", "users:access:*" );
app.grantGroupRolePermission( group.getUuid(), "admin", "groups:access:*" );
app.grantGroupRolePermission( group.getUuid(), "author", "assets:access:*" );
-
- app.getEntityManager().refreshIndex();
+ setup.getEntityIndex().refresh();
app.testDataRequest( ServiceAction.GET, "groups", group.getUuid(), "rolenames" );
app.testDataRequest( ServiceAction.GET, "groups", group.getUuid(), "roles", "admin", "permissions" );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/services/src/test/java/org/apache/usergrid/services/RolesServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/RolesServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/services/RolesServiceIT.java
index 46731d6..f686bb5 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/RolesServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/RolesServiceIT.java
@@ -199,7 +199,7 @@ public class RolesServiceIT extends AbstractServiceIT {
ServiceResults results = app.invokeService( ServiceAction.DELETE, "roles", "manager" );
assertEquals( 1, results.size() );
- app.getEntityManager().refreshIndex();
+ setup.getEntityIndex().refresh();
// check role is gone
Role role = app.get( app.getAlias( "role", "manager" ), Role.class );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/services/src/test/java/org/apache/usergrid/services/UsersServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/UsersServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/services/UsersServiceIT.java
index 261d3d2..94271ce 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/UsersServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/UsersServiceIT.java
@@ -37,8 +37,8 @@ public class UsersServiceIT extends AbstractServiceIT {
Entity user = app.create( "user" );
assertNotNull( user );
+ setup.getEntityIndex().refresh();
- app.getEntityManager().refreshIndex();
app.testRequest( ServiceAction.POST, 1, "users", user.getUuid(), "roles", "admin" );
app.testRequest( ServiceAction.POST, 1, "users", user.getUuid(), "roles", "manager" );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/services/src/test/java/org/apache/usergrid/services/notifications/AbstractServiceNotificationIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/notifications/AbstractServiceNotificationIT.java b/stack/services/src/test/java/org/apache/usergrid/services/notifications/AbstractServiceNotificationIT.java
index 55bb91f..d02d104 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/notifications/AbstractServiceNotificationIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/notifications/AbstractServiceNotificationIT.java
@@ -52,7 +52,7 @@ public abstract class AbstractServiceNotificationIT extends AbstractServiceIT {
long timeout = System.currentTimeMillis() + 60000;
while (System.currentTimeMillis() < timeout) {
Thread.sleep(200);
- app.getEntityManager().refreshIndex();
+ app.refreshIndex();
notification = app.getEntityManager().get(notification.getUuid(), Notification.class);
if (notification.getFinished() != null) {
return notification;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
index 95418ee..dec7295 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
@@ -103,7 +103,7 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
device2 = app.getEntityManager().get(e.getUuid(), Device.class);
Map<String, Object> props = app.getEntityManager().getProperties(e);
assertEquals(device2.getProperty(notifierKey), PUSH_TOKEN);
- app.getEntityManager().refreshIndex();
+ setup.getEntityIndex().refresh();
// create User
user1 = new User();
@@ -122,7 +122,7 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
DefaultQueueManager qm = new DefaultQueueManager();
ns.TEST_QUEUE_MANAGER = qm;
- app.getEntityManager().refreshIndex();
+ setup.getEntityIndex().refresh();
listener = new QueueListener(ns.getServiceManagerFactory(),ns.getEntityManagerFactory(), new Properties());
listener.TEST_QUEUE_MANAGER = qm;
@@ -143,7 +143,7 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
// create push notification //
- app.getEntityManager().refreshIndex();
+ setup.getEntityIndex().refresh();
// give queue manager a query for loading 100 devices from an application (why?)
app.clear();
@@ -179,7 +179,7 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
notification = scheduleNotificationAndWait(notification);
- app.getEntityManager().refreshIndex();
+ setup.getEntityIndex().refresh();
// verify Query for FINISHED state
query = new Query();
@@ -287,7 +287,7 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
.getEntity();
app.testRequest(ServiceAction.GET, 1, "notifications", e.getUuid());
- app.getEntityManager().refreshIndex();
+ setup.getEntityIndex().refresh();
Notification notification = app.getEntityManager().get(e.getUuid(),
Notification.class);
@@ -308,7 +308,7 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
Entity entity = results.getEntitiesMap().get(notification.getUuid());
assertNotNull(entity);
- app.getEntityManager().refreshIndex();
+ setup.getEntityIndex().refresh();
try {
e = app.testRequest(ServiceAction.DELETE, 1, "notifications",
@@ -469,7 +469,7 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
Entity e = app.testRequest(ServiceAction.POST, 1, "notifiers")
.getEntity();
- app.getEntityManager().refreshIndex();
+ setup.getEntityIndex().refresh();
app.testRequest(ServiceAction.GET, 1, "notifiers", "apNs2");
@@ -484,7 +484,7 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
device2.setProperty(key2, PUSH_TOKEN);
app.getEntityManager().update(device2);
- app.getEntityManager().refreshIndex();
+ setup.getEntityIndex().refresh();
// create push notification //
@@ -500,7 +500,7 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
e = app.testRequest(ServiceAction.POST, 1, "devices","notifications").getEntity();
app.testRequest(ServiceAction.GET, 1, "notifications", e.getUuid());
- app.getEntityManager().refreshIndex();
+ setup.getEntityIndex().refresh();
Notification notification = app.getEntityManager().get(e.getUuid(), Notification.class);
assertEquals(notification.getPayloads().get(notifierName), payload);
@@ -508,7 +508,7 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
// perform push //
notification = scheduleNotificationAndWait(notification);
- app.getEntityManager().refreshIndex();
+ setup.getEntityIndex().refresh();
checkReceipts(notification, 2); //the second notifier isn't associated correctly so its 3 instead of 4
}
@@ -533,7 +533,7 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
Entity e = app.testRequest(ServiceAction.POST, 1, "notifiers").getEntity();
app.testRequest(ServiceAction.GET, 1, "notifiers", nameValue);
- app.getEntityManager().refreshIndex();
+ setup.getEntityIndex().refresh();
Notifier notifier2 = app.getEntityManager().get(e.getUuid(), Notifier.class);
assertEquals(notifier2.getName(), nameValue);
@@ -544,7 +544,7 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
device1.setProperty(key2, PUSH_TOKEN);
app.getEntityManager().update(device1);
- app.getEntityManager().refreshIndex();
+ setup.getEntityIndex().refresh();
// create push notification //
@@ -560,7 +560,7 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
e = app.testRequest(ServiceAction.POST, 1,"devices",device1.getUuid(), "notifications").getEntity();
app.testRequest(ServiceAction.GET, 1, "notifications", e.getUuid());
- app.getEntityManager().refreshIndex();
+ setup.getEntityIndex().refresh();
Notification notification = app.getEntityManager().get(e.getUuid(),
Notification.class);
@@ -570,12 +570,12 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
ns.addDevice(notification, device1);
- app.getEntityManager().refreshIndex();
+ setup.getEntityIndex().refresh();
// perform push //
notification = scheduleNotificationAndWait(notification);
- app.getEntityManager().refreshIndex();
+ setup.getEntityIndex().refresh();
checkReceipts(notification, 2);
}
@@ -718,7 +718,7 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
assertEquals(user1Devices.size(),2);
// create push notification //
- app.getEntityManager().refreshIndex();
+ setup.getEntityIndex().refresh();
// give queue manager a query for loading 100 devices from an application (why?)
app.clear();
@@ -754,7 +754,7 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
notification = scheduleNotificationAndWait(notification);
- app.getEntityManager().refreshIndex();
+ setup.getEntityIndex().refresh();
// verify Query for FINISHED state
query = new Query();
@@ -784,7 +784,7 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
Entity entity = app.testRequest(ServiceAction.POST, 1, "notifiers").getEntity();
Notifier notifier = app.getEntityManager().get(entity.getUuid(), Notifier.class);
final String notifierKey = notifier.getName() + NOTIFIER_ID_POSTFIX;
- app.getEntityManager().refreshIndex();
+ setup.getEntityIndex().refresh();
// create a bunch of devices and add them to the notification
@@ -793,7 +793,7 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
app.put(notifierKey, PUSH_TOKEN);
app.put("name", "device"+i*10);
app.testRequest(ServiceAction.POST, 1, "devices").getEntity();
- app.getEntityManager().refreshIndex();
+ setup.getEntityIndex().refresh();
}
@@ -808,7 +808,7 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
// create a notification
entity = app.testRequest(ServiceAction.POST, 1, "devices","notifications").getEntity();
app.testRequest(ServiceAction.GET, 1, "notifications", entity.getUuid());
- app.getEntityManager().refreshIndex();
+ setup.getEntityIndex().refresh();
final Notification notification = (Notification) entity.toTypedEntity();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java
index ee00c88..c0c86ad 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/notifications/gcm/NotificationsServiceIT.java
@@ -196,13 +196,13 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
Entity e = app.testRequest(ServiceAction.POST, 1,"users",user.getUuid(), "notifications").getEntity();
app.testRequest(ServiceAction.GET, 1, "notifications", e.getUuid());
- app.getEntityManager().refreshIndex();
+ setup.getEntityIndex().refresh();
// perform push //
Notification notification = app.getEntityManager().get(e.getUuid(), Notification.class);
notification = scheduleNotificationAndWait(notification);
- app.getEntityManager().refreshIndex();
+ setup.getEntityIndex().refresh();
checkReceipts(notification, 1);
}
[12/31] incubator-usergrid git commit: tests passing in queryindex
Posted by to...@apache.org.
tests passing in queryindex
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/532b6620
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/532b6620
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/532b6620
Branch: refs/heads/USERGRID-486
Commit: 532b6620cd9769f39d5ba1cb119f66819fab5df1
Parents: 5f75292
Author: Shawn Feldman <sf...@apache.org>
Authored: Thu Mar 19 14:08:47 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Thu Mar 19 14:08:47 2015 -0600
----------------------------------------------------------------------
.../test/java/org/apache/usergrid/CoreApplication.java | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/532b6620/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java b/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
index a48ce4e..99c4654 100644
--- a/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
+++ b/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
@@ -145,11 +145,11 @@ public class CoreApplication implements Application, TestRule {
protected void after( Description description ) {
LOG.info( "Test {}: finish with application", description.getDisplayName() );
- try {
- setup.getEmf().getEntityManager(id).deleteIndex().get();
- }catch (Exception ee){
- throw new RuntimeException(ee);
- }
+// try {
+// setup.getEmf().getEntityManager(id).().get();
+// }catch (Exception ee){
+// throw new RuntimeException(ee);
+// }
}
[20/31] incubator-usergrid git commit: merge from 405
Posted by to...@apache.org.
merge from 405
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/75d61b27
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/75d61b27
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/75d61b27
Branch: refs/heads/USERGRID-486
Commit: 75d61b270efca8cd7182543a977deafcd136582c
Parents: f7e78f4 dcf4693
Author: Shawn Feldman <sf...@apache.org>
Authored: Fri Mar 20 08:44:34 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Fri Mar 20 08:44:34 2015 -0600
----------------------------------------------------------------------
stack/core/pom.xml | 26 +-
.../corepersistence/CpEntityManager.java | 2 +-
.../corepersistence/CpEntityManagerFactory.java | 7 +-
.../corepersistence/CpRelationManager.java | 24 +-
.../usergrid/corepersistence/CpWalker.java | 81 ++---
.../events/EntityVersionDeletedHandler.java | 71 ++--
.../migration/EntityTypeMappingMigration.java | 41 +--
.../persistence/ObservableIterator.java | 1 +
.../migration/EntityTypeMappingMigrationIT.java | 2 +-
.../PerformanceEntityRebuildIndexTest.java | 4 +-
stack/corepersistence/collection/pom.xml | 14 +-
.../impl/EntityCollectionManagerImpl.java | 10 +-
.../collection/impl/EntityDeletedTask.java | 20 +-
.../impl/EntityVersionCleanupTask.java | 40 +--
.../impl/EntityVersionCreatedTask.java | 26 +-
.../mvcc/stage/write/WriteCommit.java | 2 +-
.../mvcc/stage/write/WriteUniqueVerify.java | 8 +-
.../MvccEntitySerializationStrategyImpl.java | 92 ++---
.../MvccEntitySerializationStrategyV3Impl.java | 94 ++---
.../UniqueValueSerializationStrategyImpl.java | 8 -
.../migration/MvccEntityDataMigrationImpl.java | 171 ++++------
.../collection/util/EntityUtils.java | 72 ----
.../mvcc/stage/AbstractEntityStageTest.java | 2 +-
.../mvcc/stage/AbstractMvccEntityStageTest.java | 2 +-
.../mvcc/stage/TestEntityGenerator.java | 2 +-
.../persistence/collection/rx/ParallelTest.java | 10 +-
...MvccEntitySerializationStrategyImplTest.java | 4 +-
...ccEntitySerializationStrategyV1ImplTest.java | 4 +-
...ccEntitySerializationStrategyV2ImplTest.java | 2 +-
.../impl/SerializationComparison.java | 4 +-
...ctMvccEntityDataMigrationV1ToV3ImplTest.java | 2 +-
.../collection/util/InvalidEntityGenerator.java | 1 +
stack/corepersistence/common/pom.xml | 15 +-
.../astyanax/MultiKeyColumnNameIterator.java | 4 +-
.../MultiKeyColumnNameIteratorTest.java | 187 +++++-----
.../astyanax/MultiRowColumnIteratorTest.java | 50 ++-
.../graph/impl/GraphManagerImpl.java | 6 +-
.../graph/impl/stage/EdgeMetaRepairImpl.java | 2 +
.../impl/stage/NodeDeleteListenerImpl.java | 2 +-
.../impl/migration/EdgeDataMigrationImpl.java | 87 +++--
.../persistence/graph/GraphManagerIT.java | 17 +-
.../graph/GraphManagerShardConsistencyIT.java | 2 +-
.../usergrid/persistence/graph/SimpleTest.java | 12 +-
.../migration/EdgeDataMigrationImplTest.java | 2 +-
stack/corepersistence/model/pom.xml | 1 -
.../persistence/model/util/EntityUtils.java | 72 ++++
stack/corepersistence/pom.xml | 8 +-
stack/corepersistence/queryindex/pom.xml | 6 -
.../persistence/index/query/EntityResults.java | 108 ------
.../persistence/index/query/Results.java | 148 --------
.../persistence/index/utils/ListUtils.java | 6 +-
.../persistence/index/guice/IndexTestFig.java | 57 ++++
.../index/guice/TestIndexModule.java | 8 +-
.../index/impl/CorePerformanceIT.java | 339 -------------------
.../impl/EntityConnectionIndexImplTest.java | 302 -----------------
.../persistence/index/impl/EntityIndexTest.java | 32 +-
.../index/impl/IndexLoadTestsIT.java | 138 ++++++++
stack/pom.xml | 8 +-
.../management/importer/ImportServiceImpl.java | 34 +-
.../impl/ApplicationQueueManagerImpl.java | 195 +++++------
.../setup/ConcurrentProcessSingleton.java | 16 +-
61 files changed, 899 insertions(+), 1814 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/75d61b27/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/75d61b27/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/75d61b27/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
----------------------------------------------------------------------
diff --cc stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
index df01c47,c4e970d..f505fa3
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
@@@ -1055,9 -1058,9 +1055,9 @@@ public class CpRelationManager implemen
cpHeadEntity.getId(), edgeType, targetEntity.getId(), System.currentTimeMillis() );
GraphManager gm = managerCache.getGraphManager( applicationScope );
- gm.writeEdge( edge ).toBlockingObservable().last();
+ gm.writeEdge( edge ).toBlocking().last();
- EntityIndex ei = managerCache.getEntityIndex( applicationScope );
+ ApplicationEntityIndex ei = managerCache.getEntityIndex( applicationScope );
EntityIndexBatch batch = ei.createBatch();
// Index the new connection in app|source|type context
@@@ -1287,9 -1290,9 +1287,9 @@@
System.currentTimeMillis() );
GraphManager gm = managerCache.getGraphManager( applicationScope );
- gm.deleteEdge( edge ).toBlockingObservable().last();
+ gm.deleteEdge( edge ).toBlocking().last();
- final EntityIndex ei = managerCache.getEntityIndex( applicationScope );
+ final ApplicationEntityIndex ei = managerCache.getEntityIndex( applicationScope );
final EntityIndexBatch batch = ei.createBatch();
// Deindex the connection in app|source|type context
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/75d61b27/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionDeletedHandler.java
----------------------------------------------------------------------
diff --cc stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionDeletedHandler.java
index ece7562,23f5a32..f0dd136
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionDeletedHandler.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionDeletedHandler.java
@@@ -17,21 -17,18 +17,20 @@@
*/
package org.apache.usergrid.corepersistence.events;
- import com.google.inject.Inject;
- import com.google.inject.Singleton;
import java.util.List;
+
+ import org.slf4j.Logger;
+ import org.slf4j.LoggerFactory;
+
import org.apache.usergrid.corepersistence.CpEntityManagerFactory;
- import static org.apache.usergrid.corepersistence.CoreModule.EVENTS_DISABLED;
import org.apache.usergrid.persistence.EntityManagerFactory;
import org.apache.usergrid.persistence.collection.CollectionScope;
- import org.apache.usergrid.persistence.collection.MvccEntity;
import org.apache.usergrid.persistence.collection.MvccLogEntry;
import org.apache.usergrid.persistence.collection.event.EntityVersionDeleted;
+import org.apache.usergrid.persistence.collection.serialization.SerializationFig;
+import org.apache.usergrid.persistence.index.ApplicationEntityIndex;
import org.apache.usergrid.persistence.index.EntityIndex;
- import org.apache.usergrid.persistence.index.EntityIndexBatch;
import org.apache.usergrid.persistence.index.IndexScope;
import org.apache.usergrid.persistence.index.impl.IndexScopeImpl;
import org.apache.usergrid.persistence.model.entity.Id;
@@@ -84,28 -78,21 +80,21 @@@ public class EntityVersionDeletedHandle
} );
}
- CpEntityManagerFactory cpemf = (CpEntityManagerFactory)emf;
+ CpEntityManagerFactory cpemf = ( CpEntityManagerFactory ) emf;
- final EntityIndex ei = cpemf.getManagerCache().getEntityIndex( scope );
+ final ApplicationEntityIndex ei = cpemf.getManagerCache().getEntityIndex( scope );
- final IndexScope indexScope = new IndexScopeImpl(
- new SimpleId(scope.getOwner().getUuid(), scope.getOwner().getType()),
- scope.getName()
- );
-
- Observable.from( entityVersions )
- .collect( ei.createBatch(), new Action2<EntityIndexBatch, MvccLogEntry>() {
- @Override
- public void call( final EntityIndexBatch entityIndexBatch, final MvccLogEntry mvccLogEntry ) {
- entityIndexBatch.deindex( indexScope, mvccLogEntry.getEntityId(), mvccLogEntry.getVersion() );
- }
- } ).doOnNext( new Action1<EntityIndexBatch>() {
- @Override
- public void call( final EntityIndexBatch entityIndexBatch ) {
+ final IndexScope indexScope =
+ new IndexScopeImpl( new SimpleId( scope.getOwner().getUuid(), scope.getOwner().getType() ),
+ scope.getName() );
+
+ //create our batch, and then collect all of them into a single batch
+ Observable.from( entityVersions ).collect( () -> ei.createBatch(), ( entityIndexBatch, mvccLogEntry ) -> {
+ entityIndexBatch.deindex( indexScope, mvccLogEntry.getEntityId(), mvccLogEntry.getVersion() );
+ } )
+ //after our batch is collected, execute it
+ .doOnNext( entityIndexBatch -> {
entityIndexBatch.execute();
- }
- } ).toBlocking().last();
+ } ).toBlocking().last();
}
-
-
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/75d61b27/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/75d61b27/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/CorePerformanceIT.java
----------------------------------------------------------------------
diff --cc stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/CorePerformanceIT.java
index 303d481,0000000..e69de29
mode 100644,000000..100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/CorePerformanceIT.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/CorePerformanceIT.java
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/75d61b27/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityConnectionIndexImplTest.java
----------------------------------------------------------------------
diff --cc stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityConnectionIndexImplTest.java
index 8e8d6c0,0000000..e69de29
mode 100644,000000..100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityConnectionIndexImplTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityConnectionIndexImplTest.java
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/75d61b27/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
----------------------------------------------------------------------
[27/31] incubator-usergrid git commit: add delete back
Posted by to...@apache.org.
add delete back
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/00d7abaf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/00d7abaf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/00d7abaf
Branch: refs/heads/USERGRID-486
Commit: 00d7abafe7303511649ce96835906cdfabcf1f61
Parents: cf80b8b
Author: Shawn Feldman <sf...@apache.org>
Authored: Fri Mar 20 15:02:02 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Fri Mar 20 15:02:02 2015 -0600
----------------------------------------------------------------------
.../persistence/index/AliasedEntityIndex.java | 7 ++++++-
.../index/impl/EsApplicationEntityIndexImpl.java | 7 +------
.../persistence/index/impl/EsEntityIndexImpl.java | 16 +++++++++-------
.../test/resources/usergrid-custom-test.properties | 2 ++
.../test/resources/usergrid-custom-test.properties | 2 ++
5 files changed, 20 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/00d7abaf/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/AliasedEntityIndex.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/AliasedEntityIndex.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/AliasedEntityIndex.java
index 118b7ad..62235b8 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/AliasedEntityIndex.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/AliasedEntityIndex.java
@@ -33,12 +33,17 @@ public interface AliasedEntityIndex extends EntityIndex{
public String[] getIndexes(final AliasType aliasType);
/**
+ * get all unique indexes
+ * @return
+ */
+ public String[] getUniqueIndexes();
+
+ /**
* Add alias to index, will remove old index from write alias
* @param indexSuffix must be different than current index
*/
public void addAlias(final String indexSuffix);
-
/**
* type of alias
*/
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/00d7abaf/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 3633c5b..de29e83 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
@@ -270,12 +270,7 @@ public class EsApplicationEntityIndexImpl implements ApplicationEntityIndex{
deleteApplicationMeter.mark();
String idString = IndexingUtils.idString(applicationScope.getApplication());
final TermQueryBuilder tqb = QueryBuilders.termQuery(APPLICATION_ID_FIELDNAME, idString);
- Set<String> indexSet = new HashSet<>();
- List<String> reads = Arrays.asList(entityIndex.getIndexes(AliasedEntityIndex.AliasType.Read));
- List<String> writes = Arrays.asList(entityIndex.getIndexes(AliasedEntityIndex.AliasType.Write));
- indexSet.addAll(reads);
- indexSet.addAll(writes);
- String[] indexes = indexSet.toArray(new String[0]);
+ final String[] indexes = entityIndex.getUniqueIndexes();
Timer.Context timer = deleteApplicationTimer.time();
//Added For Graphite Metrics
return Observable.from(indexes)
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/00d7abaf/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 7029bba..4290f23 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
@@ -340,12 +340,7 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
public boolean doOp() {
try {
- Set<String> indexSet = new HashSet<>();
- List<String> reads = Arrays.asList(getIndexes(AliasType.Read));
- List<String> writes = Arrays.asList(getIndexes(AliasType.Write));
- indexSet.addAll(reads);
- indexSet.addAll(writes);
- String[] indexes = indexSet.toArray(new String[0]);
+ final String[] indexes = getUniqueIndexes();
if ( indexes.length == 0 ) {
logger.debug( "Not refreshing indexes. none found");
@@ -378,7 +373,14 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
doInRetry(retryOperation);
}
-
+ public String[] getUniqueIndexes() {
+ Set<String> indexSet = new HashSet<>();
+ List<String> reads = Arrays.asList(getIndexes(AliasType.Read));
+ List<String> writes = Arrays.asList(getIndexes(AliasType.Write));
+ indexSet.addAll(reads);
+ indexSet.addAll(writes);
+ return indexSet.toArray(new String[0]);
+ }
/**
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/00d7abaf/stack/rest/src/test/resources/usergrid-custom-test.properties
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/resources/usergrid-custom-test.properties b/stack/rest/src/test/resources/usergrid-custom-test.properties
index d726f2b..34ce9c2 100644
--- a/stack/rest/src/test/resources/usergrid-custom-test.properties
+++ b/stack/rest/src/test/resources/usergrid-custom-test.properties
@@ -41,4 +41,6 @@ usergrid.sysadmin.login.name=superuser
usergrid.sysadmin.login.email=superuser@usergrid.com
usergrid.sysadmin.login.password=superpassword
usergrid.sysadmin.login.allowed=true
+elasticsearch.index_prefix=rest_tests
+
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/00d7abaf/stack/services/src/test/resources/usergrid-custom-test.properties
----------------------------------------------------------------------
diff --git a/stack/services/src/test/resources/usergrid-custom-test.properties b/stack/services/src/test/resources/usergrid-custom-test.properties
index 1ddfead..2663f2a 100644
--- a/stack/services/src/test/resources/usergrid-custom-test.properties
+++ b/stack/services/src/test/resources/usergrid-custom-test.properties
@@ -29,4 +29,6 @@ hystrix.threadpool.graph_async.coreSize=50
usergrid.scheduler.job.timeout=300000
usergrid.notifications.listener.run=false
+elasticsearch.index_prefix=services_tests
+
[31/31] incubator-usergrid git commit: Updated load tests to match
new index structure
Posted by to...@apache.org.
Updated load tests to match new index structure
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/a40fb8d5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/a40fb8d5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/a40fb8d5
Branch: refs/heads/USERGRID-486
Commit: a40fb8d573d2caa779422d60acd2fec041ad6580
Parents: 2195e65
Author: Todd Nine <tn...@apigee.com>
Authored: Fri Mar 20 15:32:28 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Fri Mar 20 15:32:28 2015 -0600
----------------------------------------------------------------------
.../index/impl/IndexLoadTestsIT.java | 23 +++++++++++++-------
1 file changed, 15 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a40fb8d5/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java
index e453a53..bfd713e 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java
@@ -37,6 +37,7 @@ import org.apache.usergrid.persistence.core.metrics.MetricsFactory;
import org.apache.usergrid.persistence.core.scope.ApplicationScope;
import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
import org.apache.usergrid.persistence.core.test.UseModules;
+import org.apache.usergrid.persistence.index.ApplicationEntityIndex;
import org.apache.usergrid.persistence.index.EntityIndex;
import org.apache.usergrid.persistence.index.EntityIndexFactory;
import org.apache.usergrid.persistence.index.IndexScope;
@@ -103,6 +104,9 @@ public class IndexLoadTestsIT extends BaseIT {
public EntityIndexFactory entityIndexFactory;
@Inject
+ public EntityIndex entityIndex;
+
+ @Inject
public MetricsFactory metricsFactory;
private Meter batchWriteTPS;
@@ -115,7 +119,10 @@ public class IndexLoadTestsIT extends BaseIT {
@Before
- public void setupMeters() {
+ public void setupIndexAndMeters() {
+
+ entityIndex.initializeIndex();
+
batchWriteTPS = metricsFactory.getMeter( IndexLoadTestsIT.class, "write.tps" );
batchWriteTimer = metricsFactory.getTimer( IndexLoadTestsIT.class, "write.timer" );
@@ -165,14 +172,14 @@ public class IndexLoadTestsIT extends BaseIT {
final IndexScope indexScope = new IndexScopeImpl( applicationId, "test" );
- //create our index if it doesn't exist
- index.initializeIndex();
+ final ApplicationEntityIndex appEntityIndex = entityIndexFactory.createApplicationEntityIndex( scope );
+
- final Observable<Entity> createEntities = createStreamFromWorkers( index, applicationId );
+ //create our index if it doesn't exist
//delay our verification for indexing to happen
final Observable<DataLoadResult> dataLoadResults =
- createStreamFromWorkers( index, indexScope, uniqueIdentifier ).buffer( indexTestFig.getBufferSize() )
+ createStreamFromWorkers( appEntityIndex, indexScope, uniqueIdentifier ).buffer( indexTestFig.getBufferSize() )
//perform a delay to let ES index from our batches
.delay( indexTestFig.getValidateWait(), TimeUnit.MILLISECONDS )
//do our search in parallel, otherwise this test will take far too long
@@ -188,7 +195,7 @@ public class IndexLoadTestsIT extends BaseIT {
//execute our search
- final CandidateResults results = index
+ final CandidateResults results = appEntityIndex
.search( indexScope, SearchTypes.fromTypes( indexScope.getName() ), Query.fromQLNullSafe(
"select * where " + FIELD_WORKER_INDEX + " = " + workerIndex + " AND " + FIELD_ORDINAL
+ " = " + ordinal + " AND " + FIELD_UNIQUE_IDENTIFIER + " = '" + uniqueIdentifier
@@ -239,7 +246,7 @@ public class IndexLoadTestsIT extends BaseIT {
}
- public Observable<Entity> createStreamFromWorkers( final EntityIndex entityIndex, final IndexScope indexScope,
+ public Observable<Entity> createStreamFromWorkers( final ApplicationEntityIndex entityIndex, final IndexScope indexScope,
final String uniqueIdentifier ) {
//create a sequence of observables. Each index will be it's own worker thread using the Schedulers.newthread()
@@ -249,7 +256,7 @@ public class IndexLoadTestsIT extends BaseIT {
}
- private Observable<Entity> createWriteObservable( final EntityIndex entityIndex, final IndexScope indexScope,
+ private Observable<Entity> createWriteObservable( final ApplicationEntityIndex entityIndex, final IndexScope indexScope,
final String uniqueIdentifier, final int workerIndex ) {
[05/31] incubator-usergrid git commit: Merge branch 'two-dot-o' into
USERGRID-480
Posted by to...@apache.org.
Merge branch 'two-dot-o' into USERGRID-480
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/89f2c2f1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/89f2c2f1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/89f2c2f1
Branch: refs/heads/USERGRID-486
Commit: 89f2c2f1f5b9cc864bfe047a6813dd15dae01483
Parents: 947f063 eb0c689
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Mar 18 15:54:17 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Mar 18 15:54:17 2015 -0600
----------------------------------------------------------------------
.../index/impl/EsEntityIndexImpl.java | 83 +++++++++-----------
1 file changed, 35 insertions(+), 48 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/89f2c2f1/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
----------------------------------------------------------------------
[26/31] incubator-usergrid git commit: add delete back
Posted by to...@apache.org.
add delete back
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/cf80b8bb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/cf80b8bb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/cf80b8bb
Branch: refs/heads/USERGRID-486
Commit: cf80b8bb1196d0fedb0d3b7e7b758a4b17113794
Parents: f95a756
Author: Shawn Feldman <sf...@apache.org>
Authored: Fri Mar 20 14:55:27 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Fri Mar 20 14:55:27 2015 -0600
----------------------------------------------------------------------
.../corepersistence/StaleIndexCleanupTest.java | 67 ++++++----------
.../usergrid/persistence/CollectionIT.java | 10 +--
.../PerformanceEntityRebuildIndexTest.java | 71 ++++++++---------
.../index/ApplicationEntityIndex.java | 8 ++
.../impl/EsApplicationEntityIndexImpl.java | 80 ++++++++++++++++++--
.../index/impl/EsEntityIndexBatchImpl.java | 7 +-
.../index/impl/EsEntityIndexImpl.java | 12 ++-
7 files changed, 159 insertions(+), 96 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf80b8bb/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
index 6ba1353..e27420b 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
@@ -94,40 +94,35 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
public void testUpdateVersioning() throws Exception {
// turn off post processing stuff that cleans up stale entities
- System.setProperty( EVENTS_DISABLED, "true" );
+ System.setProperty(EVENTS_DISABLED, "true");
final EntityManager em = app.getEntityManager();
- Entity thing = em.create( "thing", new HashMap<String, Object>() {{
- put( "name", "thing1" );
- }} );
+ Entity thing = em.create("thing", new HashMap<String, Object>() {{
+ put("name", "thing1");
+ }});
app.refreshIndex();
- assertEquals( 1, queryCollectionCp( "things", "thing", "select *" ).size() );
+ assertEquals(1, queryCollectionCp("things", "thing", "select *").size());
- org.apache.usergrid.persistence.model.entity.Entity cpEntity = getCpEntity( thing );
+ org.apache.usergrid.persistence.model.entity.Entity cpEntity = getCpEntity(thing);
UUID oldVersion = cpEntity.getVersion();
- em.updateProperties( thing, new HashMap<String, Object>() {{
- put( "stuff", "widget" );
- }} );
+ em.updateProperties(thing, new HashMap<String, Object>() {{
+ put("stuff", "widget");
+ }});
app.refreshIndex();
- org.apache.usergrid.persistence.model.entity.Entity cpUpdated = getCpEntity( thing );
- assertEquals( "widget", cpUpdated.getField( "stuff" ).getValue() );
+ org.apache.usergrid.persistence.model.entity.Entity cpUpdated = getCpEntity(thing);
+ assertEquals("widget", cpUpdated.getField("stuff").getValue());
UUID newVersion = cpUpdated.getVersion();
- assertTrue( "New version is greater than old",
- UUIDComparator.staticCompare( newVersion, oldVersion ) > 0 );
+ assertTrue("New version is greater than old",
+ UUIDComparator.staticCompare(newVersion, oldVersion) > 0);
CandidateResults results;
- do{
- results = queryCollectionCp( "things", "thing", "select *" );
- if(results.size()!=2){
- Thread.sleep(200);
- }
- }while(results.size()!=2);
- assertEquals( 2, results.size() );
+ results = queryCollectionCp("things", "thing", "select *");
+ assertEquals(2, results.size());
}
@@ -160,37 +155,28 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
CandidateResults candidateResults = null;
- do{
- candidateResults = queryCollectionCp("things", "thing", "select * order by ordinal desc");
- if(candidateResults.size()!=2){
- Thread.sleep(200);
- }
- }while(candidateResults.size()<2);
+
+ candidateResults = queryCollectionCp("things", "thing", "select * order by ordinal desc");
+ if(candidateResults.size()!=2){
+ Thread.sleep(200);
+ }
+
assertEquals(2, candidateResults.size());
//now run enable events and ensure we clean up
System.setProperty(EVENTS_DISABLED, "false");
- Results results = null;
- do{
- results = queryCollectionEm("things", "select * order by ordinal desc");;
- if(results.size()!=1){
- Thread.sleep(200);
- }
- }while(results.size()<1);
+ Results results = queryCollectionEm("things", "select * order by ordinal desc");
+
assertEquals( 1, results.size() );
assertEquals(1, results.getEntities().get( 0 ).getProperty( "ordinal" ));
app.refreshIndex();
//ensure it's actually gone
- do{
- candidateResults = queryCollectionCp( "things", "thing", "select * order by ordinal desc" );
- if(candidateResults.size()!=1){
- Thread.sleep(200);
- }
- }while(candidateResults.size()!=1);
+ candidateResults = queryCollectionCp( "things", "thing", "select * order by ordinal desc" );
+
assertEquals(1, candidateResults.size());
assertEquals(newVersion, candidateResults.get(0).getVersion());
@@ -397,7 +383,6 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
//trigger the repair
results = queryCollectionEm("things", "select *");
crs = queryCollectionCp("things", "thing", "select *");
- Thread.sleep(100);
} while ((results.hasCursor() || crs.size() > 0) && count++ < 2000 );
@@ -462,8 +447,6 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
// wait for indexes to be cleared for the deleted entities
count = 0;
do {
- queryCollectionEm("dogs", "select *");
- Thread.sleep(100);
crs = queryCollectionCp("dogs", "dog", "select *");
} while ( crs.size() != numEntities && count++ < 15 );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf80b8bb/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java
index b1a75d9..3e1db1b 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java
@@ -1231,13 +1231,9 @@ public class CollectionIT extends AbstractCoreIT {
query.addEqualityFilter( "rootprop1", "simpleprop" );
Entity entity;
Results results;
- do {
- results = em.searchCollection(em.getApplicationRef(), "tests", query);
- entity = results.getEntitiesMap().get(saved.getUuid());
- if (entity == null) {
- Thread.sleep(200);
- }
- }while(entity == null);
+ results = em.searchCollection(em.getApplicationRef(), "tests", query);
+ entity = results.getEntitiesMap().get(saved.getUuid());
+
assertNotNull( entity );
// query on the nested int value
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf80b8bb/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
index af31b51..4b284df 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
@@ -175,19 +175,19 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
// ----------------- delete the system and application indexes
logger.debug("Deleting app index index");
-// //deleteIndex( CpNamingUtils.SYSTEM_APP_ID );
-// deleteIndex( em.getApplicationId() );
-//
-// // ----------------- test that we can read them, should fail
-//
-// logger.debug("Reading data, should fail this time ");
-// try {
-// readData( em, "testTypes", entityCount, 0 );
-// fail("should have failed to read data");
-//
-// } catch (Exception expected) {}
+ //deleteIndex( CpNamingUtils.SYSTEM_APP_ID );
+ deleteIndex( em.getApplicationId() );
+
+ // ----------------- test that we can read them, should fail
- // ----------------- rebuild index for catherders only
+ logger.debug("Reading data, should fail this time ");
+ try {
+ readData( em, "testTypes", entityCount, 0 );
+ fail("should have failed to read data");
+
+ } catch (Exception expected) {}
+
+// ----------------- rebuild index for catherders only
logger.debug("Preparing to rebuild all indexes");;
@@ -313,20 +313,20 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
logger.debug("Deleting app index and system app index");
-// deleteIndex( em.getApplicationId() );
+ deleteIndex( em.getApplicationId() );
//
// // deleting sytem app index will interfere with other concurrently running tests
-// //deleteIndex( CpNamingUtils.SYSTEM_APP_ID );
+ //deleteIndex( CpNamingUtils.SYSTEM_APP_ID );
//
//
// // ----------------- test that we can read them, should fail
//
-// logger.debug("Reading data, should fail this time ");
-// try {
-// readData( em, "testTypes", entityCount, 3 );
-// fail("should have failed to read data");
-//
-// } catch (Exception expected) {}
+ logger.debug("Reading data, should fail this time ");
+ try {
+ readData( em, "testTypes", entityCount, 3 );
+ fail("should have failed to read data");
+
+ } catch (Exception expected) {}
// ----------------- rebuild index
@@ -371,23 +371,26 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
// ----------------- test that we can read them
+ Thread.sleep(2000);
readData( em, "testTypes", entityCount, 3 );
}
-// /**
-// * Delete index for all applications, just need the one to get started.
-// */
-// private void deleteIndex( UUID appUuid ) {
-//
-// Injector injector = SpringResource.getInstance().getBean( Injector.class );
-// EntityIndexFactory eif = injector.getInstance( EntityIndexFactory.class );
-//
-// Id appId = new SimpleId( appUuid, "application");
-// ApplicationScope scope = new ApplicationScopeImpl( appId );
-// ApplicationEntityIndex ei = eif.createApplicationEntityIndex(scope);
-// EsEntityIndexImpl eeii = (EsEntityIndexImpl)ei;
-//
-// }
+ /**
+ * Delete index for all applications, just need the one to get started.
+ */
+ private void deleteIndex( UUID appUuid ) {
+
+ Injector injector = SpringResource.getInstance().getBean( Injector.class );
+ EntityIndexFactory eif = injector.getInstance( EntityIndexFactory.class );
+
+ Id appId = new SimpleId( appUuid, "application");
+ ApplicationScope scope = new ApplicationScopeImpl( appId );
+ ApplicationEntityIndex ei = eif.createApplicationEntityIndex(scope);
+
+ ei.deleteApplication().toBlocking().lastOrDefault(null);
+ app.refreshIndex();
+
+ }
private int readData( EntityManager em,
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf80b8bb/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/ApplicationEntityIndex.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/ApplicationEntityIndex.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/ApplicationEntityIndex.java
index fab32b3..34967bd 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/ApplicationEntityIndex.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/ApplicationEntityIndex.java
@@ -19,8 +19,10 @@
*/
package org.apache.usergrid.persistence.index;
+import com.google.common.util.concurrent.ListenableFuture;
import org.apache.usergrid.persistence.index.query.CandidateResults;
import org.apache.usergrid.persistence.index.query.Query;
+import org.elasticsearch.action.ListenableActionFuture;
import rx.Observable;
/**
@@ -39,4 +41,10 @@ public interface ApplicationEntityIndex {
* Execute query in Usergrid syntax.
*/
public CandidateResults search(final IndexScope indexScope, final SearchTypes searchType, Query query );
+
+ /**
+ * delete all application records
+ * @return
+ */
+ public Observable deleteApplication();
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf80b8bb/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 c83fe41..3633c5b 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
@@ -22,6 +22,8 @@ package org.apache.usergrid.persistence.index.impl;
import com.codahale.metrics.Meter;
import com.codahale.metrics.Timer;
import com.google.common.base.Preconditions;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import org.apache.commons.lang3.ArrayUtils;
@@ -62,9 +64,7 @@ import rx.Observable;
import rx.functions.Action1;
import rx.schedulers.Schedulers;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
+import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -89,6 +89,8 @@ public class EsApplicationEntityIndexImpl implements ApplicationEntityIndex{
private final IndexFig indexFig;
private final EsProvider esProvider;
private final IndexIdentifier.IndexAlias alias;
+ private final Timer deleteApplicationTimer;
+ private final Meter deleteApplicationMeter;
private FailureMonitor failureMonitor;
private final int cursorTimeout;
@Inject
@@ -109,11 +111,16 @@ public class EsApplicationEntityIndexImpl implements ApplicationEntityIndex{
mapManager = mapManagerFactory.createMapManager(mapScope);
this.searchTimer = metricsFactory
- .getTimer(EsEntityIndexImpl.class, "search.timer");
+ .getTimer(EsApplicationEntityIndexImpl.class, "search.timer");
this.cursorTimer = metricsFactory
- .getTimer(EsEntityIndexImpl.class, "search.cursor.timer");
+ .getTimer(EsApplicationEntityIndexImpl.class, "search.cursor.timer");
this.cursorTimeout = config.getQueryCursorTimeout();
+ this.deleteApplicationTimer = metricsFactory
+ .getTimer(EsApplicationEntityIndexImpl.class, "delete.application");
+ this.deleteApplicationMeter = metricsFactory
+ .getMeter(EsApplicationEntityIndexImpl.class, "delete.application.meter");
+
this.alias = indexIdentifier.getAlias();
}
@@ -256,6 +263,69 @@ public class EsApplicationEntityIndexImpl implements ApplicationEntityIndex{
return parseResults(searchResponse, query);
}
+ /**
+ * Completely delete an index.
+ */
+ public Observable deleteApplication() {
+ deleteApplicationMeter.mark();
+ String idString = IndexingUtils.idString(applicationScope.getApplication());
+ final TermQueryBuilder tqb = QueryBuilders.termQuery(APPLICATION_ID_FIELDNAME, idString);
+ Set<String> indexSet = new HashSet<>();
+ List<String> reads = Arrays.asList(entityIndex.getIndexes(AliasedEntityIndex.AliasType.Read));
+ List<String> writes = Arrays.asList(entityIndex.getIndexes(AliasedEntityIndex.AliasType.Write));
+ indexSet.addAll(reads);
+ indexSet.addAll(writes);
+ String[] indexes = indexSet.toArray(new String[0]);
+ Timer.Context timer = deleteApplicationTimer.time();
+ //Added For Graphite Metrics
+ return Observable.from(indexes)
+ .flatMap(index -> {
+
+ final ListenableActionFuture<DeleteByQueryResponse> response = esProvider.getClient()
+ .prepareDeleteByQuery(alias.getWriteAlias()).setQuery(tqb).execute();
+
+ response.addListener(new ActionListener<DeleteByQueryResponse>() {
+
+ @Override
+ public void onResponse(DeleteByQueryResponse response) {
+ checkDeleteByQueryResponse(tqb, response);
+ }
+
+ @Override
+ public void onFailure(Throwable e) {
+ logger.error("failed on delete index", e);
+ }
+ });
+ return Observable.from(response);
+ })
+ .doOnCompleted(() -> timer.stop());
+ }
+
+ /**
+ * Validate the response doesn't contain errors, if it does, fail fast at the first error we encounter
+ */
+ private void checkDeleteByQueryResponse(
+ final QueryBuilder query, final DeleteByQueryResponse response ) {
+
+ for ( IndexDeleteByQueryResponse indexDeleteByQueryResponse : response ) {
+ final ShardOperationFailedException[] failures = indexDeleteByQueryResponse.getFailures();
+
+ for ( ShardOperationFailedException failedException : failures ) {
+ logger.error( String.format("Unable to delete by query %s. "
+ + "Failed with code %d and reason %s on shard %s in index %s",
+ query.toString(),
+ failedException.status().getStatus(),
+ failedException.reason(),
+ failedException.shardId(),
+ failedException.index() )
+ );
+ }
+
+ }
+ }
+
+
+
private CandidateResults parseResults( final SearchResponse searchResponse, final Query query ) {
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf80b8bb/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 38bf381..7b0c3b5 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
@@ -95,9 +95,7 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
ValidationUtils.verifyEntityWrite( entity );
ValidationUtils.verifyVersion( entity.getVersion() );
//add app id for indexing
- entity.setField(
- new StringField(APPLICATION_ID_FIELDNAME, IndexingUtils.idString(applicationScope.getApplication()))
- );
+
final String context = createContextName(applicationScope,indexScope);
if ( log.isDebugEnabled() ) {
@@ -110,7 +108,8 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
ValidationUtils.verifyEntityWrite( entity );
Map<String, Object> entityAsMap = entityToMap( entity, context );
-
+ //add app id
+ entityAsMap.put(APPLICATION_ID_FIELDNAME, idString(applicationScope.getApplication()));
// need prefix here because we index UUIDs as strings
// let caller add these fields if needed
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf80b8bb/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 8bdd663..7029bba 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
@@ -64,6 +64,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
+import java.util.*;
/**
@@ -338,10 +339,13 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
@Override
public boolean doOp() {
try {
- String[] indexes = ArrayUtils.addAll(
- getIndexes(AliasType.Read),
- getIndexes(AliasType.Write)
- );
+
+ Set<String> indexSet = new HashSet<>();
+ List<String> reads = Arrays.asList(getIndexes(AliasType.Read));
+ List<String> writes = Arrays.asList(getIndexes(AliasType.Write));
+ indexSet.addAll(reads);
+ indexSet.addAll(writes);
+ String[] indexes = indexSet.toArray(new String[0]);
if ( indexes.length == 0 ) {
logger.debug( "Not refreshing indexes. none found");
[07/31] incubator-usergrid git commit: add delete back
Posted by to...@apache.org.
add delete back
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/a87ca3a1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/a87ca3a1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/a87ca3a1
Branch: refs/heads/USERGRID-486
Commit: a87ca3a1968d29170314dc8a67ae108862fb04e6
Parents: 65c20a1
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Mar 18 17:45:35 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Mar 18 17:45:35 2015 -0600
----------------------------------------------------------------------
.../corepersistence/CpEntityManager.java | 5 +-
.../usergrid/persistence/EntityManager.java | 3 +-
.../cassandra/EntityManagerImpl.java | 4 +-
.../org/apache/usergrid/CoreApplication.java | 7 ++-
.../usergrid/persistence/index/EntityIndex.java | 2 +-
.../index/impl/EsEntityIndexBatchImpl.java | 5 +-
.../index/impl/EsEntityIndexImpl.java | 59 +++++++++++++++-----
.../persistence/index/impl/IndexingUtils.java | 25 +++++----
8 files changed, 80 insertions(+), 30 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a87ca3a1/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
index 789e640..8787410 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
@@ -36,6 +36,7 @@ import java.util.UUID;
import com.codahale.metrics.Meter;
import org.apache.usergrid.persistence.collection.FieldSet;
import org.apache.usergrid.persistence.core.future.BetterFuture;
+import org.elasticsearch.action.ListenableActionFuture;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.Assert;
@@ -2899,9 +2900,9 @@ public class CpEntityManager implements EntityManager {
ei.initializeIndex();
}
- public void deleteIndex(){
+ public ListenableActionFuture deleteIndex(){
EntityIndex ei = managerCache.getEntityIndex( applicationScope );
- ei.deleteIndex();
+ return ei.deleteIndex();
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a87ca3a1/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
index 65fac8d..2a951aa 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
@@ -34,6 +34,7 @@ import org.apache.usergrid.persistence.entities.Role;
import org.apache.usergrid.persistence.index.query.CounterResolution;
import org.apache.usergrid.persistence.index.query.Identifier;
import org.apache.usergrid.persistence.index.query.Query.Level;
+import org.elasticsearch.action.ListenableActionFuture;
/**
@@ -696,7 +697,7 @@ public interface EntityManager {
/**
* Create the index, should ONLY ever be called the first time an application is created
*/
- void deleteIndex();
+ ListenableActionFuture deleteIndex();
public void init( EntityManagerFactory emf, UUID applicationId);
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a87ca3a1/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
index ce45ebf..966a601 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
@@ -36,6 +36,7 @@ import java.util.UUID;
import javax.annotation.Resource;
+import org.elasticsearch.action.ListenableActionFuture;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
@@ -2895,8 +2896,9 @@ public class EntityManagerImpl implements EntityManager {
@Override
- public void deleteIndex() {
+ public ListenableActionFuture deleteIndex() {
//no op
+ return null;
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a87ca3a1/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java b/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
index 99cfcf5..a48ce4e 100644
--- a/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
+++ b/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
@@ -20,6 +20,7 @@ package org.apache.usergrid;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.UUID;
+import java.util.concurrent.ExecutionException;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
@@ -144,7 +145,11 @@ public class CoreApplication implements Application, TestRule {
protected void after( Description description ) {
LOG.info( "Test {}: finish with application", description.getDisplayName() );
- setup.getEmf().getEntityManager( id ).deleteIndex();
+ try {
+ setup.getEmf().getEntityManager(id).deleteIndex().get();
+ }catch (Exception ee){
+ throw new RuntimeException(ee);
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a87ca3a1/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 c8840fa..db4b50d 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
@@ -45,7 +45,7 @@ public interface EntityIndex {
/**
* Delete the index from ES
*/
- public void deleteIndex();
+ public ListenableActionFuture deleteIndex();
/**
* Create an index and add to alias, will create alias and remove any old index from write alias if alias already exists
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a87ca3a1/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 c0d0d1e..d7b1f9c 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
@@ -94,7 +94,10 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
IndexValidationUtils.validateIndexScope( indexScope );
ValidationUtils.verifyEntityWrite( entity );
ValidationUtils.verifyVersion( entity.getVersion() );
-
+ //add app id for indexing
+ entity.setField(
+ new StringField(APPLICATION_ID_FIELDNAME,IndexingUtils.idString(applicationScope.getApplication()))
+ );
final String context = createContextName(indexScope);
if ( log.isDebugEnabled() ) {
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a87ca3a1/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 5e23d67..0ecc31b 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
@@ -265,7 +265,7 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
String indexName = indexIdentifier.getIndex(indexSuffix);
final AdminClient adminClient = esProvider.getClient().admin();
- String[] indexNames = getIndexesFromEs( AliasType.Write );
+ String[] indexNames = getIndexesFromEs(AliasType.Write);
final IndicesAliasesRequestBuilder aliasesRequestBuilder = adminClient.indices().prepareAliases();
@@ -280,7 +280,7 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
// add read alias
aliasesRequestBuilder.addAlias( indexName, alias.getReadAlias());
- logger.info( "Created new read Alias Name [{}] on Index [{}]", alias.getReadAlias(), indexName);
+ logger.info("Created new read Alias Name [{}] on Index [{}]", alias.getReadAlias(), indexName);
//add write alias
@@ -623,23 +623,56 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
/**
* Completely delete an index.
*/
- public void deleteIndex() {
- AdminClient adminClient = esProvider.getClient().admin();
+ public ListenableActionFuture deleteIndex() {
+ String idString = IndexingUtils.idString(applicationScope.getApplication());
- DeleteIndexResponse response = adminClient.indices()
- .prepareDelete( indexIdentifier.getIndex(null) ).get();
+ final TermQueryBuilder tqb = QueryBuilders.termQuery(APPLICATION_ID_FIELDNAME, idString);
+
+ //Added For Graphite Metrics
+
+ final ListenableActionFuture<DeleteByQueryResponse> response = esProvider.getClient()
+ .prepareDeleteByQuery( alias.getWriteAlias() ).setQuery( tqb ).execute();
+
+ response.addListener(new ActionListener<DeleteByQueryResponse>() {
+
+ @Override
+ public void onResponse(DeleteByQueryResponse response) {
+ checkDeleteByQueryResponse(tqb,response);
+ }
+
+
+ @Override
+ public void onFailure(Throwable e) {
+ logger.error("failed on delete index",e);
+ }
+ });
+ return response;
+ }
+ /**
+ * Validate the response doesn't contain errors, if it does, fail fast at the first error we encounter
+ */
+ private void checkDeleteByQueryResponse(
+ final QueryBuilder query, final DeleteByQueryResponse response ) {
+
+ for ( IndexDeleteByQueryResponse indexDeleteByQueryResponse : response ) {
+ final ShardOperationFailedException[] failures = indexDeleteByQueryResponse.getFailures();
+
+ for ( ShardOperationFailedException failedException : failures ) {
+ logger.error( String.format("Unable to delete by query %s. "
+ + "Failed with code %d and reason %s on shard %s in index %s",
+ query.toString(),
+ failedException.status().getStatus(),
+ failedException.reason(),
+ failedException.shardId(),
+ failedException.index() )
+ );
+ }
- if ( response.isAcknowledged() ) {
- logger.info( "Deleted index: read {} write {}", alias.getReadAlias(), alias.getWriteAlias());
- //invlaidate the alias
- aliasCache.invalidate(alias);
- }
- else {
- logger.info( "Failed to delete index: read {} write {}", alias.getReadAlias(), alias.getWriteAlias());
}
}
+
/**
* Do the retry operation
*/
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a87ca3a1/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 aa6d0f3..d49d8cc 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
@@ -50,6 +50,7 @@ public class IndexingUtils {
//
// Reserved UG fields.
//
+ public static final String APPLICATION_ID_FIELDNAME = "ug_applicationId";
public static final String ENTITY_CONTEXT_FIELDNAME = "ug_context";
@@ -162,23 +163,27 @@ public class IndexingUtils {
.endObject()
.startArray("dynamic_templates")
// we need most specific mappings first since it's a stop on match algorithm
- .startObject()
- .startObject("entity_id_template")
- .field("match", IndexingUtils.ENTITYID_ID_FIELDNAME)
+ .startObject()
+ .startObject("application_id_template")
+ .field("match", APPLICATION_ID_FIELDNAME)
.field("match_mapping_type", "string")
- .startObject("mapping").field("type", "string")
- .field("index", "not_analyzed")
- .endObject()
- .endObject()
+ .startObject("mapping").field("type", "string").field("index", "not_analyzed").field(DOC_VALUES_KEY, true).endObject()
+ .endObject()
+ .endObject()
+ .startObject()
+ .startObject("entity_id_template")
+ .field("match", IndexingUtils.ENTITYID_ID_FIELDNAME)
+ .field("match_mapping_type", "string")
+ .startObject("mapping").field("type", "string").field("index", "not_analyzed").field(DOC_VALUES_KEY, true).endObject()
.endObject()
+ .endObject()
.startObject()
.startObject("entity_context_template")
.field("match", IndexingUtils.ENTITY_CONTEXT_FIELDNAME)
.field("match_mapping_type", "string")
.startObject("mapping")
- .field("type", "string")
- .field("index", "not_analyzed")
+ .field("type", "string").field("index", "not_analyzed").field(DOC_VALUES_KEY, true)
.endObject()
.endObject()
.endObject()
@@ -187,7 +192,7 @@ public class IndexingUtils {
.startObject("entity_version_template")
.field("match", IndexingUtils.ENTITY_VERSION_FIELDNAME)
.field("match_mapping_type", "string")
- .startObject("mapping").field("type", "long").field(DOC_VALUES_KEY, true)
+ .startObject("mapping").field("type", "long").field("index", "not_analyzed").field(DOC_VALUES_KEY, true)
.endObject()
.endObject()
.endObject()
[03/31] incubator-usergrid git commit: single index
Posted by to...@apache.org.
single index
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/346eba98
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/346eba98
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/346eba98
Branch: refs/heads/USERGRID-486
Commit: 346eba98ed1080940730fb617951e6172a1683bb
Parents: 1199e47
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Mar 18 14:56:36 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Mar 18 14:56:36 2015 -0600
----------------------------------------------------------------------
.../corepersistence/CpEntityManagerFactory.java | 3 -
.../usergrid/persistence/index/EntityIndex.java | 21 ------
.../persistence/index/IndexIdentifier.java | 16 +----
.../usergrid/persistence/index/SearchTypes.java | 14 +++-
.../index/impl/EsEntityIndexBatchImpl.java | 6 +-
.../index/impl/EsEntityIndexImpl.java | 69 +++++---------------
.../persistence/index/impl/IndexingUtils.java | 8 ++-
.../persistence/index/impl/EntityIndexTest.java | 65 +-----------------
8 files changed, 42 insertions(+), 160 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/346eba98/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 fe4d828..2bdb54c 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
@@ -292,7 +292,6 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
EntityManager appEm = getEntityManager( applicationId );
appEm.create( applicationId, TYPE_APPLICATION, properties );
- appEm.createIndex();
appEm.resetRoles();
appEm.refreshIndex();
@@ -706,7 +705,6 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
EntityManager em = getEntityManager( appId );
//explicitly invoke create index, we don't know if it exists or not in ES during a rebuild.
- em.createIndex();
Application app = em.getApplication();
em.reindex( po );
@@ -760,7 +758,6 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
EntityManager em = getEntityManager( appId );
//explicitly invoke create index, we don't know if it exists or not in ES during a rebuild.
- em.createIndex();
Application app = em.getApplication();
em.reindexCollection( po, collectionName, reverse );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/346eba98/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 aa2bf8e..c8840fa 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
@@ -68,27 +68,6 @@ public interface EntityIndex {
public CandidateResults search(final IndexScope indexScope, final SearchTypes searchType, Query query );
/**
- * Get the candidate results of all versions of the entity for this id.
- * @param indexScope The scope of the index to search in
- * @param id The id to search within.
- */
- public CandidateResults getEntityVersions(final IndexScope indexScope, final Id id);
-
-// /**
-// * Create a delete method that deletes by Id. This will delete all documents from ES with the same entity Id,
-// * effectively removing all versions of an entity from all index scopes
-// * @param entityId The entityId to remove
-// */
-// public Future deleteAllVersionsOfEntity(final Id entityId );
-//
-// /**
-// * Takes all the previous versions of the current entity and deletes all previous versions
-// * @param id The id to remove
-// * @param version The max version to retain
-// */
-// public Future deletePreviousVersions(final Id id, final UUID version);
-
- /**
* Refresh the index.
*/
public void refresh();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/346eba98/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexIdentifier.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexIdentifier.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexIdentifier.java
index f23dc36..8465d84 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexIdentifier.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexIdentifier.java
@@ -40,7 +40,7 @@ public class IndexIdentifier{
* @return
*/
public IndexAlias getAlias() {
- return new IndexAlias(config,getIndexBase());
+ return new IndexAlias(config,config.getIndexPrefix());
}
/**
@@ -50,22 +50,12 @@ public class IndexIdentifier{
*/
public String getIndex(String suffix) {
if (suffix != null) {
- return getIndexBase() + "_" + suffix;
+ return config.getIndexPrefix() + "_" + suffix;
} else {
- return getIndexBase();
+ return config.getIndexPrefix();
}
}
- /**
- * returns the base name for index which will be used to add an alias and index
- * @return
- */
- private String getIndexBase() {
- StringBuilder sb = new StringBuilder();
- sb.append(config.getIndexPrefix()).append(IndexingUtils.SEPARATOR);
- IndexingUtils.idString(sb, applicationScope.getApplication());
- return sb.toString();
- }
public class IndexAlias{
private final String readAlias;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/346eba98/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/SearchTypes.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/SearchTypes.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/SearchTypes.java
index 35b3a8b..1a97da2 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/SearchTypes.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/SearchTypes.java
@@ -20,6 +20,10 @@ 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;
+
import java.util.Arrays;
@@ -37,11 +41,17 @@ public class SearchTypes {
private SearchTypes( final String... types ) {this.types = types;}
- public String[] getTypeNames() {
- return types;
+ public String[] getTypeNames(ApplicationScope applicationScope) {
+ String[] typeNames = new String[types.length];
+ int i =0 ;
+ for(String type : types){
+ typeNames[i++] = IndexingUtils.getType(applicationScope,type);
+ }
+ return typeNames;
}
+
/**
* Create a search that will search on the specified types
* @param types
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/346eba98/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 23b9041..977fe51 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,9 +117,7 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
String indexId = createIndexDocId( entity, context );
log.debug( "Indexing entity documentId {} data {} ", indexId, entityAsMap );
- final String entityType = entity.getId().getType();
-
-
+ final String entityType =IndexingUtils.getType(applicationScope, entity.getId());
container.addIndexRequest(new IndexRequest(alias.getWriteAlias(), entityType, indexId, entityAsMap));
return this;
@@ -134,7 +132,7 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
ValidationUtils.verifyVersion( version );
final String context = createContextName(indexScope);
- final String entityType = id.getType();
+ final String entityType =IndexingUtils.getType(applicationScope, id);
final String indexId = createIndexDocId( id, version, context );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/346eba98/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 598c8d9..110b320 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
@@ -233,21 +233,21 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
//ONLY add the alias if we create the index, otherwise we're going to overwrite production settings
- /**
- * DO NOT MOVE THIS LINE OF CODE UNLESS YOU REALLY KNOW WHAT YOU'RE DOING!!!!
- */
-
- //We do NOT want to create an alias if the index already exists, we'll overwrite the indexes that
- //may have been set via other administrative endpoint
-
- addAlias(normalizedSuffix);
-
- testNewIndex();
logger.info("Created new Index Name [{}] ACK=[{}]", indexName, cir.isAcknowledged());
} catch (IndexAlreadyExistsException e) {
logger.info("Index Name [{}] already exists", indexName);
}
+ /**
+ * DO NOT MOVE THIS LINE OF CODE UNLESS YOU REALLY KNOW WHAT YOU'RE DOING!!!!
+ */
+
+ //We do NOT want to create an alias if the index already exists, we'll overwrite the indexes that
+ //may have been set via other administrative endpoint
+
+ addAlias(normalizedSuffix);
+
+ testNewIndex();
@@ -347,7 +347,7 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
// to receive documents. Occasionally we see errors.
// See this post: http://s.apache.org/index-missing-exception
- logger.debug( "Testing new index name: read {} write {}", alias.getReadAlias(), alias.getWriteAlias());
+ logger.debug("Testing new index name: read {} write {}", alias.getReadAlias(), alias.getWriteAlias());
final RetryOperation retryOperation = new RetryOperation() {
@Override
@@ -410,12 +410,9 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
public CandidateResults search(final IndexScope indexScope, final SearchTypes searchTypes,
final Query query ) {
- final String context = IndexingUtils.createContextName( indexScope );
- final String[] entityTypes = searchTypes.getTypeNames();
-
+ final String context = IndexingUtils.createContextName(indexScope);
+ final String[] entityTypes = searchTypes.getTypeNames(applicationScope);
QueryBuilder qb = query.createQueryBuilder(context);
-
-
SearchResponse searchResponse;
if ( query.getCursor() == null ) {
@@ -635,42 +632,6 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
}
- @Override
- public CandidateResults getEntityVersions( final IndexScope scope, final Id id ) {
-
- //since we don't have paging inputs, there's no point in executing a query for paging.
-
- final String context = IndexingUtils.createContextName(scope);
- final SearchTypes searchTypes = SearchTypes.fromTypes(id.getType());
-
- final QueryBuilder queryBuilder =
- QueryBuilders.termQuery( IndexingUtils.ENTITY_CONTEXT_FIELDNAME, context );
-
- final SearchRequestBuilder srb = esProvider.getClient().prepareSearch( alias.getReadAlias() )
- .setTypes(searchTypes.getTypeNames())
- .setScroll(cursorTimeout + "m")
- .setQuery(queryBuilder);
-
- final SearchResponse searchResponse;
- try {
- //Added For Graphite Metrics
- Timer.Context timeEntityIndex = getVersionsTimer.time();
- searchResponse = srb.execute().actionGet();
- timeEntityIndex.stop();
- }
- catch ( Throwable t ) {
- logger.error( "Unable to communicate with elasticsearch" );
- failureMonitor.fail( "Unable to execute batch", t);
- throw t;
- }
-
-
- failureMonitor.success();
-
- return parseResults(searchResponse, new Query());
- }
-
-
/**
* Completely delete an index.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/346eba98/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 0df3a2c..aa6d0f3 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
@@ -230,7 +230,7 @@ public class IndexingUtils {
.startObject("template__long")
.field("match", LONG_PREFIX + "*")
.field("match_mapping_type", "long")
- .startObject("mapping").field("type", "long").field("index","not_analyzed").field(DOC_VALUES_KEY, true).endObject()
+ .startObject("mapping").field("type", "long").field("index", "not_analyzed").field(DOC_VALUES_KEY, true).endObject()
.endObject()
.endObject()
@@ -249,5 +249,11 @@ public class IndexingUtils {
}
+ public static String getType(ApplicationScope applicationScope, Id entityId) {
+ return getType(applicationScope,entityId.getType());
+ }
+ public static String getType(ApplicationScope applicationScope, String type) {
+ return idString(applicationScope.getApplication()) + SEPARATOR + type;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/346eba98/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 ca9bf79..22ca51f 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
@@ -271,7 +271,7 @@ public class EntityIndexTest extends BaseIT {
ObjectMapper mapper = new ObjectMapper();
List<Object> sampleJson = mapper.readValue( is, new TypeReference<List<Object>>() {} );
EntityIndexBatch batch = entityIndex.createBatch();
- insertJsonBlob(sampleJson,batch, entityType, indexScope, max,startIndex);
+ insertJsonBlob(sampleJson,batch, entityType, indexScope, max, startIndex);
batch.execute().get();
entityIndex.refresh();
}
@@ -297,10 +297,9 @@ public class EntityIndexTest extends BaseIT {
EntityUtils.setVersion(entity, UUIDGenerator.newTimeUUID());
entity.setField(new UUIDField(IndexingUtils.ENTITYID_ID_FIELDNAME, UUID.randomUUID()));
batch.index(indexScope, entity);
+ batch.execute().get();
+
- if(count %1000 == 0){
- batch.execute().get();
- }
if ( ++count > max ) {
break;
}
@@ -370,7 +369,6 @@ public class EntityIndexTest extends BaseIT {
private void testQueries(final IndexScope scope, SearchTypes searchTypes, final EntityIndex entityIndex ) {
-
testQuery(scope, searchTypes, entityIndex, "name = 'Morgan Pierce'", 1 );
testQuery(scope, searchTypes, entityIndex, "name = 'morgan pierce'", 1 );
@@ -443,63 +441,6 @@ public class EntityIndexTest extends BaseIT {
}
}
-
- @Test
- public void getEntityVersions() throws Exception {
-
- Id appId = new SimpleId( "application" );
- Id ownerId = new SimpleId( "owner" );
-
- ApplicationScope applicationScope = new ApplicationScopeImpl( appId );
-
- IndexScope indexScope = new IndexScopeImpl( ownerId, "users" );
-
-
-
- EntityIndex entityIndex = eif.createEntityIndex( applicationScope );
- entityIndex.initializeIndex();
-
- final String middleName = "middleName" + UUIDUtils.newTimeUUID();
- Map<String, Object> properties = new LinkedHashMap<String, Object>();
- properties.put( "username", "edanuff" );
- properties.put( "email", "ed@anuff.com" );
- properties.put( "middlename", middleName );
-
- Map entityMap = new HashMap() {{
- put( "username", "edanuff" );
- put( "email", "ed@anuff.com" );
- put( "middlename", middleName );
- }};
-
- final Id userId = new SimpleId("user");
-
- Entity user = EntityIndexMapUtils.fromMap( entityMap );
- EntityUtils.setId( user, userId);
- EntityUtils.setVersion( user, UUIDGenerator.newTimeUUID() );
-
-
- final EntityIndexBatch batch = entityIndex.createBatch();
- user.setField(new UUIDField(IndexingUtils.ENTITYID_ID_FIELDNAME, UUID.randomUUID()));
-
- batch.index( indexScope, user );
-
- user.setField( new StringField( "address1", "1782 address st" ) );
- batch.index( indexScope, user );
- user.setField( new StringField( "address2", "apt 508" ) );
- batch.index( indexScope, user );
- user.setField( new StringField( "address3", "apt 508" ) );
- batch.index( indexScope, user);
- batch.execute().get();
- entityIndex.refresh();
-
- CandidateResults results = entityIndex.getEntityVersions(indexScope, user.getId() );
-
- assertEquals(1, results.size());
- assertEquals( results.get( 0 ).getId(), user.getId() );
- assertEquals( results.get(0).getVersion(), user.getVersion());
- }
-
-
@Test
public void deleteVerification() throws Throwable {
[08/31] incubator-usergrid git commit: add delete back
Posted by to...@apache.org.
add delete back
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/5ea81945
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/5ea81945
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/5ea81945
Branch: refs/heads/USERGRID-486
Commit: 5ea81945bb821e136eb7c7fdf46e5393d7acfbd6
Parents: a87ca3a
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Mar 18 17:46:01 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Mar 18 17:46:01 2015 -0600
----------------------------------------------------------------------
.../apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java | 2 ++
1 file changed, 2 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5ea81945/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 0ecc31b..f22016e 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
@@ -624,6 +624,8 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
* Completely delete an index.
*/
public ListenableActionFuture deleteIndex() {
+ //TODO: add timer
+ //TODO: add all indexes
String idString = IndexingUtils.idString(applicationScope.getApplication());
final TermQueryBuilder tqb = QueryBuilders.termQuery(APPLICATION_ID_FIELDNAME, idString);
[23/31] incubator-usergrid git commit: Merge branch 'USERGRID-405' of
https://git-wip-us.apache.org/repos/asf/incubator-usergrid into USERGRID-480
Posted by to...@apache.org.
Merge branch 'USERGRID-405' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into USERGRID-480
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/e64e15f1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/e64e15f1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/e64e15f1
Branch: refs/heads/USERGRID-486
Commit: e64e15f1c5221762e2aac8350dc23dc0c79e075a
Parents: 9800b23 c864ab6
Author: Shawn Feldman <sf...@apache.org>
Authored: Fri Mar 20 11:32:05 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Fri Mar 20 11:32:05 2015 -0600
----------------------------------------------------------------------
stack/core/pom.xml | 13 +++++++------
.../java/org/apache/usergrid/persistence/GeoIT.java | 2 +-
stack/pom.xml | 2 +-
3 files changed, 9 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e64e15f1/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
----------------------------------------------------------------------
[17/31] incubator-usergrid git commit: compiling
Posted by to...@apache.org.
compiling
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/d6bcf4bf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/d6bcf4bf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/d6bcf4bf
Branch: refs/heads/USERGRID-486
Commit: d6bcf4bf3c31e8b06af175302f7795674579fc31
Parents: 1dd6ead
Author: Shawn Feldman <sf...@apache.org>
Authored: Thu Mar 19 19:00:00 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Thu Mar 19 19:00:00 2015 -0600
----------------------------------------------------------------------
.../batch/service/SchedulerServiceImpl.java | 17 +++-
.../corepersistence/CpEntityManager.java | 7 --
.../corepersistence/CpEntityManagerFactory.java | 8 +-
.../usergrid/persistence/EntityManager.java | 6 --
.../persistence/EntityManagerFactory.java | 2 -
.../cassandra/EntityManagerFactoryImpl.java | 5 -
.../cassandra/EntityManagerImpl.java | 5 -
.../org/apache/usergrid/CoreApplication.java | 11 +-
.../java/org/apache/usergrid/CoreITSetup.java | 6 ++
.../org/apache/usergrid/CoreITSetupImpl.java | 14 +++
.../corepersistence/StaleIndexCleanupTest.java | 26 ++---
.../usergrid/persistence/CollectionIT.java | 72 ++++++-------
.../usergrid/persistence/CountingMutatorIT.java | 4 +-
.../persistence/EntityConnectionsIT.java | 14 +--
.../usergrid/persistence/EntityManagerIT.java | 16 +--
.../org/apache/usergrid/persistence/GeoIT.java | 26 ++---
.../persistence/GeoQueryBooleanTest.java | 4 +-
.../apache/usergrid/persistence/IndexIT.java | 14 +--
.../usergrid/persistence/PathQueryIT.java | 6 +-
.../PerformanceEntityRebuildIndexTest.java | 12 +--
.../usergrid/persistence/PermissionsIT.java | 4 +-
.../cassandra/EntityManagerFactoryImplIT.java | 4 +-
.../persistence/query/CollectionIoHelper.java | 2 +-
.../persistence/query/ConnectionHelper.java | 2 +-
.../persistence/query/IteratingQueryIT.java | 6 +-
.../impl/EsApplicationEntityIndexImpl.java | 2 +-
.../index/impl/EsEntityIndexImpl.java | 3 +-
.../usergrid/rest/AbstractContextResource.java | 102 +++++++++++--------
.../org/apache/usergrid/rest/IndexResource.java | 2 +-
.../rest/test/RefreshIndexResource.java | 17 ++--
.../org/apache/usergrid/ServiceApplication.java | 18 ++--
.../apache/usergrid/management/EmailFlowIT.java | 6 +-
.../usergrid/management/OrganizationIT.java | 10 +-
.../org/apache/usergrid/management/RoleIT.java | 4 +-
.../cassandra/ManagementServiceIT.java | 22 ++--
.../management/export/ExportServiceIT.java | 12 +--
.../management/importer/ImportCollectionIT.java | 15 +--
.../usergrid/services/ConnectionsServiceIT.java | 10 +-
.../usergrid/services/GroupServiceIT.java | 6 +-
.../usergrid/services/RolesServiceIT.java | 2 +-
.../usergrid/services/UsersServiceIT.java | 2 +-
.../AbstractServiceNotificationIT.java | 2 +-
.../apns/NotificationsServiceIT.java | 40 ++++----
.../gcm/NotificationsServiceIT.java | 4 +-
44 files changed, 300 insertions(+), 272 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/main/java/org/apache/usergrid/batch/service/SchedulerServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/batch/service/SchedulerServiceImpl.java b/stack/core/src/main/java/org/apache/usergrid/batch/service/SchedulerServiceImpl.java
index 3547ee6..6e6564e 100644
--- a/stack/core/src/main/java/org/apache/usergrid/batch/service/SchedulerServiceImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/batch/service/SchedulerServiceImpl.java
@@ -22,6 +22,7 @@ import java.util.List;
import java.util.UUID;
+import com.google.inject.Injector;
import org.apache.usergrid.batch.JobExecution;
import org.apache.usergrid.batch.JobExecution.Status;
import org.apache.usergrid.batch.JobRuntime;
@@ -35,6 +36,7 @@ import org.apache.usergrid.mq.QueueQuery;
import org.apache.usergrid.mq.QueueResults;
import org.apache.usergrid.persistence.EntityManager;
import org.apache.usergrid.persistence.EntityManagerFactory;
+import org.apache.usergrid.persistence.index.EntityIndex;
import org.apache.usergrid.persistence.index.query.Query;
import org.apache.usergrid.persistence.Results;
import org.apache.usergrid.persistence.Schema;
@@ -49,7 +51,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
/**
- * Should be referenced by services as a SchedulerService instance. Only the internal job
+ * Should be referenced by services as a SchedulerService instance. Only the internal job
* runtime should refer to this as a JobAccessor
*/
public class SchedulerServiceImpl implements SchedulerService, JobAccessor, JobRuntimeService {
@@ -74,6 +76,8 @@ public class SchedulerServiceImpl implements SchedulerService, JobAccessor, JobR
/** Timeout for how long to set the transaction timeout from the queue. Default is 30000 */
private long jobTimeout = 30000;
+ private Injector injector;
+ private EntityIndex entityIndex;
/**
@@ -141,7 +145,7 @@ public class SchedulerServiceImpl implements SchedulerService, JobAccessor, JobR
*/
try {
LOG.debug( "deleteJob {}", jobId );
- getEm().delete( new SimpleEntityRef(
+ getEm().delete( new SimpleEntityRef(
Schema.getDefaultSchema().getEntityType(JobData.class), jobId ) );
}
catch ( Exception e ) {
@@ -319,7 +323,7 @@ public class SchedulerServiceImpl implements SchedulerService, JobAccessor, JobR
String jobDataType = Schema.getDefaultSchema().getEntityType(JobData.class);
- return getEm().searchCollection( getEm().getApplicationRef(),
+ return getEm().searchCollection( getEm().getApplicationRef(),
Schema.defaultCollectionName(jobDataType), query );
}
@@ -400,6 +404,10 @@ public class SchedulerServiceImpl implements SchedulerService, JobAccessor, JobR
this.emf = emf;
}
+ /** @param injector **/
+ @Autowired
+ public void setInjector( Injector injector){ this.injector = injector;}
+
/** @param jobQueueName the jobQueueName to set */
public void setJobQueueName( String jobQueueName ) {
@@ -428,6 +436,7 @@ public class SchedulerServiceImpl implements SchedulerService, JobAccessor, JobR
@Override
public void refreshIndex() {
- getEm().refreshIndex();
+ this.entityIndex = entityIndex == null ? injector.getInstance(EntityIndex.class) : entityIndex;
+ entityIndex.refresh();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
index 64f0257..e33bb22 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
@@ -2884,13 +2884,6 @@ public class CpEntityManager implements EntityManager {
}
- @Override
- public void refreshIndex() {
-
- // refresh factory indexes
- emf.refreshIndex();
- }
-
@Override
public void flushManagerCaches() {
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/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 134886f..c77f6ed 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
@@ -309,7 +309,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
catch ( DuplicateUniquePropertyExistsException e ) {
throw new ApplicationAlreadyExistsException( appName );
}
- em.refreshIndex();
+ entityIndex.refresh();
// create application entity
if ( properties == null ) {
@@ -320,7 +320,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
appEm.create(applicationId, TYPE_APPLICATION, properties);
appEm.resetRoles();
- appEm.refreshIndex();
+ entityIndex.refresh();
logger.info("Initialized application {}", appName );
@@ -358,7 +358,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
em.delete(appToDelete);
}
- em.refreshIndex();
+ entityIndex.refresh();
}
@@ -383,7 +383,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
appProps.put("type", "appinfo");
Entity restoredApp = em.create("appinfo", appToRestore.getProperties());
- em.refreshIndex();
+ entityIndex.refresh();
// rebuild the apps index
this.rebuildApplicationIndexes(applicationId, new ProgressObserver() {
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
index 89a5384..7108472 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
@@ -685,12 +685,6 @@ public interface EntityManager {
/** @return the cass */
CassandraService getCass();
- /**
- * Refresh the applications index -- use sparingly.
- */
- void refreshIndex();
-
-
public void init( EntityManagerFactory emf, EntityIndex entityIndex, UUID applicationId);
/** For testing purposes */
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/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 33d72c4..2a74c74 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
@@ -117,8 +117,6 @@ public interface EntityManagerFactory {
public UUID getDefaultAppId();
- public void refreshIndex();
-
public void rebuildAllIndexes( ProgressObserver po ) throws Exception;
public void rebuildInternalIndexes( ProgressObserver po ) throws Exception;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/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 5eea12f..0e1e62a 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
@@ -409,11 +409,6 @@ public class EntityManagerFactoryImpl implements EntityManagerFactory, Applicati
}
@Override
- public void refreshIndex() {
- // no op
- }
-
- @Override
public void flushEntityManagerCaches() {
// no-op
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
index 112b684..30872c9 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
@@ -2884,11 +2884,6 @@ public class EntityManagerImpl implements EntityManager {
return Results.fromEntities( entities );
}
- @Override
- public void refreshIndex() {
- // no action necessary
- }
-
@Override
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java b/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
index 99c4654..ea7a5de 100644
--- a/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
+++ b/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
@@ -22,6 +22,8 @@ import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
+import com.google.inject.Injector;
+import org.apache.usergrid.persistence.index.EntityIndex;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
@@ -49,6 +51,7 @@ public class CoreApplication implements Application, TestRule {
protected CoreITSetup setup;
protected EntityManager em;
protected Map<String, Object> properties = new LinkedHashMap<String, Object>();
+ private EntityIndex entityIndex;
public CoreApplication( CoreITSetup setup ) {
@@ -143,7 +146,7 @@ public class CoreApplication implements Application, TestRule {
protected void after( Description description ) {
- LOG.info( "Test {}: finish with application", description.getDisplayName() );
+ LOG.info("Test {}: finish with application", description.getDisplayName());
// try {
// setup.getEmf().getEntityManager(id).().get();
@@ -165,7 +168,9 @@ public class CoreApplication implements Application, TestRule {
assertNotNull( id );
em = setup.getEmf().getEntityManager( id );
- assertNotNull( em );
+ Injector injector = setup.getInjector();
+ entityIndex = injector.getInstance(EntityIndex.class);
+ assertNotNull(em);
LOG.info( "Created new application {} in organization {}", appName, orgName );
@@ -211,7 +216,7 @@ public class CoreApplication implements Application, TestRule {
@Override
public void refreshIndex() {
- em.refreshIndex();
+ entityIndex.refresh();
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/test/java/org/apache/usergrid/CoreITSetup.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/CoreITSetup.java b/stack/core/src/test/java/org/apache/usergrid/CoreITSetup.java
index 201a0c5..a1db845 100644
--- a/stack/core/src/test/java/org/apache/usergrid/CoreITSetup.java
+++ b/stack/core/src/test/java/org/apache/usergrid/CoreITSetup.java
@@ -19,6 +19,8 @@ package org.apache.usergrid;
import java.util.UUID;
+import com.google.inject.Injector;
+import org.apache.usergrid.persistence.index.EntityIndex;
import org.junit.rules.TestRule;
import org.apache.usergrid.mq.QueueManagerFactory;
@@ -42,4 +44,8 @@ public interface CoreITSetup extends TestRule {
UUID createApplication( String organizationName, String applicationName ) throws Exception;
void dump( String name, Object obj );
+
+ Injector getInjector();
+
+ EntityIndex getEntityIndex();
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/test/java/org/apache/usergrid/CoreITSetupImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/CoreITSetupImpl.java b/stack/core/src/test/java/org/apache/usergrid/CoreITSetupImpl.java
index d4e69bc..4996684 100644
--- a/stack/core/src/test/java/org/apache/usergrid/CoreITSetupImpl.java
+++ b/stack/core/src/test/java/org/apache/usergrid/CoreITSetupImpl.java
@@ -19,6 +19,7 @@ package org.apache.usergrid;
import java.util.UUID;
+import org.apache.usergrid.persistence.index.EntityIndex;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
import org.slf4j.Logger;
@@ -39,6 +40,7 @@ import com.google.inject.Injector;
public class CoreITSetupImpl implements CoreITSetup {
private static final Logger LOG = LoggerFactory.getLogger( CoreITSetupImpl.class );
+ private final Injector injector;
protected EntityManagerFactory emf;
protected QueueManagerFactory qmf;
@@ -55,6 +57,8 @@ public class CoreITSetupImpl implements CoreITSetup {
emf = springResource.getBean( EntityManagerFactory.class );
qmf = springResource.getBean( QueueManagerFactory.class );
indexBucketLocator = springResource.getBean( IndexBucketLocator.class );
+ injector = springResource.getBean(Injector.class);
+
}
@@ -145,4 +149,14 @@ public class CoreITSetupImpl implements CoreITSetup {
LOG.info( name + ":\n" + JsonUtils.mapToFormattedJsonString( obj ) );
}
}
+
+ @Override
+ public Injector getInjector() {
+ return injector;
+ }
+
+ @Override
+ public EntityIndex getEntityIndex(){
+ return getInjector().getInstance(EntityIndex.class);
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
index 450f44b..6ba1353 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
@@ -101,7 +101,7 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
Entity thing = em.create( "thing", new HashMap<String, Object>() {{
put( "name", "thing1" );
}} );
- em.refreshIndex();
+ app.refreshIndex();
assertEquals( 1, queryCollectionCp( "things", "thing", "select *" ).size() );
@@ -111,7 +111,7 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
em.updateProperties( thing, new HashMap<String, Object>() {{
put( "stuff", "widget" );
}} );
- em.refreshIndex();
+ app.refreshIndex();
org.apache.usergrid.persistence.model.entity.Entity cpUpdated = getCpEntity( thing );
assertEquals( "widget", cpUpdated.getField( "stuff" ).getValue() );
@@ -147,14 +147,14 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
put( "ordinal", 0 );
}} );
- em.refreshIndex();
+ app.refreshIndex();
assertEquals( 1, queryCollectionCp( "things", "thing", "select *" ).size() );
em.updateProperties( thing, new HashMap<String, Object>() {{
put( "ordinal", 1 );
}} );
- em.refreshIndex();
+ app.refreshIndex();
UUID newVersion = getCpEntity( thing ).getVersion();
@@ -182,7 +182,7 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
assertEquals( 1, results.size() );
assertEquals(1, results.getEntities().get( 0 ).getProperty( "ordinal" ));
- em.refreshIndex();
+ app.refreshIndex();
//ensure it's actually gone
do{
@@ -228,7 +228,7 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
}} ) );
}
- em.refreshIndex();
+ app.refreshIndex();
CandidateResults crs = queryCollectionCp( "things", "thing", "select * order by updateCount asc" );
Assert.assertEquals( "Expect no stale candidates yet", numEntities, crs.size() );
@@ -258,7 +258,7 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
maxVersions.add( toUpdate );
}
- em.refreshIndex();
+ app.refreshIndex();
// query Core Persistence directly for total number of result candidates
crs = queryCollectionCp( "things", "thing", "select * order by updateCount asc" );
@@ -303,7 +303,7 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
assertEquals( "Expect no stale candidates", numEntities, thingCount );
- em.refreshIndex();
+ app.refreshIndex();
// query for total number of result candidates = numEntities
@@ -339,7 +339,7 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
}}));
Thread.sleep( writeDelayMs );
}
- em.refreshIndex();
+ app.refreshIndex();
CandidateResults crs = queryCollectionCp( "things", "thing", "select *");
Assert.assertEquals( "Expect no stale candidates yet", numEntities, crs.size() );
@@ -367,7 +367,7 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
maxVersions.add( toUpdate );
}
- em.refreshIndex();
+ app.refreshIndex();
// query Core Persistence directly for total number of result candidates
crs = queryCollectionCp("things", "thing", "select *");
@@ -383,7 +383,7 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
//put this into the top of the queue, once it's acked we've been flushed
- em.refreshIndex();
+ app.refreshIndex();
// wait for indexes to be cleared for the deleted entities
count = 0;
@@ -430,7 +430,7 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
put("name", dogName);
}}));
}
- em.refreshIndex();
+ app.refreshIndex();
CandidateResults crs = queryCollectionCp( "dogs", "dog", "select *");
Assert.assertEquals( "Expect no stale candidates yet", numEntities, crs.size() );
@@ -457,7 +457,7 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
maxVersions.add( toUpdate );
}
- em.refreshIndex();
+ app.refreshIndex();
// wait for indexes to be cleared for the deleted entities
count = 0;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java
index aa75a9a..b1a75d9 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java
@@ -24,6 +24,7 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
+import org.apache.usergrid.persistence.index.EntityIndex;
import org.junit.Rule;
import org.junit.Test;
import org.slf4j.Logger;
@@ -56,6 +57,7 @@ public class CollectionIT extends AbstractCoreIT {
@Rule
public Application app = new CoreApplication( setup );
+
@Test
public void testSimpleCrud() throws Exception {
@@ -226,7 +228,7 @@ public class CollectionIT extends AbstractCoreIT {
Entity user = em.create( "user", properties );
assertNotNull( user );
- em.refreshIndex();
+ app.refreshIndex();
// EntityRef
Query query = new Query();
@@ -247,7 +249,7 @@ public class CollectionIT extends AbstractCoreIT {
em.update( user );
- em.refreshIndex();
+ app.refreshIndex();
// search with the old username, should be no results
query.addEqualityFilter( "firstname", firstName );
@@ -287,7 +289,7 @@ public class CollectionIT extends AbstractCoreIT {
Entity user = em.create( "user", properties );
assertNotNull( user );
- em.refreshIndex();
+ app.refreshIndex();
// EntityRef
Query query = new Query();
@@ -320,7 +322,7 @@ public class CollectionIT extends AbstractCoreIT {
Entity user = em.create( "user", properties );
assertNotNull( user );
- em.refreshIndex();
+ app.refreshIndex();
// EntityRef
Query query = new Query();
@@ -369,7 +371,7 @@ public class CollectionIT extends AbstractCoreIT {
properties.put( "nickname", "ed" );
em.updateProperties( user1, properties );
- em.refreshIndex();
+ app.refreshIndex();
Results r = em.searchCollection( group, "users",
new Query().addEqualityFilter( "nickname", "ed" )
@@ -399,7 +401,7 @@ public class CollectionIT extends AbstractCoreIT {
Entity group = em.create( "group", properties );
assertNotNull( group );
- em.refreshIndex();
+ app.refreshIndex();
// EntityRef
Query query = new Query();
@@ -432,7 +434,7 @@ public class CollectionIT extends AbstractCoreIT {
Entity group = em.create( "group", properties );
assertNotNull( group );
- em.refreshIndex();
+ app.refreshIndex();
// EntityRef
Query query = new Query();
@@ -490,7 +492,7 @@ public class CollectionIT extends AbstractCoreIT {
em.addToCollection( user, "activities", em.create( "activity", properties ) );
- em.refreshIndex();
+ app.refreshIndex();
Results r = em.searchCollection( user, "activities", Query.searchForProperty( "verb", "post" ) );
LOG.info( JsonUtils.mapToFormattedJsonString( r.getEntities() ) );
@@ -522,7 +524,7 @@ public class CollectionIT extends AbstractCoreIT {
Entity user2 = em.create( "user", properties );
assertNotNull( user2 );
- em.refreshIndex();
+ app.refreshIndex();
// EntityRef
Query query = new Query();
@@ -565,7 +567,7 @@ public class CollectionIT extends AbstractCoreIT {
Entity user2 = em.create( "user", properties );
assertNotNull( user2 );
- em.refreshIndex();
+ app.refreshIndex();
// EntityRef
Query query = new Query();
@@ -606,7 +608,7 @@ public class CollectionIT extends AbstractCoreIT {
Entity game2 = em.create( "orquerygame", properties );
assertNotNull( game2 );
- em.refreshIndex();
+ app.refreshIndex();
// EntityRef
Query query = Query.fromQL( "select * where keywords contains 'Random' "
@@ -685,7 +687,7 @@ public class CollectionIT extends AbstractCoreIT {
Entity game2 = em.create( "game", properties );
assertNotNull( game2 );
- em.refreshIndex();
+ app.refreshIndex();
// overlap
Query query = Query.fromQL( "select * where keywords contains 'test' "
@@ -746,7 +748,7 @@ public class CollectionIT extends AbstractCoreIT {
Entity game2 = em.create( "game", properties );
assertNotNull( game2 );
- em.refreshIndex();
+ app.refreshIndex();
// simple not
Query query = Query.fromQL( "select * where NOT keywords contains 'game'" );
@@ -823,7 +825,7 @@ public class CollectionIT extends AbstractCoreIT {
Entity entity2 = em.create( "game", properties );
assertNotNull( entity2 );
- em.refreshIndex();
+ app.refreshIndex();
// search for games without sub-field Foo should returned zero entities
@@ -880,7 +882,7 @@ public class CollectionIT extends AbstractCoreIT {
properties.put( "keywords", "Action, New" );
em.create( "game", properties );
- em.refreshIndex();
+ app.refreshIndex();
Query query = Query.fromQL( "select * where keywords contains 'hot' or title contains 'hot'" );
Results r = em.searchCollection( em.getApplicationRef(), "games", query );
@@ -911,7 +913,7 @@ public class CollectionIT extends AbstractCoreIT {
properties.put( "keywords", "Action, New" );
Entity thirdGame = em.create( "game", properties );
- em.refreshIndex();//need to track all batches then resolve promises
+ app.refreshIndex();//need to track all batches then resolve promises
Query query = Query.fromQL( "select * where keywords contains 'new' and title contains 'extreme'" );
Results r = em.searchCollection( em.getApplicationRef(), "games", query );
@@ -942,7 +944,7 @@ public class CollectionIT extends AbstractCoreIT {
entityIds.add( created.getUuid() );
}
- em.refreshIndex();
+ app.refreshIndex();
Query query = new Query();
query.setLimit( 50 );
@@ -967,7 +969,7 @@ public class CollectionIT extends AbstractCoreIT {
numDeleted++;
}
- em.refreshIndex();
+ app.refreshIndex();
// wait for indexes to be cleared
Thread.sleep( 500 );
@@ -1016,7 +1018,7 @@ public class CollectionIT extends AbstractCoreIT {
int pageSize = 10;
- em.refreshIndex();
+ app.refreshIndex();
Query query = new Query();
query.setLimit( pageSize );
@@ -1069,7 +1071,7 @@ public class CollectionIT extends AbstractCoreIT {
int pageSize = 10;
- em.refreshIndex();
+ app.refreshIndex();
Query query = Query.fromQL("select * where index >= " + size / 2);
query.setLimit( pageSize );
@@ -1119,7 +1121,7 @@ public class CollectionIT extends AbstractCoreIT {
entityIds.add( created.getUuid() );
}
- em.refreshIndex();
+ app.refreshIndex();
int pageSize = 10;
@@ -1171,7 +1173,7 @@ public class CollectionIT extends AbstractCoreIT {
entityIds.add( created.getUuid() );
}
- em.refreshIndex();
+ app.refreshIndex();
int pageSize = 10;
@@ -1223,7 +1225,7 @@ public class CollectionIT extends AbstractCoreIT {
Entity saved = em.create( "test", root );
- em.refreshIndex();
+ app.refreshIndex();
Query query = new Query();
query.addEqualityFilter( "rootprop1", "simpleprop" );
@@ -1278,7 +1280,7 @@ public class CollectionIT extends AbstractCoreIT {
Entity saved = em.create( "test", jsonData );
- em.refreshIndex();
+ app.refreshIndex();
Query query = new Query();
query.addEqualityFilter( "intprop", 10 );
@@ -1342,7 +1344,7 @@ public class CollectionIT extends AbstractCoreIT {
Entity saved = em.create( "test", props );
- em.refreshIndex();
+ app.refreshIndex();
Query query = new Query();
query.addEqualityFilter( "myString", "My simple string" );
@@ -1368,7 +1370,7 @@ public class CollectionIT extends AbstractCoreIT {
em.create( "user", properties );
- em.refreshIndex();
+ app.refreshIndex();
String s = "select username, email where username = 'edanuff'";
Query query = Query.fromQL( s );
@@ -1398,7 +1400,7 @@ public class CollectionIT extends AbstractCoreIT {
em.create( "user", properties );
- em.refreshIndex();
+ app.refreshIndex();
String s = "select {name: username, email: email} where username = 'edanuff'";
Query query = Query.fromQL( s );
@@ -1430,7 +1432,7 @@ public class CollectionIT extends AbstractCoreIT {
em.create( "user", properties );
- em.refreshIndex();
+ app.refreshIndex();
String s = "select * where username = 'ed@anuff.com'";
Query query = Query.fromQL( s );
@@ -1452,7 +1454,7 @@ public class CollectionIT extends AbstractCoreIT {
em.createConnection( foo, "testconnection", entity );
- em.refreshIndex();
+ app.refreshIndex();
// now query via the testConnection, this should work
@@ -1495,7 +1497,7 @@ public class CollectionIT extends AbstractCoreIT {
em.create( "loveobject", properties );
- em.refreshIndex();
+ app.refreshIndex();
location = new LinkedHashMap<String, Object>();
location.put( "Place",
@@ -1514,7 +1516,7 @@ public class CollectionIT extends AbstractCoreIT {
em.create( "loveobject", properties );
- em.refreshIndex();
+ app.refreshIndex();
// String s = "select * where Flag = 'requested'";
// String s = "select * where Flag = 'requested' and NOT Recipient.Username =
@@ -1560,7 +1562,7 @@ public class CollectionIT extends AbstractCoreIT {
createdEntities.add( created );
}
- em.refreshIndex();
+ app.refreshIndex();
Results r = em.getCollection( em.getApplicationRef(), "users", null, 50, Level.ALL_PROPERTIES, false );
@@ -1655,7 +1657,7 @@ public class CollectionIT extends AbstractCoreIT {
Entity game2 = em.create( "game", properties );
assertNotNull( game2 );
- em.refreshIndex();
+ app.refreshIndex();
// overlap
Query query = new Query();
@@ -1689,7 +1691,7 @@ public class CollectionIT extends AbstractCoreIT {
Entity game2 = em.create( "game", properties );
assertNotNull( game2 );
- em.refreshIndex();
+ app.refreshIndex();
// overlap
Query query = new Query();
@@ -1723,7 +1725,7 @@ public class CollectionIT extends AbstractCoreIT {
Entity createUser2 = em.create( user2 );
assertNotNull( createUser2 );
- em.refreshIndex();
+ app.refreshIndex();
// overlap
Query query = new Query();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/test/java/org/apache/usergrid/persistence/CountingMutatorIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/CountingMutatorIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/CountingMutatorIT.java
index 68afbb9..175cc74 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/CountingMutatorIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/CountingMutatorIT.java
@@ -76,7 +76,7 @@ public class CountingMutatorIT extends AbstractCoreIT {
properties.put( "username", "testuser" );
properties.put( "email", "test@foo.bar" );
Entity created = em.create( "user", properties );
- em.refreshIndex();
+ app.refreshIndex();
Entity returned = em.get( created.getUuid() );
@@ -91,7 +91,7 @@ public class CountingMutatorIT extends AbstractCoreIT {
Entity connectedEntity = em.create( "user", connectedProps );
- em.refreshIndex();
+ app.refreshIndex();
// Connect from our new entity to our root one so it's updated when paging
em.createConnection( connectedEntity, "following", returned );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/test/java/org/apache/usergrid/persistence/EntityConnectionsIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/EntityConnectionsIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/EntityConnectionsIT.java
index 9780b8b..2e7de4f 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/EntityConnectionsIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/EntityConnectionsIT.java
@@ -70,7 +70,7 @@ public class EntityConnectionsIT extends AbstractCoreIT {
em.createConnection( firstUserEntity, "likes", secondUserEntity );
- em.refreshIndex();
+ app.refreshIndex();
Results r = em.getConnectedEntities( firstUserEntity, "likes", null, Level.IDS );
@@ -134,7 +134,7 @@ public class EntityConnectionsIT extends AbstractCoreIT {
LOG.info( "\n\nConnecting " + awardA.getUuid() + " \"awarded\" " + catB.getUuid() + "\n" );
em.createConnection( awardA, "awarded", catB );
- em.refreshIndex();
+ app.refreshIndex();
// List forward connections for cat A
@@ -155,7 +155,7 @@ public class EntityConnectionsIT extends AbstractCoreIT {
LOG.info( "\n\nConnecting " + awardA.getUuid() + " \"awarded\" " + catA.getUuid() + "\n" );
em.createConnection( awardA, "awarded", catA );
- em.refreshIndex();
+ app.refreshIndex();
// List forward connections for cat A
// Not valid with current usages
@@ -262,7 +262,7 @@ public class EntityConnectionsIT extends AbstractCoreIT {
em.createConnection( secondUserEntity, "likes", arrogantbutcher );
- em.refreshIndex();
+ app.refreshIndex();
Results r = em.getConnectedEntities( firstUserEntity, "likes", "restaurant", Level.IDS );
@@ -316,7 +316,7 @@ public class EntityConnectionsIT extends AbstractCoreIT {
em.createConnection( fredEntity, "likes", wilmaEntity );
- em.refreshIndex();
+ app.refreshIndex();
// // search for "likes" edges from fred
// assertEquals( 1,
@@ -370,7 +370,7 @@ public class EntityConnectionsIT extends AbstractCoreIT {
}
- em.refreshIndex();
+ app.refreshIndex();
Results r = em.getConnectedEntities( firstUserEntity, "likes", null, Level.ALL_PROPERTIES ) ;
@@ -414,7 +414,7 @@ public class EntityConnectionsIT extends AbstractCoreIT {
//
// em.createConnection( fredEntity, "likes", wilmaEntity );
//
-// em.refreshIndex();
+// app.refreshIndex();
//
//// // search for "likes" edges from fred
//// assertEquals( 1,
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/test/java/org/apache/usergrid/persistence/EntityManagerIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/EntityManagerIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/EntityManagerIT.java
index 4896fc1..f86b2a3 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/EntityManagerIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/EntityManagerIT.java
@@ -79,7 +79,7 @@ public class EntityManagerIT extends AbstractCoreIT {
assertEquals( "user.username not expected value", "edanuff", user.getProperty( "username"));
assertEquals( "user.email not expected value", "ed@anuff.com", user.getProperty( "email" ));
- em.refreshIndex();
+ app.refreshIndex();
EntityRef userRef = em.getAlias(
new SimpleEntityRef("application", applicationId), "users", "edanuff" );
@@ -281,7 +281,7 @@ public class EntityManagerIT extends AbstractCoreIT {
em.delete( thing );
LOG.info( "Entity deleted" );
- em.refreshIndex();
+ app.refreshIndex();
// now search by username, no results should be returned
@@ -308,13 +308,13 @@ public class EntityManagerIT extends AbstractCoreIT {
Entity user = em.create( "user", properties );
LOG.info( "Entity created" );
- em.refreshIndex();
+ app.refreshIndex();
LOG.info( "Starting entity delete" );
em.delete( user );
LOG.info( "Entity deleted" );
- em.refreshIndex();
+ app.refreshIndex();
// now search by username, no results should be returned
@@ -333,7 +333,7 @@ public class EntityManagerIT extends AbstractCoreIT {
user = em.create( "user", properties );
LOG.info( "Entity created" );
- em.refreshIndex();
+ app.refreshIndex();
r = em.searchCollection( em.getApplicationRef(), "users",
new Query().addEqualityFilter( "username", name ) );
@@ -451,7 +451,7 @@ public class EntityManagerIT extends AbstractCoreIT {
EntityRef appRef = em.get( new SimpleEntityRef("application", app.getId() ) );
- em.refreshIndex();
+ app.refreshIndex();
Results r = em.getCollection( appRef, "things", null, 10, Level.ALL_PROPERTIES, false );
@@ -543,7 +543,7 @@ public class EntityManagerIT extends AbstractCoreIT {
Entity createdDevice = em.createItemInCollection( createdUser, "devices", "device", device );
- em.refreshIndex();
+ app.refreshIndex();
Entity returnedDevice = em.get( new SimpleEntityRef("device", createdDevice.getUuid()));
@@ -575,7 +575,7 @@ public class EntityManagerIT extends AbstractCoreIT {
Entity user = em.create( "robot", properties );
assertNotNull( user );
- em.refreshIndex();
+ app.refreshIndex();
assertNotNull( em.get( user.getUuid() ));
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
index ff15063..6070933 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
@@ -97,7 +97,7 @@ public class GeoIT extends AbstractCoreIT {
}};
Entity user = em.create("user", properties);
assertNotNull(user);
- em.refreshIndex();
+ app.refreshIndex();
//2. Query with a globally large distance to verify location
Query query = Query.fromQL("select * where location within " + Integer.MAX_VALUE + " of 0, 0");
@@ -107,7 +107,7 @@ public class GeoIT extends AbstractCoreIT {
//3. Remove the entity's location
properties.remove("location");
em.updateProperties(user, properties);
- em.refreshIndex();
+ app.refreshIndex();
//4. Repeat the query, expecting no results
listResults = em.searchCollection(em.getApplicationRef(), "users", query);
@@ -141,7 +141,7 @@ public class GeoIT extends AbstractCoreIT {
}};
Entity user = em.create("user", properties);
assertNotNull(user);
- em.refreshIndex();
+ app.refreshIndex();
Point center = new Point(37.776753, -122.407846);
//2. Query from a point near the entity's location
@@ -193,12 +193,12 @@ public class GeoIT extends AbstractCoreIT {
Entity user = em.create("user", userProperties);
assertNotNull(user);
- em.refreshIndex();
+ app.refreshIndex();
//3. Create a connection between the user and the entity
em.createConnection(user, "likes", restaurant);
- em.refreshIndex();
+ app.refreshIndex();
//4. Test that the user is within 2000m of the entity
Results emSearchResults = em.searchConnectedEntities(user,
Query.fromQL("location within 5000 of "
@@ -235,7 +235,7 @@ public class GeoIT extends AbstractCoreIT {
assertNotNull(entity);
LOG.debug("Entity {} created", entity.getProperty("name"));
}
- em.refreshIndex();
+ app.refreshIndex();
//2. validate the size of the result
Query query = new Query();
Results listResults = em.searchCollection(em.getApplicationRef(), "stores", query);
@@ -392,7 +392,7 @@ public class GeoIT extends AbstractCoreIT {
em.create("store", data);
}
- em.refreshIndex();
+ app.refreshIndex();
Query query = new Query();
// earth's circumference is 40,075 kilometers. Up it to 50,000kilometers
@@ -439,7 +439,7 @@ public class GeoIT extends AbstractCoreIT {
em.create("store", data);
}
- em.refreshIndex();
+ app.refreshIndex();
Query query = new Query();
// earth's circumference is 40,075 kilometers. Up it to 50,000kilometers
@@ -500,7 +500,7 @@ public class GeoIT extends AbstractCoreIT {
em.create("store", data);
}
- em.refreshIndex();
+ app.refreshIndex();
Query query = new Query();
// earth's circumference is 40,075 kilometers. Up it to 50,000kilometers
@@ -550,7 +550,7 @@ public class GeoIT extends AbstractCoreIT {
created.add(e);
}
- em.refreshIndex();
+ app.refreshIndex();
int startDelta = size - min;
@@ -615,7 +615,7 @@ public class GeoIT extends AbstractCoreIT {
em.create("store", data);
}
- em.refreshIndex();
+ app.refreshIndex();
//do a direct geo iterator test. We need to make sure that we short circuit on the correct tile.
@@ -679,7 +679,7 @@ public class GeoIT extends AbstractCoreIT {
assertNotNull(entity);
}
//3. refresh the index
- em.refreshIndex();
+ app.refreshIndex();
//4. return the entity manager
return em;
}
@@ -698,7 +698,7 @@ public class GeoIT extends AbstractCoreIT {
latlong.put("longitude", longitude);
em.setProperty(entity, "location", latlong);
- em.refreshIndex();
+ app.refreshIndex();
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java
index 97ef0fe..3dfab3f 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/GeoQueryBooleanTest.java
@@ -84,7 +84,7 @@ public class GeoQueryBooleanTest extends AbstractCoreIT {
Entity user2 = em.create( "user", properties );
assertNotNull( user2 );
- em.refreshIndex();
+ app.refreshIndex();
// define center point about 300m from that location
Point center = new Point( 37.774277, -122.404744 );
@@ -163,7 +163,7 @@ public class GeoQueryBooleanTest extends AbstractCoreIT {
Entity userFred = em.create( "user", properties );
assertNotNull( userFred );
- em.refreshIndex();
+ app.refreshIndex();
// define center point about 300m from that location
Point center = new Point( 37.774277, -122.404744 );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/test/java/org/apache/usergrid/persistence/IndexIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/IndexIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/IndexIT.java
index 66d9276..a60a6b5 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/IndexIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/IndexIT.java
@@ -74,7 +74,7 @@ public class IndexIT extends AbstractCoreIT {
em.create( "item", properties );
}
- em.refreshIndex();
+ app.refreshIndex();
int i = 0;
@@ -147,7 +147,7 @@ public class IndexIT extends AbstractCoreIT {
em.create( "item", properties );
}
- em.refreshIndex();
+ app.refreshIndex();
Query query = Query.fromQL( "name < 'delta' order by name asc" );
Results r = em.searchCollection( em.getApplicationRef(), "items", query );
@@ -275,7 +275,7 @@ public class IndexIT extends AbstractCoreIT {
em.create( "item", properties );
}
- em.refreshIndex();
+ app.refreshIndex();
Query query = Query.fromQL( "group = 1 order by name desc" );
Results r = em.searchCollection( em.getApplicationRef(), "items", query );
@@ -314,7 +314,7 @@ public class IndexIT extends AbstractCoreIT {
em.createConnection( entity2Ref, "connecting", entity1Ref );
- em.refreshIndex();
+ app.refreshIndex();
//should return valid values
Query query = Query.fromQL( "select * where status = 'pickled'" );
@@ -333,7 +333,7 @@ public class IndexIT extends AbstractCoreIT {
em.update( entity1Ref );
- em.refreshIndex();
+ app.refreshIndex();
//query and check the status has been updated, shouldn't return results
query = Query.fromQL( "select * where status = 'pickled'" );
@@ -389,7 +389,7 @@ public class IndexIT extends AbstractCoreIT {
em.createConnection( entity2Ref, "connecting", entity1Ref );
- em.refreshIndex();
+ app.refreshIndex();
//should return valid values
Query query = Query.fromQL( "select * where status = 'pickled'" );
@@ -408,7 +408,7 @@ public class IndexIT extends AbstractCoreIT {
em.update( entity1Ref );
- em.refreshIndex();
+ app.refreshIndex();
//query and check the status has been updated, shouldn't return results
query = Query.fromQL( "select * where status = 'pickled'" );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java
index c56c07f..24cb563 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/PathQueryIT.java
@@ -65,7 +65,7 @@ public class PathQueryIT extends AbstractCoreIT {
}
}
- em.refreshIndex();
+ app.refreshIndex();
// pick an arbitrary user, ensure it has 5 devices
Results devices = em.getCollection( users.get( 10 ), "devices", null, 20, Level.IDS, false );
@@ -137,7 +137,7 @@ public class PathQueryIT extends AbstractCoreIT {
}
}
- em.refreshIndex();
+ app.refreshIndex();
// pick an arbitrary group, ensure it has 7 users
Results ru = em.getCollection( groups.get( 2 ), "users", null, 20, Level.IDS, false );
@@ -154,7 +154,7 @@ public class PathQueryIT extends AbstractCoreIT {
}
}
- em.refreshIndex();
+ app.refreshIndex();
// pick an arbitrary user, ensure it has 7 devices
Results rd = em.getCollection( users.get( 6 ), "devices", null, 20, Level.IDS, false );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
index c58750b..879f42c 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
@@ -145,7 +145,7 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
shepardCount++;
}
- em.refreshIndex();
+ app.refreshIndex();
// em.createConnection(entity, "herds", cat1);
// em.createConnection(entity, "herds", cat2);
@@ -165,7 +165,7 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
}
logger.info("Created {} entities", entityCount);
- em.refreshIndex();
+ app.refreshIndex();
// ----------------- test that we can read them, should work fine
@@ -283,7 +283,7 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
entityMap.put("key", entityCount );
entity = em.create("testType", entityMap );
- em.refreshIndex();
+ app.refreshIndex();
em.createConnection(entity, "herds", cat1);
em.createConnection(entity, "herds", cat2);
@@ -303,7 +303,7 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
}
logger.info("Created {} entities", entityCount);
- em.refreshIndex();
+ app.refreshIndex();
// ----------------- test that we can read them, should work fine
@@ -363,7 +363,7 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
registry.remove( meterName );
logger.info("Rebuilt index");
- setup.getEmf().refreshIndex();
+ app.refreshIndex();
} catch (Exception ex) {
logger.error("Error rebuilding index", ex);
@@ -394,7 +394,7 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
private int readData( EntityManager em,
String collectionName, int expectedEntities, int expectedConnections ) throws Exception {
- em.refreshIndex();
+ app.refreshIndex();
Query q = Query.fromQL("select * where key1=1000");
q.setLimit(40);
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/test/java/org/apache/usergrid/persistence/PermissionsIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/PermissionsIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/PermissionsIT.java
index 5e83a34..6f76a79 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/PermissionsIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/PermissionsIT.java
@@ -151,10 +151,10 @@ public class PermissionsIT extends AbstractCoreIT {
assertEquals( "proper number of group roles not set", 1, roles.size() );
dump( "group roles", roles );
- em.refreshIndex();
+ app.refreshIndex();
em.addUserToGroupRole( user.getUuid(), group.getUuid(), "admin" );
- em.refreshIndex();
+ app.refreshIndex();
Results r = em.getUsersInGroupRole( group.getUuid(), "admin", Level.ALL_PROPERTIES );
assertEquals( "proper number of users in group role not set", 1, r.size() );
dump( "entities", r.getEntities() );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
index dea4967..56b6ff4 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
@@ -116,7 +116,7 @@ public class EntityManagerFactoryImplIT extends AbstractCoreIT {
properties2.put( "Year", 1992 );
Entity film2 = em.create( "film", properties2 );
- em.refreshIndex();
+ app.refreshIndex();
// TODO: this assertion should work!
//assertNotNull( "cannot lookup app by name", setup.getEmf().lookupApplication("test-app-" + rand) );
@@ -125,7 +125,7 @@ public class EntityManagerFactoryImplIT extends AbstractCoreIT {
setup.getEmf().deleteApplication( applicationId );
- em.refreshIndex();
+ app.refreshIndex();
Func2<UUID, Map<String, UUID> ,Boolean> findApps = new Func2<UUID,Map<String, UUID> ,Boolean>() {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/test/java/org/apache/usergrid/persistence/query/CollectionIoHelper.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/CollectionIoHelper.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/CollectionIoHelper.java
index 109ec14..8965013 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/query/CollectionIoHelper.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/query/CollectionIoHelper.java
@@ -55,7 +55,7 @@ public class CollectionIoHelper implements IoHelper {
@Override
public Results getResults( Query query ) throws Exception {
- app.getEntityManager().refreshIndex();
+ app.refreshIndex();
return app.getEntityManager().searchCollection( app.getEntityManager().getApplicationRef(), "tests", query );
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/test/java/org/apache/usergrid/persistence/query/ConnectionHelper.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/ConnectionHelper.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/ConnectionHelper.java
index aca1778..5f9874b 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/query/ConnectionHelper.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/query/ConnectionHelper.java
@@ -76,7 +76,7 @@ public class ConnectionHelper extends CollectionIoHelper {
@Override
public Results getResults( Query query ) throws Exception {
- app.getEntityManager().refreshIndex();
+ app.refreshIndex();
query.setConnectionType( CONNECTION );
query.setEntityType( "test" );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java
index f602a53..f4c5c0e 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java
@@ -1123,7 +1123,7 @@ public class IteratingQueryIT {
LOG.info( "Writes took {} ms", stop - start );
- app.getEntityManager().refreshIndex();
+ app.refreshIndex();
Query query = new Query();
query.setLimit( 100 );
@@ -1224,7 +1224,7 @@ public class IteratingQueryIT {
LOG.info( "Writes took {} ms", stop - start );
- app.getEntityManager().refreshIndex();
+ app.refreshIndex();
Query query = Query.fromQL( "select * order by boolean desc, index asc" );
query.setLimit( queryLimit );
@@ -1330,7 +1330,7 @@ public class IteratingQueryIT {
LOG.info( "Writes took {} ms", stop - start );
- app.getEntityManager().refreshIndex();
+ app.refreshIndex();
Query query =
Query.fromQL( "select * where intersect = true OR intersect2 = true order by created, intersect desc" );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/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 f8ed107..c83fe41 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
@@ -129,7 +129,7 @@ public class EsApplicationEntityIndexImpl implements ApplicationEntityIndex{
public CandidateResults search(final IndexScope indexScope, final SearchTypes searchTypes,
final Query query ) {
- final String context = IndexingUtils.createContextName(indexScope);
+ final String context = IndexingUtils.createContextName(applicationScope,indexScope);
final String[] entityTypes = searchTypes.getTypeNames(applicationScope);
QueryBuilder qb = query.createQueryBuilder(context);
SearchResponse searchResponse;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/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 04fde6a..1eb73d3 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
@@ -327,7 +327,7 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
public void refresh() {
refreshIndexMeter.mark();
-
+ final Timer.Context timeRefreshIndex = refreshTimer.time();
BetterFuture future = indexBatchBufferProducer.put(new IndexOperationMessage());
future.get();
//loop through all batches and retrieve promises and call get
@@ -346,7 +346,6 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
return true;
}
//Added For Graphite Metrics
- Timer.Context timeRefreshIndex = refreshTimer.time();
esProvider.getClient().admin().indices().prepareRefresh( indexes ).execute().actionGet();
timeRefreshIndex.stop();
logger.debug("Refreshed indexes: {}", StringUtils.join(indexes, ", "));
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/rest/src/main/java/org/apache/usergrid/rest/AbstractContextResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/AbstractContextResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/AbstractContextResource.java
index 422eedd..cd73991 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/AbstractContextResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/AbstractContextResource.java
@@ -28,6 +28,8 @@ import javax.ws.rs.core.Request;
import javax.ws.rs.core.SecurityContext;
import javax.ws.rs.core.UriInfo;
+import com.google.inject.Injector;
+import org.apache.usergrid.persistence.index.EntityIndex;
import org.springframework.beans.factory.annotation.Autowired;
import org.apache.usergrid.management.ManagementService;
import org.apache.usergrid.mq.QueueManagerFactory;
@@ -54,9 +56,13 @@ import org.slf4j.LoggerFactory;
public abstract class AbstractContextResource {
- protected static final TypeReference<Map<String, Object>> mapTypeReference = new TypeReference<Map<String, Object>>() {};
- protected static final TypeReference<List<Object>> listTypeReference = new TypeReference<List<Object>>() {};
- protected static final ObjectMapper mapper = new ObjectMapper();
+ protected static final TypeReference<Map<String, Object>> mapTypeReference = new TypeReference<Map<String, Object>>() {
+ };
+ protected static final TypeReference<List<Object>> listTypeReference = new TypeReference<List<Object>>() {
+ };
+ protected static final ObjectMapper mapper = new ObjectMapper();
+
+ private EntityIndex entityIndex;
protected AbstractContextResource parent;
@@ -98,9 +104,12 @@ public abstract class AbstractContextResource {
protected QueueManagerFactory qmf;
@Autowired
+ protected Injector injector;
+
+ @Autowired
protected TokenService tokens;
- private static final Logger logger = LoggerFactory.getLogger( AbstractContextResource.class );
+ private static final Logger logger = LoggerFactory.getLogger(AbstractContextResource.class);
public AbstractContextResource() {
@@ -112,26 +121,26 @@ public abstract class AbstractContextResource {
}
- public void setParent( AbstractContextResource parent ) {
+ public void setParent(AbstractContextResource parent) {
this.parent = parent;
}
- public <T extends AbstractContextResource> T getSubResource( Class<T> t ) {
+ public <T extends AbstractContextResource> T getSubResource(Class<T> t) {
logger.debug("getSubResource: " + t.getCanonicalName());
- T subResource = resourceContext.getResource( t );
- subResource.setParent( this );
+ T subResource = resourceContext.getResource(t);
+ subResource.setParent(this);
return subResource;
}
- public PathSegment getFirstPathSegment( String name ) {
- if ( name == null ) {
+ public PathSegment getFirstPathSegment(String name) {
+ if (name == null) {
return null;
}
List<PathSegment> segments = uriInfo.getPathSegments();
- for ( PathSegment segment : segments ) {
- if ( name.equals( segment.getPath() ) ) {
+ for (PathSegment segment : segments) {
+ if (name.equals(segment.getPath())) {
return segment;
}
}
@@ -140,70 +149,73 @@ public abstract class AbstractContextResource {
public boolean useReCaptcha() {
- return StringUtils.isNotBlank( properties.getRecaptchaPublic() )
- && StringUtils.isNotBlank( properties.getRecaptchaPrivate() );
+ return StringUtils.isNotBlank(properties.getRecaptchaPublic())
+ && StringUtils.isNotBlank(properties.getRecaptchaPrivate());
}
public String getReCaptchaHtml() {
- if ( !useReCaptcha() ) {
+ if (!useReCaptcha()) {
return "";
}
ReCaptcha c = ReCaptchaFactory.newSecureReCaptcha(
- properties.getRecaptchaPublic(), properties.getRecaptchaPrivate(), false );
- return c.createRecaptchaHtml( null, null );
+ properties.getRecaptchaPublic(), properties.getRecaptchaPrivate(), false);
+ return c.createRecaptchaHtml(null, null);
}
- public void sendRedirect( String location ) {
- if ( StringUtils.isNotBlank( location ) ) {
- throw new RedirectionException( location );
+ public void sendRedirect(String location) {
+ if (StringUtils.isNotBlank(location)) {
+ throw new RedirectionException(location);
}
}
- public Viewable handleViewable( String template, Object model ) {
+ public Viewable handleViewable(String template, Object model) {
String className = this.getClass().getName().toLowerCase();
String packageName = AbstractContextResource.class.getPackage().getName();
String template_property = "usergrid.view" +
- StringUtils.removeEnd( className.toLowerCase(), "resource" )
- .substring( packageName.length() ) + "." + template.toLowerCase();
+ StringUtils.removeEnd(className.toLowerCase(), "resource")
+ .substring(packageName.length()) + "." + template.toLowerCase();
- String redirect_url = properties.getProperty( template_property );
+ String redirect_url = properties.getProperty(template_property);
- if ( StringUtils.isNotBlank( redirect_url ) ) {
+ if (StringUtils.isNotBlank(redirect_url)) {
logger.debug("Redirecting to URL: ", redirect_url);
- sendRedirect( redirect_url );
+ sendRedirect(redirect_url);
}
logger.debug("Dispatching to viewable with template: {}",
- template, template_property );
+ template, template_property);
- Viewable viewable = new Viewable( template, model, this.getClass() );
+ Viewable viewable = new Viewable(template, model, this.getClass());
return viewable;
}
-
protected ApiResponse createApiResponse() {
- return new ApiResponse( properties );
+ return new ApiResponse(properties);
}
+ protected EntityIndex getEntityIndex(){
+ entityIndex = entityIndex == null ? injector.getInstance(EntityIndex.class) : entityIndex;
+ return entityIndex;
+ }
/**
- * Next three new methods necessary to work around inexplicable problems with EntityHolder.
- * This problem happens consistently when you deploy "two-dot-o" to Tomcat:
- * https://groups.google.com/forum/#!topic/usergrid/yyAJdmsBfig
- */
- protected Object readJsonToObject( String content ) throws IOException {
-
- JsonNode jsonNode = mapper.readTree( content );
- Object jsonObject;
- if ( jsonNode.isArray() ) {
- jsonObject = mapper.readValue( content, listTypeReference );
- } else {
- jsonObject = mapper.readValue( content, mapTypeReference );
- }
- return jsonObject;
- }
+ * Next three new methods necessary to work around inexplicable problems with EntityHolder.
+ * This problem happens consistently when you deploy "two-dot-o" to Tomcat:
+ * https://groups.google.com/forum/#!topic/usergrid/yyAJdmsBfig
+ */
+ protected Object readJsonToObject(String content) throws IOException {
+
+ JsonNode jsonNode = mapper.readTree(content);
+ Object jsonObject;
+ if (jsonNode.isArray()) {
+ jsonObject = mapper.readValue(content, listTypeReference);
+ } else {
+ jsonObject = mapper.readValue(content, mapTypeReference);
+ }
+ return jsonObject;
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/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 f3238a4..d68b894 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
@@ -300,7 +300,7 @@ public class IndexResource extends AbstractContextResource {
logger.info( "Reindexing for app id: {} and collection {}", applicationId, collectionName );
emf.rebuildCollectionIndex(applicationId, collectionName, reverse, po);
- emf.refreshIndex();
+ getEntityIndex().refresh();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/rest/src/main/java/org/apache/usergrid/rest/test/RefreshIndexResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/test/RefreshIndexResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/test/RefreshIndexResource.java
index 4d0adb7..1717011 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/test/RefreshIndexResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/test/RefreshIndexResource.java
@@ -36,7 +36,7 @@ import org.springframework.stereotype.Component;
import org.apache.usergrid.rest.AbstractContextResource;
-/**
+/**
* Refresh index of an application, FOR TESTING PURPOSES ONLY. Only works with usergrid.test=true.
*/
@Component
@@ -49,9 +49,9 @@ public class RefreshIndexResource extends AbstractContextResource {
public RefreshIndexResource() {}
@POST
- public Response refresh(
- @QueryParam("org_name") String orgName,
- @QueryParam("app_name") String appName,
+ public Response refresh(
+ @QueryParam("org_name") String orgName,
+ @QueryParam("app_name") String appName,
@QueryParam("app_id") String appIdString ) throws IOException, Exception {
try {
@@ -64,7 +64,7 @@ public class RefreshIndexResource extends AbstractContextResource {
}
// refresh the system apps or app lookup below may fail
- emf.refreshIndex();
+ getEntityIndex().refresh();
UUID appId;
if ( orgName != null && appName != null ) {
@@ -72,12 +72,13 @@ public class RefreshIndexResource extends AbstractContextResource {
} else {
appId = UUID.fromString(appIdString);
}
-
+
if ( appId != null ) {
// found an app, then refresh it!
EntityManager em = emf.getEntityManager( appId );
- em.refreshIndex();
- }
+ getEntityIndex().refresh();
+
+ }
} catch (Exception e) {
logger.error("Error in refresh", e);
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/services/src/test/java/org/apache/usergrid/ServiceApplication.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/ServiceApplication.java b/stack/services/src/test/java/org/apache/usergrid/ServiceApplication.java
index 4172327..4ba85f3 100644
--- a/stack/services/src/test/java/org/apache/usergrid/ServiceApplication.java
+++ b/stack/services/src/test/java/org/apache/usergrid/ServiceApplication.java
@@ -73,7 +73,7 @@ public class ServiceApplication extends CoreApplication {
ServiceResults testRequest = testRequest( action, expectedCount, true, params );
if ( !action.equals( ServiceAction.GET )) {
- getEntityManager().refreshIndex();
+ setup.getEntityIndex().refresh();
}
return testRequest;
@@ -105,7 +105,7 @@ public class ServiceApplication extends CoreApplication {
dumpResults( results );
if ( !action.name().equals( ServiceAction.GET )) {
- getEntityManager().refreshIndex();
+ setup.getEntityIndex().refresh();
}
return results;
@@ -131,14 +131,14 @@ public class ServiceApplication extends CoreApplication {
put( "name", name );
Entity entity = testRequest( ServiceAction.POST, 1, pluralize( entityType ) ).getEntity();
- getEntityManager().refreshIndex();
+ setup.getEntityIndex().refresh();
return entity;
}
public void createConnection( Entity subject, String verb, Entity noun ) throws Exception {
sm.getEntityManager().createConnection( subject, verb, noun );
- getEntityManager().refreshIndex();
+ setup.getEntityIndex().refresh();
}
@@ -153,7 +153,7 @@ public class ServiceApplication extends CoreApplication {
dumpResults( results );
if ( !action.name().equals( ServiceAction.GET )) {
- getEntityManager().refreshIndex();
+ setup.getEntityIndex().refresh();
}
return results;
@@ -169,7 +169,7 @@ public class ServiceApplication extends CoreApplication {
assertNotNull( results.getData() );
if ( !action.name().equals( ServiceAction.GET )) {
- getEntityManager().refreshIndex();
+ setup.getEntityIndex().refresh();
}
// dump( results.getData() );
@@ -179,20 +179,20 @@ public class ServiceApplication extends CoreApplication {
public Entity createRole( String name, String title, int inactivity ) throws Exception {
Entity createRole = sm.getEntityManager().createRole( name, title, inactivity );
- getEntityManager().refreshIndex();
+ setup.getEntityIndex().refresh();
return createRole;
}
public void grantRolePermission( String role, String permission ) throws Exception {
sm.getEntityManager().grantRolePermission( role, permission );
- getEntityManager().refreshIndex();
+ setup.getEntityIndex().refresh();
}
public void grantUserPermission( UUID uuid, String permission ) throws Exception {
sm.getEntityManager().grantUserPermission( uuid, permission );
- getEntityManager().refreshIndex();
+ setup.getEntityIndex().refresh();
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/services/src/test/java/org/apache/usergrid/management/EmailFlowIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/EmailFlowIT.java b/stack/services/src/test/java/org/apache/usergrid/management/EmailFlowIT.java
index 2632909..1062120 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/EmailFlowIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/EmailFlowIT.java
@@ -283,7 +283,7 @@ public class EmailFlowIT {
String activation_url = String.format( setup.get( PROPERTIES_USER_ACTIVATION_URL ), orgName, appName,
appUser.getUuid().toString() );
- setup.getEmf().refreshIndex();
+ setup.getEntityIndex().refresh();
// Activation
setup.getMgmtSvc().startAppUserActivationFlow( app.getId(), appUser );
@@ -356,7 +356,7 @@ public class EmailFlowIT {
orgOwner = createOwnerAndOrganization( orgName, appName, userName, email, passwd, false, false );
assertNotNull( orgOwner );
- setup.getEmf().refreshIndex();
+ setup.getEntityIndex().refresh();
ApplicationInfo app = setup.getMgmtSvc().createApplication( orgOwner.getOrganization().getUuid(), appName );
assertNotNull( app );
@@ -466,7 +466,7 @@ public class EmailFlowIT {
userProps.put( "activated", activated );
User user = em.create( User.ENTITY_TYPE, User.class, userProps );
- em.refreshIndex();
+ setup.getEntityIndex().refresh();
return user;
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/services/src/test/java/org/apache/usergrid/management/OrganizationIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/OrganizationIT.java b/stack/services/src/test/java/org/apache/usergrid/management/OrganizationIT.java
index 5bf0c3d..7bd6574 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/OrganizationIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/OrganizationIT.java
@@ -70,7 +70,7 @@ public class OrganizationIT {
//createOrganization( orgName, user, false );
assertNotNull( organization );
- setup.getEmf().getEntityManager( setup.getSmf().getManagementAppId() ).refreshIndex();
+ setup.getEntityIndex().refresh();
Map<UUID, String> userOrganizations = setup.getMgmtSvc().getOrganizationsForAdminUser(
organization.getOwner().getUuid() );
assertEquals( "wrong number of organizations", 1, userOrganizations.size() );
@@ -82,8 +82,8 @@ public class OrganizationIT {
UUID applicationId = setup.getMgmtSvc().createApplication( organization.getOrganization().getUuid(), "ed-application" ).getId();
assertNotNull( applicationId );
- setup.getEmf().getEntityManager( setup.getSmf().getManagementAppId() ).refreshIndex();
- setup.getEmf().getEntityManager( applicationId ).refreshIndex();
+
+ setup.getEntityIndex().refresh();
Map<UUID, String> applications = setup.getMgmtSvc().getApplicationsForOrganization( organization.getOrganization().getUuid() );
assertEquals( "wrong number of applications", 1, applications.size() );
@@ -97,7 +97,7 @@ public class OrganizationIT {
setup.getMgmtSvc().activateOrganization( organization2 );
- setup.getEmf().getEntityManager( setup.getSmf().getManagementAppId() ).refreshIndex();
+ setup.getEntityIndex().refresh();
UserInfo u = setup.getMgmtSvc().verifyAdminUserPasswordCredentials( organization.getOwner().getUuid().toString(), "test" );
assertNotNull( u );
@@ -215,7 +215,7 @@ public class OrganizationIT {
OrganizationInfo organization2 = setup.getMgmtSvc().createOrganization(uniqueOrg(), user, false );
assertNotNull( organization2 );
- setup.getEmf().getEntityManager( setup.getSmf().getManagementAppId() ).refreshIndex();
+ setup.getEntityIndex().refresh();
Map<UUID, String> userOrganizations = setup.getMgmtSvc().getOrganizationsForAdminUser( user.getUuid() );
assertEquals( "wrong number of organizations", 2, userOrganizations.size() );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/services/src/test/java/org/apache/usergrid/management/RoleIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/RoleIT.java b/stack/services/src/test/java/org/apache/usergrid/management/RoleIT.java
index 05cc7c3..64109b2 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/RoleIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/RoleIT.java
@@ -66,7 +66,7 @@ public class RoleIT {
UUID applicationId = setup.getMgmtSvc().createApplication( organization.getUuid(), "test-app" ).getId();
EntityManager em = setup.getEmf().getEntityManager( applicationId );
- em.refreshIndex();
+ setup.getEntityIndex().refresh();
Map<String, Object> properties = new LinkedHashMap<String, Object>();
properties.put( "username", "edanuff5" );
@@ -75,7 +75,7 @@ public class RoleIT {
User user = em.create( User.ENTITY_TYPE, User.class, properties );
em.createRole( "logged-in", "Logged In", 1000 );
- em.refreshIndex();
+ setup.getEntityIndex().refresh();
em.addUserToRole( user.getUuid(), "logged-in" );
String accessToken = setup.getMgmtSvc().getAccessTokenForAppUser( applicationId, user.getUuid(), 0 );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d6bcf4bf/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
index 8d551cf..9f4fc94 100644
--- a/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/management/cassandra/ManagementServiceIT.java
@@ -97,7 +97,7 @@ public class ManagementServiceIT {
adminUser = orgAppAdminRule.getAdminInfo();
applicationId = orgAppAdminRule.getApplicationInfo().getId();
- setup.getEmf().refreshIndex();
+ setup.getEntityIndex().refresh();
}
@@ -195,7 +195,7 @@ public class ManagementServiceIT {
setup.getMgmtSvc().activateAppUser( applicationId, user.getUuid() );
- em.refreshIndex();
+ setup.getEntityIndex().refresh();
user = em.get( entity.getUuid(), User.class );
@@ -491,7 +491,7 @@ public class ManagementServiceIT {
false, false );
EntityManager em = setup.getEmf().getEntityManager( setup.getSmf().getManagementAppId() );
- em.refreshIndex();
+ setup.getEntityIndex().refresh();
UserInfo authedUser = setup.getMgmtSvc().verifyAdminUserPasswordCredentials( username, password );
@@ -542,7 +542,7 @@ public class ManagementServiceIT {
em.addToDictionary( storedUser, DICTIONARY_CREDENTIALS, "password", info );
- em.refreshIndex();
+ setup.getEntityIndex().refresh();
//verify authorization works
@@ -580,7 +580,7 @@ public class ManagementServiceIT {
EntityManager em = setup.getEmf().getEntityManager( setup.getEmf().getManagementAppId() );
User storedUser = em.create( user );
- em.refreshIndex();
+ setup.getEntityIndex().refresh();
UUID userId = storedUser.getUuid();
@@ -647,7 +647,7 @@ public class ManagementServiceIT {
User storedUser = em.create( user );
- em.refreshIndex();
+ setup.getEntityIndex().refresh();
UUID userId = storedUser.getUuid();
@@ -664,7 +664,7 @@ public class ManagementServiceIT {
setup.getMgmtSvc().setAppUserPassword( appId, userId, password, newPassword );
- em.refreshIndex();
+ setup.getEntityIndex().refresh();
//verify authorization works
authedUser = setup.getMgmtSvc().verifyAppUserPasswordCredentials( appId, username, newPassword );
@@ -691,7 +691,7 @@ public class ManagementServiceIT {
User storedUser = em.create( user );
- em.refreshIndex();
+ setup.getEntityIndex().refresh();
UUID userId = storedUser.getUuid();
@@ -721,7 +721,7 @@ public class ManagementServiceIT {
setup.getMgmtSvc().setAppUserPassword( appId, userId, password, newPassword );
- em.refreshIndex();
+ setup.getEntityIndex().refresh();
//verify authorization works
authedUser = setup.getMgmtSvc().verifyAppUserPasswordCredentials( appId, username, newPassword );
@@ -750,7 +750,7 @@ public class ManagementServiceIT {
User storedUser = em.create( user );
- em.refreshIndex();
+ setup.getEntityIndex().refresh();
UUID userId = storedUser.getUuid();
@@ -787,7 +787,7 @@ public class ManagementServiceIT {
setup.getMgmtSvc().setAppUserPassword( appId, userId, password, newPassword );
- em.refreshIndex();
+ setup.getEntityIndex().refresh();
//verify authorization works
authedUser = setup.getMgmtSvc().verifyAppUserPasswordCredentials( appId, username, newPassword );
[11/31] incubator-usergrid git commit: tests passing in queryindex
Posted by to...@apache.org.
tests passing in queryindex
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/5f75292c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/5f75292c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/5f75292c
Branch: refs/heads/USERGRID-486
Commit: 5f75292c13fbb8c8acd722ce59c014828f1619c6
Parents: b5ce085
Author: Shawn Feldman <sf...@apache.org>
Authored: Thu Mar 19 13:57:19 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Thu Mar 19 13:57:19 2015 -0600
----------------------------------------------------------------------
.../corepersistence/CpEntityManager.java | 23 +++----
.../corepersistence/CpEntityManagerFactory.java | 2 +-
.../corepersistence/CpManagerCache.java | 6 +-
.../corepersistence/CpRelationManager.java | 19 +++---
.../events/EntityDeletedHandler.java | 3 +-
.../events/EntityVersionDeletedHandler.java | 3 +-
.../results/FilteringLoader.java | 3 +-
.../usergrid/persistence/EntityManager.java | 7 +--
.../cassandra/EntityManagerImpl.java | 9 +--
.../corepersistence/StaleIndexCleanupTest.java | 17 +++--
.../persistence/index/IndexIdentifier.java | 3 +
.../index/impl/EsEntityIndexImpl.java | 66 +++++++++-----------
.../persistence/index/impl/EntityIndexTest.java | 17 +++--
13 files changed, 76 insertions(+), 102 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5f75292c/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
index 8787410..b23111a 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
@@ -36,6 +36,7 @@ import java.util.UUID;
import com.codahale.metrics.Meter;
import org.apache.usergrid.persistence.collection.FieldSet;
import org.apache.usergrid.persistence.core.future.BetterFuture;
+import org.apache.usergrid.persistence.index.ApplicationEntityIndex;
import org.elasticsearch.action.ListenableActionFuture;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -211,6 +212,7 @@ public class CpEntityManager implements EntityManager {
private Timer entGetRepairedEntityTimer;
private Timer updateEntityTimer;
private Meter updateEntityMeter;
+ private EntityIndex ei;
// /** Short-term cache to keep us from reloading same Entity during single request. */
// private LoadingCache<EntityScope, org.apache.usergrid.persistence.model.entity.Entity> entityCache;
@@ -221,7 +223,8 @@ public class CpEntityManager implements EntityManager {
}
@Override
- public void init( EntityManagerFactory emf, UUID applicationId ) {
+ public void init( EntityManagerFactory emf, EntityIndex ei, UUID applicationId ) {
+ this.ei = ei;
Preconditions.checkNotNull( emf, "emf must not be null" );
Preconditions.checkNotNull( applicationId, "applicationId must not be null" );
@@ -286,7 +289,6 @@ public class CpEntityManager implements EntityManager {
@Override
public Health getIndexHealth() {
- EntityIndex ei = managerCache.getEntityIndex( applicationScope );
return ei.getIndexHealth();
}
@@ -1079,7 +1081,7 @@ public class CpEntityManager implements EntityManager {
getCollectionScopeNameFromEntityType( entityRef.getType() ) );
EntityCollectionManager ecm = managerCache.getEntityCollectionManager( collectionScope );
- EntityIndex ei = managerCache.getEntityIndex( getApplicationScope() );
+ ApplicationEntityIndex aei = managerCache.getEntityIndex( getApplicationScope() );
Id entityId = new SimpleId( entityRef.getUuid(), entityRef.getType() );
@@ -1106,7 +1108,7 @@ public class CpEntityManager implements EntityManager {
//Adding graphite metrics
Timer.Context timeESBatch = esDeletePropertyTimer.time();
- BetterFuture future = ei.createBatch().index( defaultIndexScope, cpEntity ).execute();
+ BetterFuture future = aei.createBatch().index( defaultIndexScope, cpEntity ).execute();
timeESBatch.stop();
// update in all containing collections and connection indexes
CpRelationManager rm = ( CpRelationManager ) getRelationManager( entityRef );
@@ -2889,24 +2891,15 @@ public class CpEntityManager implements EntityManager {
emf.refreshIndex();
// refresh this Entity Manager's application's index
- EntityIndex ei = managerCache.getEntityIndex( getApplicationScope() );
ei.refresh();
}
@Override
public void createIndex() {
- EntityIndex ei = managerCache.getEntityIndex( applicationScope );
ei.initializeIndex();
}
- public ListenableActionFuture deleteIndex(){
- EntityIndex ei = managerCache.getEntityIndex( applicationScope );
- return ei.deleteIndex();
- }
-
-
-
@Override
@@ -2981,8 +2974,8 @@ public class CpEntityManager implements EntityManager {
org.apache.usergrid.persistence.model.entity.Entity memberEntity,
String collName ) {
- final EntityIndex ei = getManagerCache().getEntityIndex( getApplicationScope() );
- final EntityIndexBatch batch = ei.createBatch();
+ final ApplicationEntityIndex aie = getManagerCache().getEntityIndex( getApplicationScope() );
+ final EntityIndexBatch batch = aie.createBatch();
// index member into entity collection | type scope
IndexScope collectionIndexScope = new IndexScopeImpl( collectionEntity.getId(),
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5f75292c/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 e70e538..14b7865 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
@@ -199,7 +199,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
private EntityManager _getEntityManager( UUID applicationId ) {
EntityManager em = new CpEntityManager();
- em.init( this, applicationId );
+ em.init( this,entityIndex ,applicationId );
return em;
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5f75292c/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpManagerCache.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpManagerCache.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpManagerCache.java
index aa8a139..4e35f8c 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpManagerCache.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpManagerCache.java
@@ -25,6 +25,7 @@ import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory
import org.apache.usergrid.persistence.core.scope.ApplicationScope;
import org.apache.usergrid.persistence.graph.GraphManager;
import org.apache.usergrid.persistence.graph.GraphManagerFactory;
+import org.apache.usergrid.persistence.index.ApplicationEntityIndex;
import org.apache.usergrid.persistence.index.EntityIndex;
import org.apache.usergrid.persistence.index.EntityIndexFactory;
import org.apache.usergrid.persistence.map.MapManager;
@@ -62,16 +63,15 @@ public class CpManagerCache implements ManagerCache {
@Override
public EntityCollectionManager getEntityCollectionManager( CollectionScope scope ) {
-
//cache is now in the colletion manager level
return ecmf.createCollectionManager( scope );
}
@Override
- public EntityIndex getEntityIndex( ApplicationScope appScope ) {
+ public ApplicationEntityIndex getEntityIndex( ApplicationScope appScope ) {
- return eif.createEntityIndex( appScope );
+ return eif.createApplicationEntityIndex( appScope );
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5f75292c/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
index 2eeee28..df01c47 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
@@ -30,6 +30,7 @@ import java.util.Set;
import java.util.UUID;
import org.apache.usergrid.persistence.core.future.BetterFuture;
+import org.apache.usergrid.persistence.index.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.Assert;
@@ -75,10 +76,6 @@ import org.apache.usergrid.persistence.graph.impl.SimpleEdge;
import org.apache.usergrid.persistence.graph.impl.SimpleSearchByEdge;
import org.apache.usergrid.persistence.graph.impl.SimpleSearchByEdgeType;
import org.apache.usergrid.persistence.graph.impl.SimpleSearchEdgeType;
-import org.apache.usergrid.persistence.index.EntityIndex;
-import org.apache.usergrid.persistence.index.EntityIndexBatch;
-import org.apache.usergrid.persistence.index.IndexScope;
-import org.apache.usergrid.persistence.index.SearchTypes;
import org.apache.usergrid.persistence.index.impl.IndexScopeImpl;
import org.apache.usergrid.persistence.index.query.CandidateResult;
import org.apache.usergrid.persistence.index.query.CandidateResults;
@@ -397,7 +394,7 @@ public class CpRelationManager implements RelationManager {
// loop through all types of edge to target
- final EntityIndex ei = managerCache.getEntityIndex( applicationScope );
+ final ApplicationEntityIndex ei = managerCache.getEntityIndex(applicationScope);
final EntityIndexBatch entityIndexBatch = ei.createBatch();
@@ -828,7 +825,7 @@ public class CpRelationManager implements RelationManager {
org.apache.usergrid.persistence.model.entity.Entity memberEntity =
((CpEntityManager)em).load( new CpEntityManager.EntityScope( memberScope, entityId));
- final EntityIndex ei = managerCache.getEntityIndex( applicationScope );
+ final ApplicationEntityIndex ei = managerCache.getEntityIndex( applicationScope );
final EntityIndexBatch batch = ei.createBatch();
// remove item from collection index
@@ -945,7 +942,7 @@ public class CpRelationManager implements RelationManager {
cpHeadEntity.getId(),
CpNamingUtils.getCollectionScopeNameFromCollectionName( collName ) );
- final EntityIndex ei = managerCache.getEntityIndex( applicationScope );
+ final ApplicationEntityIndex ei = managerCache.getEntityIndex( applicationScope );
final SearchTypes types = SearchTypes.fromTypes( collection.getType() );
@@ -1060,7 +1057,7 @@ public class CpRelationManager implements RelationManager {
GraphManager gm = managerCache.getGraphManager( applicationScope );
gm.writeEdge( edge ).toBlockingObservable().last();
- EntityIndex ei = managerCache.getEntityIndex( applicationScope );
+ ApplicationEntityIndex ei = managerCache.getEntityIndex( applicationScope );
EntityIndexBatch batch = ei.createBatch();
// Index the new connection in app|source|type context
@@ -1292,7 +1289,7 @@ public class CpRelationManager implements RelationManager {
GraphManager gm = managerCache.getGraphManager( applicationScope );
gm.deleteEdge( edge ).toBlockingObservable().last();
- final EntityIndex ei = managerCache.getEntityIndex( applicationScope );
+ final ApplicationEntityIndex ei = managerCache.getEntityIndex( applicationScope );
final EntityIndexBatch batch = ei.createBatch();
// Deindex the connection in app|source|type context
@@ -1372,7 +1369,7 @@ public class CpRelationManager implements RelationManager {
final SearchTypes searchTypes = SearchTypes.fromNullableTypes( connectedEntityType );
- final EntityIndex ei = managerCache.getEntityIndex( applicationScope );
+ final ApplicationEntityIndex ei = managerCache.getEntityIndex( applicationScope );
logger.debug("Searching connected entities from scope {}:{}",
@@ -1465,7 +1462,7 @@ public class CpRelationManager implements RelationManager {
final SearchTypes searchTypes = SearchTypes.fromNullableTypes( query.getEntityType() );
- EntityIndex ei = managerCache.getEntityIndex( applicationScope );
+ ApplicationEntityIndex ei = managerCache.getEntityIndex( applicationScope );
logger.debug( "Searching connections from the scope {}:{} with types {}", new Object[] {
indexScope.getOwner().toString(), indexScope.getName(), searchTypes
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5f75292c/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityDeletedHandler.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityDeletedHandler.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityDeletedHandler.java
index 94ef5e4..85c59da 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityDeletedHandler.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityDeletedHandler.java
@@ -20,6 +20,7 @@ package org.apache.usergrid.corepersistence.events;
import java.util.UUID;
+import org.apache.usergrid.persistence.index.ApplicationEntityIndex;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -70,7 +71,7 @@ public class EntityDeletedHandler implements EntityDeleted {
} );
CpEntityManagerFactory cpemf = ( CpEntityManagerFactory ) emf;
- final EntityIndex ei = cpemf.getManagerCache().getEntityIndex( scope );
+ final ApplicationEntityIndex ei = cpemf.getManagerCache().getEntityIndex( scope );
final IndexScope indexScope =
new IndexScopeImpl( new SimpleId( scope.getOwner().getUuid(), scope.getOwner().getType() ),
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5f75292c/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionDeletedHandler.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionDeletedHandler.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionDeletedHandler.java
index c45949b..ece7562 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionDeletedHandler.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/events/EntityVersionDeletedHandler.java
@@ -29,6 +29,7 @@ import org.apache.usergrid.persistence.collection.MvccEntity;
import org.apache.usergrid.persistence.collection.MvccLogEntry;
import org.apache.usergrid.persistence.collection.event.EntityVersionDeleted;
import org.apache.usergrid.persistence.collection.serialization.SerializationFig;
+import org.apache.usergrid.persistence.index.ApplicationEntityIndex;
import org.apache.usergrid.persistence.index.EntityIndex;
import org.apache.usergrid.persistence.index.EntityIndexBatch;
import org.apache.usergrid.persistence.index.IndexScope;
@@ -85,7 +86,7 @@ public class EntityVersionDeletedHandler implements EntityVersionDeleted {
CpEntityManagerFactory cpemf = (CpEntityManagerFactory)emf;
- final EntityIndex ei = cpemf.getManagerCache().getEntityIndex( scope );
+ final ApplicationEntityIndex ei = cpemf.getManagerCache().getEntityIndex( scope );
final IndexScope indexScope = new IndexScopeImpl(
new SimpleId(scope.getOwner().getUuid(), scope.getOwner().getType()),
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5f75292c/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/FilteringLoader.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/FilteringLoader.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/FilteringLoader.java
index b571f21..0a0f71a 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/FilteringLoader.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/FilteringLoader.java
@@ -30,6 +30,7 @@ import java.util.UUID;
import javax.annotation.Nullable;
+import org.apache.usergrid.persistence.index.ApplicationEntityIndex;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -82,7 +83,7 @@ public class FilteringLoader implements ResultsLoader {
this.applicationScope = applicationScope;
this.indexScope = indexScope;
- final EntityIndex index = managerCache.getEntityIndex( applicationScope );
+ final ApplicationEntityIndex index = managerCache.getEntityIndex( applicationScope );
indexBatch = index.createBatch();
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5f75292c/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
index 2a951aa..71dcd07 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManager.java
@@ -17,6 +17,7 @@
package org.apache.usergrid.persistence;
+import org.apache.usergrid.persistence.index.EntityIndex;
import org.apache.usergrid.persistence.index.query.Query;
import java.nio.ByteBuffer;
import java.util.Collection;
@@ -694,12 +695,8 @@ public interface EntityManager {
*/
void createIndex();
- /**
- * Create the index, should ONLY ever be called the first time an application is created
- */
- ListenableActionFuture deleteIndex();
- public void init( EntityManagerFactory emf, UUID applicationId);
+ public void init( EntityManagerFactory emf, EntityIndex entityIndex, UUID applicationId);
/** For testing purposes */
public void flushManagerCaches();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5f75292c/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
index 966a601..803512b 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
@@ -36,6 +36,7 @@ import java.util.UUID;
import javax.annotation.Resource;
+import org.apache.usergrid.persistence.index.EntityIndex;
import org.elasticsearch.action.ListenableActionFuture;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -214,7 +215,7 @@ public class EntityManagerImpl implements EntityManager {
@Override
- public void init(EntityManagerFactory emf, UUID applicationId) {
+ public void init(EntityManagerFactory emf, EntityIndex entityIndex, UUID applicationId) {
init( (EntityManagerFactoryImpl)emf, null, null, applicationId, false);
}
@@ -2895,12 +2896,6 @@ public class EntityManagerImpl implements EntityManager {
}
- @Override
- public ListenableActionFuture deleteIndex() {
- //no op
- return null;
- }
-
@Override
public EntityRef getGroupRoleRef( UUID ownerId, String roleName) throws Exception {
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5f75292c/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
index 1becee4..fdd230c 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/StaleIndexCleanupTest.java
@@ -24,6 +24,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
+import org.apache.usergrid.persistence.index.*;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
@@ -46,10 +47,6 @@ import org.apache.usergrid.persistence.collection.EntityCollectionManager;
import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory;
import org.apache.usergrid.persistence.core.scope.ApplicationScope;
import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
-import org.apache.usergrid.persistence.index.EntityIndex;
-import org.apache.usergrid.persistence.index.EntityIndexFactory;
-import org.apache.usergrid.persistence.index.IndexScope;
-import org.apache.usergrid.persistence.index.SearchTypes;
import org.apache.usergrid.persistence.index.impl.IndexScopeImpl;
import org.apache.usergrid.persistence.index.query.CandidateResults;
import org.apache.usergrid.persistence.index.query.Query;
@@ -155,12 +152,12 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
UUID newVersion = getCpEntity( thing ).getVersion();
- assertEquals( 2, queryCollectionCp( "things", "thing", "select * order by ordinal desc" ).size() );
+ assertEquals(2, queryCollectionCp("things", "thing", "select * order by ordinal desc").size());
//now run enable events and ensure we clean up
- System.setProperty( EVENTS_DISABLED, "false" );
+ System.setProperty(EVENTS_DISABLED, "false");
- final Results results = queryCollectionEm( "things", "select * order by ordinal desc" );
+ final Results results = queryCollectionEm("things", "select * order by ordinal desc");
assertEquals( 1, results.size() );
assertEquals(1, results.getEntities().get( 0 ).getProperty( "ordinal" ));
@@ -169,9 +166,9 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
//ensure it's actually gone
final CandidateResults candidates = queryCollectionCp( "things", "thing", "select * order by ordinal desc" );
- assertEquals( 1, candidates.size() );
+ assertEquals(1, candidates.size());
- assertEquals(newVersion, candidates.get( 0 ).getVersion());
+ assertEquals(newVersion, candidates.get(0).getVersion());
}
@@ -483,7 +480,7 @@ public class StaleIndexCleanupTest extends AbstractCoreIT {
ApplicationScope as = new ApplicationScopeImpl(
new SimpleId( em.getApplicationId(), TYPE_APPLICATION ) );
- EntityIndex ei = eif.createEntityIndex( as );
+ ApplicationEntityIndex ei = eif.createApplicationEntityIndex(as);
IndexScope is = new IndexScopeImpl( new SimpleId( em.getApplicationId(), TYPE_APPLICATION ),
CpNamingUtils.getCollectionScopeNameFromCollectionName( collName ) );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5f75292c/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexIdentifier.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexIdentifier.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexIdentifier.java
index 1ac9d49..c659ed6 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexIdentifier.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexIdentifier.java
@@ -20,12 +20,15 @@
package org.apache.usergrid.persistence.index;
+import com.google.inject.Inject;
+
/**
* Class is used to generate an index name and alias name
*/
public class IndexIdentifier{
private final IndexFig config;
+ @Inject
public IndexIdentifier(IndexFig config) {
this.config = config;
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5f75292c/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 d510a8d..e92e133 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
@@ -55,6 +55,8 @@ import org.elasticsearch.index.query.*;
import org.elasticsearch.indices.IndexAlreadyExistsException;
import org.elasticsearch.indices.IndexMissingException;
+import org.elasticsearch.indices.InvalidAliasNameException;
+import org.elasticsearch.rest.action.admin.indices.alias.delete.AliasesMissingException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -119,9 +121,6 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
this.esProvider = provider;
this.config = config;
-
-
-
this.alias = indexIdentifier.getAlias();
this.aliasCache = indexCache;
this.addTimer = metricsFactory
@@ -143,14 +142,14 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
if(indexes == null || indexes.length==0) {
addIndex(null, numberOfShards, numberOfReplicas, config.getWriteConsistencyLevel());
}
+
}
@Override
public void addIndex(final String indexSuffix,final int numberOfShards, final int numberOfReplicas, final String writeConsistency) {
- String normalizedSuffix = StringUtils.isNotEmpty(indexSuffix) ? indexSuffix : null;
try {
//get index name with suffix attached
- String indexName = indexIdentifier.getIndex(normalizedSuffix);
+ String indexName = indexIdentifier.getIndex(indexSuffix);
//Create index
try {
@@ -186,12 +185,10 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
//We do NOT want to create an alias if the index already exists, we'll overwrite the indexes that
//may have been set via other administrative endpoint
- addAlias(normalizedSuffix);
+ addAlias(indexSuffix);
testNewIndex();
-
-
} catch (IndexAlreadyExistsException expected) {
// this is expected to happen if index already exists, it's a no-op and swallow
} catch (IOException e) {
@@ -202,51 +199,47 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
@Override
public void addAlias(final String indexSuffix) {
-
- final Timer.Context timeRemoveAlias = updateAliasTimer.time();
+ Timer.Context timer = updateAliasTimer.time();
try {
-
-
+ Boolean isAck;
String indexName = indexIdentifier.getIndex(indexSuffix);
final AdminClient adminClient = esProvider.getClient().admin();
- String[] indexNames = getIndexesFromEs(AliasType.Write);
-
-
- final IndicesAliasesRequestBuilder aliasesRequestBuilder = adminClient.indices().prepareAliases();
+ String[] indexNames = getIndexes(AliasType.Write);
- //remove the write alias from it's target
+ int count = 0;
+ IndicesAliasesRequestBuilder aliasesRequestBuilder = adminClient.indices().prepareAliases();
for ( String currentIndex : indexNames ) {
aliasesRequestBuilder.removeAlias( currentIndex, alias.getWriteAlias() );
- logger.info("Removing existing write Alias Name [{}] from Index [{}]", alias.getWriteAlias(), currentIndex);
+ count++;
}
+ if(count>0) {
+ isAck = aliasesRequestBuilder.execute().actionGet().isAcknowledged();
+ logger.info("Removed Index Name from Alias=[{}] ACK=[{}]", alias, isAck);
+ }
+ aliasesRequestBuilder = adminClient.indices().prepareAliases();
//Added For Graphite Metrics
-
// add read alias
- aliasesRequestBuilder.addAlias( indexName, alias.getReadAlias());
- logger.info("Created new read Alias Name [{}] on Index [{}]", alias.getReadAlias(), indexName);
-
+ aliasesRequestBuilder.addAlias(
+ indexName, alias.getReadAlias());
+ //Added For Graphite Metrics
//add write alias
- aliasesRequestBuilder.addAlias( indexName, alias.getWriteAlias() );
-
- logger.info("Created new write Alias Name [{}] on Index [{}]", alias.getWriteAlias(), indexName);
+ aliasesRequestBuilder.addAlias(
+ indexName, alias.getWriteAlias());
- final IndicesAliasesResponse result = aliasesRequestBuilder.execute().actionGet();
+ isAck = aliasesRequestBuilder.execute().actionGet().isAcknowledged();
- final boolean isAcknowledged = result.isAcknowledged();
+ logger.info("Created new aliases ACK=[{}]", isAck);
- if(!isAcknowledged){
- throw new RuntimeException( "Unable to add aliases to the new index. Elasticsearch did not acknowledge to the alias change for index '" + indexSuffix + "'");
- }
+ aliasCache.invalidate(alias);
+ } catch (Exception e) {
+ logger.warn("Failed to create alias ", e);
}
- finally{
- //invalidate the alias
- aliasCache.invalidate(alias);
- //stop the timer
- timeRemoveAlias.stop();
+ finally {
+ timer.stop();
}
}
@@ -255,7 +248,6 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
return aliasCache.getIndexes(alias, aliasType);
}
-
/**
* Get our index info from ES, but clear our cache first
* @param aliasType
@@ -266,8 +258,6 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
return getIndexes( aliasType );
}
-
-
/**
* Tests writing a document to a new index to ensure it's working correctly. See this post:
* http://s.apache.org/index-missing-exception
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/5f75292c/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 483efb9..28c548d 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
@@ -81,22 +81,21 @@ public class EntityIndexTest extends BaseIT {
@Test
public void testIndex() throws IOException, InterruptedException {
- Id appId = new SimpleId( "application" );
+ Id appId = new SimpleId("application");
+ ei.initializeIndex();
- ApplicationScope applicationScope = new ApplicationScopeImpl( appId );
+ ApplicationScope applicationScope = new ApplicationScopeImpl(appId);
ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex(applicationScope);
-
final String entityType = "thing";
- IndexScope indexScope = new IndexScopeImpl( appId, "things" );
- final SearchTypes searchTypes = SearchTypes.fromTypes( entityType );
+ IndexScope indexScope = new IndexScopeImpl(appId, "things");
+ final SearchTypes searchTypes = SearchTypes.fromTypes(entityType);
- insertJsonBlob(entityIndex, entityType, indexScope, "/sample-large.json",101,0);
-
- ei.refresh();
+ insertJsonBlob(entityIndex, entityType, indexScope, "/sample-large.json", 101, 0);
+ ei.refresh();
- testQueries( indexScope, searchTypes, entityIndex );
+ testQueries(indexScope, searchTypes, entityIndex);
}
@Test
[24/31] incubator-usergrid git commit: add small sleep
Posted by to...@apache.org.
add small sleep
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/7002051c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/7002051c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/7002051c
Branch: refs/heads/USERGRID-486
Commit: 7002051c8993d7791ff50c1257e82155e60ab818
Parents: e64e15f
Author: Shawn Feldman <sf...@apache.org>
Authored: Fri Mar 20 12:51:31 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Fri Mar 20 12:51:31 2015 -0600
----------------------------------------------------------------------
.../src/test/java/org/apache/usergrid/CoreApplication.java | 6 ++++++
1 file changed, 6 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/7002051c/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java b/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
index ea7a5de..00972ea 100644
--- a/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
+++ b/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
@@ -216,6 +216,12 @@ public class CoreApplication implements Application, TestRule {
@Override
public void refreshIndex() {
+ try{
+ Thread.sleep(100);
+ }catch (InterruptedException ie){
+
+ }
+
entityIndex.refresh();
}
[18/31] incubator-usergrid git commit: Merge branch 'USERGRID-405' of
https://git-wip-us.apache.org/repos/asf/incubator-usergrid into USERGRID-480
Posted by to...@apache.org.
Merge branch 'USERGRID-405' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into USERGRID-480
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/51a38fc1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/51a38fc1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/51a38fc1
Branch: refs/heads/USERGRID-486
Commit: 51a38fc1a9321f1eb66e82293bcab9b52c478a77
Parents: d6bcf4b 0a16033
Author: Shawn Feldman <sf...@apache.org>
Authored: Fri Mar 20 07:10:06 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Fri Mar 20 07:10:06 2015 -0600
----------------------------------------------------------------------
stack/core/pom.xml | 7 +++----
stack/pom.xml | 6 ++++--
stack/rest/pom.xml | 1 +
stack/services/pom.xml | 1 +
4 files changed, 9 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
[10/31] incubator-usergrid git commit: merge 408
Posted by to...@apache.org.
merge 408
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/b5ce0856
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/b5ce0856
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/b5ce0856
Branch: refs/heads/USERGRID-486
Commit: b5ce08566ba8442f0e69d16c0e7714103c0e8d14
Parents: b35551a 679812e
Author: Shawn Feldman <sf...@apache.org>
Authored: Thu Mar 19 10:37:14 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Thu Mar 19 10:37:14 2015 -0600
----------------------------------------------------------------------
.../corepersistence/CpEntityManager.java | 5 +-
.../corepersistence/CpEntityManagerFactory.java | 39 +-
.../usergrid/corepersistence/ManagerCache.java | 3 +-
.../usergrid/persistence/EntityManager.java | 3 +-
.../cassandra/EntityManagerImpl.java | 4 +-
.../org/apache/usergrid/CoreApplication.java | 7 +-
.../org/apache/usergrid/CoreITSetupImpl.java | 1 +
.../PerformanceEntityRebuildIndexTest.java | 80 ++--
.../index/ApplicationEntityIndex.java | 42 +++
.../usergrid/persistence/index/EntityIndex.java | 46 +--
.../persistence/index/EntityIndexFactory.java | 2 +-
.../persistence/index/IndexIdentifier.java | 25 +-
.../usergrid/persistence/index/SearchType.java | 49 +++
.../usergrid/persistence/index/SearchTypes.java | 14 +-
.../persistence/index/guice/IndexModule.java | 5 +-
.../impl/EsApplicationEntityIndexImpl.java | 305 +++++++++++++++
.../index/impl/EsEntityIndexBatchImpl.java | 45 +--
.../index/impl/EsEntityIndexFactoryImpl.java | 27 +-
.../index/impl/EsEntityIndexImpl.java | 375 ++-----------------
.../persistence/index/impl/EsQueryVistor.java | 88 +++--
.../persistence/index/impl/IndexingUtils.java | 136 ++++---
.../index/impl/CorePerformanceIT.java | 20 +-
.../impl/EntityConnectionIndexImplTest.java | 20 +-
.../persistence/index/impl/EntityIndexTest.java | 159 +++-----
24 files changed, 756 insertions(+), 744 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b5ce0856/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
----------------------------------------------------------------------
diff --cc stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
index f76b9fc,41bcf62..e70e538
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
@@@ -15,24 -15,20 +15,25 @@@
*/
package org.apache.usergrid.corepersistence;
-import com.google.common.base.Optional;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.LoadingCache;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import static java.lang.String.CASE_INSENSITIVE_ORDER;
-import java.util.*;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
++import org.apache.usergrid.persistence.index.ApplicationEntityIndex;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
import org.apache.commons.lang.StringUtils;
-import org.apache.usergrid.corepersistence.rx.AllEntitiesInSystemObservable;
import org.apache.usergrid.corepersistence.util.CpNamingUtils;
import org.apache.usergrid.persistence.AbstractEntity;
import org.apache.usergrid.persistence.Entity;
@@@ -118,15 -105,16 +119,17 @@@ public class CpEntityManagerFactory imp
private CassandraService cassandraService;
private CounterUtils counterUtils;
private Injector injector;
++ private final EntityIndex entityIndex;
private final MetricsFactory metricsFactory;
public CpEntityManagerFactory(
-- final CassandraService cassandraService, final CounterUtils counterUtils, final Injector injector) {
++ final CassandraService cassandraService, final CounterUtils counterUtils, final Injector injector, final EntityIndex entityIndex) {
this.cassandraService = cassandraService;
this.counterUtils = counterUtils;
this.injector = injector;
++ this.entityIndex = entityIndex;
this.managerCache = injector.getInstance( ManagerCache.class );
- this.dataMigrationManager = injector.getInstance( DataMigrationManager.class );
this.metricsFactory = injector.getInstance( MetricsFactory.class );
this.orgApplicationCache = new OrgApplicationCacheImpl( this );
@@@ -311,10 -291,9 +316,9 @@@
properties = new TreeMap<String, Object>( CASE_INSENSITIVE_ORDER );
}
properties.put( PROPERTY_NAME, appName );
- EntityManager appEm = getEntityManager( applicationId );
+ EntityManager appEm = getEntityManager( applicationId);
- appEm.create( applicationId, TYPE_APPLICATION, properties );
- appEm.createIndex();
- appEm.create(applicationId, TYPE_APPLICATION, properties );
++ appEm.create(applicationId, TYPE_APPLICATION, properties);
appEm.resetRoles();
appEm.refreshIndex();
@@@ -354,9 -333,9 +358,6 @@@
em.delete(appToDelete);
}
-- // delete the application's index
-- EntityIndex ei = managerCache.getEntityIndex(new ApplicationScopeImpl(new SimpleId(applicationId, TYPE_APPLICATION)));
-- ei.deleteIndex();
em.refreshIndex();
}
@@@ -367,7 -346,7 +368,7 @@@
// remove old delete_appinfos Entity
EntityManager em = getEntityManager(CpNamingUtils.SYSTEM_APP_ID);
Query q = Query.fromQL(String.format("select * where applicationUuid = '%s'", applicationId.toString()));
-- Results results = em.searchCollection( em.getApplicationRef(), "deleted_appinfos", q);
++ Results results = em.searchCollection(em.getApplicationRef(), "deleted_appinfos", q);
Entity appToRestore = results.getEntity();
if ( appToRestore == null ) {
@@@ -413,7 -392,7 +414,7 @@@
@Override
public Map<String, UUID> getApplications() throws Exception {
-- return getApplications( false );
++ return getApplications(false);
}
@@@ -664,9 -644,9 +665,7 @@@
maybeCreateIndexes();
// system app
-- for ( EntityIndex index : getManagementIndexes() ) {
-- index.refresh();
-- }
++ entityIndex.refresh();
}
@@@ -676,13 -656,13 +675,11 @@@
return;
}
-- for ( EntityIndex index : getManagementIndexes() ) {
-- index.initializeIndex();
-- }
++ entityIndex.initializeIndex();
}
-- private List<EntityIndex> getManagementIndexes() {
++ private List<ApplicationEntityIndex> getManagementIndexes() {
return Arrays.asList( managerCache.getEntityIndex(
new ApplicationScopeImpl( new SimpleId( CpNamingUtils.SYSTEM_APP_ID, "application" ) ) ),
@@@ -764,7 -770,7 +760,6 @@@
@Override
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,writeConsistency);
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b5ce0856/stack/core/src/main/java/org/apache/usergrid/corepersistence/ManagerCache.java
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b5ce0856/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
----------------------------------------------------------------------
diff --cc stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
index f1f165d,f1f165d..c58750b
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
@@@ -25,6 -25,6 +25,7 @@@ import java.util.UUID
import java.util.concurrent.TimeUnit;
import org.apache.commons.lang.RandomStringUtils;
++import org.apache.usergrid.persistence.index.ApplicationEntityIndex;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@@ -175,17 -175,17 +176,17 @@@ public class PerformanceEntityRebuildIn
// ----------------- delete the system and application indexes
logger.debug("Deleting app index index");
-- //deleteIndex( CpNamingUtils.SYSTEM_APP_ID );
-- deleteIndex( em.getApplicationId() );
--
-- // ----------------- test that we can read them, should fail
--
-- logger.debug("Reading data, should fail this time ");
-- try {
-- readData( em, "testTypes", entityCount, 0 );
-- fail("should have failed to read data");
--
-- } catch (Exception expected) {}
++// //deleteIndex( CpNamingUtils.SYSTEM_APP_ID );
++// deleteIndex( em.getApplicationId() );
++//
++// // ----------------- test that we can read them, should fail
++//
++// logger.debug("Reading data, should fail this time ");
++// try {
++// readData( em, "testTypes", entityCount, 0 );
++// fail("should have failed to read data");
++//
++// } catch (Exception expected) {}
// ----------------- rebuild index for catherders only
@@@ -313,20 -313,20 +314,20 @@@
logger.debug("Deleting app index and system app index");
-- deleteIndex( em.getApplicationId() );
--
-- // deleting sytem app index will interfere with other concurrently running tests
-- //deleteIndex( CpNamingUtils.SYSTEM_APP_ID );
--
--
-- // ----------------- test that we can read them, should fail
--
-- logger.debug("Reading data, should fail this time ");
-- try {
-- readData( em, "testTypes", entityCount, 3 );
-- fail("should have failed to read data");
--
-- } catch (Exception expected) {}
++// deleteIndex( em.getApplicationId() );
++//
++// // deleting sytem app index will interfere with other concurrently running tests
++// //deleteIndex( CpNamingUtils.SYSTEM_APP_ID );
++//
++//
++// // ----------------- test that we can read them, should fail
++//
++// logger.debug("Reading data, should fail this time ");
++// try {
++// readData( em, "testTypes", entityCount, 3 );
++// fail("should have failed to read data");
++//
++// } catch (Exception expected) {}
// ----------------- rebuild index
@@@ -374,21 -374,21 +375,20 @@@
readData( em, "testTypes", entityCount, 3 );
}
-- /**
-- * Delete index for all applications, just need the one to get started.
-- */
-- private void deleteIndex( UUID appUuid ) {
--
-- Injector injector = SpringResource.getInstance().getBean( Injector.class );
-- EntityIndexFactory eif = injector.getInstance( EntityIndexFactory.class );
--
-- Id appId = new SimpleId( appUuid, "application");
-- ApplicationScope scope = new ApplicationScopeImpl( appId );
-- EntityIndex ei = eif.createEntityIndex(scope);
-- EsEntityIndexImpl eeii = (EsEntityIndexImpl)ei;
--
-- eeii.deleteIndex();
-- }
++// /**
++// * Delete index for all applications, just need the one to get started.
++// */
++// private void deleteIndex( UUID appUuid ) {
++//
++// Injector injector = SpringResource.getInstance().getBean( Injector.class );
++// EntityIndexFactory eif = injector.getInstance( EntityIndexFactory.class );
++//
++// Id appId = new SimpleId( appUuid, "application");
++// ApplicationScope scope = new ApplicationScopeImpl( appId );
++// ApplicationEntityIndex ei = eif.createApplicationEntityIndex(scope);
++// EsEntityIndexImpl eeii = (EsEntityIndexImpl)ei;
++//
++// }
private int readData( EntityManager em,
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b5ce0856/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java
----------------------------------------------------------------------
diff --cc stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java
index 1b3b115,521a4e7..854c976
--- 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
@@@ -33,9 -33,9 +34,9 @@@ import java.util.concurrent.Future
/**
- * Provides indexing of Entities within a scope.
+ * Provides management operations for single index
*/
-public interface EntityIndex {
+public interface EntityIndex extends CPManager {
/**
* This should ONLY ever be called once on application create.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b5ce0856/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
----------------------------------------------------------------------
diff --cc stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
index e66bd8d,ae5e3c3..d510a8d
--- 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
@@@ -49,16 -33,9 +33,14 @@@ import org.apache.usergrid.persistence.
import org.apache.usergrid.persistence.model.util.UUIDGenerator;
import org.elasticsearch.action.ActionFuture;
- import org.elasticsearch.action.ActionListener;
- import org.elasticsearch.action.ListenableActionFuture;
- import org.elasticsearch.action.ShardOperationFailedException;
+
import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
+import org.elasticsearch.action.admin.cluster.tasks.PendingClusterTasksRequest;
+import org.elasticsearch.action.admin.cluster.tasks.PendingClusterTasksResponse;
+import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse;
+import org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequest;
+import org.elasticsearch.action.admin.indices.alias.get.GetAliasesResponse;
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequestBuilder;
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse;
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
[13/31] incubator-usergrid git commit: fix dependency
Posted by to...@apache.org.
fix dependency
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/70fe2851
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/70fe2851
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/70fe2851
Branch: refs/heads/USERGRID-486
Commit: 70fe28512b20e2c5537c27424f18299a5bb3b58c
Parents: 532b662 8ea46ba
Author: Shawn Feldman <sf...@apache.org>
Authored: Thu Mar 19 14:40:28 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Thu Mar 19 14:40:28 2015 -0600
----------------------------------------------------------------------
.../apache/usergrid/corepersistence/CpEntityManager.java | 3 ---
.../usergrid/corepersistence/CpEntityManagerFactory.java | 9 ++++-----
2 files changed, 4 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/70fe2851/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
----------------------------------------------------------------------
diff --cc stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
index b23111a,789e640..a9f00b4
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
@@@ -2889,9 -2886,10 +2889,6 @@@ public class CpEntityManager implement
// refresh factory indexes
emf.refreshIndex();
--
-- // refresh this Entity Manager's application's index
- EntityIndex ei = managerCache.getEntityIndex( getApplicationScope() );
-- ei.refresh();
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/70fe2851/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
----------------------------------------------------------------------
diff --cc stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
index 14b7865,f76b9fc..f3d18d0
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
@@@ -128,7 -126,6 +128,7 @@@ public class CpEntityManagerFactory imp
this.cassandraService = cassandraService;
this.counterUtils = counterUtils;
this.injector = injector;
- this.entityIndex = entityIndex;
++ this.entityIndex = injector.getInstance(EntityIndex.class);
this.managerCache = injector.getInstance( ManagerCache.class );
this.metricsFactory = injector.getInstance( MetricsFactory.class );
@@@ -664,8 -663,10 +664,7 @@@
// refresh special indexes without calling EntityManager refresh because stack overflow
maybeCreateIndexes();
// system app
--
- entityIndex.refresh();
- for ( EntityIndex index : getManagementIndexes() ) {
- index.refresh();
- }
++ entityIndex.refresh();
}
@@@ -675,7 -676,9 +674,7 @@@
return;
}
- entityIndex.initializeIndex();
- for ( EntityIndex index : getManagementIndexes() ) {
- index.initializeIndex();
- }
++// entityIndex.initializeIndex();
}
[15/31] incubator-usergrid git commit: create correct context
Posted by to...@apache.org.
create correct context
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/1dd6ead8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/1dd6ead8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/1dd6ead8
Branch: refs/heads/USERGRID-486
Commit: 1dd6ead8a8426dc5e97910668d140da46767fa18
Parents: 735eedb
Author: Shawn Feldman <sf...@apache.org>
Authored: Thu Mar 19 17:48:42 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Thu Mar 19 17:48:42 2015 -0600
----------------------------------------------------------------------
.../usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java | 4 ++--
.../apache/usergrid/persistence/index/impl/IndexingUtils.java | 4 +++-
2 files changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1dd6ead8/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 1082201..38bf381 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 {
entity.setField(
new StringField(APPLICATION_ID_FIELDNAME, IndexingUtils.idString(applicationScope.getApplication()))
);
- final String context = createContextName(indexScope);
+ final String context = createContextName(applicationScope,indexScope);
if ( log.isDebugEnabled() ) {
log.debug( "Indexing entity {}:{}\n alias: {}\n" +
@@ -134,7 +134,7 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
ValidationUtils.verifyIdentity(id);
ValidationUtils.verifyVersion( version );
- final String context = createContextName(indexScope);
+ final String context = createContextName(applicationScope,indexScope);
final SearchType entityType =SearchType.fromId(id);
final String indexId = createIndexDocId( id, version, context );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1dd6ead8/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 c74ce93..c365ff4 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
@@ -65,8 +65,10 @@ public class IndexingUtils {
* @param scope
* @return
*/
- public static String createContextName( IndexScope scope ) {
+ public static String createContextName(ApplicationScope applicationScope, IndexScope scope ) {
StringBuilder sb = new StringBuilder();
+ idString(sb,applicationScope.getApplication());
+ sb.append(SEPARATOR);
idString(sb, scope.getOwner());
sb.append( SEPARATOR );
sb.append( scope.getName() );
[22/31] incubator-usergrid git commit: search change
Posted by to...@apache.org.
search change
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/9800b23d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/9800b23d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/9800b23d
Branch: refs/heads/USERGRID-486
Commit: 9800b23de03a6663167bee41f5c6fb91127acd39
Parents: 336c222
Author: Shawn Feldman <sf...@apache.org>
Authored: Fri Mar 20 11:31:54 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Fri Mar 20 11:31:54 2015 -0600
----------------------------------------------------------------------
.../apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/9800b23d/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 2be3e51..8bdd663 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
@@ -327,6 +327,7 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
public void refresh() {
+
refreshIndexMeter.mark();
final Timer.Context timeRefreshIndex = refreshTimer.time();
BetterFuture future = indexBatchBufferProducer.put(new IndexOperationMessage());
[09/31] incubator-usergrid git commit: add application entity index
Posted by to...@apache.org.
add application entity index
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/679812e6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/679812e6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/679812e6
Branch: refs/heads/USERGRID-486
Commit: 679812e6dbb52f1ab3b303adfe209167b3b25f7f
Parents: 5ea8194
Author: Shawn Feldman <sf...@apache.org>
Authored: Thu Mar 19 10:13:48 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Thu Mar 19 10:13:48 2015 -0600
----------------------------------------------------------------------
.../usergrid/corepersistence/ManagerCache.java | 3 +-
.../index/ApplicationEntityIndex.java | 42 +++
.../usergrid/persistence/index/EntityIndex.java | 25 +-
.../persistence/index/EntityIndexFactory.java | 2 +-
.../persistence/index/IndexIdentifier.java | 9 +-
.../persistence/index/guice/IndexModule.java | 5 +-
.../impl/EsApplicationEntityIndexImpl.java | 305 ++++++++++++++++
.../index/impl/EsEntityIndexBatchImpl.java | 8 +-
.../index/impl/EsEntityIndexFactoryImpl.java | 27 +-
.../index/impl/EsEntityIndexImpl.java | 351 ++-----------------
.../persistence/index/impl/IndexingUtils.java | 15 -
.../index/impl/CorePerformanceIT.java | 20 +-
.../impl/EntityConnectionIndexImplTest.java | 20 +-
.../persistence/index/impl/EntityIndexTest.java | 92 +++--
14 files changed, 461 insertions(+), 463 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/679812e6/stack/core/src/main/java/org/apache/usergrid/corepersistence/ManagerCache.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/ManagerCache.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/ManagerCache.java
index c1b7b95..d747f55 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/ManagerCache.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/ManagerCache.java
@@ -24,6 +24,7 @@ import org.apache.usergrid.persistence.collection.CollectionScope;
import org.apache.usergrid.persistence.collection.EntityCollectionManager;
import org.apache.usergrid.persistence.core.scope.ApplicationScope;
import org.apache.usergrid.persistence.graph.GraphManager;
+import org.apache.usergrid.persistence.index.ApplicationEntityIndex;
import org.apache.usergrid.persistence.index.EntityIndex;
import org.apache.usergrid.persistence.map.MapManager;
import org.apache.usergrid.persistence.map.MapScope;
@@ -45,7 +46,7 @@ public interface ManagerCache {
* @param appScope
* @return
*/
- EntityIndex getEntityIndex( ApplicationScope appScope );
+ ApplicationEntityIndex getEntityIndex( ApplicationScope appScope );
/**
* Get the graph manager for the graph scope
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/679812e6/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/ApplicationEntityIndex.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/ApplicationEntityIndex.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/ApplicationEntityIndex.java
new file mode 100644
index 0000000..fab32b3
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/ApplicationEntityIndex.java
@@ -0,0 +1,42 @@
+/*
+ *
+ * * 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.index.query.CandidateResults;
+import org.apache.usergrid.persistence.index.query.Query;
+import rx.Observable;
+
+/**
+ * Classy class class.
+ */
+public interface ApplicationEntityIndex {
+
+
+ /**
+ * Create the index batch.
+ */
+ public EntityIndexBatch createBatch();
+
+
+ /**
+ * Execute query in Usergrid syntax.
+ */
+ public CandidateResults search(final IndexScope indexScope, final SearchTypes searchType, Query query );
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/679812e6/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 db4b50d..521a4e7 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
@@ -26,13 +26,14 @@ import org.apache.usergrid.persistence.index.query.Query;
import org.apache.usergrid.persistence.index.query.CandidateResults;
import org.apache.usergrid.persistence.model.entity.Id;
import org.elasticsearch.action.ListenableActionFuture;
+import rx.Observable;
import java.util.Map;
import java.util.concurrent.Future;
/**
- * Provides indexing of Entities within a scope.
+ * Provides management operations for single index
*/
public interface EntityIndex {
@@ -41,12 +42,6 @@ public interface EntityIndex {
* Otherwise we're introducing slowness into our system
*/
public void initializeIndex();
-
- /**
- * Delete the index from ES
- */
- public ListenableActionFuture deleteIndex();
-
/**
* Create an index and add to alias, will create alias and remove any old index from write alias if alias already exists
* @param indexSuffix index name
@@ -56,27 +51,13 @@ public interface EntityIndex {
*/
public void addIndex(final String indexSuffix, final int shards, final int replicas, final String writeConsistency);
- /**
- * Create the index batch.
- */
- public EntityIndexBatch createBatch();
-
-
- /**
- * Execute query in Usergrid syntax.
- */
- public CandidateResults search(final IndexScope indexScope, final SearchTypes searchType, Query query );
/**
* Refresh the index.
*/
public void refresh();
- /**
- * Return the number of pending tasks in the cluster
- * @return
- */
- public int getPendingTasks();
+
/**
* Check health of cluster.
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/679812e6/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndexFactory.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndexFactory.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndexFactory.java
index 10752d1..1c594e7 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndexFactory.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndexFactory.java
@@ -25,7 +25,7 @@ import com.google.inject.assistedinject.Assisted;
public interface EntityIndexFactory {
- public EntityIndex createEntityIndex(
+ public ApplicationEntityIndex createApplicationEntityIndex(
@Assisted ApplicationScope appScope);
void invalidate();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/679812e6/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexIdentifier.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexIdentifier.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexIdentifier.java
index 8465d84..1ac9d49 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexIdentifier.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexIdentifier.java
@@ -20,19 +20,14 @@
package org.apache.usergrid.persistence.index;
-import org.apache.usergrid.persistence.core.scope.ApplicationScope;
-import org.apache.usergrid.persistence.index.impl.IndexingUtils;
-
/**
* Class is used to generate an index name and alias name
*/
public class IndexIdentifier{
private final IndexFig config;
- private final ApplicationScope applicationScope;
- public IndexIdentifier(IndexFig config, ApplicationScope applicationScope) {
+ public IndexIdentifier(IndexFig config) {
this.config = config;
- this.applicationScope = applicationScope;
}
/**
@@ -76,7 +71,7 @@ public class IndexIdentifier{
}
public String toString() {
- return "application: " + applicationScope.getApplication().getUuid();
+ return "index id"+config.getIndexPrefix();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/679812e6/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/guice/IndexModule.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/guice/IndexModule.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/guice/IndexModule.java
index 95f3bd4..c9125c5 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/guice/IndexModule.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/guice/IndexModule.java
@@ -45,8 +45,11 @@ public class IndexModule extends AbstractModule {
install(new MapModule());
install(new QueueModule());
-
bind(EntityIndexFactory.class).to( EsEntityIndexFactoryImpl.class );
+ bind(AliasedEntityIndex.class).to(EsEntityIndexImpl.class);
+ bind(EntityIndex.class).to(EsEntityIndexImpl.class);
+ bind(IndexIdentifier.class);
+
bind(IndexBufferProducer.class).to(EsIndexBufferProducerImpl.class);
bind(IndexBufferConsumer.class).to(EsIndexBufferConsumerImpl.class).asEagerSingleton();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/679812e6/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
new file mode 100644
index 0000000..f8ed107
--- /dev/null
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsApplicationEntityIndexImpl.java
@@ -0,0 +1,305 @@
+/*
+ *
+ * * 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.impl;
+
+import com.codahale.metrics.Meter;
+import com.codahale.metrics.Timer;
+import com.google.common.base.Preconditions;
+import com.google.inject.Inject;
+import com.google.inject.assistedinject.Assisted;
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.usergrid.persistence.core.metrics.MetricsFactory;
+import org.apache.usergrid.persistence.core.scope.ApplicationScope;
+import org.apache.usergrid.persistence.core.util.ValidationUtils;
+import org.apache.usergrid.persistence.index.*;
+import org.apache.usergrid.persistence.index.query.CandidateResult;
+import org.apache.usergrid.persistence.index.query.CandidateResults;
+import org.apache.usergrid.persistence.index.query.Query;
+import org.apache.usergrid.persistence.map.MapManager;
+import org.apache.usergrid.persistence.map.MapManagerFactory;
+import org.apache.usergrid.persistence.map.MapScope;
+import org.apache.usergrid.persistence.map.impl.MapScopeImpl;
+import org.apache.usergrid.persistence.model.entity.Id;
+import org.apache.usergrid.persistence.model.entity.SimpleId;
+import org.apache.usergrid.persistence.model.util.UUIDGenerator;
+import org.elasticsearch.action.ActionListener;
+import org.elasticsearch.action.ListenableActionFuture;
+import org.elasticsearch.action.ShardOperationFailedException;
+import org.elasticsearch.action.deletebyquery.DeleteByQueryResponse;
+import org.elasticsearch.action.deletebyquery.IndexDeleteByQueryResponse;
+import org.elasticsearch.action.search.SearchRequestBuilder;
+import org.elasticsearch.action.search.SearchResponse;
+import org.elasticsearch.action.search.SearchScrollRequestBuilder;
+import org.elasticsearch.index.query.FilterBuilder;
+import org.elasticsearch.index.query.QueryBuilder;
+import org.elasticsearch.index.query.QueryBuilders;
+import org.elasticsearch.index.query.TermQueryBuilder;
+import org.elasticsearch.search.SearchHit;
+import org.elasticsearch.search.SearchHits;
+import org.elasticsearch.search.sort.FieldSortBuilder;
+import org.elasticsearch.search.sort.SortBuilders;
+import org.elasticsearch.search.sort.SortOrder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import rx.Observable;
+import rx.functions.Action1;
+import rx.schedulers.Schedulers;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import static org.apache.usergrid.persistence.index.impl.IndexingUtils.*;
+import static org.apache.usergrid.persistence.index.impl.IndexingUtils.SPLITTER;
+
+/**
+ * Classy class class.
+ */
+public class EsApplicationEntityIndexImpl implements ApplicationEntityIndex{
+
+ private static final Logger logger = LoggerFactory.getLogger(EsApplicationEntityIndexImpl.class);
+
+ private final ApplicationScope applicationScope;
+ private final IndexIdentifier indexIdentifier;
+ private final Timer searchTimer;
+ private final Timer cursorTimer;
+ private final MapManager mapManager;
+ private final AliasedEntityIndex entityIndex;
+ private final IndexBufferProducer indexBatchBufferProducer;
+ private final EsIndexCache indexCache;
+ private final IndexFig indexFig;
+ private final EsProvider esProvider;
+ private final IndexIdentifier.IndexAlias alias;
+ private FailureMonitor failureMonitor;
+ private final int cursorTimeout;
+ @Inject
+ public EsApplicationEntityIndexImpl(@Assisted ApplicationScope appScope, final AliasedEntityIndex entityIndex, final IndexFig config,
+ final IndexBufferProducer indexBatchBufferProducer, final EsProvider provider,
+ final EsIndexCache indexCache, final MetricsFactory metricsFactory,
+ final MapManagerFactory mapManagerFactory, final IndexFig indexFig, final IndexIdentifier indexIdentifier){
+ this.entityIndex = entityIndex;
+ this.indexBatchBufferProducer = indexBatchBufferProducer;
+ this.indexCache = indexCache;
+ this.indexFig = indexFig;
+ this.indexIdentifier = indexIdentifier;
+ ValidationUtils.validateApplicationScope(appScope);
+ this.applicationScope = appScope;
+ final MapScope mapScope = new MapScopeImpl(appScope.getApplication(), "cursorcache");
+ this.failureMonitor = new FailureMonitorImpl(config, provider);
+ this.esProvider = provider;
+
+ mapManager = mapManagerFactory.createMapManager(mapScope);
+ this.searchTimer = metricsFactory
+ .getTimer(EsEntityIndexImpl.class, "search.timer");
+ this.cursorTimer = metricsFactory
+ .getTimer(EsEntityIndexImpl.class, "search.cursor.timer");
+ this.cursorTimeout = config.getQueryCursorTimeout();
+
+ this.alias = indexIdentifier.getAlias();
+
+ }
+
+ @Override
+ public EntityIndexBatch createBatch() {
+ EntityIndexBatch batch = new EsEntityIndexBatchImpl(
+ applicationScope, indexBatchBufferProducer, entityIndex, indexIdentifier );
+ return batch;
+ }
+
+ @Override
+ public CandidateResults search(final IndexScope indexScope, final SearchTypes searchTypes,
+ final Query query ) {
+
+ final String context = IndexingUtils.createContextName(indexScope);
+ final String[] entityTypes = searchTypes.getTypeNames(applicationScope);
+ QueryBuilder qb = query.createQueryBuilder(context);
+ SearchResponse searchResponse;
+
+ if ( query.getCursor() == null ) {
+ SearchRequestBuilder srb = esProvider.getClient().prepareSearch( alias.getReadAlias() )
+ .setTypes(entityTypes)
+ .setScroll(cursorTimeout + "m")
+ .setQuery(qb);
+
+ final FilterBuilder fb = query.createFilterBuilder();
+
+ //we have post filters, apply them
+ if ( fb != null ) {
+ logger.debug( " Filter: {} ", fb.toString() );
+ srb = srb.setPostFilter( fb );
+ }
+
+
+ srb = srb.setFrom( 0 ).setSize( query.getLimit() );
+
+ for ( Query.SortPredicate sp : query.getSortPredicates() ) {
+
+ final SortOrder order;
+ if ( sp.getDirection().equals( Query.SortDirection.ASCENDING ) ) {
+ order = SortOrder.ASC;
+ }
+ else {
+ order = SortOrder.DESC;
+ }
+
+ // we do not know the type of the "order by" property and so we do not know what
+ // type prefix to use. So, here we add an order by clause for every possible type
+ // that you can order by: string, number and boolean and we ask ElasticSearch
+ // to ignore any fields that are not present.
+
+ final String stringFieldName = STRING_PREFIX + sp.getPropertyName();
+ final FieldSortBuilder stringSort = SortBuilders.fieldSort(stringFieldName)
+ .order( order ).ignoreUnmapped( true );
+ srb.addSort( stringSort );
+
+ logger.debug( " Sort: {} order by {}", stringFieldName, order.toString() );
+
+ final String longFieldName = LONG_PREFIX + sp.getPropertyName();
+ final FieldSortBuilder longSort = SortBuilders.fieldSort( longFieldName )
+ .order( order ).ignoreUnmapped( true );
+ srb.addSort( longSort );
+ logger.debug( " Sort: {} order by {}", longFieldName, order.toString() );
+
+
+ final String doubleFieldName = DOUBLE_PREFIX + sp.getPropertyName();
+ final FieldSortBuilder doubleSort = SortBuilders.fieldSort( doubleFieldName )
+ .order( order ).ignoreUnmapped( true );
+ srb.addSort( doubleSort );
+ logger.debug( " Sort: {} order by {}", doubleFieldName, order.toString() );
+
+
+ final String booleanFieldName = BOOLEAN_PREFIX + sp.getPropertyName();
+ final FieldSortBuilder booleanSort = SortBuilders.fieldSort( booleanFieldName )
+ .order( order ).ignoreUnmapped( true );
+ srb.addSort( booleanSort );
+ logger.debug( " Sort: {} order by {}", booleanFieldName, order.toString() );
+ }
+
+
+ if ( logger.isDebugEnabled() ) {
+ logger.debug( "Searching index (read alias): {}\n scope: {} \n type: {}\n query: {} ",
+ this.alias.getReadAlias(), context, entityTypes, srb );
+ }
+
+ try {
+ //Added For Graphite Metrics
+ Timer.Context timeSearch = searchTimer.time();
+ searchResponse = srb.execute().actionGet();
+ timeSearch.stop();
+ }
+ catch ( Throwable t ) {
+ logger.error( "Unable to communicate with Elasticsearch", t );
+ failureMonitor.fail( "Unable to execute batch", t );
+ throw t;
+ }
+
+
+ failureMonitor.success();
+ }
+ else {
+ String userCursorString = query.getCursor();
+ if ( userCursorString.startsWith( "\"" ) ) {
+ userCursorString = userCursorString.substring( 1 );
+ }
+ if ( userCursorString.endsWith( "\"" ) ) {
+ userCursorString = userCursorString.substring( 0, userCursorString.length() - 1 );
+ }
+
+ //now get the cursor from the map and validate
+ final String esScrollCursor = mapManager.getString( userCursorString );
+
+ Preconditions.checkArgument(esScrollCursor != null, "Could not find a cursor for the value '{}' ", esScrollCursor);
+
+
+
+ logger.debug( "Executing query with cursor: {} ", esScrollCursor );
+
+
+ SearchScrollRequestBuilder ssrb = esProvider.getClient()
+ .prepareSearchScroll(esScrollCursor).setScroll( cursorTimeout + "m" );
+
+ try {
+ //Added For Graphite Metrics
+ Timer.Context timeSearchCursor = cursorTimer.time();
+ searchResponse = ssrb.execute().actionGet();
+ timeSearchCursor.stop();
+ }
+ catch ( Throwable t ) {
+ logger.error( "Unable to communicate with elasticsearch", t );
+ failureMonitor.fail( "Unable to execute batch", t );
+ throw t;
+ }
+
+
+ failureMonitor.success();
+ }
+
+ return parseResults(searchResponse, query);
+ }
+
+
+ private CandidateResults parseResults( final SearchResponse searchResponse, final Query query ) {
+
+ final SearchHits searchHits = searchResponse.getHits();
+ final SearchHit[] hits = searchHits.getHits();
+ final int length = hits.length;
+
+ logger.debug(" Hit count: {} Total hits: {}", length, searchHits.getTotalHits());
+
+ List<CandidateResult> candidates = new ArrayList<>( length );
+
+ for ( SearchHit hit : hits ) {
+
+ String[] idparts = hit.getId().split( SPLITTER );
+ String id = idparts[0];
+ String type = idparts[1];
+ String version = idparts[2];
+
+ Id entityId = new SimpleId( UUID.fromString(id), type );
+
+ candidates.add( new CandidateResult( entityId, UUID.fromString( version ) ) );
+ }
+
+ CandidateResults candidateResults = new CandidateResults( query, candidates );
+
+ if ( candidates.size() >= query.getLimit() ) {
+ //USERGRID-461 our cursor is getting too large, map it to a new time UUID
+ //TODO T.N., this shouldn't live here. This should live at the UG core tier. However the RM/EM are an absolute mess, so until they're refactored, this is it's home
+
+ final String userCursorString = org.apache.usergrid.persistence.index.utils.StringUtils.sanitizeUUID( UUIDGenerator.newTimeUUID() );
+
+ final String esScrollCursor = searchResponse.getScrollId();
+
+ //now set this into our map module
+ final int minutes = indexFig.getQueryCursorTimeout();
+
+ //just truncate it, we'll never hit a long value anyway
+ mapManager.putString( userCursorString, esScrollCursor, ( int ) TimeUnit.MINUTES.toSeconds( minutes ) );
+
+ candidateResults.setCursor( userCursorString );
+ logger.debug(" User cursor = {}, Cursor = {} ", userCursorString, esScrollCursor);
+ }
+
+ return candidateResults;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/679812e6/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 d7b1f9c..1082201 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
@@ -76,13 +76,13 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
public EsEntityIndexBatchImpl(final ApplicationScope applicationScope,
- final IndexBufferProducer indexBatchBufferProducer,final IndexFig config,
- final AliasedEntityIndex entityIndex ) {
+ final IndexBufferProducer indexBatchBufferProducer,
+ final AliasedEntityIndex entityIndex, IndexIdentifier indexIdentifier ) {
this.applicationScope = applicationScope;
this.indexBatchBufferProducer = indexBatchBufferProducer;
this.entityIndex = entityIndex;
- this.indexIdentifier = IndexingUtils.createIndexIdentifier(config, applicationScope);
+ this.indexIdentifier = indexIdentifier;
this.alias = indexIdentifier.getAlias();
//constrained
this.container = new IndexOperationMessage();
@@ -96,7 +96,7 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
ValidationUtils.verifyVersion( entity.getVersion() );
//add app id for indexing
entity.setField(
- new StringField(APPLICATION_ID_FIELDNAME,IndexingUtils.idString(applicationScope.getApplication()))
+ new StringField(APPLICATION_ID_FIELDNAME, IndexingUtils.idString(applicationScope.getApplication()))
);
final String context = createContextName(indexScope);
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/679812e6/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexFactoryImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexFactoryImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexFactoryImpl.java
index 8af309d..426f587 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexFactoryImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexFactoryImpl.java
@@ -24,12 +24,10 @@ import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.inject.Inject;
+import com.google.inject.assistedinject.Assisted;
import org.apache.usergrid.persistence.core.metrics.MetricsFactory;
import org.apache.usergrid.persistence.core.scope.ApplicationScope;
-import org.apache.usergrid.persistence.index.EntityIndex;
-import org.apache.usergrid.persistence.index.EntityIndexFactory;
-import org.apache.usergrid.persistence.index.IndexBufferProducer;
-import org.apache.usergrid.persistence.index.IndexFig;
+import org.apache.usergrid.persistence.index.*;
import org.apache.usergrid.persistence.map.MapManagerFactory;
import java.util.concurrent.ExecutionException;
@@ -46,12 +44,15 @@ public class EsEntityIndexFactoryImpl implements EntityIndexFactory{
private final MetricsFactory metricsFactory;
private final MapManagerFactory mapManagerFactory;
private final IndexFig indexFig;
+ private final AliasedEntityIndex entityIndex;
+ private final IndexIdentifier indexIdentifier;
- private LoadingCache<ApplicationScope, EntityIndex> eiCache =
- CacheBuilder.newBuilder().maximumSize( 1000 ).build( new CacheLoader<ApplicationScope, EntityIndex>() {
- public EntityIndex load( ApplicationScope scope ) {
- return new EsEntityIndexImpl(scope,config, indexBatchBufferProducer, provider,indexCache, metricsFactory,
- mapManagerFactory, indexFig );
+ private LoadingCache<ApplicationScope, ApplicationEntityIndex> eiCache =
+ CacheBuilder.newBuilder().maximumSize( 1000 ).build( new CacheLoader<ApplicationScope, ApplicationEntityIndex>() {
+ public ApplicationEntityIndex load( ApplicationScope scope ) {
+ return new EsApplicationEntityIndexImpl(
+ scope,entityIndex,config, indexBatchBufferProducer, provider,indexCache, metricsFactory, mapManagerFactory, indexFig, indexIdentifier
+ );
}
} );
@@ -59,7 +60,7 @@ public class EsEntityIndexFactoryImpl implements EntityIndexFactory{
public EsEntityIndexFactoryImpl( final IndexFig config, final EsProvider provider, final EsIndexCache indexCache,
final IndexBufferProducer indexBatchBufferProducer,
final MetricsFactory metricsFactory, final MapManagerFactory mapManagerFactory,
- final IndexFig indexFig ){
+ final IndexFig indexFig, final AliasedEntityIndex entityIndex, final IndexIdentifier indexIdentifier ){
this.config = config;
this.provider = provider;
this.indexCache = indexCache;
@@ -67,10 +68,14 @@ public class EsEntityIndexFactoryImpl implements EntityIndexFactory{
this.metricsFactory = metricsFactory;
this.mapManagerFactory = mapManagerFactory;
this.indexFig = indexFig;
+ this.entityIndex = entityIndex;
+ this.indexIdentifier = indexIdentifier;
}
+
+
@Override
- public EntityIndex createEntityIndex(final ApplicationScope appScope) {
+ public ApplicationEntityIndex createApplicationEntityIndex(@Assisted final ApplicationScope appScope) {
try{
return eiCache.get(appScope);
}catch (ExecutionException ee){
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/679812e6/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 f22016e..ae5e3c3 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
@@ -18,55 +18,29 @@
package org.apache.usergrid.persistence.index.impl;
-import com.codahale.metrics.Meter;
import com.codahale.metrics.Timer;
-import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
import com.google.inject.Inject;
-import com.google.inject.assistedinject.Assisted;
-import com.yammer.metrics.core.Clock;
+import com.google.inject.Singleton;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.usergrid.persistence.core.future.BetterFuture;
import org.apache.usergrid.persistence.core.metrics.MetricsFactory;
-import org.apache.usergrid.persistence.core.scope.ApplicationScope;
import org.apache.usergrid.persistence.core.util.Health;
-import org.apache.usergrid.persistence.core.util.ValidationUtils;
import org.apache.usergrid.persistence.index.*;
import org.apache.usergrid.persistence.index.exceptions.IndexException;
-import org.apache.usergrid.persistence.index.query.CandidateResult;
-import org.apache.usergrid.persistence.index.query.CandidateResults;
-import org.apache.usergrid.persistence.index.query.Query;
-import org.apache.usergrid.persistence.index.utils.UUIDUtils;
-import org.apache.usergrid.persistence.map.MapManager;
-import org.apache.usergrid.persistence.map.MapManagerFactory;
-import org.apache.usergrid.persistence.map.MapScope;
-import org.apache.usergrid.persistence.map.impl.MapScopeImpl;
-import org.apache.usergrid.persistence.model.entity.Id;
-import org.apache.usergrid.persistence.model.entity.SimpleId;
+
import org.apache.usergrid.persistence.model.util.UUIDGenerator;
import org.elasticsearch.action.ActionFuture;
-import org.elasticsearch.action.ActionListener;
-import org.elasticsearch.action.ListenableActionFuture;
-import org.elasticsearch.action.ShardOperationFailedException;
+
import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
-import org.elasticsearch.action.admin.cluster.tasks.PendingClusterTasksRequest;
-import org.elasticsearch.action.admin.cluster.tasks.PendingClusterTasksResponse;
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequestBuilder;
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse;
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
-import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse;
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse;
-import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateResponse;
-import org.elasticsearch.action.deletebyquery.DeleteByQueryResponse;
-import org.elasticsearch.action.deletebyquery.IndexDeleteByQueryResponse;
-import org.elasticsearch.action.search.SearchRequestBuilder;
-import org.elasticsearch.action.search.SearchResponse;
-import org.elasticsearch.action.search.SearchScrollRequestBuilder;
+
import org.elasticsearch.client.AdminClient;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings;
@@ -75,61 +49,39 @@ import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.query.*;
import org.elasticsearch.indices.IndexAlreadyExistsException;
import org.elasticsearch.indices.IndexMissingException;
-import org.elasticsearch.indices.InvalidAliasNameException;
-import org.elasticsearch.rest.action.admin.indices.alias.delete.AliasesMissingException;
-import org.elasticsearch.search.SearchHit;
-import org.elasticsearch.search.SearchHits;
-import org.elasticsearch.search.sort.FieldSortBuilder;
-import org.elasticsearch.search.sort.SortBuilders;
-import org.elasticsearch.search.sort.SortOrder;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import rx.Observable;
-import rx.functions.Func1;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-import static org.apache.usergrid.persistence.index.impl.IndexingUtils.*;
+import java.io.IOException;
/**
* Implements index using ElasticSearch Java API.
*/
+@Singleton
public class EsEntityIndexImpl implements AliasedEntityIndex {
private static final Logger logger = LoggerFactory.getLogger( EsEntityIndexImpl.class );
- private static final AtomicBoolean mappingsCreated = new AtomicBoolean( false );
public static final String DEFAULT_TYPE = "_default_";
private final IndexIdentifier.IndexAlias alias;
- private final IndexIdentifier indexIdentifier;
private final IndexBufferProducer indexBatchBufferProducer;
private final IndexFig indexFig;
private final Timer addTimer;
private final Timer updateAliasTimer;
- private final Timer searchTimer;
+
/**
* We purposefully make this per instance. Some indexes may work, while others may fail
*/
- private FailureMonitor failureMonitor;
- private final ApplicationScope applicationScope;
private final EsProvider esProvider;
-
- private final int cursorTimeout;
-
private final IndexFig config;
-
-
//number of times to wait for the index to refresh properly.
private static final int MAX_WAITS = 10;
//number of milliseconds to try again before sleeping
@@ -141,53 +93,41 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
ImmutableMap.<String, Object>builder().put( "field", "test" ).put(IndexingUtils.ENTITYID_ID_FIELDNAME, UUIDGenerator.newTimeUUID().toString()).build();
private static final MatchAllQueryBuilder MATCH_ALL_QUERY_BUILDER = QueryBuilders.matchAllQuery();
+ private final IndexIdentifier indexIdentifier;
private EsIndexCache aliasCache;
private Timer mappingTimer;
private Timer refreshTimer;
- private Timer cursorTimer;
- private Timer getVersionsTimer;
- private final MapManager mapManager;
// private final Timer indexTimer;
@Inject
- public EsEntityIndexImpl( @Assisted final ApplicationScope appScope, final IndexFig config,
+ public EsEntityIndexImpl( final IndexFig config,
final IndexBufferProducer indexBatchBufferProducer, final EsProvider provider,
final EsIndexCache indexCache, final MetricsFactory metricsFactory,
- final MapManagerFactory mapManagerFactory, final IndexFig indexFig ) {
+ final IndexFig indexFig, final IndexIdentifier indexIdentifier ) {
this.indexBatchBufferProducer = indexBatchBufferProducer;
this.indexFig = indexFig;
- ValidationUtils.validateApplicationScope( appScope );
- this.applicationScope = appScope;
+ this.indexIdentifier = indexIdentifier;
+
this.esProvider = provider;
this.config = config;
- this.cursorTimeout = config.getQueryCursorTimeout();
- this.indexIdentifier = IndexingUtils.createIndexIdentifier( config, appScope );
+
+
+
this.alias = indexIdentifier.getAlias();
- this.failureMonitor = new FailureMonitorImpl( config, provider );
this.aliasCache = indexCache;
this.addTimer = metricsFactory
- .getTimer( EsEntityIndexImpl.class, "add.timer" );
+ .getTimer(EsEntityIndexImpl.class, "add.timer");
this.updateAliasTimer = metricsFactory
- .getTimer( EsEntityIndexImpl.class, "update.alias.timer" );
+ .getTimer(EsEntityIndexImpl.class, "update.alias.timer");
this.mappingTimer = metricsFactory
- .getTimer( EsEntityIndexImpl.class, "create.mapping.timer" );
+ .getTimer(EsEntityIndexImpl.class, "create.mapping.timer");
this.refreshTimer = metricsFactory
- .getTimer( EsEntityIndexImpl.class, "refresh.timer" );
- this.searchTimer =metricsFactory
- .getTimer( EsEntityIndexImpl.class, "search.timer" );
- this.cursorTimer = metricsFactory
- .getTimer( EsEntityIndexImpl.class, "search.cursor.timer" );
- this.getVersionsTimer =metricsFactory
- .getTimer( EsEntityIndexImpl.class, "get.versions.timer" );
-
-
- final MapScope mapScope = new MapScopeImpl( appScope.getApplication(), "cursorcache" );
+ .getTimer(EsEntityIndexImpl.class, "refresh.timer");
- mapManager = mapManagerFactory.createMapManager(mapScope);
}
@Override
@@ -385,190 +325,6 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
}
- @Override
- public EntityIndexBatch createBatch() {
- EntityIndexBatch batch = new EsEntityIndexBatchImpl(
- applicationScope, indexBatchBufferProducer, config, this );
- return batch;
- }
-
-
- @Override
- public CandidateResults search(final IndexScope indexScope, final SearchTypes searchTypes,
- final Query query ) {
-
- final String context = IndexingUtils.createContextName(indexScope);
- final String[] entityTypes = searchTypes.getTypeNames(applicationScope);
- QueryBuilder qb = query.createQueryBuilder(context);
- SearchResponse searchResponse;
-
- if ( query.getCursor() == null ) {
- SearchRequestBuilder srb = esProvider.getClient().prepareSearch( alias.getReadAlias() )
- .setTypes(entityTypes)
- .setScroll(cursorTimeout + "m")
- .setQuery(qb);
-
- final FilterBuilder fb = query.createFilterBuilder();
-
- //we have post filters, apply them
- if ( fb != null ) {
- logger.debug( " Filter: {} ", fb.toString() );
- srb = srb.setPostFilter( fb );
- }
-
-
- srb = srb.setFrom( 0 ).setSize( query.getLimit() );
-
- for ( Query.SortPredicate sp : query.getSortPredicates() ) {
-
- final SortOrder order;
- if ( sp.getDirection().equals( Query.SortDirection.ASCENDING ) ) {
- order = SortOrder.ASC;
- }
- else {
- order = SortOrder.DESC;
- }
-
- // we do not know the type of the "order by" property and so we do not know what
- // type prefix to use. So, here we add an order by clause for every possible type
- // that you can order by: string, number and boolean and we ask ElasticSearch
- // to ignore any fields that are not present.
-
- final String stringFieldName = STRING_PREFIX + sp.getPropertyName();
- final FieldSortBuilder stringSort = SortBuilders.fieldSort( stringFieldName )
- .order( order ).ignoreUnmapped( true );
- srb.addSort( stringSort );
-
- logger.debug( " Sort: {} order by {}", stringFieldName, order.toString() );
-
- final String longFieldName = LONG_PREFIX + sp.getPropertyName();
- final FieldSortBuilder longSort = SortBuilders.fieldSort( longFieldName )
- .order( order ).ignoreUnmapped( true );
- srb.addSort( longSort );
- logger.debug( " Sort: {} order by {}", longFieldName, order.toString() );
-
-
- final String doubleFieldName = DOUBLE_PREFIX + sp.getPropertyName();
- final FieldSortBuilder doubleSort = SortBuilders.fieldSort( doubleFieldName )
- .order( order ).ignoreUnmapped( true );
- srb.addSort( doubleSort );
- logger.debug( " Sort: {} order by {}", doubleFieldName, order.toString() );
-
-
- final String booleanFieldName = BOOLEAN_PREFIX + sp.getPropertyName();
- final FieldSortBuilder booleanSort = SortBuilders.fieldSort( booleanFieldName )
- .order( order ).ignoreUnmapped( true );
- srb.addSort( booleanSort );
- logger.debug( " Sort: {} order by {}", booleanFieldName, order.toString() );
- }
-
-
- if ( logger.isDebugEnabled() ) {
- logger.debug( "Searching index (read alias): {}\n scope: {} \n type: {}\n query: {} ",
- this.alias.getReadAlias(), context, entityTypes, srb );
- }
-
- try {
- //Added For Graphite Metrics
- Timer.Context timeSearch = searchTimer.time();
- searchResponse = srb.execute().actionGet();
- timeSearch.stop();
- }
- catch ( Throwable t ) {
- logger.error( "Unable to communicate with Elasticsearch", t );
- failureMonitor.fail( "Unable to execute batch", t );
- throw t;
- }
-
-
- failureMonitor.success();
- }
- else {
- String userCursorString = query.getCursor();
- if ( userCursorString.startsWith( "\"" ) ) {
- userCursorString = userCursorString.substring( 1 );
- }
- if ( userCursorString.endsWith( "\"" ) ) {
- userCursorString = userCursorString.substring( 0, userCursorString.length() - 1 );
- }
-
- //now get the cursor from the map and validate
- final String esScrollCursor = mapManager.getString( userCursorString );
-
- Preconditions.checkArgument(esScrollCursor != null, "Could not find a cursor for the value '{}' ", esScrollCursor);
-
-
-
- logger.debug( "Executing query with cursor: {} ", esScrollCursor );
-
-
- SearchScrollRequestBuilder ssrb = esProvider.getClient()
- .prepareSearchScroll(esScrollCursor).setScroll( cursorTimeout + "m" );
-
- try {
- //Added For Graphite Metrics
- Timer.Context timeSearchCursor = cursorTimer.time();
- searchResponse = ssrb.execute().actionGet();
- timeSearchCursor.stop();
- }
- catch ( Throwable t ) {
- logger.error( "Unable to communicate with elasticsearch", t );
- failureMonitor.fail( "Unable to execute batch", t );
- throw t;
- }
-
-
- failureMonitor.success();
- }
-
- return parseResults(searchResponse, query);
- }
-
-
- private CandidateResults parseResults( final SearchResponse searchResponse, final Query query ) {
-
- final SearchHits searchHits = searchResponse.getHits();
- final SearchHit[] hits = searchHits.getHits();
- final int length = hits.length;
-
- logger.debug(" Hit count: {} Total hits: {}", length, searchHits.getTotalHits());
-
- List<CandidateResult> candidates = new ArrayList<>( length );
-
- for ( SearchHit hit : hits ) {
-
- String[] idparts = hit.getId().split( SPLITTER );
- String id = idparts[0];
- String type = idparts[1];
- String version = idparts[2];
-
- Id entityId = new SimpleId( UUID.fromString( id ), type );
-
- candidates.add( new CandidateResult( entityId, UUID.fromString( version ) ) );
- }
-
- CandidateResults candidateResults = new CandidateResults( query, candidates );
-
- if ( candidates.size() >= query.getLimit() ) {
- //USERGRID-461 our cursor is getting too large, map it to a new time UUID
- //TODO T.N., this shouldn't live here. This should live at the UG core tier. However the RM/EM are an absolute mess, so until they're refactored, this is it's home
-
- final String userCursorString = org.apache.usergrid.persistence.index.utils.StringUtils.sanitizeUUID( UUIDGenerator.newTimeUUID() );
-
- final String esScrollCursor = searchResponse.getScrollId();
-
- //now set this into our map module
- final int minutes = indexFig.getQueryCursorTimeout();
-
- //just truncate it, we'll never hit a long value anyway
- mapManager.putString( userCursorString, esScrollCursor, ( int ) TimeUnit.MINUTES.toSeconds( minutes ) );
-
- candidateResults.setCursor( userCursorString );
- logger.debug(" User cursor = {}, Cursor = {} ", userCursorString, esScrollCursor);
- }
-
- return candidateResults;
- }
public void refresh() {
@@ -587,8 +343,7 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
);
if ( indexes.length == 0 ) {
- logger.debug( "Not refreshing indexes, none found for app {}",
- applicationScope.getApplication().getUuid() );
+ logger.debug( "Not refreshing indexes. none found");
return true;
}
//Added For Graphite Metrics
@@ -609,70 +364,6 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
}
- @Override
- public int getPendingTasks() {
-
- final PendingClusterTasksResponse tasksResponse = esProvider.getClient().admin()
- .cluster().pendingClusterTasks( new PendingClusterTasksRequest() ).actionGet();
-
- return tasksResponse.pendingTasks().size();
- }
-
-
-
- /**
- * Completely delete an index.
- */
- public ListenableActionFuture deleteIndex() {
- //TODO: add timer
- //TODO: add all indexes
- String idString = IndexingUtils.idString(applicationScope.getApplication());
-
- final TermQueryBuilder tqb = QueryBuilders.termQuery(APPLICATION_ID_FIELDNAME, idString);
-
- //Added For Graphite Metrics
-
- final ListenableActionFuture<DeleteByQueryResponse> response = esProvider.getClient()
- .prepareDeleteByQuery( alias.getWriteAlias() ).setQuery( tqb ).execute();
-
- response.addListener(new ActionListener<DeleteByQueryResponse>() {
-
- @Override
- public void onResponse(DeleteByQueryResponse response) {
- checkDeleteByQueryResponse(tqb,response);
- }
-
-
- @Override
- public void onFailure(Throwable e) {
- logger.error("failed on delete index",e);
- }
- });
- return response;
- }
- /**
- * Validate the response doesn't contain errors, if it does, fail fast at the first error we encounter
- */
- private void checkDeleteByQueryResponse(
- final QueryBuilder query, final DeleteByQueryResponse response ) {
-
- for ( IndexDeleteByQueryResponse indexDeleteByQueryResponse : response ) {
- final ShardOperationFailedException[] failures = indexDeleteByQueryResponse.getFailures();
-
- for ( ShardOperationFailedException failedException : failures ) {
- logger.error( String.format("Unable to delete by query %s. "
- + "Failed with code %d and reason %s on shard %s in index %s",
- query.toString(),
- failedException.status().getStatus(),
- failedException.reason(),
- failedException.shardId(),
- failedException.index() )
- );
- }
-
- }
- }
-
/**
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/679812e6/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 d49d8cc..c74ce93 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
@@ -96,21 +96,6 @@ public class IndexingUtils {
return sb.toString();
}
-
- /**
- * Create the facilities to retrieve an index name and alias name
- * @param fig
- * @param applicationScope
- * @return
- */
- public static IndexIdentifier createIndexIdentifier(IndexFig fig, ApplicationScope applicationScope) {
- return new IndexIdentifier(fig,applicationScope);
- }
-
-
-
-
-
/**
* Create the index doc from the given entity
* @param entity
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/679812e6/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/CorePerformanceIT.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/CorePerformanceIT.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/CorePerformanceIT.java
index c1bfe38..303d481 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/CorePerformanceIT.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/CorePerformanceIT.java
@@ -26,6 +26,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
+import org.apache.usergrid.persistence.index.*;
import org.junit.ClassRule;
import org.junit.Ignore;
import org.junit.Test;
@@ -40,11 +41,6 @@ import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory
import org.apache.usergrid.persistence.collection.impl.CollectionScopeImpl;
import org.apache.usergrid.persistence.core.scope.ApplicationScope;
import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
-import org.apache.usergrid.persistence.index.EntityIndex;
-import org.apache.usergrid.persistence.index.EntityIndexBatch;
-import org.apache.usergrid.persistence.index.EntityIndexFactory;
-import org.apache.usergrid.persistence.index.IndexScope;
-import org.apache.usergrid.persistence.index.SearchTypes;
import org.apache.usergrid.persistence.index.guice.TestIndexModule;
import org.apache.usergrid.persistence.index.query.CandidateResults;
import org.apache.usergrid.persistence.index.query.EntityResults;
@@ -83,6 +79,7 @@ public class CorePerformanceIT extends BaseIT {
static EntityCollectionManagerFactory ecmf;
static EntityIndexFactory ecif ;
+ static EntityIndex ecf;
@Ignore("Relies on finefoods.txt which must be downloaded separately")
@@ -97,6 +94,7 @@ public class CorePerformanceIT extends BaseIT {
ecmf = injector.getInstance( EntityCollectionManagerFactory.class );
ecif = injector.getInstance( EntityIndexFactory.class );
+ ecf = injector.getInstance(EntityIndex.class);
final ApplicationScope scope = new ApplicationScopeImpl( new SimpleId( "application" ) );
@@ -174,7 +172,7 @@ public class CorePerformanceIT extends BaseIT {
public void run() {
- EntityIndex eci = ecif.createEntityIndex( scope);
+ ApplicationEntityIndex eci = ecif.createApplicationEntityIndex(scope);
EntityCollectionManager ecm = ecmf.createCollectionManager( new CollectionScopeImpl( scope.getApplication(), indexScope.getOwner(), indexScope.getName() ) );
Query query = Query.fromQL( "review_score > 0"); // get all reviews;
@@ -219,7 +217,8 @@ public class CorePerformanceIT extends BaseIT {
CollectionScope collectionScope = new CollectionScopeImpl(
applicationScope.getApplication(), indexScope.getOwner(), indexScope.getName() );
EntityCollectionManager ecm = ecmf.createCollectionManager(collectionScope );
- EntityIndex eci = ecif.createEntityIndex(applicationScope );
+ ApplicationEntityIndex eci = ecif.createApplicationEntityIndex(applicationScope);
+
FileReader fr;
try {
@@ -304,7 +303,7 @@ public class CorePerformanceIT extends BaseIT {
throw new RuntimeException("Error reading file", ex);
}
- eci.refresh();
+ ecf.refresh();
}
}
@@ -312,7 +311,8 @@ public class CorePerformanceIT extends BaseIT {
public void runSelectedQueries(final ApplicationScope scope, List<IndexScope> indexScopes ) {
for ( IndexScope indexScope : indexScopes ) {
- EntityIndex eci = ecif.createEntityIndex(scope );
+ ApplicationEntityIndex eci = ecif.createApplicationEntityIndex(scope);
+
// TODO: come up with more and more complex queries for CorePerformanceIT
@@ -330,7 +330,7 @@ public class CorePerformanceIT extends BaseIT {
}
}
- public static void query(final IndexScope indexScope, final EntityIndex eci, final String query ) {;
+ public static void query(final IndexScope indexScope, final ApplicationEntityIndex eci, final String query ) {;
Query q = Query.fromQL(query) ;
// CandidateResults candidateResults = eci.search(indexScope, q ); TODO FIXME
// log.info("size = {} returned from query {}", candidateResults.size(), q.getQl() );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/679812e6/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityConnectionIndexImplTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityConnectionIndexImplTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityConnectionIndexImplTest.java
index a399809..8e8d6c0 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityConnectionIndexImplTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityConnectionIndexImplTest.java
@@ -21,6 +21,7 @@ package org.apache.usergrid.persistence.index.impl;
import java.io.IOException;
import java.util.HashMap;
+import org.apache.usergrid.persistence.index.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
@@ -30,11 +31,6 @@ import org.apache.usergrid.persistence.collection.util.EntityUtils;
import org.apache.usergrid.persistence.core.scope.ApplicationScope;
import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
import org.apache.usergrid.persistence.core.test.UseModules;
-import org.apache.usergrid.persistence.index.EntityIndex;
-import org.apache.usergrid.persistence.index.EntityIndexBatch;
-import org.apache.usergrid.persistence.index.EntityIndexFactory;
-import org.apache.usergrid.persistence.index.IndexScope;
-import org.apache.usergrid.persistence.index.SearchTypes;
import org.apache.usergrid.persistence.index.exceptions.QueryParseException;
import org.apache.usergrid.persistence.index.guice.TestIndexModule;
import org.apache.usergrid.persistence.index.query.CandidateResult;
@@ -65,6 +61,8 @@ public class EntityConnectionIndexImplTest extends BaseIT {
@Inject
public EntityIndexFactory ecif;
+ @Inject
+ public EntityIndex ei;
@Test
public void testBasicOperation() throws IOException, InterruptedException {
@@ -117,8 +115,7 @@ public class EntityConnectionIndexImplTest extends BaseIT {
IndexScope otherIndexScope =
new IndexScopeImpl( new SimpleId( UUIDGenerator.newTimeUUID(), "animal" ), "likes" );
- EntityIndex personLikesIndex = ecif.createEntityIndex( applicationScope );
- personLikesIndex.initializeIndex();
+ ApplicationEntityIndex personLikesIndex = ecif.createApplicationEntityIndex(applicationScope);
EntityIndexBatch batch = personLikesIndex.createBatch();
@@ -137,7 +134,7 @@ public class EntityConnectionIndexImplTest extends BaseIT {
batch.index( otherIndexScope, oj );
batch.execute().get();
- personLikesIndex.refresh();
+ ei.refresh();
Thread.sleep( 2000 );
@@ -247,8 +244,7 @@ public class EntityConnectionIndexImplTest extends BaseIT {
IndexScope otherIndexScope =
new IndexScopeImpl( new SimpleId( UUIDGenerator.newTimeUUID(), "animal" ), "likes" );
- EntityIndex personLikesIndex = ecif.createEntityIndex( applicationScope );
- personLikesIndex.initializeIndex();
+ ApplicationEntityIndex personLikesIndex = ecif.createApplicationEntityIndex(applicationScope);
EntityIndexBatch batch = personLikesIndex.createBatch();
@@ -267,7 +263,7 @@ public class EntityConnectionIndexImplTest extends BaseIT {
batch.index( otherIndexScope, oj );
batch.execute().get();
- personLikesIndex.refresh();
+ ei.refresh();
// now, let's search for muffins
@@ -285,7 +281,7 @@ public class EntityConnectionIndexImplTest extends BaseIT {
batch.deindex( searchScope, muffin );
batch.deindex( searchScope, oj );
batch.execute().get();
- personLikesIndex.refresh();
+ ei.refresh();
likes = personLikesIndex.search( searchScope,
SearchTypes.fromTypes( muffin.getId().getType(), egg.getId().getType(), oj.getId().getType() ),
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/679812e6/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 047fbe8..483efb9 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
@@ -70,6 +70,8 @@ public class EntityIndexTest extends BaseIT {
@Inject
public EntityIndexFactory eif;
+ @Inject
+ public EntityIndex ei;
//TODO T.N. Remove this when we move the cursor mapping back to core
@Inject
@@ -82,9 +84,8 @@ public class EntityIndexTest extends BaseIT {
Id appId = new SimpleId( "application" );
ApplicationScope applicationScope = new ApplicationScopeImpl( appId );
+ ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex(applicationScope);
- EntityIndex entityIndex = eif.createEntityIndex( applicationScope );
- entityIndex.initializeIndex();
final String entityType = "thing";
IndexScope indexScope = new IndexScopeImpl( appId, "things" );
@@ -92,7 +93,7 @@ public class EntityIndexTest extends BaseIT {
insertJsonBlob(entityIndex, entityType, indexScope, "/sample-large.json",101,0);
- entityIndex.refresh();
+ ei.refresh();
testQueries( indexScope, searchTypes, entityIndex );
@@ -105,8 +106,7 @@ public class EntityIndexTest extends BaseIT {
ApplicationScope applicationScope = new ApplicationScopeImpl( appId );
- EntityIndex entityIndex = eif.createEntityIndex( applicationScope );
- entityIndex.initializeIndex();
+ ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex(applicationScope);
final String entityType = "thing";
IndexScope indexScope = new IndexScopeImpl( appId, "things" );
@@ -133,7 +133,7 @@ public class EntityIndexTest extends BaseIT {
batch.index(indexScope, entity);
batch.execute().get();
- entityIndex.refresh();
+ ei.refresh();
testQueries( indexScope, searchTypes, entityIndex );
}
@@ -147,10 +147,10 @@ public class EntityIndexTest extends BaseIT {
long now = System.currentTimeMillis();
final int threads = 20;
final int size = 30;
- final EntityIndex entityIndex = eif.createEntityIndex( applicationScope );
+ final ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex(applicationScope);
final IndexScope indexScope = new IndexScopeImpl(appId, "things");
final String entityType = "thing";
- entityIndex.initializeIndex();
+ ei.initializeIndex();
final CountDownLatch latch = new CountDownLatch(threads);
final AtomicLong failTime=new AtomicLong(0);
InputStream is = this.getClass().getResourceAsStream( "/sample-large.json" );
@@ -192,10 +192,10 @@ public class EntityIndexTest extends BaseIT {
ApplicationScope applicationScope = new ApplicationScopeImpl( appId );
- EntityIndex entityIndex = eif.createEntityIndex( applicationScope );
- entityIndex.initializeIndex();
+ ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex(applicationScope);
+ ei.initializeIndex();
for(int i=0;i<10;i++) {
- entityIndex.initializeIndex();
+ ei.initializeIndex();
}
}
@@ -206,8 +206,8 @@ public class EntityIndexTest extends BaseIT {
ApplicationScope applicationScope = new ApplicationScopeImpl( appId );
- AliasedEntityIndex entityIndex =(AliasedEntityIndex) eif.createEntityIndex( applicationScope );
- entityIndex.initializeIndex();
+ ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex(applicationScope);
+ ei.initializeIndex();
final String entityType = "thing";
IndexScope indexScope = new IndexScopeImpl( appId, "things" );
@@ -215,15 +215,15 @@ public class EntityIndexTest extends BaseIT {
insertJsonBlob(entityIndex, entityType, indexScope, "/sample-large.json",101,0);
- entityIndex.refresh();
+ ei.refresh();
testQueries( indexScope, searchTypes, entityIndex );
- entityIndex.addIndex("v2", 1,0,"one");
+ ei.addIndex("v2", 1,0,"one");
insertJsonBlob(entityIndex, entityType, indexScope, "/sample-large.json",101,100);
- entityIndex.refresh();
+ ei.refresh();
//Hilda Youn
testQuery(indexScope, searchTypes, entityIndex, "name = 'Hilda Young'", 1 );
@@ -237,9 +237,8 @@ public class EntityIndexTest extends BaseIT {
ApplicationScope applicationScope = new ApplicationScopeImpl( appId );
- AliasedEntityIndex entityIndex =(AliasedEntityIndex) eif.createEntityIndex( applicationScope );
+ ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex( applicationScope );
- entityIndex.initializeIndex();
final String entityType = "thing";
IndexScope indexScope = new IndexScopeImpl( appId, "things" );
@@ -247,33 +246,33 @@ public class EntityIndexTest extends BaseIT {
insertJsonBlob(entityIndex, entityType, indexScope, "/sample-large.json",1,0);
- entityIndex.refresh();
+ ei.refresh();
- entityIndex.addIndex("v2", 1, 0, "one");
+ ei.addIndex("v2", 1, 0, "one");
insertJsonBlob(entityIndex, entityType, indexScope, "/sample-large.json", 1, 0);
- entityIndex.refresh();
+ ei.refresh();
CandidateResults crs = testQuery(indexScope, searchTypes, entityIndex, "name = 'Bowers Oneil'", 2);
EntityIndexBatch entityIndexBatch = entityIndex.createBatch();
entityIndexBatch.deindex(indexScope, crs.get(0));
entityIndexBatch.deindex(indexScope, crs.get(1));
entityIndexBatch.execute().get();
- entityIndex.refresh();
+ ei.refresh();
//Hilda Youn
testQuery(indexScope, searchTypes, entityIndex, "name = 'Bowers Oneil'", 0);
}
- private void insertJsonBlob(EntityIndex entityIndex, String entityType, IndexScope indexScope, String filePath,final int max,final int startIndex) throws IOException {
+ private void insertJsonBlob(ApplicationEntityIndex entityIndex, String entityType, IndexScope indexScope, String filePath,final int max,final int startIndex) throws IOException {
InputStream is = this.getClass().getResourceAsStream( filePath );
ObjectMapper mapper = new ObjectMapper();
List<Object> sampleJson = mapper.readValue( is, new TypeReference<List<Object>>() {} );
EntityIndexBatch batch = entityIndex.createBatch();
insertJsonBlob(sampleJson,batch, entityType, indexScope, max, startIndex);
batch.execute().get();
- entityIndex.refresh();
+ ei.refresh();
}
private void insertJsonBlob(List<Object> sampleJson, EntityIndexBatch batch, String entityType, IndexScope indexScope,final int max,final int startIndex) throws IOException {
@@ -320,8 +319,8 @@ public class EntityIndexTest extends BaseIT {
IndexScope indexScope = new IndexScopeImpl( appId, "fastcars" );
- EntityIndex entityIndex = eif.createEntityIndex( applicationScope );
- entityIndex.initializeIndex();
+ ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex(applicationScope);
+ ei.initializeIndex();
Map entityMap = new HashMap() {{
put( "name", "Ferrari 212 Inter" );
@@ -336,7 +335,7 @@ public class EntityIndexTest extends BaseIT {
entity.setField(new UUIDField(IndexingUtils.ENTITYID_ID_FIELDNAME, UUID.randomUUID()));
entityIndex.createBatch().index(indexScope , entity ).execute().get();
- entityIndex.refresh();
+ ei.refresh();
CandidateResults candidateResults = entityIndex.search( indexScope,
SearchTypes.fromTypes( entity.getId().getType() ), Query.fromQL( "name contains 'Ferrari*'" ) );
@@ -345,14 +344,14 @@ public class EntityIndexTest extends BaseIT {
EntityIndexBatch batch = entityIndex.createBatch();
batch.deindex(indexScope, entity).execute().get();
batch.execute().get();
- entityIndex.refresh();
+ ei.refresh();
candidateResults = entityIndex.search( indexScope, SearchTypes.fromTypes(entity.getId().getType()), Query.fromQL( "name contains 'Ferrari*'" ) );
assertEquals( 0, candidateResults.size() );
}
- private CandidateResults testQuery(final IndexScope scope, final SearchTypes searchTypes, final EntityIndex entityIndex, final String queryString, final int num ) {
+ private CandidateResults testQuery(final IndexScope scope, final SearchTypes searchTypes, final ApplicationEntityIndex entityIndex, final String queryString, final int num ) {
StopWatch timer = new StopWatch();
timer.start();
@@ -367,7 +366,7 @@ public class EntityIndexTest extends BaseIT {
}
- private void testQueries(final IndexScope scope, SearchTypes searchTypes, final EntityIndex entityIndex ) {
+ private void testQueries(final IndexScope scope, SearchTypes searchTypes, final ApplicationEntityIndex entityIndex ) {
testQuery(scope, searchTypes, entityIndex, "name = 'Morgan Pierce'", 1 );
@@ -451,7 +450,7 @@ public class EntityIndexTest extends BaseIT {
IndexScope appScope = new IndexScopeImpl( ownerId, "user" );
- EntityIndex ei = eif.createEntityIndex( applicationScope );
+ ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex(applicationScope);
ei.initializeIndex();
final String middleName = "middleName" + UUIDUtils.newTimeUUID();
@@ -467,7 +466,7 @@ public class EntityIndexTest extends BaseIT {
EntityUtils.setVersion( user, UUIDGenerator.newTimeUUID() );
- EntityIndexBatch batch = ei.createBatch();
+ EntityIndexBatch batch = entityIndex.createBatch();
batch.index( appScope, user);
batch.execute().get();
@@ -475,7 +474,7 @@ public class EntityIndexTest extends BaseIT {
Query query = new Query();
query.addEqualityFilter( "username", "edanuff" );
- CandidateResults r = ei.search( appScope, SearchTypes.fromTypes( "edanuff" ), query );
+ CandidateResults r = entityIndex.search( appScope, SearchTypes.fromTypes( "edanuff" ), query );
assertEquals( user.getId(), r.get( 0 ).getId() );
batch.deindex(appScope, user.getId(), user.getVersion() );
@@ -486,7 +485,7 @@ public class EntityIndexTest extends BaseIT {
query = new Query();
query.addEqualityFilter( "username", "edanuff" );
- r = ei.search(appScope,SearchTypes.fromTypes( "edanuff" ), query );
+ r = entityIndex.search(appScope,SearchTypes.fromTypes( "edanuff" ), query );
assertFalse( r.iterator().hasNext() );
}
@@ -500,9 +499,9 @@ public class EntityIndexTest extends BaseIT {
IndexScope appScope = new IndexScopeImpl( ownerId, "user" );
- EntityIndex ei = eif.createEntityIndex( applicationScope );
+ ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex(applicationScope);
ei.initializeIndex();
- ei.createBatch();
+ entityIndex.createBatch();
// Bill has favorites as string, age as string and retirement goal as number
Map billMap = new HashMap() {{
@@ -516,7 +515,7 @@ public class EntityIndexTest extends BaseIT {
EntityUtils.setId( bill, new SimpleId( UUIDGenerator.newTimeUUID(), "user" ) );
EntityUtils.setVersion( bill, UUIDGenerator.newTimeUUID() );
- EntityIndexBatch batch = ei.createBatch();
+ EntityIndexBatch batch = entityIndex.createBatch();
batch.index( appScope, bill );
@@ -547,22 +546,22 @@ public class EntityIndexTest extends BaseIT {
Query query = new Query();
query.addEqualityFilter( "username", "bill" );
- CandidateResults r = ei.search( appScope, searchTypes, query );
+ CandidateResults r = entityIndex.search( appScope, searchTypes, query );
assertEquals( bill.getId(), r.get( 0 ).getId() );
query = new Query();
query.addEqualityFilter( "username", "fred" );
- r = ei.search( appScope, searchTypes, query );
+ r = entityIndex.search( appScope, searchTypes, query );
assertEquals( fred.getId(), r.get( 0 ).getId() );
query = new Query();
query.addEqualityFilter( "age", 41 );
- r = ei.search( appScope, searchTypes, query );
+ r = entityIndex.search( appScope, searchTypes, query );
assertEquals( fred.getId(), r.get( 0 ).getId() );
query = new Query();
query.addEqualityFilter( "age", "thirtysomething" );
- r = ei.search( appScope, searchTypes, query );
+ r = entityIndex.search( appScope, searchTypes, query );
assertEquals( bill.getId(), r.get( 0 ).getId() );
}
@@ -570,11 +569,6 @@ public class EntityIndexTest extends BaseIT {
@Test
public void healthTest() {
- Id appId = new SimpleId( "application" );
- ApplicationScope applicationScope = new ApplicationScopeImpl( appId );
-
- EntityIndex ei = eif.createEntityIndex( applicationScope );
-
assertNotEquals( "cluster should be ok", Health.RED, ei.getClusterHealth() );
assertEquals( "index should be ready", Health.GREEN, ei.getIndexHealth() );
@@ -597,8 +591,8 @@ public class EntityIndexTest extends BaseIT {
IndexScope indexScope = new IndexScopeImpl( ownerId, "users" );
- EntityIndex entityIndex = eif.createEntityIndex( applicationScope );
- entityIndex.initializeIndex();
+ ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex(applicationScope);
+ ei.initializeIndex();
final EntityIndexBatch batch = entityIndex.createBatch();
@@ -634,7 +628,7 @@ public class EntityIndexTest extends BaseIT {
batch.execute().get();
- entityIndex.refresh();
+ ei.refresh();
final int limit = 1;
[06/31] incubator-usergrid git commit: change app creation to create
index
Posted by to...@apache.org.
change app creation to create index
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/65c20a11
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/65c20a11
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/65c20a11
Branch: refs/heads/USERGRID-486
Commit: 65c20a119250cbf3586a286c9a3d79af42cd4b52
Parents: 89f2c2f
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Mar 18 16:38:16 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Mar 18 16:38:16 2015 -0600
----------------------------------------------------------------------
.../corepersistence/CpEntityManagerFactory.java | 12 +++++++-----
.../test/java/org/apache/usergrid/CoreITSetupImpl.java | 1 +
2 files changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/65c20a11/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 2bdb54c..41bcf62 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
@@ -141,16 +141,18 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
EntityManager em = getEntityManager( CpNamingUtils.SYSTEM_APP_ID);
try {
- if ( em.getApplication() == null ) {
+ if (em.getApplication() == null) {
logger.info("Creating system application");
Map sysAppProps = new HashMap<String, Object>();
sysAppProps.put(PROPERTY_NAME, "systemapp");
em.create(CpNamingUtils.SYSTEM_APP_ID, TYPE_APPLICATION, sysAppProps);
em.getApplication();
- em.createIndex();
- em.refreshIndex();
}
+ em.createIndex();
+ em.refreshIndex();
+
+
} catch (Exception ex) {
throw new RuntimeException("Fatal error creating system application", ex);
}
@@ -289,9 +291,9 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
properties = new TreeMap<String, Object>( CASE_INSENSITIVE_ORDER );
}
properties.put( PROPERTY_NAME, appName );
- EntityManager appEm = getEntityManager( applicationId );
+ EntityManager appEm = getEntityManager( applicationId);
- appEm.create( applicationId, TYPE_APPLICATION, properties );
+ appEm.create(applicationId, TYPE_APPLICATION, properties );
appEm.resetRoles();
appEm.refreshIndex();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/65c20a11/stack/core/src/test/java/org/apache/usergrid/CoreITSetupImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/CoreITSetupImpl.java b/stack/core/src/test/java/org/apache/usergrid/CoreITSetupImpl.java
index d403a1e..d4e69bc 100644
--- a/stack/core/src/test/java/org/apache/usergrid/CoreITSetupImpl.java
+++ b/stack/core/src/test/java/org/apache/usergrid/CoreITSetupImpl.java
@@ -130,6 +130,7 @@ public class CoreITSetupImpl implements CoreITSetup {
@Override
public UUID createApplication( String organizationName, String applicationName ) throws Exception {
+ emf.setup();
if ( USE_DEFAULT_APPLICATION ) {
return emf.getDefaultAppId();
}
[19/31] incubator-usergrid git commit: adding refresh retry
Posted by to...@apache.org.
adding refresh retry
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/f7e78f4a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/f7e78f4a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/f7e78f4a
Branch: refs/heads/USERGRID-486
Commit: f7e78f4a65cca60c4f4ba064a872331a0d820843
Parents: 51a38fc
Author: Shawn Feldman <sf...@apache.org>
Authored: Fri Mar 20 07:45:22 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Fri Mar 20 07:45:22 2015 -0600
----------------------------------------------------------------------
.../test/resources/usergrid-custom-test.properties | 1 +
.../persistence/index/impl/EsEntityIndexImpl.java | 17 +++++++++++++++--
2 files changed, 16 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f7e78f4a/stack/core/src/test/resources/usergrid-custom-test.properties
----------------------------------------------------------------------
diff --git a/stack/core/src/test/resources/usergrid-custom-test.properties b/stack/core/src/test/resources/usergrid-custom-test.properties
index 949b60e..fe528fd 100644
--- a/stack/core/src/test/resources/usergrid-custom-test.properties
+++ b/stack/core/src/test/resources/usergrid-custom-test.properties
@@ -24,4 +24,5 @@ cassandra.connections=1000
#This is just way more efficient for a single node and the number of shards we're creating
elasticsearch.number_shards=1
elasticsearch.number_replicas=0
+elasticsearch.index_prefix=core_tests
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f7e78f4a/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 1eb73d3..18c3d67 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
@@ -35,6 +35,7 @@ import org.apache.usergrid.persistence.model.util.UUIDGenerator;
import org.elasticsearch.action.ActionFuture;
+import org.elasticsearch.action.ShardOperationFailedException;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.action.admin.cluster.tasks.PendingClusterTasksRequest;
@@ -47,6 +48,7 @@ import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse;
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse;
+import org.elasticsearch.action.admin.indices.refresh.RefreshResponse;
import org.elasticsearch.client.AdminClient;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings;
@@ -346,9 +348,20 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
return true;
}
//Added For Graphite Metrics
- esProvider.getClient().admin().indices().prepareRefresh( indexes ).execute().actionGet();
+ RefreshResponse response = esProvider.getClient().admin().indices().prepareRefresh( indexes ).execute().actionGet();
+ int failedShards = response.getFailedShards();
+ int successfulShards = response.getSuccessfulShards();
+ ShardOperationFailedException[] sfes = response.getShardFailures();
+ if(sfes!=null) {
+ for (ShardOperationFailedException sfe : sfes) {
+ logger.error("Failed to refresh index:{} reason:{}", sfe.index(), sfe.reason());
+ }
+ }
+ logger.debug("Refreshed indexes: {},success:{} failed:{} ", StringUtils.join(indexes, ", "),successfulShards,failedShards);
timeRefreshIndex.stop();
- logger.debug("Refreshed indexes: {}", StringUtils.join(indexes, ", "));
+ if(failedShards>0){
+ throw new RuntimeException("Failed to update all shards in refresh operation");
+ }
return true;
}
catch ( IndexMissingException e ) {
[02/31] incubator-usergrid git commit: rollback array fix
Posted by to...@apache.org.
rollback array fix
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/1199e477
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/1199e477
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/1199e477
Branch: refs/heads/USERGRID-486
Commit: 1199e477e7336a8aebfdef67f2ea8f2d9407c54a
Parents: 98bc9a4
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Mar 18 11:23:08 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Mar 18 11:23:08 2015 -0600
----------------------------------------------------------------------
.../usergrid/persistence/index/impl/EsEntityIndexBatchImpl.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1199e477/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 34e7702..23b9041 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
@@ -235,7 +235,7 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
if ( f instanceof ListField ) {
List list = ( List ) field.getValue();
- entityMap.put( ARRAY_PREFIX+ field.getName().toLowerCase(),
+ entityMap.put( field.getName().toLowerCase(),
new ArrayList( processCollectionForMap( list ) ) );
if ( !list.isEmpty() ) {
@@ -247,7 +247,7 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
}
else if ( f instanceof ArrayField ) {
List list = ( List ) field.getValue();
- entityMap.put( ARRAY_PREFIX+ field.getName().toLowerCase(),
+ entityMap.put( field.getName().toLowerCase(),
new ArrayList( processCollectionForMap( list ) ) );
}
else if ( f instanceof SetField ) {
[21/31] incubator-usergrid git commit: merge issues
Posted by to...@apache.org.
merge issues
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/336c2228
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/336c2228
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/336c2228
Branch: refs/heads/USERGRID-486
Commit: 336c222851cd8f18aa7b0719ca307a95d103c598
Parents: 75d61b2
Author: Shawn Feldman <sf...@apache.org>
Authored: Fri Mar 20 10:51:31 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Fri Mar 20 10:51:31 2015 -0600
----------------------------------------------------------------------
.../persistence/index/impl/EsEntityIndexImpl.java | 1 -
.../persistence/index/impl/EntityIndexTest.java | 7 +------
.../persistence/index/impl/IndexLoadTestsIT.java | 12 ++++++++----
3 files changed, 9 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/336c2228/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 18c3d67..2be3e51 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
@@ -63,7 +63,6 @@ import org.elasticsearch.rest.action.admin.indices.alias.delete.AliasesMissingEx
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
import java.io.IOException;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/336c2228/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 a21ccda..b562ccf 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
@@ -29,6 +29,7 @@ import java.util.UUID;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicLong;
+import org.apache.usergrid.persistence.index.*;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
@@ -43,12 +44,6 @@ import org.apache.usergrid.persistence.core.scope.ApplicationScope;
import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
import org.apache.usergrid.persistence.core.test.UseModules;
import org.apache.usergrid.persistence.core.util.Health;
-import org.apache.usergrid.persistence.index.AliasedEntityIndex;
-import org.apache.usergrid.persistence.index.EntityIndex;
-import org.apache.usergrid.persistence.index.EntityIndexBatch;
-import org.apache.usergrid.persistence.index.EntityIndexFactory;
-import org.apache.usergrid.persistence.index.IndexScope;
-import org.apache.usergrid.persistence.index.SearchTypes;
import org.apache.usergrid.persistence.index.guice.TestIndexModule;
import org.apache.usergrid.persistence.index.query.CandidateResults;
import org.apache.usergrid.persistence.index.query.Query;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/336c2228/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java
index 82af950..623f9dd 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java
@@ -22,6 +22,7 @@ package org.apache.usergrid.persistence.index.impl;
import java.util.List;
import java.util.UUID;
+import org.apache.usergrid.persistence.index.ApplicationEntityIndex;
import org.junit.ClassRule;
import org.junit.Ignore;
import org.junit.Test;
@@ -69,6 +70,9 @@ public class IndexLoadTestsIT extends BaseIT {
@Inject
public EntityIndexFactory entityIndexFactory;
+ @Inject
+ public EntityIndex index;
+
@Test
public void testHeavyLoad() {
@@ -78,19 +82,19 @@ public class IndexLoadTestsIT extends BaseIT {
final Id applicationId = new SimpleId( applicationUUID, "application" );
final ApplicationScope scope = new ApplicationScopeImpl( applicationId );
- final EntityIndex index = entityIndexFactory.createEntityIndex( scope );
//create our index if it doesn't exist
index.initializeIndex();
- final Observable<Entity> createEntities = createStreamFromWorkers( index, applicationId );
+ ApplicationEntityIndex applicationEntityIndex = entityIndexFactory.createApplicationEntityIndex(scope);
+ final Observable<Entity> createEntities = createStreamFromWorkers( applicationEntityIndex, applicationId );
//run them all
createEntities.toBlocking().last();
}
- public Observable<Entity> createStreamFromWorkers( final EntityIndex entityIndex, final Id ownerId ) {
+ public Observable<Entity> createStreamFromWorkers( final ApplicationEntityIndex entityIndex, final Id ownerId ) {
//create a sequence of observables. Each index will be it's own worker thread using the Schedulers.newthread()
return Observable.range( 0, indexTestFig.getNumberOfWorkers() ).flatMap(
@@ -98,7 +102,7 @@ public class IndexLoadTestsIT extends BaseIT {
}
- private Observable<Entity> createWriteObservable( final EntityIndex entityIndex, final Id ownerId,
+ private Observable<Entity> createWriteObservable( final ApplicationEntityIndex entityIndex, final Id ownerId,
final int workerIndex ) {