You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by to...@apache.org on 2015/11/12 23:14:56 UTC

[06/15] usergrid git commit: Addresses issues found in the review.

Addresses issues found in the review.


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

Branch: refs/heads/master
Commit: 7725d90ec504f2002712636cfcad6a395de21226
Parents: 0e1f0e6
Author: Todd Nine <tn...@apigee.com>
Authored: Thu Nov 12 11:54:12 2015 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Thu Nov 12 11:54:12 2015 -0700

----------------------------------------------------------------------
 .../usergrid/corepersistence/CoreModule.java    | 12 ++++---
 .../corepersistence/rx/impl/ImportRepair.java   | 38 --------------------
 .../rx/impl/ResponseImportTasks.java            | 38 ++++++++++++++++++++
 .../collection/guice/CollectionModule.java      |  4 ++-
 .../impl/EntityCollectionManagerImpl.java       |  3 ++
 .../core/executor/TaskExecutorFactory.java      |  9 ++++-
 .../usergrid/services/AbstractService.java      |  5 ++-
 7 files changed, 62 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/7725d90e/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 09db151..650bb4d 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
@@ -47,7 +47,7 @@ import org.apache.usergrid.corepersistence.rx.impl.AllEntityIdsObservable;
 import org.apache.usergrid.corepersistence.rx.impl.AllEntityIdsObservableImpl;
 import org.apache.usergrid.corepersistence.rx.impl.AllNodesInGraphImpl;
 import org.apache.usergrid.corepersistence.rx.impl.AsyncRepair;
-import org.apache.usergrid.corepersistence.rx.impl.ImportRepair;
+import org.apache.usergrid.corepersistence.rx.impl.ResponseImportTasks;
 import org.apache.usergrid.corepersistence.service.AggregationService;
 import org.apache.usergrid.corepersistence.service.AggregationServiceFactory;
 import org.apache.usergrid.corepersistence.service.AggregationServiceImpl;
@@ -77,6 +77,7 @@ import org.apache.usergrid.persistence.index.guice.IndexModule;
 import com.google.inject.AbstractModule;
 import com.google.inject.Inject;
 import com.google.inject.Provides;
+import com.google.inject.Singleton;
 import com.google.inject.TypeLiteral;
 import com.google.inject.assistedinject.FactoryModuleBuilder;
 import com.google.inject.multibindings.Multibinder;
