You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by mr...@apache.org on 2016/09/07 01:51:16 UTC
[2/2] usergrid git commit: Initial work to add feature flags to
Usergrid allowing different runtime features/injections
Initial work to add feature flags to Usergrid allowing different runtime features/injections
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/5b42c0a6
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/5b42c0a6
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/5b42c0a6
Branch: refs/heads/feature-flags
Commit: 5b42c0a60d69dc2d47f6fd31a95a5aecd055bce0
Parents: 867060f
Author: Michael Russo <mr...@apigee.com>
Authored: Tue Sep 6 18:50:20 2016 -0700
Committer: Michael Russo <mr...@apigee.com>
Committed: Tue Sep 6 18:50:20 2016 -0700
----------------------------------------------------------------------
.../main/resources/usergrid-default.properties | 13 +-
.../usergrid/corepersistence/CoreModule.java | 87 +++--
.../corepersistence/CpEntityManagerFactory.java | 35 +-
.../corepersistence/CpManagerCache.java | 30 +-
.../usergrid/corepersistence/CpSetup.java | 17 +-
.../usergrid/corepersistence/ManagerCache.java | 6 -
.../asyncevents/AsyncEventServiceImpl.java | 46 +--
.../asyncevents/AsyncIndexProvider.java | 46 ++-
.../asyncevents/EventBuilderImpl.java | 60 +++-
.../corepersistence/index/EventServiceFig.java | 121 +++++++
.../index/IndexProcessorFig.java | 121 -------
.../index/ReIndexServiceImpl.java | 10 +-
.../pipeline/PipelineModule.java | 12 +-
.../pipeline/builder/CandidateBuilder.java | 8 +-
.../pipeline/builder/IdBuilder.java | 26 +-
.../pipeline/builder/PipelineBuilder.java | 19 +-
.../pipeline/read/FilterFactory.java | 23 --
.../pipeline/read/SearchFilterFactory.java | 53 +++
.../read/search/CandidateEntityFilter.java | 31 +-
.../pipeline/read/search/CandidateIdFilter.java | 26 +-
.../org/apache/usergrid/persistence/Query.java | 9 +-
.../usergrid/system/UsergridFeatures.java | 69 ++++
.../index/AsyncEventServiceImplTest.java | 10 +-
.../core/datastax/impl/DataStaxClusterImpl.java | 3 +-
stack/corepersistence/pom.xml | 4 +-
.../persistence/index/guice/IndexModule.java | 2 -
stack/pom.xml | 2 +-
.../query/validator/users/UserQueryIT.java | 19 +-
.../usergrid/rest/AbstractContextResource.java | 9 +
.../usergrid/rest/JobServiceBoostrap.java | 3 +-
.../org/apache/usergrid/rest/RootResource.java | 7 +-
.../rest/applications/ApplicationResource.java | 7 +
.../rest/applications/ServiceResource.java | 2 +-
.../rest/applications/kvm/KvmResource.java | 358 +++++++++++++++++++
.../UnsupportedOperationExceptionMapper.java | 3 +-
.../usergrid/rest/system/IndexResource.java | 7 +
.../usergrid/rest/system/SystemResource.java | 1 -
.../rest/test/resource/AbstractRestIT.java | 1 -
.../cassandra/ManagementServiceImpl.java | 11 +-
39 files changed, 998 insertions(+), 319 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/5b42c0a6/stack/config/src/main/resources/usergrid-default.properties
----------------------------------------------------------------------
diff --git a/stack/config/src/main/resources/usergrid-default.properties b/stack/config/src/main/resources/usergrid-default.properties
index 34d46ad..3209ae4 100644
--- a/stack/config/src/main/resources/usergrid-default.properties
+++ b/stack/config/src/main/resources/usergrid-default.properties
@@ -49,6 +49,17 @@
usergrid.persistence=CP
+################### Usergrid Feature Implementation ####################
+#
+# Set the features that should be enabled. This will optionally inject certain dependencies.
+#
+# Valid values: all or kvm
+#
+# all - all features available including graph and query
+# graph - only graph and key-value map features available ( no query and no Elasticsearch required )
+#
+usergrid.features.enabled=all
+
########################### Cassandra (Datastore) ###########################
@@ -64,7 +75,7 @@ cassandra.version=2.1
# Set the Cassandra cluster name that this instance of Usergrid should use.
#
-cassandra.cluster=Test Cluster
+cassandra.cluster=CassandraClientCluster
# Set a comma-separated list of one or more Cassandra hosts (host:port) that Usergrid will connect to.
# If no port is provided, the default Cassandra port of 9160 will be used.
http://git-wip-us.apache.org/repos/asf/usergrid/blob/5b42c0a6/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
index 781eede..b5926eb 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
@@ -41,7 +41,11 @@ import org.apache.usergrid.persistence.core.rx.RxTaskSchedulerImpl;
import org.apache.usergrid.persistence.core.scope.ApplicationScope;
import org.apache.usergrid.persistence.graph.guice.GraphModule;
import org.apache.usergrid.persistence.graph.serialization.impl.migration.GraphNode;
+import org.apache.usergrid.persistence.index.IndexFig;
import org.apache.usergrid.persistence.index.guice.IndexModule;
+import org.apache.usergrid.persistence.map.guice.MapModule;
+import org.apache.usergrid.persistence.queue.guice.QueueModule;
+import org.apache.usergrid.system.UsergridFeatures;
import org.safehaus.guicyfig.GuicyFigModule;
import java.util.concurrent.ThreadPoolExecutor;
@@ -79,14 +83,59 @@ public class CoreModule extends AbstractModule {
bind( new TypeLiteral<MigrationDataProvider<GraphNode>>() {} ).to( AllNodesInGraphImpl.class );
}
} );
- install( new IndexModule() {
- @Override
- public void configureMigrationProvider() {
- bind( new TypeLiteral<MigrationDataProvider<ApplicationScope>>() {} )
- .to( AllApplicationsObservableImpl.class );
- }
- } );
- // install(new MapModule()); TODO, re-enable when index module doesn't depend on queue
+
+ // figs are just properties, load em always
+ install( new GuicyFigModule( EventServiceFig.class ) );
+ install( new GuicyFigModule( CoreIndexFig.class ) );
+
+ install(new QueueModule());
+
+
+ //bind the async queue provider
+ bind( AsyncEventService.class ).toProvider( AsyncIndexProvider.class );
+
+ //bind the event handlers
+ bind( EventBuilder.class ).to( EventBuilderImpl.class );
+
+ // requires indexing dependencies to be available
+ bind( ApplicationService.class ).to( ApplicationServiceImpl.class );
+
+ if(UsergridFeatures.isQueryFeatureEnabled()) {
+
+ install( new IndexModule() {
+ @Override
+ public void configureMigrationProvider() {
+ bind( new TypeLiteral<MigrationDataProvider<ApplicationScope>>() {} )
+ .to( AllApplicationsObservableImpl.class );
+ }
+ } );
+
+ /*****
+ * Indexing service
+ *****/
+
+ // This just uses figs to come up with named instances. Doesn't require all of indexing, but used injected
+ // in places that may or may not need this.
+ bind( IndexLocationStrategyFactory.class ).to( IndexLocationStrategyFactoryImpl.class );
+
+
+ bind( IndexService.class ).to( IndexServiceImpl.class );
+
+ bind( ApplicationIndexBucketLocator.class );
+
+
+ bind( ReIndexService.class ).to( ReIndexServiceImpl.class );
+
+ install( new FactoryModuleBuilder().implement( AggregationService.class, AggregationServiceImpl.class )
+ .build( AggregationServiceFactory.class ) );
+
+
+ }
+
+
+
+
+ install(new MapModule()); //TODO, re-enable when index module doesn't depend on queue
// install(new QueueModule());
bind( ManagerCache.class ).to( CpManagerCache.class );
@@ -113,31 +162,11 @@ public class CoreModule extends AbstractModule {
bind( AllEntityIdsObservable.class ).to( AllEntityIdsObservableImpl.class );
- /*****
- * Indexing service
- *****/
- bind( IndexService.class ).to( IndexServiceImpl.class );
- //bind the event handlers
- bind( EventBuilder.class ).to( EventBuilderImpl.class );
- bind( ApplicationIndexBucketLocator.class );
-
- //bind the queue provider
- bind( AsyncEventService.class ).toProvider( AsyncIndexProvider.class );
-
-
- bind( ReIndexService.class ).to( ReIndexServiceImpl.class );
- install( new FactoryModuleBuilder().implement( AggregationService.class, AggregationServiceImpl.class )
- .build( AggregationServiceFactory.class ) );
- bind( IndexLocationStrategyFactory.class ).to( IndexLocationStrategyFactoryImpl.class );
-
- install( new GuicyFigModule( IndexProcessorFig.class ) );
-
- install( new GuicyFigModule( CoreIndexFig.class ) );
install( new GuicyFigModule( ApplicationIdCacheFig.class ) );
@@ -161,7 +190,7 @@ public class CoreModule extends AbstractModule {
bind( ConnectionService.class ).to( ConnectionServiceImpl.class );
- bind( ApplicationService.class ).to( ApplicationServiceImpl.class );
+
bind( StatusService.class ).to( StatusServiceImpl.class );
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/5b42c0a6/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 2a88302..89d07cc 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
@@ -60,6 +60,7 @@ import org.apache.usergrid.persistence.index.EntityIndex;
import org.apache.usergrid.persistence.model.entity.Id;
import org.apache.usergrid.persistence.model.entity.SimpleId;
import org.apache.usergrid.persistence.model.util.UUIDGenerator;
+import org.apache.usergrid.system.UsergridFeatures;
import org.apache.usergrid.utils.UUIDUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -105,7 +106,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
private CassandraService cassandraService;
private CounterUtils counterUtils;
private Injector injector;
- private final ReIndexService reIndexService;
+ private ReIndexService reIndexService = null;
private final MetricsFactory metricsFactory;
private final AsyncEventService indexService;
private final CollectionService collectionService;
@@ -128,7 +129,6 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
this.cassandraService = cassandraService;
this.counterUtils = counterUtils;
this.injector = injector;
- this.reIndexService = injector.getInstance(ReIndexService.class);
this.entityManagerFig = injector.getInstance(EntityManagerFig.class);
this.actorSystemFig = injector.getInstance( ActorSystemFig.class );
this.managerCache = injector.getInstance( ManagerCache.class );
@@ -169,6 +169,12 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
getManagementEntityManager() );
checkManagementApp( properties );
+
+ if(UsergridFeatures.isQueryFeatureEnabled()) {
+
+ this.reIndexService = this.injector.getInstance(ReIndexService.class);
+
+ }
}
@@ -329,7 +335,11 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
private void initMgmtAppInternal() {
EntityManager em = getEntityManager(getManagementAppId());
- indexService.queueInitializeApplicationIndex(CpNamingUtils.getApplicationScope(getManagementAppId()));
+
+ if( UsergridFeatures.isQueryFeatureEnabled() ) {
+
+ indexService.queueInitializeApplicationIndex(CpNamingUtils.getApplicationScope(getManagementAppId()));
+ }
try {
if ( em.getApplication() == null ) {
@@ -440,9 +450,14 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
throw new ApplicationAlreadyExistsException( appName );
}
- // Initialize the index for this new application
- appEm.initializeIndex();
- indexService.queueInitializeApplicationIndex(CpNamingUtils.getApplicationScope(applicationId));
+
+ if( UsergridFeatures.isQueryFeatureEnabled() ) {
+
+ // Initialize the index for this new application
+ appEm.initializeIndex();
+
+ indexService.queueInitializeApplicationIndex(CpNamingUtils.getApplicationScope(applicationId));
+ }
if ( properties == null ) {
properties = new TreeMap<>( CASE_INSENSITIVE_ORDER);
}
@@ -507,9 +522,11 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
CpNamingUtils.APPLICATION_INFOS , CpNamingUtils.APPLICATION_INFO ).lastOrDefault( null )
.map( appInfo -> {
- //start the index rebuild
- final ReIndexRequestBuilder builder = reIndexService.getBuilder().withApplicationId( applicationId );
- reIndexService.rebuildIndex( builder );
+ if( UsergridFeatures.isQueryFeatureEnabled() ) {
+ //start the index rebuild
+ final ReIndexRequestBuilder builder = reIndexService.getBuilder().withApplicationId(applicationId);
+ reIndexService.rebuildIndex(builder);
+ }
//load the entity
final EntityManager managementEm = getEntityManager( getManagementAppId() );
http://git-wip-us.apache.org/repos/asf/usergrid/blob/5b42c0a6/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpManagerCache.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpManagerCache.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpManagerCache.java
index 4e1f5e3..af64a4f 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpManagerCache.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpManagerCache.java
@@ -16,6 +16,7 @@
package org.apache.usergrid.corepersistence;
+import com.google.inject.Injector;
import org.apache.usergrid.corepersistence.index.IndexLocationStrategyFactory;
import org.apache.usergrid.persistence.collection.EntityCollectionManager;
import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory;
@@ -31,6 +32,7 @@ import org.apache.usergrid.persistence.map.MapManagerFactory;
import org.apache.usergrid.persistence.map.MapScope;
import com.google.inject.Inject;
+import org.apache.usergrid.system.UsergridFeatures;
/**
@@ -40,30 +42,35 @@ import com.google.inject.Inject;
public class CpManagerCache implements ManagerCache {
private final EntityCollectionManagerFactory ecmf;
- private final EntityIndexFactory eif;
+ private EntityIndexFactory eif = null;
private final GraphManagerFactory gmf;
private final MapManagerFactory mmf;
- private final IndexLocationStrategyFactory indexLocationStrategyFactory;
- private final IndexProducer indexProducer;
+ private IndexLocationStrategyFactory indexLocationStrategyFactory;
+ private final Injector injector;
// TODO: consider making these cache sizes and timeouts configurable
@Inject
public CpManagerCache( final EntityCollectionManagerFactory ecmf,
- final EntityIndexFactory eif,
final GraphManagerFactory gmf,
final MapManagerFactory mmf,
- final IndexLocationStrategyFactory indexLocationStrategyFactory,
- final IndexProducer indexProducer
+ final Injector injector
) {
+
this.ecmf = ecmf;
- this.eif = eif;
+ if(UsergridFeatures.isQueryFeatureEnabled()) {
+
+ this.eif = injector.getInstance(EntityIndexFactory.class);
+ this.indexLocationStrategyFactory = injector.getInstance(IndexLocationStrategyFactory.class);
+
+
+ }
+
this.gmf = gmf;
this.mmf = mmf;
- this.indexLocationStrategyFactory = indexLocationStrategyFactory;
- this.indexProducer = indexProducer;
+ this.injector = injector;
}
@@ -93,11 +100,6 @@ public class CpManagerCache implements ManagerCache {
return mmf.createMapManager( mapScope );
}
- @Override
- public IndexProducer getIndexProducer() {
- return indexProducer;
- }
-
@Override
public void invalidate() {
http://git-wip-us.apache.org/repos/asf/usergrid/blob/5b42c0a6/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 28b1ccc..5203e32 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
@@ -17,6 +17,7 @@
package org.apache.usergrid.corepersistence;
+import org.apache.usergrid.system.UsergridFeatures;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -51,7 +52,6 @@ public class CpSetup implements Setup {
private static final Logger logger = LoggerFactory.getLogger( CpSetup.class );
-
private final Injector injector;
@@ -77,8 +77,13 @@ public class CpSetup implements Setup {
@Override
public void initSchema() throws Exception {
- // Initialize the management app index in Elasticsearch
- this.emf.initializeManagementIndex();
+ if(UsergridFeatures.isQueryFeatureEnabled()) {
+
+ // Initialize the management app index in Elasticsearch
+ this.emf.initializeManagementIndex();
+
+ }
+
// Create the schema (including keyspace) in Cassandra
setupSchema();
@@ -125,8 +130,10 @@ public class CpSetup implements Setup {
cass.createColumnFamilies( getApplicationKeyspace(),
getCfDefs( ApplicationCF.class, getApplicationKeyspace() ) );
- cass.createColumnFamilies( getApplicationKeyspace(),
- getCfDefs( QueuesCF.class, getApplicationKeyspace() ) );
+ if( UsergridFeatures.isQueryFeatureEnabled() || UsergridFeatures.isGraphFeatureEnabled() ) {
+ cass.createColumnFamilies(getApplicationKeyspace(),
+ getCfDefs(QueuesCF.class, getApplicationKeyspace()));
+ }
logger.info( "Keyspace and legacy column families initialized" );
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/5b42c0a6/stack/core/src/main/java/org/apache/usergrid/corepersistence/ManagerCache.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/ManagerCache.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/ManagerCache.java
index 60212df..ddcd997 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/ManagerCache.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/ManagerCache.java
@@ -67,12 +67,6 @@ public interface ManagerCache {
MapManager getMapManager(MapScope mapScope);
/**
- * gets index producer
- * @return
- */
- IndexProducer getIndexProducer();
-
- /**
* invalidate the cache
*/
void invalidate();
http://git-wip-us.apache.org/repos/asf/usergrid/blob/5b42c0a6/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/AsyncEventServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/AsyncEventServiceImpl.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/AsyncEventServiceImpl.java
index 0bff887..1febe5b 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/AsyncEventServiceImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/AsyncEventServiceImpl.java
@@ -28,15 +28,14 @@ import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Collectors;
import java.util.stream.Stream;
+import com.google.inject.Injector;
import org.apache.usergrid.corepersistence.asyncevents.model.*;
+import org.apache.usergrid.corepersistence.index.*;
import org.apache.usergrid.persistence.index.impl.*;
+import org.apache.usergrid.system.UsergridFeatures;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.usergrid.corepersistence.index.EntityIndexOperation;
-import org.apache.usergrid.corepersistence.index.IndexLocationStrategyFactory;
-import org.apache.usergrid.corepersistence.index.IndexProcessorFig;
-import org.apache.usergrid.corepersistence.index.ReplicatedIndexLocationStrategy;
import org.apache.usergrid.corepersistence.rx.impl.EdgeScope;
import org.apache.usergrid.corepersistence.util.CpNamingUtils;
import org.apache.usergrid.corepersistence.util.ObjectJsonSerializer;
@@ -97,7 +96,6 @@ import rx.schedulers.Schedulers;
@Singleton
public class AsyncEventServiceImpl implements AsyncEventService {
-
private static final Logger logger = LoggerFactory.getLogger(AsyncEventServiceImpl.class);
// SQS maximum receive messages is 10
@@ -105,12 +103,12 @@ public class AsyncEventServiceImpl implements AsyncEventService {
public static final String QUEUE_NAME = "index"; //keep this short as AWS limits queue name size to 80 chars
private final QueueManager queue;
- private final IndexProcessorFig indexProcessorFig;
+ private final EventServiceFig eventServiceFig;
private final QueueFig queueFig;
- private final IndexProducer indexProducer;
+ private IndexProducer indexProducer = null;
private final EntityCollectionManagerFactory entityCollectionManagerFactory;
- private final IndexLocationStrategyFactory indexLocationStrategyFactory;
- private final EntityIndexFactory entityIndexFactory;
+ private IndexLocationStrategyFactory indexLocationStrategyFactory;
+ private EntityIndexFactory entityIndexFactory = null;
private final EventBuilder eventBuilder;
private final RxTaskScheduler rxTaskScheduler;
@@ -132,25 +130,33 @@ public class AsyncEventServiceImpl implements AsyncEventService {
//the actively running subscription
private List<Subscription> subscriptions = new ArrayList<>();
+ private final Injector injector;
+
@Inject
public AsyncEventServiceImpl(final QueueManagerFactory queueManagerFactory,
- final IndexProcessorFig indexProcessorFig,
- final IndexProducer indexProducer,
+ final EventServiceFig eventServiceFig,
final MetricsFactory metricsFactory,
final EntityCollectionManagerFactory entityCollectionManagerFactory,
- final IndexLocationStrategyFactory indexLocationStrategyFactory,
final EntityIndexFactory entityIndexFactory,
final EventBuilder eventBuilder,
final MapManagerFactory mapManagerFactory,
final QueueFig queueFig,
@EventExecutionScheduler
- final RxTaskScheduler rxTaskScheduler ) {
- this.indexProducer = indexProducer;
+ final RxTaskScheduler rxTaskScheduler,
+ final Injector injector ) {
this.entityCollectionManagerFactory = entityCollectionManagerFactory;
- this.indexLocationStrategyFactory = indexLocationStrategyFactory;
this.entityIndexFactory = entityIndexFactory;
+ this.injector = injector;
+ if(UsergridFeatures.isQueryFeatureEnabled() ) {
+
+ this.entityIndexFactory = this.injector.getInstance(EntityIndexFactory.class);
+ this.indexProducer = this.injector.getInstance(IndexProducer.class);
+ this.indexLocationStrategyFactory = this.injector.getInstance(IndexLocationStrategyFactory.class);
+ }
+
+
this.eventBuilder = eventBuilder;
final MapScope mapScope = new MapScopeImpl( CpNamingUtils.getManagementApplicationId(), "indexEvents");
@@ -162,7 +168,7 @@ public class AsyncEventServiceImpl implements AsyncEventService {
QueueScope queueScope = new QueueScopeImpl(QUEUE_NAME, QueueScope.RegionImplementation.ALL);
this.queue = queueManagerFactory.getQueueManager(queueScope);
- this.indexProcessorFig = indexProcessorFig;
+ this.eventServiceFig = eventServiceFig;
this.queueFig = queueFig;
this.writeTimer = metricsFactory.getTimer(AsyncEventServiceImpl.class, "async_event.write");
@@ -528,7 +534,7 @@ public class AsyncEventServiceImpl implements AsyncEventService {
final UUID newMessageId = UUIDGenerator.newTimeUUID();
final int expirationTimeInSeconds =
- ( int ) TimeUnit.MILLISECONDS.toSeconds( indexProcessorFig.getIndexMessageTtl() );
+ ( int ) TimeUnit.MILLISECONDS.toSeconds( eventServiceFig.getIndexMessageTtl() );
//write to the map in ES
esMapPersistence.putString( newMessageId.toString(), jsonValue, expirationTimeInSeconds );
@@ -716,7 +722,7 @@ public class AsyncEventServiceImpl implements AsyncEventService {
* Loop through and start the workers
*/
public void start() {
- final int count = indexProcessorFig.getWorkerCount();
+ final int count = eventServiceFig.getWorkerCount();
for (int i = 0; i < count; i++) {
startWorker();
@@ -761,7 +767,7 @@ public class AsyncEventServiceImpl implements AsyncEventService {
inFlight.addAndGet( drainList.size() );
}
catch ( Throwable t ) {
- final long sleepTime = indexProcessorFig.getFailureRetryTime();
+ final long sleepTime = eventServiceFig.getFailureRetryTime();
logger.error( "Failed to dequeue. Sleeping for {} milliseconds", sleepTime, t );
@@ -820,7 +826,7 @@ public class AsyncEventServiceImpl implements AsyncEventService {
}
} ).subscribeOn( rxTaskScheduler.getAsyncIOScheduler() );
//end flatMap
- }, indexProcessorFig.getEventConcurrencyFactor() );
+ }, eventServiceFig.getEventConcurrencyFactor() );
//start in the background
http://git-wip-us.apache.org/repos/asf/usergrid/blob/5b42c0a6/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/AsyncIndexProvider.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/AsyncIndexProvider.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/AsyncIndexProvider.java
index abd4ce1..7d7be38 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/AsyncIndexProvider.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/AsyncIndexProvider.java
@@ -20,8 +20,9 @@
package org.apache.usergrid.corepersistence.asyncevents;
+import com.google.inject.Injector;
import org.apache.usergrid.corepersistence.index.IndexLocationStrategyFactory;
-import org.apache.usergrid.corepersistence.index.IndexProcessorFig;
+import org.apache.usergrid.corepersistence.index.EventServiceFig;
import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory;
import org.apache.usergrid.persistence.core.rx.RxTaskScheduler;
import org.apache.usergrid.persistence.core.metrics.MetricsFactory;
@@ -35,6 +36,7 @@ import org.apache.usergrid.persistence.queue.QueueManagerFactory;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
+import org.apache.usergrid.system.UsergridFeatures;
/**
@@ -43,46 +45,52 @@ import com.google.inject.Singleton;
@Singleton
public class AsyncIndexProvider implements Provider<AsyncEventService> {
- private final IndexProcessorFig indexProcessorFig;
+ private final EventServiceFig eventServiceFig;
private final QueueManagerFactory queueManagerFactory;
private final MetricsFactory metricsFactory;
private final RxTaskScheduler rxTaskScheduler;
private final EntityCollectionManagerFactory entityCollectionManagerFactory;
private final EventBuilder eventBuilder;
- private final IndexLocationStrategyFactory indexLocationStrategyFactory;
- private final EntityIndexFactory entityIndexFactory;
- private final IndexProducer indexProducer;
+ private IndexLocationStrategyFactory indexLocationStrategyFactory;
+ private EntityIndexFactory entityIndexFactory = null;
+ private IndexProducer indexProducer = null;
private final MapManagerFactory mapManagerFactory;
private final QueueFig queueFig;
private AsyncEventService asyncEventService;
+ private final Injector injector;
@Inject
- public AsyncIndexProvider(final IndexProcessorFig indexProcessorFig,
+ public AsyncIndexProvider(final EventServiceFig eventServiceFig,
final QueueManagerFactory queueManagerFactory,
final MetricsFactory metricsFactory,
@EventExecutionScheduler final RxTaskScheduler rxTaskScheduler,
final EntityCollectionManagerFactory entityCollectionManagerFactory,
final EventBuilder eventBuilder,
- final IndexLocationStrategyFactory indexLocationStrategyFactory,
- final EntityIndexFactory entityIndexFactory,
- final IndexProducer indexProducer,
final MapManagerFactory mapManagerFactory,
- final QueueFig queueFig) {
+ final QueueFig queueFig,
+ final Injector injector) {
- this.indexProcessorFig = indexProcessorFig;
+ this.eventServiceFig = eventServiceFig;
this.queueManagerFactory = queueManagerFactory;
this.metricsFactory = metricsFactory;
this.rxTaskScheduler = rxTaskScheduler;
this.entityCollectionManagerFactory = entityCollectionManagerFactory;
this.eventBuilder = eventBuilder;
- this.indexLocationStrategyFactory = indexLocationStrategyFactory;
- this.entityIndexFactory = entityIndexFactory;
- this.indexProducer = indexProducer;
this.mapManagerFactory = mapManagerFactory;
this.queueFig = queueFig;
+ this.injector = injector;
+
+ if(UsergridFeatures.isQueryFeatureEnabled()) {
+
+ this.entityIndexFactory = this.injector.getInstance(EntityIndexFactory.class);
+ this.indexProducer = this.injector.getInstance(IndexProducer.class);
+ this.indexLocationStrategyFactory = this.injector.getInstance(IndexLocationStrategyFactory.class);
+
+
+ }
}
@@ -98,21 +106,21 @@ public class AsyncIndexProvider implements Provider<AsyncEventService> {
private AsyncEventService getIndexService() {
- final String value = indexProcessorFig.getQueueImplementation();
+ final String value = eventServiceFig.getQueueImplementation();
final Implementations impl = Implementations.valueOf(value);
switch (impl) {
case LOCAL:
- AsyncEventServiceImpl eventService = new AsyncEventServiceImpl(scope -> new LocalQueueManager(), indexProcessorFig, indexProducer, metricsFactory,
- entityCollectionManagerFactory, indexLocationStrategyFactory, entityIndexFactory, eventBuilder,mapManagerFactory, queueFig,rxTaskScheduler);
+ AsyncEventServiceImpl eventService = new AsyncEventServiceImpl(scope -> new LocalQueueManager(), eventServiceFig, metricsFactory,
+ entityCollectionManagerFactory, entityIndexFactory, eventBuilder,mapManagerFactory, queueFig,rxTaskScheduler, injector);
eventService.MAX_TAKE = 1000;
return eventService;
case SQS:
throw new IllegalArgumentException("Configuration value of SQS is no longer allowed. Use SNS instead with only a single region");
case SNS:
- return new AsyncEventServiceImpl(queueManagerFactory, indexProcessorFig, indexProducer, metricsFactory,
- entityCollectionManagerFactory, indexLocationStrategyFactory,entityIndexFactory, eventBuilder, mapManagerFactory, queueFig, rxTaskScheduler );
+ return new AsyncEventServiceImpl(queueManagerFactory, eventServiceFig, metricsFactory,
+ entityCollectionManagerFactory,entityIndexFactory, eventBuilder, mapManagerFactory, queueFig, rxTaskScheduler, injector );
default:
throw new IllegalArgumentException("Configuration value of " + getErrorValues() + " are allowed");
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/5b42c0a6/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/EventBuilderImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/EventBuilderImpl.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/EventBuilderImpl.java
index bbdce5a..7136022 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/EventBuilderImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/EventBuilderImpl.java
@@ -24,6 +24,9 @@ import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
+import com.google.inject.Injector;
+import org.apache.usergrid.persistence.index.impl.IndexOperation;
+import org.apache.usergrid.system.UsergridFeatures;
import org.apache.usergrid.utils.UUIDUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -58,20 +61,28 @@ public class EventBuilderImpl implements EventBuilder {
private static final Logger logger = LoggerFactory.getLogger( EventBuilderImpl.class );
- private final IndexService indexService;
+ private IndexService indexService = null;
private final EntityCollectionManagerFactory entityCollectionManagerFactory;
private final GraphManagerFactory graphManagerFactory;
private final SerializationFig serializationFig;
+ private final Injector injector;
+
@Inject
- public EventBuilderImpl( final IndexService indexService,
- final EntityCollectionManagerFactory entityCollectionManagerFactory,
- final GraphManagerFactory graphManagerFactory, final SerializationFig serializationFig ) {
- this.indexService = indexService;
+ public EventBuilderImpl( final EntityCollectionManagerFactory entityCollectionManagerFactory,
+ final GraphManagerFactory graphManagerFactory, final SerializationFig serializationFig,
+ final Injector injector ) {
+
this.entityCollectionManagerFactory = entityCollectionManagerFactory;
this.graphManagerFactory = graphManagerFactory;
this.serializationFig = serializationFig;
+ this.injector = injector;
+
+ if(UsergridFeatures.isQueryFeatureEnabled()) {
+
+ this.indexService = injector.getInstance(IndexService.class);
+ }
}
@@ -85,6 +96,10 @@ public class EventBuilderImpl implements EventBuilder {
applicationScope, entity, newEdge);
}
+ if( indexService == null ){
+ return Observable.just(new IndexOperationMessage());
+ }
+
return indexService.indexEdge( applicationScope, entity, newEdge );
}
@@ -98,7 +113,15 @@ public class EventBuilderImpl implements EventBuilder {
final GraphManager gm = graphManagerFactory.createEdgeManager( applicationScope );
return gm.deleteEdge( edge )
- .flatMap( deletedEdge -> indexService.deleteIndexEdge( applicationScope, deletedEdge ));
+ .flatMap( deletedEdge -> {
+
+ if ( indexService != null ) {
+ return indexService.deleteIndexEdge(applicationScope, deletedEdge);
+ }else{
+ return Observable.just(new IndexOperationMessage());
+ }
+
+ });
}
@@ -127,9 +150,14 @@ public class EventBuilderImpl implements EventBuilder {
if(mostRecentlyMarked != null){
// fetch entity versions to be de-index by looking in cassandra
- deIndexObservable =
- indexService.deIndexEntity(applicationScope, entityId, mostRecentlyMarked.getVersion(),
- getVersionsOlderThanMarked(ecm, entityId, mostRecentlyMarked.getVersion()));
+ if(indexService != null ) {
+ deIndexObservable =
+ indexService.deIndexEntity(applicationScope, entityId, mostRecentlyMarked.getVersion(),
+ getVersionsOlderThanMarked(ecm, entityId, mostRecentlyMarked.getVersion()));
+ }
+
+
+
ecmDeleteObservable =
ecm.getVersionsFromMaxToMin( entityId, mostRecentlyMarked.getVersion() )
@@ -169,7 +197,16 @@ public class EventBuilderImpl implements EventBuilder {
return modified.getValue() >= entityIndexOperation.getUpdatedSince();
} )
//perform indexing on the task scheduler and start it
- .flatMap( entity -> indexService.indexEntity( applicationScope, entity ) );
+ .flatMap( entity -> {
+
+ if( indexService != null ) {
+ return indexService.indexEntity(applicationScope, entity);
+ }else{
+ return Observable.just(new IndexOperationMessage());
+ }
+
+
+ } );
}
@@ -181,6 +218,9 @@ public class EventBuilderImpl implements EventBuilder {
logger.debug("Removing old versions of entity {} from index in app scope {}", entityId, applicationScope );
}
+ if(indexService == null){
+ return Observable.just(new IndexOperationMessage());
+ }
final EntityCollectionManager ecm = entityCollectionManagerFactory.createCollectionManager( applicationScope );
http://git-wip-us.apache.org/repos/asf/usergrid/blob/5b42c0a6/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/EventServiceFig.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/EventServiceFig.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/EventServiceFig.java
new file mode 100644
index 0000000..a32bcc3
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/EventServiceFig.java
@@ -0,0 +1,121 @@
+/*
+ * 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.index;
+
+
+import org.safehaus.guicyfig.Default;
+import org.safehaus.guicyfig.FigSingleton;
+import org.safehaus.guicyfig.GuicyFig;
+import org.safehaus.guicyfig.Key;
+
+
+/**
+ * Application id cache fig
+ */
+@FigSingleton
+public interface EventServiceFig extends GuicyFig {
+
+
+ String FAILURE_REJECTED_RETRY_WAIT_TIME = "elasticsearch.rejected_retry_wait";
+
+ String ELASTICSEARCH_WORKER_COUNT = "elasticsearch.worker_count";
+
+ String EVENT_CONCURRENCY_FACTOR = "event.concurrency.factor";
+
+ String ELASTICSEARCH_QUEUE_IMPL = "elasticsearch.queue_impl";
+
+ String INDEX_QUEUE_VISIBILITY_TIMEOUT = "elasticsearch.queue_visibility_timeout";
+
+ String REINDEX_BUFFER_SIZE = "elasticsearch.reindex.buffer_size";
+
+ String REINDEX_CONCURRENCY_FACTOR = "elasticsearch.reindex.concurrency.factor";
+
+
+ /**
+ * Set the amount of time to wait when Elasticsearch rejects a requests before
+ * retrying. This provides simple back pressure. (in milliseconds)
+ */
+ @Default("1000")
+ @Key(FAILURE_REJECTED_RETRY_WAIT_TIME)
+ long getFailureRetryTime();
+
+
+ /**
+ * Set the visibility timeout for messages received from the queue. (in milliseconds).
+ * Received messages will remain 'in flight' until they are ack'd(deleted) or this timeout occurs.
+ * If the timeout occurs, the messages will become visible again for re-processing.
+ */
+ @Default( "30000" ) // 30 seconds
+ @Key( INDEX_QUEUE_VISIBILITY_TIMEOUT )
+ int getIndexQueueVisibilityTimeout();
+
+ /**
+ * The number of worker threads used when handing off messages from the SQS thread
+ */
+ @Default( "5" )
+ @Key( EVENT_CONCURRENCY_FACTOR )
+ int getEventConcurrencyFactor();
+
+
+
+ /**
+ * The number of worker threads used to read index write requests from the queue.
+ */
+ @Default("8")
+ @Key(ELASTICSEARCH_WORKER_COUNT)
+ int getWorkerCount();
+
+ /**
+ * Set the implementation to use for queuing.
+ * Valid values: TEST, LOCAL, SQS, SNS
+ * NOTE: SQS and SNS equate to the same implementation of Amazon queue services.
+ */
+ @Default("LOCAL")
+ @Key(ELASTICSEARCH_QUEUE_IMPL)
+ String getQueueImplementation();
+
+ @Default("100")
+ @Key(REINDEX_BUFFER_SIZE)
+ int getReindexBufferSize();
+
+ /**
+ * The number of parallel buffers during re-index that can be processed
+ */
+ @Default("10")
+ @Key(REINDEX_CONCURRENCY_FACTOR)
+ int getReindexConcurrencyFactor();
+
+ /**
+ * Flag to resolve the LOCAL queue implementation service synchronously.
+ */
+ @Default("false")
+ @Key("elasticsearch.queue_impl.resolution")
+ boolean resolveSynchronously();
+
+ /**
+ * Get the message TTL in milliseconds. Defaults to 24 hours
+ *
+ * 24 * 60 * 60 * 1000
+ *
+ * @return
+ */
+ @Default("86400000")
+ @Key( "elasticsearch.message.ttl" )
+ int getIndexMessageTtl();
+}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/5b42c0a6/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexProcessorFig.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexProcessorFig.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexProcessorFig.java
deleted file mode 100644
index c05c047..0000000
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexProcessorFig.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * 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.index;
-
-
-import org.safehaus.guicyfig.Default;
-import org.safehaus.guicyfig.FigSingleton;
-import org.safehaus.guicyfig.GuicyFig;
-import org.safehaus.guicyfig.Key;
-
-
-/**
- * Application id cache fig
- */
-@FigSingleton
-public interface IndexProcessorFig extends GuicyFig {
-
-
- String FAILURE_REJECTED_RETRY_WAIT_TIME = "elasticsearch.rejected_retry_wait";
-
- String ELASTICSEARCH_WORKER_COUNT = "elasticsearch.worker_count";
-
- String EVENT_CONCURRENCY_FACTOR = "event.concurrency.factor";
-
- String ELASTICSEARCH_QUEUE_IMPL = "elasticsearch.queue_impl";
-
- String INDEX_QUEUE_VISIBILITY_TIMEOUT = "elasticsearch.queue_visibility_timeout";
-
- String REINDEX_BUFFER_SIZE = "elasticsearch.reindex.buffer_size";
-
- String REINDEX_CONCURRENCY_FACTOR = "elasticsearch.reindex.concurrency.factor";
-
-
- /**
- * Set the amount of time to wait when Elasticsearch rejects a requests before
- * retrying. This provides simple back pressure. (in milliseconds)
- */
- @Default("1000")
- @Key(FAILURE_REJECTED_RETRY_WAIT_TIME)
- long getFailureRetryTime();
-
-
- /**
- * Set the visibility timeout for messages received from the queue. (in milliseconds).
- * Received messages will remain 'in flight' until they are ack'd(deleted) or this timeout occurs.
- * If the timeout occurs, the messages will become visible again for re-processing.
- */
- @Default( "30000" ) // 30 seconds
- @Key( INDEX_QUEUE_VISIBILITY_TIMEOUT )
- int getIndexQueueVisibilityTimeout();
-
- /**
- * The number of worker threads used when handing off messages from the SQS thread
- */
- @Default( "5" )
- @Key( EVENT_CONCURRENCY_FACTOR )
- int getEventConcurrencyFactor();
-
-
-
- /**
- * The number of worker threads used to read index write requests from the queue.
- */
- @Default("8")
- @Key(ELASTICSEARCH_WORKER_COUNT)
- int getWorkerCount();
-
- /**
- * Set the implementation to use for queuing.
- * Valid values: TEST, LOCAL, SQS, SNS
- * NOTE: SQS and SNS equate to the same implementation of Amazon queue services.
- */
- @Default("LOCAL")
- @Key(ELASTICSEARCH_QUEUE_IMPL)
- String getQueueImplementation();
-
- @Default("100")
- @Key(REINDEX_BUFFER_SIZE)
- int getReindexBufferSize();
-
- /**
- * The number of parallel buffers during re-index that can be processed
- */
- @Default("10")
- @Key(REINDEX_CONCURRENCY_FACTOR)
- int getReindexConcurrencyFactor();
-
- /**
- * Flag to resolve the LOCAL queue implementation service synchronously.
- */
- @Default("false")
- @Key("elasticsearch.queue_impl.resolution")
- boolean resolveSynchronously();
-
- /**
- * Get the message TTL in milliseconds. Defaults to 24 hours
- *
- * 24 * 60 * 60 * 1000
- *
- * @return
- */
- @Default("86400000")
- @Key( "elasticsearch.message.ttl" )
- int getIndexMessageTtl();
-}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/5b42c0a6/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/ReIndexServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/ReIndexServiceImpl.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/ReIndexServiceImpl.java
index 4d4edaa..4255e69 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/ReIndexServiceImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/ReIndexServiceImpl.java
@@ -78,7 +78,7 @@ public class ReIndexServiceImpl implements ReIndexService {
private final AllApplicationsObservable allApplicationsObservable;
private final IndexLocationStrategyFactory indexLocationStrategyFactory;
private final AllEntityIdsObservable allEntityIdsObservable;
- private final IndexProcessorFig indexProcessorFig;
+ private final EventServiceFig eventServiceFig;
private final MapManager mapManager;
private final MapManagerFactory mapManagerFactory;
private final AsyncEventService indexService;
@@ -92,14 +92,14 @@ public class ReIndexServiceImpl implements ReIndexService {
final AllEntityIdsObservable allEntityIdsObservable,
final MapManagerFactory mapManagerFactory,
final AllApplicationsObservable allApplicationsObservable,
- final IndexProcessorFig indexProcessorFig,
+ final EventServiceFig eventServiceFig,
final CollectionSettingsFactory collectionSettingsFactory,
final AsyncEventService indexService ) {
this.entityIndexFactory = entityIndexFactory;
this.indexLocationStrategyFactory = indexLocationStrategyFactory;
this.allEntityIdsObservable = allEntityIdsObservable;
this.allApplicationsObservable = allApplicationsObservable;
- this.indexProcessorFig = indexProcessorFig;
+ this.eventServiceFig = eventServiceFig;
this.indexService = indexService;
this.collectionSettingsFactory = collectionSettingsFactory;
this.mapManagerFactory = mapManagerFactory;
@@ -164,14 +164,14 @@ public class ReIndexServiceImpl implements ReIndexService {
Observable<List<EdgeScope>> runningReIndex = allEntityIdsObservable.getEdgesToEntities( applicationScopes,
reIndexRequestBuilder.getCollectionName(), cursorSeek.getSeekValue() )
- .buffer( indexProcessorFig.getReindexBufferSize())
+ .buffer( eventServiceFig.getReindexBufferSize())
.flatMap( edgeScopes -> Observable.just(edgeScopes)
.doOnNext(edges -> {
logger.info("Sending batch of {} to be indexed.", edges.size());
indexService.indexBatch(edges, modifiedSince);
})
- .subscribeOn( Schedulers.io() ), indexProcessorFig.getReindexConcurrencyFactor());
+ .subscribeOn( Schedulers.io() ), eventServiceFig.getReindexConcurrencyFactor());
// start our sampler and state persistence
http://git-wip-us.apache.org/repos/asf/usergrid/blob/5b42c0a6/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/PipelineModule.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/PipelineModule.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/PipelineModule.java
index 66265be..2085dc4 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/PipelineModule.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/PipelineModule.java
@@ -25,6 +25,8 @@ import org.apache.usergrid.corepersistence.pipeline.read.FilterFactory;
import com.google.inject.AbstractModule;
import com.google.inject.assistedinject.FactoryModuleBuilder;
+import org.apache.usergrid.corepersistence.pipeline.read.SearchFilterFactory;
+import org.apache.usergrid.system.UsergridFeatures;
/**
@@ -35,10 +37,18 @@ public class PipelineModule extends AbstractModule {
@Override
protected void configure() {
- //Use Guice to create the builder since we don't really need to do anything
+ //Use Guice to create the builder since we don't really need to do anything
//other than DI when creating the filters
install( new FactoryModuleBuilder().build( FilterFactory.class ) );
+ if( UsergridFeatures.isQueryFeatureEnabled() ) {
+
+ // only inject search filters that use Elasticsearch if the UG feature is enabled
+ install( new FactoryModuleBuilder().build( SearchFilterFactory.class ) );
+
+ }
+
+
install( new FactoryModuleBuilder().build( PipelineBuilderFactory.class ) );
}
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/5b42c0a6/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/builder/CandidateBuilder.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/builder/CandidateBuilder.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/builder/CandidateBuilder.java
index 9354127..0d1e775 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/builder/CandidateBuilder.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/builder/CandidateBuilder.java
@@ -23,6 +23,7 @@ package org.apache.usergrid.corepersistence.pipeline.builder;
import org.apache.usergrid.corepersistence.pipeline.read.FilterFactory;
import org.apache.usergrid.corepersistence.pipeline.Pipeline;
import org.apache.usergrid.corepersistence.pipeline.read.FilterResult;
+import org.apache.usergrid.corepersistence.pipeline.read.SearchFilterFactory;
import org.apache.usergrid.corepersistence.pipeline.read.search.Candidate;
import org.apache.usergrid.persistence.model.entity.Entity;
import org.apache.usergrid.persistence.model.entity.Id;
@@ -31,14 +32,17 @@ import org.apache.usergrid.persistence.model.entity.Id;
public class CandidateBuilder {
+ private final SearchFilterFactory searchFilterFactory;
private final Pipeline<FilterResult<Candidate>> pipeline;
private final FilterFactory filterFactory;
public CandidateBuilder( final Pipeline<FilterResult<Candidate>> pipeline,
- final FilterFactory filterFactory ) {
+ final FilterFactory filterFactory,
+ final SearchFilterFactory searchFilterFactory ) {
this.pipeline = pipeline;
this.filterFactory = filterFactory;
+ this.searchFilterFactory = searchFilterFactory;
}
@@ -50,7 +54,7 @@ public class CandidateBuilder {
final Pipeline<FilterResult<Id>> newFilter = pipeline.withFilter( filterFactory.candidateResultsIdVerifyFilter() );
- return new IdBuilder( newFilter, filterFactory );
+ return new IdBuilder( newFilter, filterFactory, searchFilterFactory );
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/5b42c0a6/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/builder/IdBuilder.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/builder/IdBuilder.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/builder/IdBuilder.java
index 85e9069..d81bd24 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/builder/IdBuilder.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/builder/IdBuilder.java
@@ -26,6 +26,7 @@ import org.apache.usergrid.corepersistence.pipeline.PipelineOperation;
import org.apache.usergrid.corepersistence.pipeline.read.FilterFactory;
import org.apache.usergrid.corepersistence.pipeline.read.FilterResult;
import org.apache.usergrid.corepersistence.pipeline.read.ResultsPage;
+import org.apache.usergrid.corepersistence.pipeline.read.SearchFilterFactory;
import org.apache.usergrid.corepersistence.pipeline.read.collect.ConnectionRefFilter;
import org.apache.usergrid.corepersistence.pipeline.read.collect.ConnectionRefResumeFilter;
import org.apache.usergrid.corepersistence.pipeline.read.collect.IdResumeFilter;
@@ -42,17 +43,26 @@ import rx.Observable;
*/
public class IdBuilder {
-
+ private final SearchFilterFactory searchFilterFactory;
private final FilterFactory filterFactory;
private final Pipeline<FilterResult<Id>> pipeline;
+ public IdBuilder( final Pipeline<FilterResult<Id>> pipeline, final FilterFactory filterFactory,
+ final SearchFilterFactory searchFilterFactory ) {
+ this.pipeline = pipeline;
+ this.filterFactory = filterFactory;
+ this.searchFilterFactory = searchFilterFactory;
+ }
+
public IdBuilder( final Pipeline<FilterResult<Id>> pipeline, final FilterFactory filterFactory ) {
this.pipeline = pipeline;
this.filterFactory = filterFactory;
+ this.searchFilterFactory = null;
}
+
/**
* Load all the ids we encounter when traversing the graph as entities
* @return
@@ -74,7 +84,7 @@ public class IdBuilder {
public IdBuilder traverseReverseConnection( final String connectionName, final Optional<String> entityType ) {
final PipelineOperation<FilterResult<Id>, FilterResult<Id>> filter;
filter = filterFactory.readGraphReverseConnectionFilter( connectionName );
- return new IdBuilder( pipeline.withFilter(filter ), filterFactory );
+ return new IdBuilder( pipeline.withFilter(filter ), filterFactory, searchFilterFactory );
}
@@ -87,7 +97,7 @@ public class IdBuilder {
final Pipeline<FilterResult<Id>> newFilter =
pipeline.withFilter( filterFactory.readGraphCollectionFilter( collectionName ) );
- return new IdBuilder( newFilter, filterFactory );
+ return new IdBuilder( newFilter, filterFactory, searchFilterFactory );
}
@@ -108,7 +118,7 @@ public class IdBuilder {
}
- return new IdBuilder( pipeline.withFilter(filter ), filterFactory );
+ return new IdBuilder( pipeline.withFilter(filter ), filterFactory, searchFilterFactory );
}
@@ -121,10 +131,10 @@ public class IdBuilder {
*/
public CandidateBuilder searchCollection( final String collectionName, final String ql, final String entityType ) {
- final Pipeline<FilterResult<Candidate>> newFilter = pipeline.withFilter( filterFactory.searchCollectionFilter(
+ final Pipeline<FilterResult<Candidate>> newFilter = pipeline.withFilter( searchFilterFactory.searchCollectionFilter(
ql, collectionName, entityType ) );
- return new CandidateBuilder( newFilter, filterFactory );
+ return new CandidateBuilder( newFilter, filterFactory, searchFilterFactory );
}
@@ -138,10 +148,10 @@ public class IdBuilder {
public CandidateBuilder searchConnection( final String connectionName, final String ql , final Optional<String> entityType) {
- final Pipeline<FilterResult<Candidate>> newFilter = pipeline.withFilter( filterFactory.searchConnectionFilter(
+ final Pipeline<FilterResult<Candidate>> newFilter = pipeline.withFilter( searchFilterFactory.searchConnectionFilter(
ql, connectionName, entityType ) );
- return new CandidateBuilder( newFilter, filterFactory );
+ return new CandidateBuilder( newFilter, filterFactory, searchFilterFactory );
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/5b42c0a6/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/builder/PipelineBuilder.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/builder/PipelineBuilder.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/builder/PipelineBuilder.java
index f1a44ea..14c94a2 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/builder/PipelineBuilder.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/builder/PipelineBuilder.java
@@ -20,9 +20,11 @@
package org.apache.usergrid.corepersistence.pipeline.builder;
+import com.google.inject.Injector;
import org.apache.usergrid.corepersistence.pipeline.read.FilterFactory;
import org.apache.usergrid.corepersistence.pipeline.Pipeline;
import org.apache.usergrid.corepersistence.pipeline.read.FilterResult;
+import org.apache.usergrid.corepersistence.pipeline.read.SearchFilterFactory;
import org.apache.usergrid.persistence.core.scope.ApplicationScope;
import org.apache.usergrid.persistence.model.entity.Id;
@@ -30,6 +32,7 @@ import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
+import org.apache.usergrid.system.UsergridFeatures;
/**
@@ -38,12 +41,12 @@ import com.google.inject.assistedinject.Assisted;
*/
public class PipelineBuilder {
-
-
private final ApplicationScope applicationScope;
private Optional<String> cursor = Optional.absent();
private int limit = 10;
private final FilterFactory filterFactory;
+ private SearchFilterFactory searchFilterFactory = null;
+ private final Injector injector;
/**
@@ -51,9 +54,19 @@ public class PipelineBuilder {
* @param filterFactory
*/
@Inject
- public PipelineBuilder( final FilterFactory filterFactory, @Assisted final ApplicationScope applicationScope ) {
+ public PipelineBuilder( final FilterFactory filterFactory, @Assisted final ApplicationScope applicationScope,
+ final Injector injector ) {
this.filterFactory = filterFactory;
this.applicationScope = applicationScope;
+ this.injector = injector;
+
+ if(UsergridFeatures.isQueryFeatureEnabled()) {
+
+ this.searchFilterFactory = injector.getInstance(SearchFilterFactory.class);
+
+ }
+
+
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/5b42c0a6/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/FilterFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/FilterFactory.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/FilterFactory.java
index 4b615d8..06c49e2 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/FilterFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/FilterFactory.java
@@ -88,29 +88,6 @@ public interface FilterFactory {
*/
ReadGraphConnectionByIdFilter readGraphConnectionByIdFilter( final String connectionName, final Id targetId );
- /**
- * Generate a new instance of the command with the specified parameters
- *
- * @param query The query to use when querying the entities in the collection
- * @param collectionName The collection name to use when querying
- */
- SearchCollectionFilter searchCollectionFilter( @Assisted( "query" ) final String query,
- @Assisted( "collectionName" ) final String collectionName,
- @Assisted( "entityType" ) final String entityType );
-
-
- /**
- * Generate a new instance of the command with the specified parameters
- *
- * @param query The query to use when querying the entities in the connection
- * @param connectionName The type of connection to query
- * @param connectedEntityType The type of entity in the connection. Leave absent to query all entity types
- */
- SearchConnectionFilter searchConnectionFilter( @Assisted( "query" ) final String query,
- @Assisted( "connectionName" ) final String connectionName,
- @Assisted( "connectedEntityType" )
- final Optional<String> connectedEntityType );
-
/**
* Generate a new instance of the command with the specified parameters
http://git-wip-us.apache.org/repos/asf/usergrid/blob/5b42c0a6/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/SearchFilterFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/SearchFilterFactory.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/SearchFilterFactory.java
new file mode 100644
index 0000000..3f19cd5
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/SearchFilterFactory.java
@@ -0,0 +1,53 @@
+/*
+ * 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.pipeline.read;
+
+import com.google.common.base.Optional;
+import com.google.inject.assistedinject.Assisted;
+import org.apache.usergrid.corepersistence.pipeline.read.search.SearchCollectionFilter;
+import org.apache.usergrid.corepersistence.pipeline.read.search.SearchConnectionFilter;
+
+/**
+ * Created by russo on 9/2/16.
+ */
+public interface SearchFilterFactory {
+
+ /**
+ * Generate a new instance of the command with the specified parameters
+ *
+ * @param query The query to use when querying the entities in the collection
+ * @param collectionName The collection name to use when querying
+ */
+ SearchCollectionFilter searchCollectionFilter(@Assisted( "query" ) final String query,
+ @Assisted( "collectionName" ) final String collectionName,
+ @Assisted( "entityType" ) final String entityType );
+
+
+ /**
+ * Generate a new instance of the command with the specified parameters
+ *
+ * @param query The query to use when querying the entities in the connection
+ * @param connectionName The type of connection to query
+ * @param connectedEntityType The type of entity in the connection. Leave absent to query all entity types
+ */
+ SearchConnectionFilter searchConnectionFilter(@Assisted( "query" ) final String query,
+ @Assisted( "connectionName" ) final String connectionName,
+ @Assisted( "connectedEntityType" )
+ final Optional<String> connectedEntityType );
+}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/5b42c0a6/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/search/CandidateEntityFilter.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/search/CandidateEntityFilter.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/search/CandidateEntityFilter.java
index 7770436..c7b8a4e 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/search/CandidateEntityFilter.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/search/CandidateEntityFilter.java
@@ -22,6 +22,7 @@ package org.apache.usergrid.corepersistence.pipeline.read.search;
import java.util.*;
+import com.google.inject.Injector;
import org.apache.usergrid.corepersistence.index.IndexLocationStrategyFactory;
import org.apache.usergrid.persistence.index.*;
import org.apache.usergrid.persistence.index.impl.IndexProducer;
@@ -30,6 +31,7 @@ import org.apache.usergrid.persistence.model.field.DoubleField;
import org.apache.usergrid.persistence.model.field.EntityObjectField;
import org.apache.usergrid.persistence.model.field.Field;
import org.apache.usergrid.persistence.model.field.value.EntityObject;
+import org.apache.usergrid.system.UsergridFeatures;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -59,21 +61,28 @@ import rx.Observable;
public class CandidateEntityFilter extends AbstractFilter<FilterResult<Candidate>, FilterResult<Entity>> {
private final EntityCollectionManagerFactory entityCollectionManagerFactory;
- private final EntityIndexFactory entityIndexFactory;
- private final IndexLocationStrategyFactory indexLocationStrategyFactory;
- private final IndexProducer indexProducer;
+ private EntityIndexFactory entityIndexFactory = null;
+ private IndexLocationStrategyFactory indexLocationStrategyFactory;
+ private IndexProducer indexProducer = null;
+ private final Injector injector;
@Inject
- public CandidateEntityFilter( final EntityCollectionManagerFactory entityCollectionManagerFactory,
- final EntityIndexFactory entityIndexFactory,
- final IndexLocationStrategyFactory indexLocationStrategyFactory,
- final IndexProducer indexProducer
- ) {
+ public CandidateEntityFilter(final EntityCollectionManagerFactory entityCollectionManagerFactory,
+ final Injector injector ) {
+
this.entityCollectionManagerFactory = entityCollectionManagerFactory;
- this.entityIndexFactory = entityIndexFactory;
- this.indexLocationStrategyFactory = indexLocationStrategyFactory;
- this.indexProducer = indexProducer;
+ this.injector = injector;
+
+
+ if(UsergridFeatures.isQueryFeatureEnabled()) {
+
+ this.entityIndexFactory = this.injector.getInstance(EntityIndexFactory.class);
+ this.indexProducer = this.injector.getInstance(IndexProducer.class);
+ this.indexLocationStrategyFactory = this.injector.getInstance(IndexLocationStrategyFactory.class);
+
+
+ }
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/5b42c0a6/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/search/CandidateIdFilter.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/search/CandidateIdFilter.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/search/CandidateIdFilter.java
index 96849f8..5cfbfa3 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/search/CandidateIdFilter.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/search/CandidateIdFilter.java
@@ -24,9 +24,11 @@ import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
+import com.google.inject.Injector;
import org.apache.usergrid.corepersistence.index.IndexLocationStrategyFactory;
import org.apache.usergrid.persistence.index.*;
import org.apache.usergrid.persistence.index.impl.IndexProducer;
+import org.apache.usergrid.system.UsergridFeatures;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -52,20 +54,26 @@ import rx.Observable;
public class CandidateIdFilter extends AbstractFilter<FilterResult<Candidate>, FilterResult<Id>> {
private final EntityCollectionManagerFactory entityCollectionManagerFactory;
- private final EntityIndexFactory entityIndexFactory;
- private final IndexLocationStrategyFactory indexLocationStrategyFactory;
- private final IndexProducer indexProducer;
+ private EntityIndexFactory entityIndexFactory = null;
+ private IndexLocationStrategyFactory indexLocationStrategyFactory;
+ private IndexProducer indexProducer = null;
+ private final Injector injector;
@Inject
public CandidateIdFilter( final EntityCollectionManagerFactory entityCollectionManagerFactory,
- final EntityIndexFactory entityIndexFactory,
- final IndexLocationStrategyFactory indexLocationStrategyFactory,
- final IndexProducer indexProducer) {
+ final Injector injector ) {
+
+ this.injector = injector;
this.entityCollectionManagerFactory = entityCollectionManagerFactory;
- this.entityIndexFactory = entityIndexFactory;
- this.indexLocationStrategyFactory = indexLocationStrategyFactory;
- this.indexProducer = indexProducer;
+
+ if (UsergridFeatures.isQueryFeatureEnabled()) {
+
+ this.entityIndexFactory = this.injector.getInstance(EntityIndexFactory.class);
+ this.indexProducer = this.injector.getInstance(IndexProducer.class);
+ this.indexLocationStrategyFactory = this.injector.getInstance(IndexLocationStrategyFactory.class);
+
+ }
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/5b42c0a6/stack/core/src/main/java/org/apache/usergrid/persistence/Query.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/Query.java b/stack/core/src/main/java/org/apache/usergrid/persistence/Query.java
index d68c085..08b8f9c 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/Query.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/Query.java
@@ -31,6 +31,7 @@ import org.apache.usergrid.persistence.index.query.tree.Operand;
import org.apache.usergrid.persistence.index.utils.ClassUtils;
import org.apache.usergrid.persistence.index.utils.ListUtils;
import org.apache.usergrid.persistence.index.utils.MapUtils;
+import org.apache.usergrid.system.UsergridFeatures;
import java.io.IOException;
import java.io.Serializable;
@@ -42,8 +43,6 @@ import java.util.Map.Entry;
public class Query {
-
-
public enum Level {
IDS, REFS, CORE_PROPERTIES, ALL_PROPERTIES, LINKED_PROPERTIES
}
@@ -199,6 +198,12 @@ public class Query {
List<CounterFilterPredicate> counterFilters = null;
String ql = QueryUtils.queryStrFrom( params );
+ final boolean queryFeatureEnabled = UsergridFeatures.isQueryFeatureEnabled();
+
+ if( StringUtils.isNotEmpty(ql) && (!queryFeatureEnabled && !ql.equalsIgnoreCase("select *")) ){
+ throw new UnsupportedOperationException("Query features are not enabled.");
+ }
+
String type = ListUtils.first( params.get( "type" ) );
Boolean reversed = ListUtils.firstBoolean( params.get( "reversed" ) );
String connection = ListUtils.first( params.get( "connectionType" ) );
http://git-wip-us.apache.org/repos/asf/usergrid/blob/5b42c0a6/stack/core/src/main/java/org/apache/usergrid/system/UsergridFeatures.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/system/UsergridFeatures.java b/stack/core/src/main/java/org/apache/usergrid/system/UsergridFeatures.java
new file mode 100644
index 0000000..22ba48c
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/system/UsergridFeatures.java
@@ -0,0 +1,69 @@
+/*
+ * 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.system;
+
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+public class UsergridFeatures {
+
+ public static final String USERGRID_FEATURES_ENABLED_PROP = "usergrid.features.enabled";
+
+ public enum Feature {
+
+ ALL, GRAPH, KVM
+
+ }
+
+
+ public static Collection<Feature> getFeaturesEnabled(){
+
+ List<Feature> features = new ArrayList<>();
+
+ String featureString = System.getProperty(USERGRID_FEATURES_ENABLED_PROP, "all");
+
+ String[] splitFeatures = featureString.split(",");
+ for(String feature : splitFeatures){
+
+ features.add(Feature.valueOf(feature.toUpperCase()));
+
+ }
+
+ return features;
+
+ }
+
+ public static boolean isGraphFeatureEnabled(){
+
+ return getFeaturesEnabled().contains(Feature.ALL) || getFeaturesEnabled().contains(Feature.GRAPH);
+
+ }
+
+ public static boolean isQueryFeatureEnabled(){
+
+ return getFeaturesEnabled().contains(Feature.ALL);
+
+ }
+
+ public static boolean isKvmFeatureEnabled(){
+
+ return getFeaturesEnabled().contains(Feature.KVM);
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/5b42c0a6/stack/core/src/test/java/org/apache/usergrid/corepersistence/index/AsyncEventServiceImplTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/corepersistence/index/AsyncEventServiceImplTest.java b/stack/core/src/test/java/org/apache/usergrid/corepersistence/index/AsyncEventServiceImplTest.java
index 4c0058b..0ec28b5 100644
--- a/stack/core/src/test/java/org/apache/usergrid/corepersistence/index/AsyncEventServiceImplTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/corepersistence/index/AsyncEventServiceImplTest.java
@@ -21,6 +21,7 @@ package org.apache.usergrid.corepersistence.index;
import com.google.inject.Inject;
+import com.google.inject.Injector;
import net.jcip.annotations.NotThreadSafe;
import org.apache.usergrid.corepersistence.TestIndexModule;
import org.apache.usergrid.corepersistence.asyncevents.AsyncEventService;
@@ -56,7 +57,7 @@ public class AsyncEventServiceImplTest extends AsyncIndexServiceTest {
public QueueManagerFactory queueManagerFactory;
@Inject
- public IndexProcessorFig indexProcessorFig;
+ public EventServiceFig eventServiceFig;
@Inject
public QueueFig queueFig;
@@ -84,9 +85,14 @@ public class AsyncEventServiceImplTest extends AsyncIndexServiceTest {
@Inject
public EntityIndexFactory entityIndexFactory;
+ @Inject
+ public Injector injector;
+
@Override
protected AsyncEventService getAsyncEventService() {
- return new AsyncEventServiceImpl( queueManagerFactory, indexProcessorFig, indexProducer, metricsFactory, entityCollectionManagerFactory, indexLocationStrategyFactory, entityIndexFactory, eventBuilder, mapManagerFactory, queueFig, rxTaskScheduler );
+ return new AsyncEventServiceImpl( queueManagerFactory, eventServiceFig, metricsFactory,
+ entityCollectionManagerFactory, entityIndexFactory, eventBuilder,
+ mapManagerFactory, queueFig, rxTaskScheduler, injector );
}
http://git-wip-us.apache.org/repos/asf/usergrid/blob/5b42c0a6/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/datastax/impl/DataStaxClusterImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/datastax/impl/DataStaxClusterImpl.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/datastax/impl/DataStaxClusterImpl.java
index f926d1e..71aa3b0 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/datastax/impl/DataStaxClusterImpl.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/datastax/impl/DataStaxClusterImpl.java
@@ -185,7 +185,8 @@ public class DataStaxClusterImpl implements DataStaxCluster {
.withPoolingOptions(poolingOptions)
.withQueryOptions(queryOptions)
.withSocketOptions(socketOptions)
- .withProtocolVersion(getProtocolVersion(cassandraFig.getVersion()));
+ .withProtocolVersion(getProtocolVersion(cassandraFig.getVersion()))
+ .withTimestampGenerator(new AtomicMonotonicTimestampGenerator());
// only add auth credentials if they were provided
if ( !cassandraFig.getUsername().isEmpty() && !cassandraFig.getPassword().isEmpty() ){
http://git-wip-us.apache.org/repos/asf/usergrid/blob/5b42c0a6/stack/corepersistence/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/pom.xml b/stack/corepersistence/pom.xml
index fe976bc..e76bc98 100644
--- a/stack/corepersistence/pom.xml
+++ b/stack/corepersistence/pom.xml
@@ -80,11 +80,11 @@ limitations under the License.
<commons.collections.version>3.2.1</commons.collections.version>
<commons.io.version>2.4</commons.io.version>
<commons.lang.version>3.1</commons.lang.version>
- <datastax.version>2.1.9</datastax.version>
+ <datastax.version>2.1.10.3</datastax.version>
<elasticsearch.version>1.4.4</elasticsearch.version>
<fasterxml-uuid.version>3.1.3</fasterxml-uuid.version>
<guava.version>18.0</guava.version>
- <guice.version>4.0-beta5</guice.version>
+ <guice.version>4.0</guice.version>
<guicyfig.version>3.2</guicyfig.version>
<hystrix.version>1.4.0</hystrix.version>
<jackson-2-version>2.4.1</jackson-2-version>
http://git-wip-us.apache.org/repos/asf/usergrid/blob/5b42c0a6/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 b828934..04b8959 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
@@ -44,9 +44,7 @@ public abstract class IndexModule extends AbstractModule {
// install our configuration
install(new GuicyFigModule(IndexFig.class));
-
install(new MapModule());
- install(new QueueModule());
bind( EntityIndexFactory.class ).to( EsEntityIndexFactoryImpl.class );
bind(IndexCache.class).to(EsIndexCacheImpl.class);
http://git-wip-us.apache.org/repos/asf/usergrid/blob/5b42c0a6/stack/pom.xml
----------------------------------------------------------------------
diff --git a/stack/pom.xml b/stack/pom.xml
index 5186a13..15d1499 100644
--- a/stack/pom.xml
+++ b/stack/pom.xml
@@ -102,7 +102,7 @@
<aws.version>1.10.20</aws.version>
<cassandra-version>1.2.18</cassandra-version>
<guava.version>18.0</guava.version>
- <guice.version>4.0-beta5</guice.version>
+ <guice.version>4.0</guice.version>
<hector-om-version>3.0-03</hector-om-version>
<hector-version>1.1-4</hector-version>
<hector-test-version>1.1-4</hector-test-version>
http://git-wip-us.apache.org/repos/asf/usergrid/blob/5b42c0a6/stack/query-validator/src/test/java/org/apache/usergrid/query/validator/users/UserQueryIT.java
----------------------------------------------------------------------
diff --git a/stack/query-validator/src/test/java/org/apache/usergrid/query/validator/users/UserQueryIT.java b/stack/query-validator/src/test/java/org/apache/usergrid/query/validator/users/UserQueryIT.java
index 445d153..027dc56 100644
--- a/stack/query-validator/src/test/java/org/apache/usergrid/query/validator/users/UserQueryIT.java
+++ b/stack/query-validator/src/test/java/org/apache/usergrid/query/validator/users/UserQueryIT.java
@@ -17,10 +17,8 @@
package org.apache.usergrid.query.validator.users;
import net.jcip.annotations.NotThreadSafe;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.apache.usergrid.system.UsergridFeatures;
+import org.junit.*;
import org.apache.usergrid.persistence.Entity;
import org.apache.usergrid.query.validator.AbstractQueryIT;
import org.apache.usergrid.query.validator.QueryRequest;
@@ -30,6 +28,10 @@ import org.apache.usergrid.utils.StringUtils;
import java.util.List;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.junit.Assume.assumeThat;
+import static org.junit.Assume.assumeTrue;
+
/**
* @author Sungju Jin
@@ -42,6 +44,15 @@ public class UserQueryIT extends AbstractQueryIT {
createInitializationDatas("user");
}
+ @Before
+ public void checkFeatures(){
+
+ assumeTrue(UsergridFeatures.isQueryFeatureEnabled());
+
+ }
+
+
+
@Test
public void sexEqualAndNameEqual() {
String sqlite = "SELECT * FROM users WHERE sex = 'male' and name = 'judekim' LIMIT 10";
http://git-wip-us.apache.org/repos/asf/usergrid/blob/5b42c0a6/stack/rest/src/main/java/org/apache/usergrid/rest/AbstractContextResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/AbstractContextResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/AbstractContextResource.java
index 8f5d549..6133a90 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/AbstractContextResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/AbstractContextResource.java
@@ -125,6 +125,9 @@ public abstract class AbstractContextResource {
logger.trace("getSubResource: {}", t.getCanonicalName());
}
T subResource = resourceContext.getResource(t);
+ if(!subResource.isEnabled()){
+ return null;
+ }
subResource.setParent(this);
return subResource;
}
@@ -275,4 +278,10 @@ public abstract class AbstractContextResource {
}
return false;
}
+
+ public boolean isEnabled(){
+
+ return true;
+
+ }
}