Repository: incubator-usergrid Updated Branches: refs/heads/USERGRID-593 b144cc2bc -> 461613e4e
WIP Squash Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/461613e4 Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/461613e4 Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/461613e4 Branch: refs/heads/USERGRID-593 Commit: 461613e4e698a92dc804094475ceff68630e2322 Parents: b144cc2 Author: Todd Nine <tn...@apigee.com> Authored: Thu Apr 23 22:27:51 2015 -0600 Committer: Todd Nine <tn...@apigee.com> Committed: Thu Apr 23 22:27:51 2015 -0600 ---------------------------------------------------------------------- .../corepersistence/CpEntityManager.java | 29 +++-- .../corepersistence/CpEntityManagerFactory.java | 19 ++- .../corepersistence/CpRelationManager.java | 62 ++++++--- .../command/read/entity/EntityLoadCommand.java | 128 ++++++++++++------- .../read/graph/AbstractReadGraphCommand.java | 11 +- .../read/graph/ReadGraphCollectionCommand.java | 2 +- .../results/AbstractGraphQueryExecutor.java | 128 +++++++++++++++++++ .../results/CollectionGraphQueryExecutor.java | 60 +++++++++ .../results/ConnectionGraphQueryExecutor.java | 59 +++++++++ .../results/GraphQueryExecutor.java | 117 ++++++----------- .../usergrid/persistence/EntityManager.java | 7 +- .../cassandra/EntityManagerImpl.java | 45 ++++--- .../usergrid/persistence/index/query/Query.java | 8 ++ 13 files changed, 498 insertions(+), 177 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/461613e4/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..038be44 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 @@ -34,6 +34,8 @@ import java.util.TreeSet; import java.util.UUID; import com.codahale.metrics.Meter; + +import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory; import org.apache.usergrid.persistence.collection.FieldSet; import org.apache.usergrid.persistence.core.future.BetterFuture; import org.slf4j.Logger; @@ -86,6 +88,7 @@ import org.apache.usergrid.persistence.exceptions.DuplicateUniquePropertyExistsE import org.apache.usergrid.persistence.exceptions.EntityNotFoundException; import org.apache.usergrid.persistence.exceptions.RequiredPropertyNotFoundException; import org.apache.usergrid.persistence.exceptions.UnexpectedEntityTypeException; +import org.apache.usergrid.persistence.graph.GraphManagerFactory; import org.apache.usergrid.persistence.index.EntityIndex; import org.apache.usergrid.persistence.index.EntityIndexBatch; import org.apache.usergrid.persistence.index.IndexScope; @@ -178,8 +181,6 @@ public class CpEntityManager implements EntityManager { private UUID applicationId; private Application application; - private CpEntityManagerFactory emf; - private ManagerCache managerCache; private ApplicationScope applicationScope; @@ -188,6 +189,10 @@ public class CpEntityManager implements EntityManager { private CounterUtils counterUtils; + + private EntityCollectionManagerFactory entityCollectionManagerFactory; + private GraphManagerFactory graphManagerFactory; + private boolean skipAggregateCounters; private MetricsFactory metricsFactory; private Timer aggCounterTimer; @@ -220,22 +225,24 @@ public class CpEntityManager implements EntityManager { } @Override - public void init( EntityManagerFactory emf, UUID applicationId ) { + public void init( final CassandraService cassandraService, final CounterUtils counterUtils, final MetricsFactory metricsFactory, final GraphManagerFactory graphManagerFactory, final EntityCollectionManagerFactory entityCollectionManagerFactory, final ManagerCache managerCache, UUID applicationId ) { - Preconditions.checkNotNull( emf, "emf must not be null" ); Preconditions.checkNotNull( applicationId, "applicationId must not be null" ); - this.emf = ( CpEntityManagerFactory ) emf; - this.managerCache = this.emf.getManagerCache(); + this.managerCache = managerCache; this.applicationId = applicationId; applicationScope = CpNamingUtils.getApplicationScope( applicationId ); - this.cass = this.emf.getCassandraService(); - this.counterUtils = this.emf.getCounterUtils(); + this.cass = cassandraService; + this.counterUtils = counterUtils; //Timer Setup - this.metricsFactory = this.emf.getMetricsFactory(); + this.metricsFactory = metricsFactory; + + this.graphManagerFactory = graphManagerFactory; + this.entityCollectionManagerFactory = entityCollectionManagerFactory; + this.aggCounterTimer =this.metricsFactory.getTimer( CpEntityManager.class, "cp.entity.get.aggregate.counters.timer" ); this.entCreateTimer =this.metricsFactory.getTimer( CpEntityManager.class, "cp.entity.create.timer" ); @@ -766,7 +773,7 @@ public class CpEntityManager implements EntityManager { public RelationManager getRelationManager( EntityRef entityRef ) { Preconditions.checkNotNull( entityRef, "entityRef cannot be null" ); CpRelationManager rmi = new CpRelationManager(); - rmi.init( this, emf, applicationId, entityRef, null, metricsFactory ); + rmi.init( this, applicationId, entityRef, null, metricsFactory, managerCache, entityCollectionManagerFactory, graphManagerFactory ); return rmi; } @@ -2885,7 +2892,7 @@ public class CpEntityManager implements EntityManager { public void refreshIndex() { // refresh factory indexes - emf.refreshIndex(); + // refresh this Entity Manager's application's index EntityIndex ei = managerCache.getEntityIndex( getApplicationScope() ); http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/461613e4/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 b12b6ce..5b8e715 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 @@ -44,6 +44,7 @@ import org.apache.usergrid.persistence.cassandra.CounterUtils; import org.apache.usergrid.persistence.cassandra.Setup; import org.apache.usergrid.persistence.collection.CollectionScope; import org.apache.usergrid.persistence.collection.EntityCollectionManager; +import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory; import org.apache.usergrid.persistence.collection.impl.CollectionScopeImpl; import org.apache.usergrid.persistence.core.metrics.MetricsFactory; import org.apache.usergrid.persistence.core.migration.data.DataMigrationManager; @@ -57,6 +58,7 @@ import org.apache.usergrid.persistence.exceptions.EntityNotFoundException; import org.apache.usergrid.persistence.exceptions.OrganizationAlreadyExistsException; import org.apache.usergrid.persistence.graph.Edge; import org.apache.usergrid.persistence.graph.GraphManager; +import org.apache.usergrid.persistence.graph.GraphManagerFactory; import org.apache.usergrid.persistence.graph.SearchByEdgeType; import org.apache.usergrid.persistence.graph.impl.SimpleSearchByEdgeType; import org.apache.usergrid.persistence.index.EntityIndex; @@ -99,12 +101,14 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application private final OrgApplicationCache orgApplicationCache; - private ManagerCache managerCache; - private DataMigrationManager dataMigrationManager; + private final ManagerCache managerCache; + private final DataMigrationManager dataMigrationManager; + private final GraphManagerFactory graphManagerFactory; + private final EntityCollectionManagerFactory entityCollectionManagerFactory; - private CassandraService cassandraService; - private CounterUtils counterUtils; - private Injector injector; + private final CassandraService cassandraService; + private final CounterUtils counterUtils; + private final Injector injector; private final MetricsFactory metricsFactory; public CpEntityManagerFactory( @@ -115,8 +119,11 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application this.injector = injector; this.managerCache = injector.getInstance( ManagerCache.class ); this.dataMigrationManager = injector.getInstance( DataMigrationManager.class ); + this.graphManagerFactory = injector.getInstance( GraphManagerFactory.class ); + this.entityCollectionManagerFactory = injector.getInstance( EntityCollectionManagerFactory.class ); this.metricsFactory = injector.getInstance( MetricsFactory.class ); + this.orgApplicationCache = new OrgApplicationCacheImpl( this ); } @@ -172,7 +179,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application private EntityManager _getEntityManager( UUID applicationId ) { EntityManager em = new CpEntityManager(); - em.init( this, applicationId ); + em.init( cassandraService, counterUtils, metricsFactory, graphManagerFactory, entityCollectionManagerFactory, managerCache, applicationId ); return em; } http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/461613e4/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 2ee136e..64708a2 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 @@ -33,6 +33,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.util.Assert; +import org.apache.usergrid.corepersistence.results.CollectionGraphQueryExecutor; +import org.apache.usergrid.corepersistence.results.ConnectionGraphQueryExecutor; import org.apache.usergrid.corepersistence.results.ConnectionResultsLoaderFactoryImpl; import org.apache.usergrid.corepersistence.results.ElasticSearchQueryExecutor; import org.apache.usergrid.corepersistence.results.QueryExecutor; @@ -61,6 +63,8 @@ import org.apache.usergrid.persistence.cassandra.index.IndexBucketScanner; import org.apache.usergrid.persistence.cassandra.index.IndexScanner; import org.apache.usergrid.persistence.cassandra.index.NoOpIndexScanner; import org.apache.usergrid.persistence.collection.CollectionScope; +import org.apache.usergrid.persistence.collection.EntityCollectionManager; +import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory; import org.apache.usergrid.persistence.core.future.BetterFuture; import org.apache.usergrid.persistence.core.metrics.MetricsFactory; import org.apache.usergrid.persistence.core.scope.ApplicationScope; @@ -71,6 +75,7 @@ import org.apache.usergrid.persistence.geo.EntityLocationRef; import org.apache.usergrid.persistence.geo.model.Point; import org.apache.usergrid.persistence.graph.Edge; import org.apache.usergrid.persistence.graph.GraphManager; +import org.apache.usergrid.persistence.graph.GraphManagerFactory; import org.apache.usergrid.persistence.graph.SearchByEdgeType; import org.apache.usergrid.persistence.graph.impl.SimpleEdge; import org.apache.usergrid.persistence.graph.impl.SimpleSearchByEdge; @@ -168,9 +173,9 @@ public class CpRelationManager implements RelationManager { private static final Logger logger = LoggerFactory.getLogger( CpRelationManager.class ); - private CpEntityManagerFactory emf; - private ManagerCache managerCache; + private EntityCollectionManagerFactory entityCollectionManagerFactory; + private GraphManagerFactory graphManagerFactory; private EntityManager em; @@ -197,15 +202,16 @@ public class CpRelationManager implements RelationManager { public CpRelationManager init( - EntityManager em, - CpEntityManagerFactory emf, + EntityManager em, UUID applicationId, EntityRef headEntity, IndexBucketLocator indexBucketLocator, - MetricsFactory metricsFactory) { + MetricsFactory metricsFactory, + ManagerCache managerCache, + EntityCollectionManagerFactory entityCollectionManagerFactory, + GraphManagerFactory graphManagerFactory ) { Assert.notNull( em, "Entity manager cannot be null" ); - Assert.notNull( emf, "Entity manager factory cannot be null" ); Assert.notNull( applicationId, "Application Id cannot be null" ); Assert.notNull( headEntity, "Head entity cannot be null" ); Assert.notNull( headEntity.getUuid(), "Head entity uuid cannot be null" ); @@ -214,10 +220,9 @@ public class CpRelationManager implements RelationManager { //Assert.notNull( indexBucketLocator, "indexBucketLocator cannot be null" ); this.em = em; - this.emf = emf; this.applicationId = applicationId; this.headEntity = headEntity; - this.managerCache = emf.getManagerCache(); + this.managerCache = managerCache; this.applicationScope = CpNamingUtils.getApplicationScope( applicationId ); this.cass = em.getCass(); // TODO: eliminate need for this via Core Persistence @@ -233,6 +238,8 @@ public class CpRelationManager implements RelationManager { // load the Core Persistence version of the head entity as well this.headEntityScope = getCollectionScopeNameFromEntityType( applicationScope.getApplication(), headEntity.getType()); + this.entityCollectionManagerFactory = entityCollectionManagerFactory; + this.graphManagerFactory = graphManagerFactory; if ( logger.isDebugEnabled() ) { logger.debug( "Loading head entity {}:{} from scope\n app {}\n owner {}\n name {}", @@ -928,6 +935,21 @@ public class CpRelationManager implements RelationManager { + "' of " + headEntity.getType() + ":" + headEntity .getUuid() ); } + query.setEntityType( collection.getType() ); + query = adjustQuery( query ); + + /** + * It's a graph query, execute the graph query executor. + * + * TODO refactor all of this away into commands + */ + if(query.isGraphQuery()){ + final QueryExecutor executor = new CollectionGraphQueryExecutor( this.entityCollectionManagerFactory,graphManagerFactory, applicationScope, headEntity, query.getCursor(), collName ); + return executor.next(); + } + + + final IndexScope indexScope = new IndexScopeImpl( cpHeadEntity.getId(), CpNamingUtils.getCollectionScopeNameFromCollectionName( collName ) ); @@ -940,9 +962,6 @@ public class CpRelationManager implements RelationManager { indexScope.getOwner().toString(), indexScope.getName() ); - query.setEntityType( collection.getType() ); - query = adjustQuery( query ); - final CollectionResultsLoaderFactoryImpl resultsLoaderFactory = new CollectionResultsLoaderFactoryImpl( managerCache ); @@ -1363,6 +1382,21 @@ public class CpRelationManager implements RelationManager { headEntity = em.validate( headEntity ); + + query = adjustQuery( query ); + + + /** + * It's a graph query, execute the graph query executor. + * + * TODO refactor all of this away into commands + */ + if(query.isGraphQuery()){ + final QueryExecutor executor = new ConnectionGraphQueryExecutor( this.entityCollectionManagerFactory,graphManagerFactory, applicationScope, headEntity, query.getCursor(), connection ); + return executor.next(); + } + + final IndexScope indexScope = new IndexScopeImpl( cpHeadEntity.getId(), CpNamingUtils.getConnectionScopeName( connection ) ); @@ -1374,7 +1408,6 @@ public class CpRelationManager implements RelationManager { indexScope.getOwner().toString(), indexScope.getName(), searchTypes } ); - query = adjustQuery( query ); final ConnectionResultsLoaderFactoryImpl resultsLoaderFactory = new ConnectionResultsLoaderFactoryImpl( managerCache, headEntity, connection ); @@ -1382,9 +1415,6 @@ public class CpRelationManager implements RelationManager { final QueryExecutor executor = new ElasticSearchQueryExecutor(resultsLoaderFactory, ei, applicationScope, indexScope, searchTypes, query); return executor.next(); -// CandidateResults crs = ei.search( indexScope, searchTypes, query ); - -// return buildConnectionResults( indexScope, query, crs, connection ); } @@ -1456,7 +1486,7 @@ public class CpRelationManager implements RelationManager { private CpRelationManager getRelationManager( EntityRef headEntity ) { CpRelationManager rmi = new CpRelationManager(); - rmi.init( em, emf, applicationId, headEntity, null, metricsFactory); + rmi.init( em, applicationId, headEntity, null, metricsFactory, managerCache, entityCollectionManagerFactory, graphManagerFactory); return rmi; } http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/461613e4/stack/core/src/main/java/org/apache/usergrid/corepersistence/command/read/entity/EntityLoadCommand.java ---------------------------------------------------------------------- diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/command/read/entity/EntityLoadCommand.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/command/read/entity/EntityLoadCommand.java index 3b6cade..4e292c5 100644 --- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/command/read/entity/EntityLoadCommand.java +++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/command/read/entity/EntityLoadCommand.java @@ -21,7 +21,6 @@ package org.apache.usergrid.corepersistence.command.read.entity; import java.io.Serializable; -import java.util.Collection; import java.util.List; import java.util.Map; @@ -35,11 +34,15 @@ import org.apache.usergrid.persistence.collection.EntityCollectionManager; import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory; import org.apache.usergrid.persistence.collection.EntitySet; import org.apache.usergrid.persistence.collection.MvccEntity; +import org.apache.usergrid.persistence.core.scope.ApplicationScope; import org.apache.usergrid.persistence.model.entity.Entity; import org.apache.usergrid.persistence.model.entity.Id; import rx.Observable; import rx.functions.Func1; +import rx.observables.GroupedObservable; + +import static org.apache.usergrid.corepersistence.util.CpNamingUtils.getCollectionScopeNameFromEntityType; /** @@ -52,14 +55,14 @@ public class EntityLoadCommand extends AbstractCommand<Results, Serializable> im private final EntityCollectionManagerFactory entityCollectionManagerFactory; //TODO get rid of this when merged into 2.0 dev - private final CollectionScope collectionScope; + private final ApplicationScope applicationScope; private int resultSize; public EntityLoadCommand( final EntityCollectionManagerFactory entityCollectionManagerFactory, - final CollectionScope collectionScope ) { + final ApplicationScope applicationScope ) { this.entityCollectionManagerFactory = entityCollectionManagerFactory; - this.collectionScope = collectionScope; + this.applicationScope = applicationScope; } @@ -72,21 +75,86 @@ public class EntityLoadCommand extends AbstractCommand<Results, Serializable> im @Override public Observable<Results> call( final Observable<? extends Id> observable ) { - final EntityCollectionManager ecm = - entityCollectionManagerFactory.createCollectionManager( this.collectionScope ); + + /** + * A bit kludgy from old 1.0 -> 2.0 apis. Refactor this as we clean up our lower levels and create new results + * objects + */ + return observable.buffer( resultSize ).flatMap( new Func1<List<? extends Id>, Observable<Results>>() { @Override public Observable<Results> call( final List<? extends Id> ids ) { - //load the entities - final Observable<EntitySet> entities = ecm.load( ( Collection<Id> ) ids ); - - - return entities.flatMap( new Func1<EntitySet, Observable<Results>>() { + return Observable.from( ids ) + //group them by type so we can load them, in 2.0 dev this step will be removed + .groupBy( new Func1<Id, String>() { + @Override + public String call( final Id id ) { + return id.getType(); + } + } ) + + //take all our groups and load them as id sets + + .flatMap( new Func1<GroupedObservable<String, Id>, Observable<EntitySet>>() { + @Override + public Observable<EntitySet> call( + final GroupedObservable<String, Id> stringIdGroupedObservable ) { + + + final String entityType = stringIdGroupedObservable.getKey(); + + final CollectionScope collectionScope = + getCollectionScopeNameFromEntityType( applicationScope.getApplication(), entityType ); + + + return stringIdGroupedObservable.toList() + .flatMap( new Func1<List<Id>, Observable<EntitySet>>() { + @Override + public Observable<EntitySet> call( + final List<Id> ids ) { + + final EntityCollectionManager ecm = + entityCollectionManagerFactory + .createCollectionManager( + collectionScope ); + return ecm.load( ids ); + } + } ); + } + } ) + //emit our groups of entities as a stream of entities + .flatMap( new Func1<EntitySet, Observable<org.apache.usergrid.persistence.Entity>>() { + @Override + public Observable<org.apache.usergrid.persistence.Entity> call( final EntitySet entitySet ) { + //emit our entities, and filter out deleted entites + return Observable.from( entitySet.getEntities() ).map( + new Func1<MvccEntity, org.apache.usergrid.persistence.Entity>() { + + @Override + public org.apache.usergrid.persistence.Entity call( final MvccEntity mvccEntity ) { + return mapEntity( mvccEntity ); + } + } ) + //filter null entities + .filter( new Func1<org.apache.usergrid.persistence.Entity, Boolean>() { + @Override + public Boolean call( final org.apache.usergrid.persistence.Entity entity ) { + return entity == null; + } + } ); + } + } ) + + //convert them to a list, then map them into results + .toList().map( new Func1<List<org.apache.usergrid.persistence.Entity>, Results>() { @Override - public Observable<Results> call( final EntitySet entitySet ) { - return createResults( entitySet ); + public Results call( final List<org.apache.usergrid.persistence.Entity> entities ) { + final Results results = Results.fromEntities( entities ); + results.setCursor( generateCursor() ); + + return results; } } ); } @@ -94,40 +162,6 @@ public class EntityLoadCommand extends AbstractCommand<Results, Serializable> im } - /** - * A bit kludgy from old 1.0 -> 2.0 apis. Refactor this as we clean up our lower levels and create new results - * objects - */ - public Observable<Results> createResults( final EntitySet entitySet ) { - - - return Observable.from( entitySet.getEntities() ).map( - new Func1<MvccEntity, org.apache.usergrid.persistence.Entity>() { - - @Override - public org.apache.usergrid.persistence.Entity call( final MvccEntity mvccEntity ) { - return mapEntity( mvccEntity ); - } - } ) - //filter null entities - .filter( new Func1<org.apache.usergrid.persistence.Entity, Boolean>() { - @Override - public Boolean call( final org.apache.usergrid.persistence.Entity entity ) { - return entity == null; - } - } ) - //buffer them and put them in as a map - .toList().map( new Func1<List<org.apache.usergrid.persistence.Entity>, Results>() { - @Override - public Results call( final List<org.apache.usergrid.persistence.Entity> entities ) { - final Results results = Results.fromEntities( entities ); - results.setCursor( generateCursor() ); - - return results; - } - } ); - } - /** * Map a new cp entity to an old entity. May be null if not present http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/461613e4/stack/core/src/main/java/org/apache/usergrid/corepersistence/command/read/graph/AbstractReadGraphCommand.java ---------------------------------------------------------------------- diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/command/read/graph/AbstractReadGraphCommand.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/command/read/graph/AbstractReadGraphCommand.java index f637510..141fb06 100644 --- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/command/read/graph/AbstractReadGraphCommand.java +++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/command/read/graph/AbstractReadGraphCommand.java @@ -32,6 +32,7 @@ import org.apache.usergrid.persistence.model.entity.Id; import com.google.common.base.Optional; import rx.Observable; +import rx.functions.Action1; import rx.functions.Func1; import static org.apache.usergrid.corepersistence.util.CpNamingUtils.getCollectionScopeNameFromCollectionName; @@ -75,7 +76,15 @@ public abstract class AbstractReadGraphCommand extends AbstractCommand<Id, Edge> final SimpleSearchByEdgeType search = new SimpleSearchByEdgeType(id,edgeName, Long.MAX_VALUE, SearchByEdgeType.Order.DESCENDING, startFromCursor ); - return graphManager.loadEdgesFromSource( search ).map( new Func1<Edge, Id>() { + /** + * TODO, pass a message with pointers to our cursor values to be generated later + */ + return graphManager.loadEdgesFromSource( search ).doOnNext( new Action1<Edge>() { + @Override + public void call( final Edge edge ) { + setCursor( edge ); + } + } ).map( new Func1<Edge, Id>() { @Override public Id call( final Edge edge ) { return edge.getTargetNode(); http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/461613e4/stack/core/src/main/java/org/apache/usergrid/corepersistence/command/read/graph/ReadGraphCollectionCommand.java ---------------------------------------------------------------------- diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/command/read/graph/ReadGraphCollectionCommand.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/command/read/graph/ReadGraphCollectionCommand.java index aec0d8b..d68a716 100644 --- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/command/read/graph/ReadGraphCollectionCommand.java +++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/command/read/graph/ReadGraphCollectionCommand.java @@ -38,7 +38,7 @@ public class ReadGraphCollectionCommand extends AbstractReadGraphCommand{ * @param graphManagerFactory * @param collectionName */ - public ReadGraphCollectionCommand( final GraphManagerFactory graphManagerFactory, final String collectionName ) { + public ReadGraphCollectionCommand( final GraphManagerFactory graphManagerFactory, final String collectionName) { super(graphManagerFactory); this.collectionName = collectionName; } http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/461613e4/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/AbstractGraphQueryExecutor.java ---------------------------------------------------------------------- diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/AbstractGraphQueryExecutor.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/AbstractGraphQueryExecutor.java new file mode 100644 index 0000000..7ae4e19 --- /dev/null +++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/AbstractGraphQueryExecutor.java @@ -0,0 +1,128 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. 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. + */ + +package org.apache.usergrid.corepersistence.results; + + +import java.util.Iterator; +import java.util.NoSuchElementException; + +import org.apache.usergrid.corepersistence.command.CommandBuilder; +import org.apache.usergrid.corepersistence.command.read.entity.EntityLoadCommand; +import org.apache.usergrid.corepersistence.command.read.graph.ReadGraphConnectionCommand; +import org.apache.usergrid.persistence.EntityRef; +import org.apache.usergrid.persistence.Results; +import org.apache.usergrid.persistence.collection.CollectionScope; +import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory; +import org.apache.usergrid.persistence.core.scope.ApplicationScope; +import org.apache.usergrid.persistence.graph.GraphManagerFactory; +import org.apache.usergrid.persistence.model.entity.Id; +import org.apache.usergrid.persistence.model.entity.SimpleId; + +import com.google.common.base.Optional; + +import rx.Observable; + + +/** + * This class is a nasty hack to bridge 2.0 observables into 1.0 iterators DO NOT use this as a model for moving + * forward, pandas will die. + */ +public abstract class AbstractGraphQueryExecutor implements QueryExecutor { + + + private final Optional<String> requestCursor; + + + //construct our results + private final Observable<Results> resultsObservable; + + private Iterator<Results> observableIterator; + + + public AbstractGraphQueryExecutor( final EntityCollectionManagerFactory entityCollectionManagerFactory, + final ApplicationScope applicationScope, final EntityRef source, + final String cursor ) { + + final Id sourceId = new SimpleId( source.getUuid(), source.getType() ); + + this.requestCursor = Optional.fromNullable( cursor ); + + //set up our command builder + final CommandBuilder commandBuilder = new CommandBuilder( applicationScope, sourceId, requestCursor ); + + + + addTraverseCommand( commandBuilder ); + + //construct our results to be observed later. This is a cold observable + resultsObservable = + commandBuilder.build( new EntityLoadCommand( entityCollectionManagerFactory, applicationScope ) ); + } + + + @Override + public Iterator<Results> iterator() { + return this; + } + + + @Override + public boolean hasNext() { + + //hasn't been set up yet, run through our first setup + if ( observableIterator == null ) { + //assign them to an interator. this now uses an internal buffer with backpressure, so we won't load all + // results + this.observableIterator = resultsObservable.toBlocking().getIterator(); + } + + + //see if our current results are not null + return observableIterator.hasNext(); + } + + + @Override + public Results next() { + if ( !hasNext() ) { + throw new NoSuchElementException( "No more results present" ); + } + + final Results results = observableIterator.next(); + + //ugly and tight coupling, but we don't have a choice until we finish some refactoring + results.setQueryExecutor( this ); + + return results; + } + + + @Override + public void remove() { + throw new RuntimeException( "Remove not implemented!!" ); + } + + + /** + * Add the traverse command to the graph + * @param commandBuilder + */ + protected abstract void addTraverseCommand(final CommandBuilder commandBuilder); +} http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/461613e4/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/CollectionGraphQueryExecutor.java ---------------------------------------------------------------------- diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/CollectionGraphQueryExecutor.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/CollectionGraphQueryExecutor.java new file mode 100644 index 0000000..022a096 --- /dev/null +++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/CollectionGraphQueryExecutor.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. 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. + */ + +package org.apache.usergrid.corepersistence.results; + + +import org.apache.usergrid.corepersistence.command.CommandBuilder; +import org.apache.usergrid.corepersistence.command.read.graph.ReadGraphCollectionCommand; +import org.apache.usergrid.persistence.EntityRef; +import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory; +import org.apache.usergrid.persistence.core.scope.ApplicationScope; +import org.apache.usergrid.persistence.graph.GraphManagerFactory; + +import com.google.common.base.Preconditions; + + +/** + * Create The collection graph query executor + */ +public class CollectionGraphQueryExecutor extends AbstractGraphQueryExecutor { + + private final GraphManagerFactory graphManagerFactory; + private final String collectionName; + + + public CollectionGraphQueryExecutor( final EntityCollectionManagerFactory entityCollectionManagerFactory, + final GraphManagerFactory graphManagerFactory, + final ApplicationScope applicationScope, final EntityRef source, + final String cursor, final String connectionName ) { + + super( entityCollectionManagerFactory, applicationScope, source, cursor ); + this.graphManagerFactory = graphManagerFactory; + + Preconditions.checkNotNull( connectionName, "connectionName is required on the query" ); + this.collectionName = connectionName; + } + + + @Override + protected void addTraverseCommand( final CommandBuilder commandBuilder ) { + //set the traverse command from the source Id to the connect name + commandBuilder.withTraverseCommand( new ReadGraphCollectionCommand( graphManagerFactory, collectionName ) ); + } +} http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/461613e4/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ConnectionGraphQueryExecutor.java ---------------------------------------------------------------------- diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ConnectionGraphQueryExecutor.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ConnectionGraphQueryExecutor.java new file mode 100644 index 0000000..7e812e7 --- /dev/null +++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/ConnectionGraphQueryExecutor.java @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. 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. + */ + +package org.apache.usergrid.corepersistence.results; + + +import org.apache.usergrid.corepersistence.command.CommandBuilder; +import org.apache.usergrid.corepersistence.command.read.graph.ReadGraphConnectionCommand; +import org.apache.usergrid.persistence.EntityRef; +import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory; +import org.apache.usergrid.persistence.core.scope.ApplicationScope; +import org.apache.usergrid.persistence.graph.GraphManagerFactory; +import org.apache.usergrid.persistence.index.query.Query; + +import com.google.common.base.Preconditions; + + +public class ConnectionGraphQueryExecutor extends AbstractGraphQueryExecutor { + + private final GraphManagerFactory graphManagerFactory; + private final String connectionName; + + + public ConnectionGraphQueryExecutor( final EntityCollectionManagerFactory entityCollectionManagerFactory, + final GraphManagerFactory graphManagerFactory, + final ApplicationScope applicationScope, final EntityRef source, + final String cursor, final String connectionType ) { + + super( entityCollectionManagerFactory, applicationScope, source, cursor ); + this.graphManagerFactory = graphManagerFactory; + + Preconditions.checkNotNull(connectionType, "connectionType is required on the query" ); + this.connectionName = connectionType; + } + + + + @Override + protected void addTraverseCommand( final CommandBuilder commandBuilder ) { + //set the traverse command from the source Id to the connect name + commandBuilder.withTraverseCommand( new ReadGraphConnectionCommand( graphManagerFactory, connectionName ) ); + } +} http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/461613e4/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/GraphQueryExecutor.java ---------------------------------------------------------------------- diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/GraphQueryExecutor.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/GraphQueryExecutor.java index df1a57a..222880f 100644 --- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/GraphQueryExecutor.java +++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/results/GraphQueryExecutor.java @@ -23,44 +23,56 @@ package org.apache.usergrid.corepersistence.results; import java.util.Iterator; import java.util.NoSuchElementException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import org.apache.usergrid.corepersistence.command.CommandBuilder; +import org.apache.usergrid.corepersistence.command.read.entity.EntityLoadCommand; +import org.apache.usergrid.corepersistence.command.read.graph.ReadGraphConnectionCommand; import org.apache.usergrid.persistence.EntityRef; import org.apache.usergrid.persistence.Results; -import org.apache.usergrid.persistence.core.scope.ApplicationScope; -import org.apache.usergrid.persistence.index.EntityIndex; -import org.apache.usergrid.persistence.index.IndexScope; -import org.apache.usergrid.persistence.index.SearchTypes; -import org.apache.usergrid.persistence.index.query.CandidateResults; -import org.apache.usergrid.persistence.index.query.Query; +import org.apache.usergrid.persistence.collection.CollectionScope; +import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory; +import org.apache.usergrid.persistence.graph.GraphManagerFactory; import org.apache.usergrid.persistence.model.entity.Id; +import org.apache.usergrid.persistence.model.entity.SimpleId; + +import com.google.common.base.Optional; + +import rx.Observable; /** - * This class is a nasty hack to bridge 2.0 observables into 1.0 iterators - * DO NOT use this as a model for moving forward, pandas will die. + * This class is a nasty hack to bridge 2.0 observables into 1.0 iterators DO NOT use this as a model for moving + * forward, pandas will die. */ public class GraphQueryExecutor implements QueryExecutor { - private static final Logger logger = LoggerFactory.getLogger( GraphQueryExecutor.class ); + + private final Optional<String> requestCursor; - private final ApplicationScope applicationScope; + //construct our results + private final Observable<Results> resultsObservable; - private final Id sourceId; + private Iterator<Results> observableIterator; - private final String connectionName; + public GraphQueryExecutor( final GraphManagerFactory graphManagerFactory, + final EntityCollectionManagerFactory entityCollectionManagerFactory, + final CollectionScope collectionScope, final EntityRef source, + final String connectionName, final String cursor ) { + final Id sourceId = new SimpleId( source.getUuid(), source.getType() ); - private Iterator<Results> observableIterator; + this.requestCursor = Optional.fromNullable( cursor ); + //set up our command builder + final CommandBuilder commandBuilder = new CommandBuilder( collectionScope, sourceId, requestCursor ); - public GraphQueryExecutor(final ApplicationScope appScope, final EntityRef source, final String connectionName ) { - this.applicationScope = appScope; - this.sourceId = + //set the traverse command from the source Id to the connect name + commandBuilder.withTraverseCommand( new ReadGraphConnectionCommand( graphManagerFactory, connectionName ) ); + + //construct our results to be observed later. This is a cold observable + resultsObservable = + commandBuilder.build( new EntityLoadCommand( entityCollectionManagerFactory, collectionScope ) ); } @@ -70,65 +82,19 @@ public class GraphQueryExecutor implements QueryExecutor { } - private void loadNextPage() { - - } - - - private void build(){ - CommandBuilder commandBuilder = new CommandBuilder( ); - } - - /** - * Build results from a set of candidates, and discard those that represent stale indexes. - * - * @param query Query that was executed - * @param crs Candidates to be considered for results - */ - private Results buildResults( final IndexScope indexScope, final Query query, final CandidateResults crs ) { - - logger.debug( "buildResults() from {} candidates", crs.size() ); - - //get an instance of our results loader - final ResultsLoader resultsLoader = - this.resultsLoaderFactory.getLoader( applicationScope, indexScope, query.getResultsLevel() ); - - //load the results - final Results results = resultsLoader.loadResults( crs ); - - //signal for post processing - resultsLoader.postProcess(); - - - results.setCursor( crs.getCursor() ); - - //ugly and tight coupling, but we don't have a choice until we finish some refactoring - results.setQueryExecutor( this ); - - logger.debug( "Returning results size {}", results.size() ); - - return results; - } - - @Override public boolean hasNext() { - //we've tried to load and it's empty and we have more to load, load the next page - if ( currentResults == null ) { - //there's nothing left to load, nothing to do - if ( !moreToLoad ) { - return false; - } - - //load the page - - loadNextPage(); + //hasn't been set up yet, run through our first setup + if ( observableIterator == null ) { + //assign them to an interator. this now uses an internal buffer with backpressure, so we won't load all + // results + this.observableIterator = resultsObservable.toBlocking().getIterator(); } //see if our current results are not null - return currentResults != null; + return observableIterator.hasNext(); } @@ -138,15 +104,12 @@ public class GraphQueryExecutor implements QueryExecutor { throw new NoSuchElementException( "No more results present" ); } - final Results toReturn = currentResults; - - currentResults = null; - - return toReturn; + return observableIterator.next(); } + @Override public void remove() { - throw new RuntimeException("Remove not implemented!!"); + throw new RuntimeException( "Remove not implemented!!" ); } } http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/461613e4/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..645618c 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,11 @@ package org.apache.usergrid.persistence; +import org.apache.usergrid.corepersistence.ManagerCache; +import org.apache.usergrid.persistence.cassandra.CounterUtils; +import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory; +import org.apache.usergrid.persistence.core.metrics.MetricsFactory; +import org.apache.usergrid.persistence.graph.GraphManagerFactory; import org.apache.usergrid.persistence.index.query.Query; import java.nio.ByteBuffer; import java.util.Collection; @@ -698,7 +703,7 @@ public interface EntityManager { */ void deleteIndex(); - public void init( EntityManagerFactory emf, UUID applicationId); + public void init( final CassandraService cassandraService, final CounterUtils counterUtils, final MetricsFactory metricsFactory, final GraphManagerFactory graphManagerFactory, final EntityCollectionManagerFactory entityCollectionManagerFactory, final ManagerCache managerCache, UUID applicationId); /** For testing purposes */ public void flushManagerCaches(); http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/461613e4/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..b34bd93 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 @@ -41,6 +41,7 @@ import org.slf4j.LoggerFactory; import org.springframework.context.ApplicationContext; import org.springframework.util.Assert; +import org.apache.usergrid.corepersistence.ManagerCache; import org.apache.usergrid.persistence.IndexBucketLocator.IndexType; import static org.apache.usergrid.persistence.cassandra.ApplicationCF.ENTITY_ID_SETS; @@ -69,6 +70,8 @@ import org.apache.usergrid.persistence.SimpleRoleRef; import org.apache.usergrid.persistence.TypedEntity; import org.apache.usergrid.persistence.cassandra.CounterUtils.AggregateCounterSelection; import org.apache.usergrid.persistence.cassandra.util.TraceParticipant; +import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory; +import org.apache.usergrid.persistence.core.metrics.MetricsFactory; import org.apache.usergrid.persistence.entities.Application; import org.apache.usergrid.persistence.entities.Event; import org.apache.usergrid.persistence.entities.Group; @@ -78,6 +81,7 @@ import org.apache.usergrid.persistence.exceptions.DuplicateUniquePropertyExistsE import org.apache.usergrid.persistence.exceptions.EntityNotFoundException; import org.apache.usergrid.persistence.exceptions.RequiredPropertyNotFoundException; import org.apache.usergrid.persistence.exceptions.UnexpectedEntityTypeException; +import org.apache.usergrid.persistence.graph.GraphManagerFactory; import org.apache.usergrid.persistence.index.query.CounterResolution; import org.apache.usergrid.persistence.index.query.Identifier; import org.apache.usergrid.persistence.index.query.Query; @@ -193,6 +197,7 @@ public class EntityManagerImpl implements EntityManager { @Resource private EntityManagerFactoryImpl emf; + @Resource private QueueManagerFactoryImpl qmf; @Resource @@ -212,10 +217,6 @@ public class EntityManagerImpl implements EntityManager { } - @Override - public void init(EntityManagerFactory emf, UUID applicationId) { - init( (EntityManagerFactoryImpl)emf, null, null, applicationId, false); - } public EntityManager init( @@ -523,7 +524,7 @@ public class EntityManagerImpl implements EntityManager { */ Set<UUID> ownerEntityIds = getUUIDsForUniqueProperty( - new SimpleEntityRef(Application.ENTITY_TYPE, applicationId), entityType, propertyName, propertyValue ); + new SimpleEntityRef( Application.ENTITY_TYPE, applicationId ), entityType, propertyName, propertyValue ); //if there are no entities for this property, we know it's unique. If there are, // we have to make sure the one we were passed is in the set. otherwise it belongs @@ -651,7 +652,7 @@ public class EntityManagerImpl implements EntityManager { @Override public Map<String, EntityRef> getAlias( String aliasType, List<String> aliases ) throws Exception { - return getAlias( new SimpleEntityRef(Application.ENTITY_TYPE, applicationId), aliasType, aliases ); + return getAlias( new SimpleEntityRef( Application.ENTITY_TYPE, applicationId ), aliasType, aliases ); } @@ -1249,9 +1250,9 @@ public class EntityManagerImpl implements EntityManager { HColumn<ByteBuffer, ByteBuffer> result = cass.getColumn( cass.getApplicationKeyspace( applicationId ), dictionaryCf, - key( entity.getUuid(), dictionaryName ), - entityHasDictionary ? bytebuffer( elementName ) : DynamicComposite.toByteBuffer( elementName ), - be, be ); + key( entity.getUuid(), dictionaryName ), + entityHasDictionary ? bytebuffer( elementName ) : DynamicComposite.toByteBuffer( elementName ), be, + be ); if ( result != null ) { if ( entityHasDictionary && coTypeIsBasic ) { value = object( dictionaryCoType, result.getValue() ); @@ -1295,7 +1296,7 @@ public class EntityManagerImpl implements EntityManager { ColumnSlice<ByteBuffer, ByteBuffer> results = cass.getColumns( cass.getApplicationKeyspace( applicationId ), dictionaryCf, - key( entity.getUuid(), dictionaryName ), columnNames, be, be ); + key( entity.getUuid(), dictionaryName ), columnNames, be, be ); if ( results != null ) { values = new HashMap<String, Object>(); for ( HColumn<ByteBuffer, ByteBuffer> result : results.getColumns() ) { @@ -1352,7 +1353,7 @@ public class EntityManagerImpl implements EntityManager { List<HColumn<ByteBuffer, ByteBuffer>> results = cass.getAllColumns( cass.getApplicationKeyspace( applicationId ), dictionaryCf, - key( entity.getUuid(), dictionaryName ), be, be ); + key( entity.getUuid(), dictionaryName ), be, be ); for ( HColumn<ByteBuffer, ByteBuffer> result : results ) { Object name = null; if ( entityHasDictionary ) { @@ -2296,7 +2297,7 @@ public class EntityManagerImpl implements EntityManager { Mutator<ByteBuffer> batch = CountingMutator.createFlushingMutator( cass.getApplicationKeyspace( applicationId ), be ); addInsertToMutator( batch, ApplicationCF.ENTITY_DICTIONARIES, getRolePermissionsKey( roleName ), permission, - ByteBuffer.allocate( 0 ), timestamp ); + ByteBuffer.allocate( 0 ), timestamp ); batchExecute( batch, CassandraService.RETRY_COUNT ); } @@ -2377,7 +2378,7 @@ public class EntityManagerImpl implements EntityManager { Mutator<ByteBuffer> batch = CountingMutator.createFlushingMutator( cass.getApplicationKeyspace( applicationId ), be ); addInsertToMutator( batch, ApplicationCF.ENTITY_DICTIONARIES, getRolePermissionsKey( groupId, roleName ), - permission, ByteBuffer.allocate( 0 ), timestamp ); + permission, ByteBuffer.allocate( 0 ), timestamp ); batchExecute( batch, CassandraService.RETRY_COUNT ); } @@ -2390,7 +2391,7 @@ public class EntityManagerImpl implements EntityManager { Mutator<ByteBuffer> batch = CountingMutator.createFlushingMutator( cass.getApplicationKeyspace( applicationId ), be ); CassandraPersistenceUtils.addDeleteToMutator( batch, ApplicationCF.ENTITY_DICTIONARIES, - getRolePermissionsKey( groupId, roleName ), permission, timestamp ); + getRolePermissionsKey( groupId, roleName ), permission, timestamp ); batchExecute( batch, CassandraService.RETRY_COUNT ); } @@ -2422,7 +2423,7 @@ public class EntityManagerImpl implements EntityManager { @Override public Map<String, Role> getUserRolesWithTitles( UUID userId ) throws Exception { return getRolesWithTitles( - ( Set<String> ) cast( getDictionaryAsSet( userRef( userId ), DICTIONARY_ROLENAMES ) ) ); + ( Set<String> ) cast( getDictionaryAsSet( userRef( userId ), DICTIONARY_ROLENAMES ) ) ); } @@ -2534,7 +2535,7 @@ public class EntityManagerImpl implements EntityManager { Mutator<ByteBuffer> m = CountingMutator.createFlushingMutator( cass.getApplicationKeyspace( applicationId ), be ); counterUtils.batchIncrementAggregateCounters( m, applicationId, userId, groupId, null, category, counters, - timestamp ); + timestamp ); batchExecute( m, CassandraService.RETRY_COUNT ); } @@ -2724,7 +2725,7 @@ public class EntityManagerImpl implements EntityManager { public Results getConnectingEntities( EntityRef entityRef, String connectionType, String connectedEntityType, Level resultsLevel ) throws Exception { - return getConnectingEntities( entityRef, connectionType, connectedEntityType, resultsLevel, 0); + return getConnectingEntities( entityRef, connectionType, connectedEntityType, resultsLevel, 0 ); } @@ -2901,6 +2902,16 @@ public class EntityManagerImpl implements EntityManager { @Override + public void init( final CassandraService cassandraService, final CounterUtils counterUtils, + final MetricsFactory metricsFactory, final GraphManagerFactory graphManagerFactory, + final EntityCollectionManagerFactory entityCollectionManagerFactory, + final ManagerCache managerCache, final UUID applicationId ) { + throw new UnsupportedOperationException( "Removed anyway" ); + + } + + + @Override public EntityRef getGroupRoleRef( UUID ownerId, String roleName) throws Exception { return new SimpleEntityRef( Role.ENTITY_TYPE, SimpleRoleRef.getIdForGroupIdAndRoleName( ownerId, roleName )); } http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/461613e4/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 9a7a867..ae89bfc 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 @@ -843,6 +843,14 @@ public class Query { } + /** + * Return true if there is no query language to execute + * @return + */ + public boolean isGraphQuery(){ + return ql == null; + } + @JsonIgnore public Operand getRootOperand() { if ( rootOperand == null ) { // attempt deserialization