@@ -200,6 +201,7 @@ public class CoreModule extends AbstractModule {
     @Provides
     @Inject
     @EventExecutionScheduler
+    @Singleton
     public RxTaskScheduler getSqsTaskScheduler( final AsyncEventsSchedulerFig asyncEventsSchedulerFig ) {
 
         final String poolName = asyncEventsSchedulerFig.getIoSchedulerName();
@@ -218,6 +220,7 @@ public class CoreModule extends AbstractModule {
     @Provides
     @Inject
     @AsyncRepair
+    @Singleton
     public RxTaskScheduler getAsyncRepairScheduler( final AsyncEventsSchedulerFig asyncEventsSchedulerFig ) {
 
         final String poolName = asyncEventsSchedulerFig.getRepairPoolName();
@@ -225,7 +228,7 @@ public class CoreModule extends AbstractModule {
 
 
         final ThreadPoolExecutor executor = TaskExecutorFactory
-            .createTaskExecutor( poolName, threadCount, 1, TaskExecutorFactory.RejectionAction.DROP );
+            .createTaskExecutor( poolName, threadCount, 0, TaskExecutorFactory.RejectionAction.DROP );
 
         final RxTaskScheduler taskScheduler = new RxTaskSchedulerImpl( executor );
 
@@ -235,7 +238,8 @@ public class CoreModule extends AbstractModule {
 
     @Provides
     @Inject
-    @ImportRepair
+    @ResponseImportTasks
+    @Singleton
     public RxTaskScheduler getImportRepairScheduler( final AsyncEventsSchedulerFig asyncEventsSchedulerFig ) {
 
         final String poolName = asyncEventsSchedulerFig.getImportSchedulerName();
@@ -243,7 +247,7 @@ public class CoreModule extends AbstractModule {
 
 
         final ThreadPoolExecutor executor = TaskExecutorFactory
-            .createTaskExecutor( poolName, threadCount, 1, TaskExecutorFactory.RejectionAction.CALLERRUNS );
+            .createTaskExecutor( poolName, threadCount, 0, TaskExecutorFactory.RejectionAction.CALLERRUNS );
 
         final RxTaskScheduler taskScheduler = new RxTaskSchedulerImpl( executor );
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/7725d90e/stack/core/src/main/java/org/apache/usergrid/corepersistence/rx/impl/ImportRepair.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/rx/impl/ImportRepair.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/rx/impl/ImportRepair.java
deleted file mode 100644
index d65d04c..0000000
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/rx/impl/ImportRepair.java
+++ /dev/null
@@ -1,38 +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.rx.impl;
-
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import com.google.inject.BindingAnnotation;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-
-/**
- * Label for using the async repair scheduler
- */
-@BindingAnnotation
-@Target({ FIELD, PARAMETER, METHOD }) @Retention(RUNTIME)
-public @interface ImportRepair {
-}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/7725d90e/stack/core/src/main/java/org/apache/usergrid/corepersistence/rx/impl/ResponseImportTasks.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/rx/impl/ResponseImportTasks.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/rx/impl/ResponseImportTasks.java
new file mode 100644
index 0000000..bf74d1f
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/rx/impl/ResponseImportTasks.java
@@ -0,0 +1,38 @@
+/*
+ * 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.rx.impl;
+
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import com.google.inject.BindingAnnotation;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+
+/**
+ * Label for using the async repair scheduler
+ */
+@BindingAnnotation
+@Target({ FIELD, PARAMETER, METHOD }) @Retention(RUNTIME)
+public @interface ResponseImportTasks {
+}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/7725d90e/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/guice/CollectionModule.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/guice/CollectionModule.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/guice/CollectionModule.java
index 0a6e270..d788174 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/guice/CollectionModule.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/guice/CollectionModule.java
@@ -39,6 +39,7 @@ import org.apache.usergrid.persistence.core.rx.RxTaskSchedulerImpl;
 import com.google.inject.AbstractModule;
 import com.google.inject.Inject;
 import com.google.inject.Provides;
+import com.google.inject.Singleton;
 
 
 /**
@@ -77,13 +78,14 @@ public abstract class CollectionModule extends AbstractModule {
     @Provides
     @Inject
     @CollectionExecutorScheduler
+    @Singleton
     public RxTaskScheduler getRxTaskScheduler( final CollectionSchedulerFig collectionSchedulerFig ){
 
         final String poolName = collectionSchedulerFig.getIoSchedulerName();
         final int threadCount = collectionSchedulerFig.getMaxIoThreads();
 
 
-        final ThreadPoolExecutor executor = TaskExecutorFactory.createTaskExecutor( poolName, threadCount, threadCount,
+        final ThreadPoolExecutor executor = TaskExecutorFactory.createTaskExecutor( poolName, threadCount, 0,
             TaskExecutorFactory.RejectionAction.CALLERRUNS );
 
         final RxTaskScheduler taskScheduler = new RxTaskSchedulerImpl(executor  );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/7725d90e/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java
index d6bbdc5..8079ad9 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java
@@ -363,6 +363,9 @@ public class EntityCollectionManagerImpl implements EntityCollectionManager {
                         continue;
                     }
 
+                    //TODO, we need to validate the property in the entity matches the property in the unique value
+
+
                     //else add it to our result set
                     response.addEntity( expectedUnique.getField(), entity );
                 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/7725d90e/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/executor/TaskExecutorFactory.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/executor/TaskExecutorFactory.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/executor/TaskExecutorFactory.java
index bd3d3e9..4ffabf7 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/executor/TaskExecutorFactory.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/executor/TaskExecutorFactory.java
@@ -23,6 +23,7 @@ package org.apache.usergrid.persistence.core.executor;
 import java.util.concurrent.ArrayBlockingQueue;
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.RejectedExecutionHandler;
+import java.util.concurrent.SynchronousQueue;
 import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
@@ -64,7 +65,13 @@ public class TaskExecutorFactory {
                                                          final int maxQueueSize, RejectionAction rejectionAction ) {
 
 
-        final BlockingQueue<Runnable> queue = new ArrayBlockingQueue<Runnable>( maxQueueSize );
+        final BlockingQueue<Runnable> queue;
+
+        if(maxQueueSize == 0){
+            queue = new SynchronousQueue();
+        }else{
+            queue = new ArrayBlockingQueue<>( maxQueueSize );
+        }
 
 
         if ( rejectionAction == RejectionAction.ABORT ) {

http://git-wip-us.apache.org/repos/asf/usergrid/blob/7725d90e/stack/services/src/main/java/org/apache/usergrid/services/AbstractService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/AbstractService.java b/stack/services/src/main/java/org/apache/usergrid/services/AbstractService.java
index 662370f..85c973e 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/AbstractService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/AbstractService.java
@@ -28,8 +28,7 @@ import java.util.UUID;
 
 import com.codahale.metrics.Timer;
 
-import org.apache.usergrid.corepersistence.rx.impl.AsyncRepair;
-import org.apache.usergrid.corepersistence.rx.impl.ImportRepair;
+import org.apache.usergrid.corepersistence.rx.impl.ResponseImportTasks;
 import org.apache.usergrid.corepersistence.service.ServiceSchedulerFig;
 import org.apache.usergrid.persistence.core.metrics.MetricsFactory;
 import org.apache.usergrid.persistence.core.metrics.ObservableTimer;
@@ -121,7 +120,7 @@ public abstract class AbstractService implements Service {
         this.sm = sm;
         em = sm.getEntityManager();
         final Injector injector = sm.getApplicationContext().getBean( Injector.class );
-        rxScheduler = injector.getInstance( Key.get(RxTaskScheduler.class, ImportRepair.class)).getAsyncIOScheduler();
+        rxScheduler = injector.getInstance( Key.get(RxTaskScheduler.class, ResponseImportTasks.class ) ).getAsyncIOScheduler();
         rxSchedulerFig = injector.getInstance(ServiceSchedulerFig.class );
         metricsFactory = injector.getInstance(MetricsFactory.class);
         this.entityGetTimer = metricsFactory.getTimer(this.getClass(), "importEntity.get");