You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2014/10/29 20:22:02 UTC
[21/22] git commit: Formatting and import cleanup only.
Formatting and import cleanup only.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/707c9b99
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/707c9b99
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/707c9b99
Branch: refs/heads/two-dot-o-events
Commit: 707c9b9989cfcdf21b39977494afb36b8a495000
Parents: 610eb2d
Author: Dave Johnson <dm...@apigee.com>
Authored: Wed Oct 29 15:19:30 2014 -0400
Committer: Dave Johnson <dm...@apigee.com>
Committed: Wed Oct 29 15:19:30 2014 -0400
----------------------------------------------------------------------
.../corepersistence/CpEntityDeleteListener.java | 45 +++++++------
.../usergrid/corepersistence/CpSetup.java | 1 -
.../usergrid/corepersistence/CpWalker.java | 44 +++++++-----
.../results/FilteringLoader.java | 63 +++++++++--------
.../results/ResultsLoaderFactory.java | 5 +-
.../results/ResultsLoaderFactoryImpl.java | 4 --
.../results/ResultsVerifier.java | 6 +-
.../results/VersionVerifier.java | 8 ++-
.../corepersistence/util/CpEntityMapUtils.java | 5 +-
.../usergrid/persistence/index/EntityIndex.java | 4 +-
.../persistence/index/EntityIndexBatch.java | 6 --
.../persistence/index/EntityIndexFactory.java | 2 -
.../usergrid/persistence/index/IndexScope.java | 9 +--
.../persistence/index/guice/IndexModule.java | 1 -
.../index/impl/EsEntityIndexBatchImpl.java | 3 +-
.../index/impl/EsEntityIndexImpl.java | 71 ++++++++++----------
.../persistence/index/impl/EsProvider.java | 11 ++-
.../index/query/CandidateResults.java | 7 +-
.../persistence/index/query/Identifier.java | 3 +-
.../usergrid/persistence/index/query/Query.java | 27 +++++---
.../persistence/index/query/Results.java | 4 +-
21 files changed, 169 insertions(+), 160 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityDeleteListener.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityDeleteListener.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityDeleteListener.java
index 70df7d5..4ec4056 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityDeleteListener.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityDeleteListener.java
@@ -68,28 +68,35 @@ public class CpEntityDeleteListener {
return Observable.create( new ObservableIterator<MvccEntity>( "deleteEntities" ) {
@Override
protected Iterator<MvccEntity> getIterator() {
- Iterator<MvccEntity> iterator = entityMetadataSerialization.loadHistory( entityEvent.getCollectionScope(), entity.getId(), entity.getVersion(), serializationFig.getHistorySize() );
+ Iterator<MvccEntity> iterator = entityMetadataSerialization.loadHistory(
+ entityEvent.getCollectionScope(),
+ entity.getId(),
+ entity.getVersion(),
+ serializationFig.getHistorySize() );
return iterator;
}
} ).subscribeOn(Schedulers.io())
- .buffer(serializationFig.getBufferSize())
- .flatMap(new Func1<List<MvccEntity>, Observable<EntityVersion>>() {
- @Override
- public Observable<EntityVersion> call(List<MvccEntity> mvccEntities) {
- MutationBatch mutationBatch = keyspace.prepareMutationBatch();
- List<EntityVersion> versions = new ArrayList<>();
- //actually delete the edge from both the commit log and
- for (MvccEntity mvccEntity : mvccEntities) {
- versions.add(mvccEntity);
- mutationBatch.mergeShallow(entityMetadataSerialization.delete(entityEvent.getCollectionScope(), mvccEntity.getId(), mvccEntity.getVersion()));
- }
- try {
- mutationBatch.execute();
- } catch (ConnectionException e) {
- throw new RuntimeException("Unable to execute mutation", e);
- }
- return Observable.from(versions);
+ .buffer(serializationFig.getBufferSize())
+ .flatMap(new Func1<List<MvccEntity>, Observable<EntityVersion>>() {
+ @Override
+ public Observable<EntityVersion> call(List<MvccEntity> mvccEntities) {
+ MutationBatch mutationBatch = keyspace.prepareMutationBatch();
+ List<EntityVersion> versions = new ArrayList<>();
+ //actually delete the edge from both the commit log and
+ for (MvccEntity mvccEntity : mvccEntities) {
+ versions.add(mvccEntity);
+ mutationBatch.mergeShallow(entityMetadataSerialization.delete(
+ entityEvent.getCollectionScope(),
+ mvccEntity.getId(),
+ mvccEntity.getVersion()));
}
- });
+ try {
+ mutationBatch.execute();
+ } catch (ConnectionException e) {
+ throw new RuntimeException("Unable to execute mutation", e);
+ }
+ return Observable.from(versions);
+ }
+ });
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/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 c1bab12..9f7b031 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
@@ -22,7 +22,6 @@ import com.google.inject.Injector;
import com.netflix.config.ConfigurationManager;
import java.util.Properties;
import java.util.UUID;
-import java.util.logging.Level;
import me.prettyprint.cassandra.service.CassandraHost;
import me.prettyprint.hector.api.ddl.ComparatorType;
import static me.prettyprint.hector.api.factory.HFactory.createColumnFamilyDefinition;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java
index 27d4224..c3a9fe6 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpWalker.java
@@ -56,40 +56,52 @@ public class CpWalker {
}
- public void walkCollections( final CpEntityManager em, final EntityRef start, final CpVisitor visitor )
- throws Exception {
+ public void walkCollections( final CpEntityManager em, final EntityRef start,
+ final CpVisitor visitor ) throws Exception {
doWalkCollections( em, new SimpleId( start.getUuid(), start.getType() ), visitor );
}
- private void doWalkCollections( final CpEntityManager em, final Id applicationId, final CpVisitor visitor ) {
+ private void doWalkCollections(
+ final CpEntityManager em, final Id applicationId, final CpVisitor visitor ) {
final ApplicationScope applicationScope = em.getApplicationScope();
final GraphManager gm = em.getManagerCache().getGraphManager( applicationScope );
- logger.debug( "Loading edges types from {}:{}\n scope {}:{}", new Object[] {
- applicationId.getType(), applicationId.getUuid(), applicationScope.getApplication().getType(),
- applicationScope.getApplication().getUuid()
- } );
+ logger.debug( "Loading edges types from {}:{}\n scope {}:{}",
+ new Object[] {
+ applicationId.getType(),
+ applicationId.getUuid(),
+ applicationScope.getApplication().getType(),
+ applicationScope.getApplication().getUuid()
+ } );
//only search edge types that start with collections
Observable<String> edgeTypes = gm.getEdgeTypesFromSource(
- new SimpleSearchEdgeType( applicationId, CpNamingUtils.EDGE_COLL_SUFFIX, null ) );
+ new SimpleSearchEdgeType( applicationId, CpNamingUtils.EDGE_COLL_SUFFIX, null ) );
edgeTypes.flatMap( new Func1<String, Observable<Edge>>() {
@Override
public Observable<Edge> call( final String edgeType ) {
- logger.debug( "Loading edges of edgeType {} from {}:{}\n scope {}:{}", new Object[] {
- edgeType, applicationId.getType(), applicationId.getUuid(), applicationScope.getApplication().getType(),
+ logger.debug( "Loading edges of edgeType {} from {}:{}\n scope {}:{}",
+ new Object[] {
+ edgeType,
+ applicationId.getType(),
+ applicationId.getUuid(),
+ applicationScope.getApplication().getType(),
applicationScope.getApplication().getUuid()
} );
- return gm.loadEdgesFromSource( new SimpleSearchByEdgeType( applicationId, edgeType, Long.MAX_VALUE,
- SearchByEdgeType.Order.DESCENDING, null ) );
+ return gm.loadEdgesFromSource( new SimpleSearchByEdgeType(
+ applicationId,
+ edgeType,
+ Long.MAX_VALUE,
+ SearchByEdgeType.Order.DESCENDING,
+ null ) );
}
} ).doOnNext( new Action1<Edge>() {
@@ -98,16 +110,16 @@ public class CpWalker {
logger.info( "Re-indexing edge {}", edge );
- EntityRef targetNodeEntityRef =
- new SimpleEntityRef( edge.getTargetNode().getType(), edge.getTargetNode().getUuid() );
+ EntityRef targetNodeEntityRef = new SimpleEntityRef(
+ edge.getTargetNode().getType(), edge.getTargetNode().getUuid() );
Entity entity;
try {
entity = em.get( targetNodeEntityRef );
}
catch ( Exception ex ) {
- logger.error( "Error getting sourceEntity {}:{}, continuing", targetNodeEntityRef.getType(),
- targetNodeEntityRef.getUuid() );
+ logger.error( "Error getting sourceEntity {}:{}, continuing",
+ targetNodeEntityRef.getType(), targetNodeEntityRef.getUuid() );
return;
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/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 00faefd..8ca2211 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
@@ -96,40 +96,32 @@ public class FilteringLoader implements ResultsLoader {
}
- /**
- * For each entity, holds the index it appears in our candidates for keeping ordering correct
- */
+ // For each entity, holds the index it appears in our candidates for keeping ordering correct
final Map<Id, Integer> orderIndex = new HashMap<>( crs.size() );
- /**
- * Maps the entity ids to our candidates
- */
+ // Maps the entity ids to our candidates
final Map<Id, CandidateResult> maxCandidateMapping = new HashMap<>( crs.size() );
- /**
- * Groups all candidate results by types. When search connections there will be multiple types,
- * so we want to batch
- * fetch them more efficiently
- */
- final HashMultimap<String, CandidateResult> groupedByScopes = HashMultimap.create( crs.size(), crs.size() );
+ // Groups all candidate results by types. When search connections there will be multiple
+ // types, so we want to batch fetch them more efficiently
+
+ final HashMultimap<String, CandidateResult> groupedByScopes =
+ HashMultimap.create( crs.size(), crs.size() );
final Iterator<CandidateResult> iter = crs.iterator();
- /**
- * TODO, in this case we're "optimizing" due to the limitations of collection scope. Perhaps we should
- * change the API to just be an application, then an "owner" scope?
- */
+ // TODO, in this case we're "optimizing" due to the limitations of collection scope.
+ // Perhaps we should change the API to just be an application, then an "owner" scope?
- /**
- * Go through the candidates and group them by scope for more efficient retrieval. Also remove duplicates before we even make a network call
- */
+ // Go through the candidates and group them by scope for more efficient retrieval.
+ // Also remove duplicates before we even make a network call
for ( int i = 0; iter.hasNext(); i++ ) {
final CandidateResult currentCandidate = iter.next();
- final String collectionType =
- CpNamingUtils.getCollectionScopeNameFromEntityType( currentCandidate.getId().getType() );
+ final String collectionType = CpNamingUtils.getCollectionScopeNameFromEntityType(
+ currentCandidate.getId().getType() );
final Id entityId = currentCandidate.getId();
@@ -154,9 +146,12 @@ public class FilteringLoader implements ResultsLoader {
if ( UUIDComparator.staticCompare( currentVersion, previousMaxVersion ) > 0 ) {
//de-index it
- logger.debug( "Stale version of Entity uuid:{} type:{}, stale v:{}, latest v:{}", new Object[] {
- entityId.getUuid(), entityId.getType(), previousMaxVersion, currentVersion
- } );
+ logger.debug( "Stale version of Entity uuid:{} type:{}, stale v:{}, latest v:{}",
+ new Object[] {
+ entityId.getUuid(),
+ entityId.getType(),
+ previousMaxVersion,
+ currentVersion } );
//deindex this document, and remove the previous maxVersion
//we have to deindex this from our ownerId, since this is what gave us the reference
@@ -197,12 +192,13 @@ public class FilteringLoader implements ResultsLoader {
//now using the scope, load the collection
- // Get the collection scope and batch load all the versions. We put all entities in app/app for easy retrieval
- // unless persistence changes, we never want to read from any scope other than the app, app, scope name scope
+ // Get the collection scope and batch load all the versions. We put all entities in
+ // app/app for easy retrieval/ unless persistence changes, we never want to read from
+ // any scope other than the app, app, scope name scope
final CollectionScope collScope = new CollectionScopeImpl(
- applicationScope.getApplication(), applicationScope.getApplication(), scopeName );
+ applicationScope.getApplication(), applicationScope.getApplication(), scopeName);
- final EntityCollectionManager ecm = managerCache.getEntityCollectionManager( collScope );
+ final EntityCollectionManager ecm = managerCache.getEntityCollectionManager( collScope);
//load the results into the loader for this scope for validation
@@ -228,7 +224,8 @@ public class FilteringLoader implements ResultsLoader {
}
- //NOTE DO NOT execute the batch here. It changes the results and we need consistent paging until we aggregate all results
+ // NOTE DO NOT execute the batch here.
+ // It changes the results and we need consistent paging until we aggregate all results
return resultsVerifier.getResults( sortedResults.values() );
}
@@ -239,10 +236,12 @@ public class FilteringLoader implements ResultsLoader {
}
- protected void deIndex( final EntityIndexBatch batch, final Id ownerId, final CandidateResult candidateResult ) {
+ protected void deIndex( final EntityIndexBatch batch, final Id ownerId,
+ final CandidateResult candidateResult ) {
- IndexScope indexScope = new IndexScopeImpl( ownerId,
- CpNamingUtils.getCollectionScopeNameFromEntityType( candidateResult.getId().getType() ) );
+ IndexScope indexScope = new IndexScopeImpl(
+ ownerId,
+ CpNamingUtils.getCollectionScopeNameFromEntityType( candidateResult.getId().getType()));
batch.deindex( indexScope, candidateResult );
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsLoaderFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsLoaderFactory.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsLoaderFactory.java
index ebd9380..779d604 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsLoaderFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsLoaderFactory.java
@@ -32,8 +32,7 @@ public interface ResultsLoaderFactory {
/**
* Get the load for results
- * @return
*/
- public ResultsLoader getLoader(final ApplicationScope applicationScope, final EntityRef ownerId,
- final Query.Level resultsLevel );
+ public ResultsLoader getLoader( final ApplicationScope applicationScope,
+ final EntityRef ownerId, final Query.Level resultsLevel );
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsLoaderFactoryImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsLoaderFactoryImpl.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsLoaderFactoryImpl.java
index e987882..0f39fe3 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsLoaderFactoryImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsLoaderFactoryImpl.java
@@ -31,10 +31,8 @@ import com.google.inject.Inject;
/**
* Factory for creating results
*/
-
public class ResultsLoaderFactoryImpl implements ResultsLoaderFactory {
-
private final CpManagerCache managerCache;
@@ -48,7 +46,6 @@ public class ResultsLoaderFactoryImpl implements ResultsLoaderFactory {
public ResultsLoader getLoader( final ApplicationScope applicationScope,
final EntityRef ownerId, final Query.Level resultsLevel ) {
-
ResultsVerifier verifier;
if ( resultsLevel == Query.Level.REFS ) {
@@ -61,7 +58,6 @@ public class ResultsLoaderFactoryImpl implements ResultsLoaderFactory {
verifier = new EntityVerifier(Query.MAX_LIMIT);
}
-
return new FilteringLoader( managerCache, verifier, ownerId, applicationScope );
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsVerifier.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsVerifier.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsVerifier.java
index 995c50a..1b92bcc 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsVerifier.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ResultsVerifier.java
@@ -21,7 +21,6 @@ package org.apache.usergrid.corepersistence.results;
import java.util.Collection;
-
import org.apache.usergrid.persistence.Results;
import org.apache.usergrid.persistence.collection.EntityCollectionManager;
import org.apache.usergrid.persistence.index.query.CandidateResult;
@@ -38,10 +37,9 @@ public interface ResultsVerifier {
public void loadResults(Collection<Id> ids, EntityCollectionManager ecm);
/**
- * Return true if the candidate result is a valid result that should be retained. * If it
- * should not it should also be removed from the list of possible return values in this loader
+ * Return true if the candidate result is a valid result that should be retained. If it should
+ * not it should also be removed from the list of possible return values in this loader
* @param candidateResult
- * @return
*/
public boolean isValid(CandidateResult candidateResult);
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/VersionVerifier.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/VersionVerifier.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/VersionVerifier.java
index 3a03b7b..c541550 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/VersionVerifier.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/VersionVerifier.java
@@ -36,7 +36,7 @@ import com.fasterxml.uuid.UUIDComparator;
/**
- * A loader that verifies versions are correct in cassandra and match elasticsearch
+ * A loader that verifies versions are correct in Cassandra and match ElasticSearch
*/
public abstract class VersionVerifier implements ResultsVerifier {
@@ -69,7 +69,11 @@ public abstract class VersionVerifier implements ResultsVerifier {
if ( UUIDComparator.staticCompare( savedVersion, candidateResult.getVersion() ) > 0 ) {
logger.debug( "Stale version of Entity uuid:{} type:{}, stale v:{}, latest v:{}",
- new Object[] { entityId.getUuid(), entityId.getType(), candidateResult.getVersion(), savedVersion
+ new Object[] {
+ entityId.getUuid(),
+ entityId.getType(),
+ candidateResult.getVersion(),
+ savedVersion
} );
return false;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpEntityMapUtils.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpEntityMapUtils.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpEntityMapUtils.java
index feed396..c110509 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpEntityMapUtils.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/util/CpEntityMapUtils.java
@@ -68,7 +68,8 @@ public class CpEntityMapUtils {
return fromMap( null, map, entityType, topLevel );
}
- public static Entity fromMap( Entity entity, Map<String, Object> map, String entityType, boolean topLevel ) {
+ public static Entity fromMap(
+ Entity entity, Map<String, Object> map, String entityType, boolean topLevel ) {
if ( entity == null ) {
entity = new Entity();
@@ -263,7 +264,7 @@ public class CpEntityMapUtils {
// field names lat and lon trigger ElasticSearch geo location
locMap.put("lat", locField.getValue().getLatitude());
locMap.put("lon", locField.getValue().getLongitude());
- entityMap.put( field.getName(), field.getValue());
+ entityMap.put( field.getName(), field.getValue());
} else if (f instanceof ByteArrayField) {
ByteArrayField bf = ( ByteArrayField ) f;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/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 44ad05c..5f4606c 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
@@ -30,8 +30,8 @@ import org.apache.usergrid.persistence.model.entity.Id;
public interface EntityIndex {
/**
- * This should ONLY ever be called once on application create. Otherwise we're introducing slowness into our system
- *
+ * This should ONLY ever be called once on application create.
+ * Otherwise we're introducing slowness into our system
*/
public void initializeIndex();
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndexBatch.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndexBatch.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndexBatch.java
index f98025b..1a11e9b 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndexBatch.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndexBatch.java
@@ -27,9 +27,6 @@ import org.apache.usergrid.persistence.model.entity.Id;
public interface EntityIndexBatch {
-
-
-
/**
* Create index for Entity
* @param indexScope The scope for the index
@@ -59,9 +56,6 @@ public interface EntityIndexBatch {
*/
public EntityIndexBatch deindex(final IndexScope scope, final Id id, final UUID version);
-
- //TODO: Create a delete method that delete's by Id. This will delete all documents from ES with the same entity Id
-
/**
* Execute the batch
*/
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/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 1a97b5a..78a5137 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
@@ -19,9 +19,7 @@
package org.apache.usergrid.persistence.index;
-
import org.apache.usergrid.persistence.core.scope.ApplicationScope;
-
import com.google.inject.assistedinject.Assisted;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexScope.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexScope.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexScope.java
index 9fbb7f5..5b70304 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexScope.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexScope.java
@@ -18,8 +18,6 @@
*/
package org.apache.usergrid.persistence.index;
-
-import org.apache.usergrid.persistence.core.scope.ApplicationScope;
import org.apache.usergrid.persistence.model.entity.Id;
@@ -31,11 +29,10 @@ public interface IndexScope {
*/
public String getName();
-
/**
- * @return A uuid that is unique to this context. It can be any uuid (time uuid preferred). Can be an application id
- * if this is indexed in a collection, or the collection owner. In a graph structure, this will be the source
- * node in the graph
+ * @return A uuid that is unique to this context. It can be any uuid (time uuid preferred).
+ * Can be an application id if this is indexed in a collection, or the collection owner.
+ * In a graph structure, this will be the source node in the graph
*/
public Id getOwner();
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/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 13661cc..edc938b 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
@@ -22,7 +22,6 @@ package org.apache.usergrid.persistence.index.guice;
import org.apache.usergrid.persistence.index.IndexFig;
import com.google.inject.AbstractModule;
import com.google.inject.assistedinject.FactoryModuleBuilder;
-import org.apache.usergrid.persistence.collection.guice.CollectionModule;
import org.apache.usergrid.persistence.index.EntityIndex;
import org.apache.usergrid.persistence.index.EntityIndexFactory;
import org.apache.usergrid.persistence.index.impl.EsEntityIndexImpl;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/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 151e850..fab135a 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
@@ -312,7 +312,8 @@ public class EsEntityIndexBatchImpl implements EntityIndexBatch {
}
else if ( f instanceof UUIDField ) {
- entityMap.put( STRING_PREFIX + field.getName().toLowerCase(), field.getValue().toString().toLowerCase() );
+ entityMap.put( STRING_PREFIX + field.getName().toLowerCase(),
+ field.getValue().toString().toLowerCase() );
}
else {
entityMap.put( field.getName().toLowerCase(), field.getValue() );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/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 7584386..fc09b5a 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
@@ -130,15 +130,12 @@ public class EsEntityIndexImpl implements EntityIndex {
CreateIndexResponse cir = admin.indices().prepareCreate( indexName ).execute().actionGet();
log.info( "Created new Index Name [{}] ACK=[{}]", indexName, cir.isAcknowledged() );
+ // create the document, this ensures the index is ready
+
+ // Immediately create a document and remove it to ensure the entire cluster is ready
+ // to receive documents. Occasionally we see errors. See this post:
+ // http://elasticsearch-users.115913.n3.nabble.com/IndexMissingException-on-create-index-followed-by-refresh-td1832793.html
- //create the document, this ensures the index is ready
- /**
- * Immediately create a document and remove it to ensure the entire cluster is ready to receive documents
- * . Occasionally we see
- * errors. See this post.
- * http://elasticsearch-users.115913.n3.nabble.com/IndexMissingException-on-create-index-followed-by-refresh-td1832793.html
- *
- */
testNewIndex();
}
catch ( IndexAlreadyExistsException expected ) {
@@ -167,18 +164,18 @@ public class EsEntityIndexImpl implements EntityIndex {
public boolean doOp() {
final String tempId = UUIDGenerator.newTimeUUID().toString();
+ client.prepareIndex( indexName, VERIFY_TYPE, tempId )
+ .setSource( DEFAULT_PAYLOAD ).get();
- client.prepareIndex( indexName, VERIFY_TYPE, tempId ).setSource( DEFAULT_PAYLOAD ).get();
-
- log.info( "Successfully created new document with docId {} in index {} and type {}", tempId, indexName,
- VERIFY_TYPE );
+ log.info( "Successfully created new document with docId {} in index {} and type {}",
+ tempId, indexName, VERIFY_TYPE );
- //delete all types, this way if we miss one it will get cleaned up
+ // delete all types, this way if we miss one it will get cleaned up
+ client.prepareDeleteByQuery( indexName ).setTypes( VERIFY_TYPE )
+ .setQuery( MATCH_ALL_QUERY_BUILDER ).get();
- client.prepareDeleteByQuery( indexName ).setTypes( VERIFY_TYPE ).setQuery( MATCH_ALL_QUERY_BUILDER )
- .get();
-
- log.info( "Successfully deleted all documents in index {} and type {}", indexName, VERIFY_TYPE );
+ log.info( "Successfully deleted all documents in index {} and type {}",
+ indexName, VERIFY_TYPE );
return true;
}
@@ -189,18 +186,19 @@ public class EsEntityIndexImpl implements EntityIndex {
/**
- * Setup ElasticSearch type mappings as a template that applies to all new indexes. Applies to all indexes that
- * start with our prefix.
+ * Setup ElasticSearch type mappings as a template that applies to all new indexes.
+ * Applies to all indexes that start with our prefix.
*/
private void createMappings() throws IOException {
- XContentBuilder xcb =
- IndexingUtils.createDoubleStringIndexMapping( XContentFactory.jsonBuilder(), "_default_" );
+ XContentBuilder xcb = IndexingUtils
+ .createDoubleStringIndexMapping( XContentFactory.jsonBuilder(), "_default_" );
- PutIndexTemplateResponse pitr = client.admin().indices().preparePutTemplate( "usergrid_template" )
- .setTemplate( config.getIndexPrefix() + "*" ).addMapping( "_default_",
- xcb ) // set mapping as the default for all types
- .execute().actionGet();
+ PutIndexTemplateResponse pitr = client.admin().indices()
+ .preparePutTemplate( "usergrid_template" )
+ .setTemplate( config.getIndexPrefix() + "*" )
+ .addMapping( "_default_", xcb ) // set mapping as the default for all types
+ .execute().actionGet();
}
@@ -226,9 +224,8 @@ public class EsEntityIndexImpl implements EntityIndex {
SearchResponse searchResponse;
if ( query.getCursor() == null ) {
- SearchRequestBuilder srb =
- client.prepareSearch( indexName ).setTypes( indexType ).setScroll( cursorTimeout + "m" )
- .setQuery( qb );
+ SearchRequestBuilder srb = client.prepareSearch( indexName )
+ .setTypes( indexType ).setScroll( cursorTimeout + "m" ) .setQuery( qb );
FilterBuilder fb = query.createFilterBuilder();
if ( fb != null ) {
@@ -252,21 +249,22 @@ public class EsEntityIndexImpl implements EntityIndex {
// 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 );
+ final FieldSortBuilder stringSort = SortBuilders.fieldSort( stringFieldName )
+ .order( order ).ignoreUnmapped( true );
srb.addSort( stringSort );
log.debug( " Sort: {} order by {}", stringFieldName, order.toString() );
final String numberFieldName = NUMBER_PREFIX + sp.getPropertyName();
- final FieldSortBuilder numberSort =
- SortBuilders.fieldSort( numberFieldName ).order( order ).ignoreUnmapped( true );
+ final FieldSortBuilder numberSort = SortBuilders.fieldSort( numberFieldName )
+ .order( order ).ignoreUnmapped( true );
srb.addSort( numberSort );
log.debug( " Sort: {} order by {}", numberFieldName, order.toString() );
final String booleanFieldName = BOOLEAN_PREFIX + sp.getPropertyName();
- final FieldSortBuilder booleanSort =
- SortBuilders.fieldSort( booleanFieldName ).order( order ).ignoreUnmapped( true );
+ final FieldSortBuilder booleanSort = SortBuilders.fieldSort( booleanFieldName )
+ .order( order ).ignoreUnmapped( true );
srb.addSort( booleanSort );
log.debug( " Sort: {} order by {}", booleanFieldName, order.toString() );
}
@@ -283,7 +281,8 @@ public class EsEntityIndexImpl implements EntityIndex {
}
log.debug( "Executing query with cursor: {} ", scrollId );
- SearchScrollRequestBuilder ssrb = client.prepareSearchScroll( scrollId ).setScroll( cursorTimeout + "m" );
+ SearchScrollRequestBuilder ssrb = client.prepareSearchScroll( scrollId )
+ .setScroll( cursorTimeout + "m" );
searchResponse = ssrb.execute().actionGet();
}
@@ -329,7 +328,7 @@ public class EsEntityIndexImpl implements EntityIndex {
return true;
}
catch ( IndexMissingException e ) {
- log.error( "Unable to refresh index after create. Waiting before sleeping.", e );
+ log.error( "Unable to refresh index after create. Waiting before sleeping.", e);
throw e;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsProvider.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsProvider.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsProvider.java
index 9b37952..efc61a9 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsProvider.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsProvider.java
@@ -25,16 +25,13 @@ import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Properties;
-import java.util.logging.Level;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.RandomStringUtils;
import org.apache.usergrid.persistence.core.util.AvailablePortFinder;
import org.apache.usergrid.persistence.index.IndexFig;
import org.elasticsearch.client.Client;
-import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.node.Node;
import org.elasticsearch.node.NodeBuilder;
import org.slf4j.Logger;
@@ -112,7 +109,7 @@ public class EsProvider {
.build();
log.info("-----------------------------------------------------------------------");
- log.info("Starting ElasticSearch embedded server with settings: \n" + settings.getAsMap() );
+ log.info("Starting ElasticSearch embedded server settings: \n"+settings.getAsMap());
log.info("-----------------------------------------------------------------------");
Node node = NodeBuilder.nodeBuilder().settings(settings)
@@ -172,8 +169,10 @@ public class EsProvider {
log.debug("Creating ElasticSearch client with settings: " + settings.getAsMap());
- //use this client when connecting via socket only, such as ssh tunnel or other firewall issues
-// newClient = new TransportClient(settings).addTransportAddress( new InetSocketTransportAddress("localhost", 9300) );
+ // use this client when connecting via socket only,
+ // such as ssh tunnel or other firewall issues
+ // newClient = new TransportClient(settings).addTransportAddress(
+ // new InetSocketTransportAddress("localhost", 9300) );
//use this client for quick connectivity
Node node = NodeBuilder.nodeBuilder().settings(settings)
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/CandidateResults.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/CandidateResults.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/CandidateResults.java
index d8c225f..a71bcbe 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/CandidateResults.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/CandidateResults.java
@@ -27,8 +27,8 @@ import org.slf4j.LoggerFactory;
/**
- * Internal results class, should not be returned as results to a user. Only returns candidate entity results
- *
+ * Internal results class, should not be returned as results to a user.
+ * Only returns candidate entity results
*/
public class CandidateResults implements Iterable<CandidateResult> {
@@ -66,8 +66,7 @@ public class CandidateResults implements Iterable<CandidateResult> {
return query;
}
-
-
+
public int size() {
return candidates.size();
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Identifier.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Identifier.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Identifier.java
index 8d886d5..66dcd3b 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Identifier.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Identifier.java
@@ -43,7 +43,8 @@ public class Identifier implements Serializable {
Object value;
static Pattern emailRegEx = Pattern.compile( EMAIL_REX );
- //"Pattern nameRegEx" below used to be [a-zA-Z0-9_\\-./], changed it to contain a 'space' to address https://issues.apache.org/jira/browse/USERGRID-94
+ // "Pattern nameRegEx" below used to be [a-zA-Z0-9_\\-./], changed it to contain a 'space' to a
+ // ddress https://issues.apache.org/jira/browse/USERGRID-94
static Pattern nameRegEx = Pattern.compile( "[a-zA-Z0-9_\\-./ ]*" );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Query.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Query.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Query.java
index a1e25da..778134e 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Query.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Query.java
@@ -115,12 +115,13 @@ public class Query {
public Query( Query q ) {
if ( q != null ) {
type = q.type;
- sortPredicates = q.sortPredicates != null ? new ArrayList<SortPredicate>( q.sortPredicates ) : null;
+ sortPredicates = q.sortPredicates != null
+ ? new ArrayList<SortPredicate>( q.sortPredicates ) : null;
startResult = q.startResult;
cursor = q.cursor;
limit = q.limit;
- selectAssignments =
- q.selectAssignments != null ? new LinkedHashMap<String, String>( q.selectAssignments ) : null;
+ selectAssignments = q.selectAssignments != null
+ ? new LinkedHashMap<String, String>( q.selectAssignments ) : null;
mergeSelectResults = q.mergeSelectResults;
//level = q.level;
connection = q.connection;
@@ -132,9 +133,10 @@ public class Query {
resolution = q.resolution;
pad = q.pad;
rootOperand = q.rootOperand;
- identifiers = q.identifiers != null ? new ArrayList<Identifier>( q.identifiers ) : null;
- counterFilters =
- q.counterFilters != null ? new ArrayList<CounterFilterPredicate>( q.counterFilters ) : null;
+ identifiers = q.identifiers != null
+ ? new ArrayList<Identifier>( q.identifiers ) : null;
+ counterFilters = q.counterFilters != null
+ ? new ArrayList<CounterFilterPredicate>( q.counterFilters ) : null;
collection = q.collection;
}
}
@@ -253,7 +255,8 @@ public class Query {
}
- public static Query fromQueryParams( Map<String, List<String>> params ) throws QueryParseException {
+ public static Query fromQueryParams( Map<String, List<String>> params )
+ throws QueryParseException {
Query q = null;
CounterResolution resolution = null;
List<Identifier> identifiers = null;
@@ -621,8 +624,8 @@ public class Query {
for ( SortPredicate s : sortPredicates ) {
if ( s.getPropertyName().equals( sort.getPropertyName() ) ) {
- throw new QueryParseException(
- String.format( "Attempted to set sort order for %s more than once", s.getPropertyName() ) );
+ throw new QueryParseException( String.format(
+ "Attempted to set sort order for %s more than once", s.getPropertyName() ) );
}
}
sortPredicates.add( sort );
@@ -1094,7 +1097,9 @@ public class Query {
private final Query.SortDirection direction;
- public SortPredicate(@JsonProperty("propertyName") String propertyName, @JsonProperty("direction") Query.SortDirection direction ) {
+ public SortPredicate(@JsonProperty("propertyName") String propertyName,
+ @JsonProperty("direction") Query.SortDirection direction ) {
+
if ( propertyName == null ) {
throw new NullPointerException( "Property name was null" );
}
@@ -1232,7 +1237,7 @@ public class Query {
}
}
- if ( ( user == null ) && ( group == null ) && ( category == null ) && ( name == null ) ) {
+ if ( ( user == null ) && ( group == null ) && ( category == null ) && ( name == null)) {
return null;
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/707c9b99/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Results.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Results.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Results.java
index d0c0571..89745d0 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Results.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/query/Results.java
@@ -53,7 +53,9 @@ public class Results implements Iterable<Entity> {
final EntityCollectionManagerFactory ecmf;
- public Results( Query query, List<CandidateResult> candidates, EntityCollectionManagerFactory ecmf ) {
+ public Results( Query query, List<CandidateResult> candidates,
+ EntityCollectionManagerFactory ecmf ) {
+
this.query = query;
this.candidates = candidates;
this.ecmf = ecmf;