You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2016/06/22 15:25:47 UTC

[1/8] usergrid git commit: auth region is required now

Repository: usergrid
Updated Branches:
  refs/heads/usergrid-1268-akka-211 645512016 -> 4fb807f81


auth region is required now


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

Branch: refs/heads/usergrid-1268-akka-211
Commit: 97aec4d4dfb60c4c708230ca9ad096e2a6d0bd67
Parents: 4394a20
Author: Dave Johnson <sn...@apache.org>
Authored: Sat Jun 18 09:23:16 2016 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Sat Jun 18 09:23:16 2016 -0400

----------------------------------------------------------------------
 .../collection/src/test/resources/usergrid.properties               | 1 +
 stack/rest/src/test/resources/usergrid-custom-test.properties       | 1 +
 2 files changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/97aec4d4/stack/corepersistence/collection/src/test/resources/usergrid.properties
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/resources/usergrid.properties b/stack/corepersistence/collection/src/test/resources/usergrid.properties
index d2650f7..f20dfe8 100644
--- a/stack/corepersistence/collection/src/test/resources/usergrid.properties
+++ b/stack/corepersistence/collection/src/test/resources/usergrid.properties
@@ -7,6 +7,7 @@ collection.akka.hostname=localhost
 collection.akka.port=2551
 collection.akka.region=us-east
 usergrid.queue.regionList=us-east
+collection.akka.uniquevalue.authoritative.region=us-east
 collection.akka.region.seeds=us-east\:localhost\:2551
 
 collection.akka.uniquevalue.actors=300

http://git-wip-us.apache.org/repos/asf/usergrid/blob/97aec4d4/stack/rest/src/test/resources/usergrid-custom-test.properties
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/resources/usergrid-custom-test.properties b/stack/rest/src/test/resources/usergrid-custom-test.properties
index 660e8b8..5c587f4 100644
--- a/stack/rest/src/test/resources/usergrid-custom-test.properties
+++ b/stack/rest/src/test/resources/usergrid-custom-test.properties
@@ -59,6 +59,7 @@ collection.akka.hostname=localhost
 collection.akka.port=2551
 collection.akka.region=us-east
 usergrid.queue.regionList=us-east
+collection.akka.uniquevalue.authoritative.region=us-east
 collection.akka.region.seeds=us-east\:localhost\:2551
 
 collection.akka.uniquevalue.actors=300


[7/8] usergrid git commit: Adding some missing license headers and a RAT config, which was missing from the corepersistence module.

Posted by sn...@apache.org.
Adding some missing license headers and a RAT config, which was missing from the corepersistence module.


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

Branch: refs/heads/usergrid-1268-akka-211
Commit: 96ae317992fb3d5f52b64f0b45cf76248b348ea2
Parents: fb1d78d
Author: Dave Johnson <sn...@apache.org>
Authored: Wed Jun 22 10:47:59 2016 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Wed Jun 22 10:47:59 2016 -0400

----------------------------------------------------------------------
 .../uniquevalues/UniqueValuesServiceImpl.java   |  1 -
 .../core/guice/SettingsValidationCluster.java   | 18 +++++
 .../core/guice/MigrationManagerRule.java        | 18 +++++
 .../guice/SettingsValidationClusterTest.java    | 19 ++++++
 .../src/test/resources/usergrid-UNIT.properties | 19 ++++++
 .../src/test/resources/usergrid.properties      | 19 ++++++
 stack/corepersistence/model/pom.xml             | 24 +++----
 .../persistence/model/entity/EntityMap.java     | 18 +++++
 .../persistence/model/util/EntityUtils.java     | 18 +++++
 .../persistence/model/util/UUIDGenerator.java   | 18 +++++
 .../persistence/model/field/EntityTest.java     | 18 +++++
 .../model/util/UUIDGeneratorTest.java           | 18 +++++
 stack/corepersistence/pom.xml                   | 71 ++++++++++++++++++++
 13 files changed, 266 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/96ae3179/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesServiceImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesServiceImpl.java
index 6035e04..119d6f6 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesServiceImpl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesServiceImpl.java
@@ -31,7 +31,6 @@ import akka.util.Timeout;
 import com.google.inject.Inject;
 import com.google.inject.Injector;
 import com.google.inject.Singleton;
-import org.apache.usergrid.persistence.actorsystem.ActorSystemFig;
 import org.apache.usergrid.persistence.actorsystem.ActorSystemManager;
 import org.apache.usergrid.persistence.actorsystem.GuiceActorProducer;
 import org.apache.usergrid.persistence.core.scope.ApplicationScope;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/96ae3179/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/guice/SettingsValidationCluster.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/guice/SettingsValidationCluster.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/guice/SettingsValidationCluster.java
index f77a86c..95ad216 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/guice/SettingsValidationCluster.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/guice/SettingsValidationCluster.java
@@ -1,3 +1,21 @@
+/*
+ * 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.persistence.core.guice;
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/96ae3179/stack/corepersistence/common/src/test/java/org/apache/usergrid/persistence/core/guice/MigrationManagerRule.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/test/java/org/apache/usergrid/persistence/core/guice/MigrationManagerRule.java b/stack/corepersistence/common/src/test/java/org/apache/usergrid/persistence/core/guice/MigrationManagerRule.java
index ac6c169..7e02a8e 100644
--- a/stack/corepersistence/common/src/test/java/org/apache/usergrid/persistence/core/guice/MigrationManagerRule.java
+++ b/stack/corepersistence/common/src/test/java/org/apache/usergrid/persistence/core/guice/MigrationManagerRule.java
@@ -1,3 +1,21 @@
+/*
+ * 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.persistence.core.guice;
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/96ae3179/stack/corepersistence/common/src/test/java/org/apache/usergrid/persistence/core/guice/SettingsValidationClusterTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/test/java/org/apache/usergrid/persistence/core/guice/SettingsValidationClusterTest.java b/stack/corepersistence/common/src/test/java/org/apache/usergrid/persistence/core/guice/SettingsValidationClusterTest.java
index 262fec7..97b7ac0 100644
--- a/stack/corepersistence/common/src/test/java/org/apache/usergrid/persistence/core/guice/SettingsValidationClusterTest.java
+++ b/stack/corepersistence/common/src/test/java/org/apache/usergrid/persistence/core/guice/SettingsValidationClusterTest.java
@@ -1,3 +1,21 @@
+/*
+ * 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.persistence.core.guice;
 
 import org.apache.usergrid.persistence.core.guicyfig.ClusterFig;
@@ -6,6 +24,7 @@ import org.junit.Test;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+
 /**
  * Created by russo on 8/27/15.
  */

http://git-wip-us.apache.org/repos/asf/usergrid/blob/96ae3179/stack/corepersistence/common/src/test/resources/usergrid-UNIT.properties
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/test/resources/usergrid-UNIT.properties b/stack/corepersistence/common/src/test/resources/usergrid-UNIT.properties
index 2004d9e..c94ea57 100644
--- a/stack/corepersistence/common/src/test/resources/usergrid-UNIT.properties
+++ b/stack/corepersistence/common/src/test/resources/usergrid-UNIT.properties
@@ -1,3 +1,22 @@
+#
+# 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.
+#
+
 # Keep nothing but overriding test defaults in here
 cassandra.connections=50
 cassandra.port=9160

http://git-wip-us.apache.org/repos/asf/usergrid/blob/96ae3179/stack/corepersistence/common/src/test/resources/usergrid.properties
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/test/resources/usergrid.properties b/stack/corepersistence/common/src/test/resources/usergrid.properties
index 015c681..0e954ce 100644
--- a/stack/corepersistence/common/src/test/resources/usergrid.properties
+++ b/stack/corepersistence/common/src/test/resources/usergrid.properties
@@ -1,2 +1,21 @@
+#
+# 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.
+#
+
 # This property is required to be set and cannot be defaulted anywhere
 usergrid.cluster_name=usergrid

http://git-wip-us.apache.org/repos/asf/usergrid/blob/96ae3179/stack/corepersistence/model/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/model/pom.xml b/stack/corepersistence/model/pom.xml
index 2c2b557..5c41340 100644
--- a/stack/corepersistence/model/pom.xml
+++ b/stack/corepersistence/model/pom.xml
@@ -1,19 +1,19 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
-    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
+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
+    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.
+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.
 -->
 <project xmlns="http://maven.apache.org/POM/4.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

http://git-wip-us.apache.org/repos/asf/usergrid/blob/96ae3179/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/EntityMap.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/EntityMap.java b/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/EntityMap.java
index 5c8fd77..bb89f12 100644
--- a/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/EntityMap.java
+++ b/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/entity/EntityMap.java
@@ -1,3 +1,21 @@
+/*
+ * 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.persistence.model.entity;
 
 import com.google.common.base.*;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/96ae3179/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/util/EntityUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/util/EntityUtils.java b/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/util/EntityUtils.java
index 929a563..76d5d7d 100644
--- a/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/util/EntityUtils.java
+++ b/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/util/EntityUtils.java
@@ -1,3 +1,21 @@
+/*
+ * 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.persistence.model.util;
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/96ae3179/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/util/UUIDGenerator.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/util/UUIDGenerator.java b/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/util/UUIDGenerator.java
index 176c97b..9e4b306 100644
--- a/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/util/UUIDGenerator.java
+++ b/stack/corepersistence/model/src/main/java/org/apache/usergrid/persistence/model/util/UUIDGenerator.java
@@ -1,3 +1,21 @@
+/*
+ * 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.persistence.model.util;
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/96ae3179/stack/corepersistence/model/src/test/java/org/apache/usergrid/persistence/model/field/EntityTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/model/src/test/java/org/apache/usergrid/persistence/model/field/EntityTest.java b/stack/corepersistence/model/src/test/java/org/apache/usergrid/persistence/model/field/EntityTest.java
index 06b8030..89ffb3e 100644
--- a/stack/corepersistence/model/src/test/java/org/apache/usergrid/persistence/model/field/EntityTest.java
+++ b/stack/corepersistence/model/src/test/java/org/apache/usergrid/persistence/model/field/EntityTest.java
@@ -1,3 +1,21 @@
+/*
+ * 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.persistence.model.field;
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/96ae3179/stack/corepersistence/model/src/test/java/org/apache/usergrid/persistence/model/util/UUIDGeneratorTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/model/src/test/java/org/apache/usergrid/persistence/model/util/UUIDGeneratorTest.java b/stack/corepersistence/model/src/test/java/org/apache/usergrid/persistence/model/util/UUIDGeneratorTest.java
index 509e80f..143f9ae 100644
--- a/stack/corepersistence/model/src/test/java/org/apache/usergrid/persistence/model/util/UUIDGeneratorTest.java
+++ b/stack/corepersistence/model/src/test/java/org/apache/usergrid/persistence/model/util/UUIDGeneratorTest.java
@@ -1,3 +1,21 @@
+/*
+ * 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.persistence.model.util;
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/96ae3179/stack/corepersistence/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/pom.xml b/stack/corepersistence/pom.xml
index 5d4ccac..7ff5dfe 100644
--- a/stack/corepersistence/pom.xml
+++ b/stack/corepersistence/pom.xml
@@ -219,6 +219,77 @@ limitations under the License.
                 <artifactId>jacoco-maven-plugin</artifactId>
             </plugin>
 
+            <!--<plugin>-->
+                <!--<groupId>org.apache.rat</groupId>-->
+                <!--<artifactId>apache-rat-plugin</artifactId>-->
+                <!--<executions>-->
+                    <!--<execution>-->
+                        <!--<phase>verify</phase>-->
+                        <!--<goals>-->
+                            <!--<goal>check</goal>-->
+                        <!--</goals>-->
+                    <!--</execution>-->
+                <!--</executions>-->
+                <!--<configuration>-->
+                    <!--<excludes>-->
+                        <!--<exclude>**/Coverage.md</exclude>-->
+                        <!--<exclude>**/jacoco/**</exclude>-->
+                        <!--<exclude>**/README.md</exclude>-->
+                        <!--<exclude>**/CHANGES.txt</exclude>-->
+                        <!--<exclude>**/*.json</exclude>-->
+                        <!--<exclude>**/*.log</exclude>-->
+                        <!--<exclude>**/*.md5</exclude>-->
+                        <!--<exclude>**/*.opts</exclude>-->
+
+                        <!--&lt;!&ndash; git and IDE project files &ndash;&gt;-->
+                        <!--<exclude>**/.git/**</exclude>-->
+                        <!--<exclude>**/.gitignore</exclude>-->
+                        <!--<exclude>**/.idea/**</exclude>-->
+                        <!--<exclude>**/*.iml</exclude>-->
+                        <!--<exclude>**/*.log</exclude>-->
+                        <!--<exclude>**/nbactions.xml</exclude>-->
+                        <!--<exclude>**/nb-configuration.xml</exclude>-->
+                        <!--<exclude>**/.classpath/**</exclude>-->
+                        <!--<exclude>**/.project</exclude>-->
+                        <!--<exclude>**/.settings/**</exclude>-->
+
+                        <!--&lt;!&ndash; temporary build files &ndash;&gt;-->
+                        <!--<exclude>**/logs/**</exclude>-->
+                        <!--<exclude>**/docs/**</exclude>-->
+                        <!--<exclude>**/tmp/**</exclude>-->
+                        <!--<exclude>**/target/**</exclude>-->
+                        <!--<exclude>**/antlr3/**</exclude>-->
+                        <!--<exclude>**/META-INF/**</exclude>-->
+                        <!--<exclude>**/dependency-reduced-pom.xml</exclude>-->
+                        <!--<exclude>**/**QueryFilter.tokens</exclude>-->
+                        <!--<exclude>**/**QueryFilterLexer.java</exclude>-->
+                        <!--<exclude>**/**QueryFilterParser.java</exclude>-->
+                        <!--<exclude>**/**.conf</exclude>-->
+                        <!--<exclude>**/**.csv</exclude>-->
+                        <!--<exclude>**/aws.properties</exclude>-->
+                        <!--<exclude>**/tempExport*</exclude>-->
+                        <!--<exclude>loadtests/loadtest_setup.sh</exclude>-->
+                        <!--<exclude>loadtests/gatling/user-files/request-bodies/**</exclude>-->
+                        <!--<exclude>loadtests/.java-version</exclude>-->
+
+                        <!--&lt;!&ndash; gatling loadtest data files &ndash;&gt;-->
+                        <!--<exclude>loadtests/src/main/scala/org/apache/usergrid/datagenerators/datafiles/**.txt</exclude>-->
+                        <!--<exclude>loadtests/src/main/scala/org/apache/usergrid/datagenerators/**.txt</exclude>-->
+                        <!--<exclude>loadtests/src/test/resources/**.csv</exclude>-->
+
+                        <!--&lt;!&ndash; other &ndash;&gt;-->
+                        <!--<exclude>**/catalina_base/**</exclude>-->
+                        <!--<exclude>**/m2/**</exclude>-->
+                        <!--<exclude>**/*.asc</exclude>-->
+                        <!--<exclude>**/dummy.txt</exclude>-->
+                        <!--<exclude>**/cloudbees.xml</exclude>-->
+                        <!--<exclude>**/catalina_base/**</exclude>-->
+
+                    <!--</excludes>-->
+                <!--</configuration>-->
+
+            <!--</plugin>-->
+
         </plugins>
 
         <resources>


[6/8] usergrid git commit: Move cluster-singleton router config into RouterProducer and out of actorsystem module.

Posted by sn...@apache.org.
Move cluster-singleton router config into RouterProducer and out of actorsystem module.


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

Branch: refs/heads/usergrid-1268-akka-211
Commit: fb1d78d0469c33067ba415cafa44540c5185dd61
Parents: 343ac51
Author: Dave Johnson <sn...@apache.org>
Authored: Wed Jun 22 10:33:30 2016 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Wed Jun 22 10:33:30 2016 -0400

----------------------------------------------------------------------
 .../persistence/actorsystem/ActorSystemFig.java | 29 ++-------
 .../actorsystem/ActorSystemManagerImpl.java     | 38 +++++------
 .../persistence/actorsystem/RouterProducer.java |  6 +-
 .../src/main/resources/application.conf         | 25 ++++++--
 .../collection/guice/CollectionModule.java      |  1 +
 .../uniquevalues/UniqueValuesFig.java           | 67 ++++++++++++++++++++
 .../uniquevalues/UniqueValuesServiceImpl.java   | 42 ++++++++++--
 .../uniquevalues/UniqueValuesTableImpl.java     |  8 +--
 .../src/test/resources/usergrid.properties      |  2 +-
 9 files changed, 160 insertions(+), 58 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/fb1d78d0/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ActorSystemFig.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ActorSystemFig.java b/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ActorSystemFig.java
index 50e860b..ec010d0 100644
--- a/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ActorSystemFig.java
+++ b/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ActorSystemFig.java
@@ -26,6 +26,7 @@ import org.safehaus.guicyfig.Key;
 
 import java.io.Serializable;
 
+
 @FigSingleton
 public interface ActorSystemFig extends GuicyFig, Serializable {
 
@@ -39,13 +40,10 @@ public interface ActorSystemFig extends GuicyFig, Serializable {
 
     String AKKA_REGION_SEEDS = "collection.akka.region.seeds";
 
-    String AKKA_UNIQUEVALUE_ACTORS = "collection.akka.uniquevalue.actors";
-
-    String AKKA_UNIQUEVALUE_CACHE_TTL = "collection.akka.uniquevalue.cache.ttl";
+    String AKKA_AUTHORITATIVE_REGION = "collection.akka.authoritative.region";
 
-    String AKKA_UNIQUEVALUE_RESERVATION_TTL= "collection.akka.uniquevalue.reservation.ttl";
+    String AKKA_INSTANCES_PER_NODE = "collection.akka.instances-per-node";
 
-    String AKKA_AUTHORITATIVE_REGION = "collection.akka.uniquevalue.authoritative.region";
 
     /**
      * Use Akka or nah
@@ -73,13 +71,6 @@ public interface ActorSystemFig extends GuicyFig, Serializable {
     String getRegionList();
 
     /**
-     * Number of UniqueValueActors to be started on each node
-     */
-    @Key(AKKA_UNIQUEVALUE_ACTORS)
-    @Default("300")
-    int getUniqueValueActors();
-
-    /**
      * Comma-separated lists of seeds each with format {region}:{hostname}:{port}.
      * Regions MUST be listed in the 'usergrid.queue.regionList'
      */
@@ -92,17 +83,11 @@ public interface ActorSystemFig extends GuicyFig, Serializable {
     @Key(AKKA_AUTHORITATIVE_REGION)
     String getAkkaAuthoritativeRegion();
 
-    /**
-     * Unique Value cache TTL in seconds.
-     */
-    @Key(AKKA_UNIQUEVALUE_CACHE_TTL)
-    @Default("10")
-    int getUniqueValueCacheTtl();
 
     /**
-     * Unique Value Reservation TTL in seconds.
+     * Number of actor instances to create on each node for each router.
      */
-    @Key(AKKA_UNIQUEVALUE_RESERVATION_TTL)
-    @Default("10")
-    int getUniqueValueReservationTtl();
+    @Key(AKKA_INSTANCES_PER_NODE)
+    @Default("300")
+    int getInstancesPerNode();
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/fb1d78d0/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ActorSystemManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ActorSystemManagerImpl.java b/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ActorSystemManagerImpl.java
index b3af978..1f7bf70 100644
--- a/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ActorSystemManagerImpl.java
+++ b/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ActorSystemManagerImpl.java
@@ -223,7 +223,7 @@ public class ActorSystemManagerImpl implements ActorSystemManager {
                 }
             }
 
-            int numInstancesPerNode = actorSystemFig.getUniqueValueActors();
+            int numInstancesPerNode = actorSystemFig.getInstancesPerNode();
 
             // read config file once for each region
 
@@ -236,15 +236,16 @@ public class ActorSystemManagerImpl implements ActorSystemManager {
                 // cluster singletons only run role "io" nodes and NOT on "client" nodes of other regions
                 String clusterRole = currentRegion.equals( region ) ? "io" : "client";
 
-                logger.info( "Config for region {} is:\n" +
-                        "   Akka Hostname {}\n" +
-                        "   Akka Seeds {}\n" +
-                        "   Akka UniqueValueActors per node {}\n" +
-                        "   Akka Authoritative Region {}",
-                    region, hostname, seeds, port, numInstancesPerNode, actorSystemFig.getAkkaAuthoritativeRegion() );
+                logger.info( "Akka Config for region {} is:\n" +
+                        "   Hostname {}\n" +
+                        "   Seeds {}\n" +
+                        "   Authoritative Region {}\n",
+                    region, hostname, seeds, actorSystemFig.getAkkaAuthoritativeRegion() );
 
                 Map<String, Object> configMap = new HashMap<String, Object>() {{
+
                     put( "akka", new HashMap<String, Object>() {{
+
                         put( "remote", new HashMap<String, Object>() {{
                             put( "netty.tcp", new HashMap<String, Object>() {{
                                 put( "hostname", hostname );
@@ -252,8 +253,9 @@ public class ActorSystemManagerImpl implements ActorSystemManager {
                                 put( "port", regionPort );
                             }} );
                         }} );
+
                         put( "cluster", new HashMap<String, Object>() {{
-                            put( "max-nr-of-instances-per-node", numInstancesPerNode );
+                            put( "max-nr-of-instances-per-node", 300);
                             put( "roles", Collections.singletonList(clusterRole) );
                             put( "seed-nodes", new ArrayList<String>() {{
                                 for (String seed : seeds) {
@@ -262,24 +264,16 @@ public class ActorSystemManagerImpl implements ActorSystemManager {
                             }} );
                         }} );
 
-                        // TODO: allow RouterProducers to add in router-specific stuff like this:
-                        put( "actor", new HashMap<String, Object>() {{
-                            put( "deployment", new HashMap<String, Object>() {{
-                                put( "/uvRouter/singleton/router", new HashMap<String, Object>() {{
-                                    put( "cluster", new HashMap<String, Object>() {{
-                                        //put( "roles", Collections.singletonList(role) );
-                                        put( "max-nr-of-instances-per-node", numInstancesPerNode );
-                                    }} );
-                                }} );
-                            }} );
-                        }} );
                     }} );
                 }};
 
-                Config config = ConfigFactory
-                    .parseMap( configMap )
+                for ( RouterProducer routerProducer : routerProducers ) {
+                    routerProducer.addConfiguration( configMap );
+                }
+
+                Config config = ConfigFactory.parseMap( configMap )
                     .withFallback( ConfigFactory.parseString( "akka.cluster.roles = [io]" ) )
-                    .withFallback( ConfigFactory.load( "cluster-singleton" ) );
+                    .withFallback( ConfigFactory.load( "application.conf" ) );
 
                 configs.put( region, config );
             }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/fb1d78d0/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/RouterProducer.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/RouterProducer.java b/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/RouterProducer.java
index ac2c7ee..3aa91cf 100644
--- a/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/RouterProducer.java
+++ b/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/RouterProducer.java
@@ -19,7 +19,6 @@
 package org.apache.usergrid.persistence.actorsystem;
 
 import akka.actor.ActorSystem;
-
 import java.util.Map;
 
 
@@ -42,4 +41,9 @@ public interface RouterProducer {
      */
     void createLocalSystemActors( ActorSystem localSystem, Map<String, ActorSystem> systemMap );
 
+    /**
+     * Add configuration for the router to configuration map
+     */
+    void addConfiguration( Map<String, Object> configMap );
+
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/fb1d78d0/stack/corepersistence/actorsystem/src/main/resources/application.conf
----------------------------------------------------------------------
diff --git a/stack/corepersistence/actorsystem/src/main/resources/application.conf b/stack/corepersistence/actorsystem/src/main/resources/application.conf
index 93854f9..a243163 100644
--- a/stack/corepersistence/actorsystem/src/main/resources/application.conf
+++ b/stack/corepersistence/actorsystem/src/main/resources/application.conf
@@ -1,13 +1,30 @@
+# 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.
+
 akka {
-  
+
   loggers = ["akka.event.slf4j.Slf4jLogger"]
   loglevel = "ERROR"
   logging-filter = "akka.event.slf4j.Slf4jLoggingFilter"
-  
+
   actor {
     provider = "akka.cluster.ClusterActorRefProvider"
   }
-  
+
   remote {
     log-remote-lifecycle-events = off
     netty.tcp {
@@ -24,5 +41,5 @@ akka.cluster.metrics.enabled=off
 akka.extensions=["akka.cluster.metrics.ClusterMetricsExtension", "akka.cluster.pubsub.DistributedPubSub"]
 
 # Sigar native library extract location during tests.
-# Note: use per-jvm-instance folder when running multiple jvm on one host. 
+# Note: use per-jvm-instance folder when running multiple jvm on one host.
 akka.cluster.metrics.native-library-extract-folder=${user.dir}/target/native

http://git-wip-us.apache.org/repos/asf/usergrid/blob/fb1d78d0/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 ae73e47..daf3fdc 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
@@ -59,6 +59,7 @@ public abstract class CollectionModule extends AbstractModule {
         // noinspection unchecked
         install( new GuicyFigModule( SerializationFig.class ) );
         install( new GuicyFigModule( CollectionSchedulerFig.class ) );
+        install( new GuicyFigModule( UniqueValuesFig.class ) );
         install( new SerializationModule() );
         install( new ServiceModule() );
         install( new ActorSystemModule() );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/fb1d78d0/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesFig.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesFig.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesFig.java
new file mode 100644
index 0000000..c99824f
--- /dev/null
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesFig.java
@@ -0,0 +1,67 @@
+/*
+ * 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.persistence.collection.uniquevalues;
+
+import org.safehaus.guicyfig.Default;
+import org.safehaus.guicyfig.FigSingleton;
+import org.safehaus.guicyfig.GuicyFig;
+import org.safehaus.guicyfig.Key;
+import java.io.Serializable;
+
+
+@FigSingleton
+public interface UniqueValuesFig extends GuicyFig, Serializable {
+
+    String AKKA_UNIQUEVALUE_ACTORS = "collection.akka.uniquevalue.actors";
+
+    String AKKA_UNIQUEVALUE_CACHE_TTL = "collection.akka.uniquevalue.cache.ttl";
+
+    String AKKA_UNIQUEVALUE_RESERVATION_TTL= "collection.akka.uniquevalue.reservation.ttl";
+
+    String AKKA_UNIQUEVALUE_INSTANCES_PER_NODE = "collection.akka.uniquevalue.instances-per-node";
+
+
+    /**
+     * Number of UniqueValueActors to be started on each node
+     */
+    @Key(AKKA_UNIQUEVALUE_ACTORS)
+    @Default("300")
+    int getUniqueValueActors();
+
+    /**
+     * Unique Value cache TTL in seconds.
+     */
+    @Key(AKKA_UNIQUEVALUE_CACHE_TTL)
+    @Default("10")
+    int getUniqueValueCacheTtl();
+
+    /**
+     * Unique Value Reservation TTL in seconds.
+     */
+    @Key(AKKA_UNIQUEVALUE_RESERVATION_TTL)
+    @Default("10")
+    int getUniqueValueReservationTtl();
+
+    /**
+     * Number of actor instances to create on each.
+     */
+    @Key(AKKA_UNIQUEVALUE_INSTANCES_PER_NODE)
+    @Default("300")
+    int getUniqueValueInstancesPerNode();
+}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/fb1d78d0/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesServiceImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesServiceImpl.java
index 85b9d1a..6035e04 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesServiceImpl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesServiceImpl.java
@@ -42,6 +42,7 @@ import org.slf4j.LoggerFactory;
 import scala.concurrent.Await;
 import scala.concurrent.Future;
 
+import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
 import java.util.concurrent.TimeUnit;
@@ -52,7 +53,7 @@ public class UniqueValuesServiceImpl implements UniqueValuesService {
     private static final Logger logger = LoggerFactory.getLogger( UniqueValuesServiceImpl.class );
 
     static Injector          injector;
-    ActorSystemFig           actorSystemFig;
+    UniqueValuesFig          uniqueValuesFig;
     ActorSystemManager       actorSystemManager;
     UniqueValuesTable        table;
     private ReservationCache reservationCache;
@@ -61,16 +62,16 @@ public class UniqueValuesServiceImpl implements UniqueValuesService {
     @Inject
     public UniqueValuesServiceImpl(
         Injector inj,
-        ActorSystemFig actorSystemFig,
+        UniqueValuesFig uniqueValuesFig,
         ActorSystemManager actorSystemManager,
         UniqueValuesTable table ) {
 
         injector = inj;
         this.actorSystemManager = actorSystemManager;
-        this.actorSystemFig = actorSystemFig;
+        this.uniqueValuesFig = uniqueValuesFig;
         this.table = table;
 
-        ReservationCache.init( actorSystemFig.getUniqueValueCacheTtl() );
+        ReservationCache.init( uniqueValuesFig.getUniqueValueCacheTtl() );
         this.reservationCache = ReservationCache.getInstance();
     }
 
@@ -300,4 +301,37 @@ public class UniqueValuesServiceImpl implements UniqueValuesService {
     public void createLocalSystemActors( ActorSystem localSystem, Map<String, ActorSystem> systemMap ) {
         subscribeToReservations( localSystem, systemMap );
     }
+
+    @Override
+    public void addConfiguration(Map<String, Object> configMap) {
+
+        int numInstancesPerNode = uniqueValuesFig.getUniqueValueInstancesPerNode();
+
+        // TODO: will the below overwrite things other routers have added under "actor.deployment"?
+
+        Map<String, Object> akka = (Map<String, Object>)configMap.get("akka");
+
+        akka.put( "actor", new HashMap<String, Object>() {{
+            put( "deployment", new HashMap<String, Object>() {{
+                put( "/uvRouter/singleton/router", new HashMap<String, Object>() {{
+                    put( "router", "consistent-hashing-pool" );
+                    put( "cluster", new HashMap<String, Object>() {{
+                        put( "enabled", "on" );
+                        put( "allow-local-routees", "on" );
+                        put( "user-role", "io" );
+                        put( "max-nr-of-instances-per-node", numInstancesPerNode );
+                        put( "failure-detector", new HashMap<String, Object>() {{
+                            put( "threshold", "" );
+                            put( "acceptable-heartbeat-pause", "3 s" );
+                            put( "heartbeat-interval", "1 s" );
+                            put( "heartbeat-request", new HashMap<String, Object>() {{
+                                put( "expected-response-after", "3 s" );
+                            }} );
+                        }} );
+                    }} );
+                }} );
+            }} );
+        }} );
+
+    }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/fb1d78d0/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesTableImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesTableImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesTableImpl.java
index de326dd..9cb13be 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesTableImpl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesTableImpl.java
@@ -42,12 +42,12 @@ public class UniqueValuesTableImpl implements UniqueValuesTable {
     private static final Logger logger = LoggerFactory.getLogger( UniqueValuesTableImpl.class );
 
     final UniqueValueSerializationStrategy strat;
-    final ActorSystemFig actorSystemFig;
+    final UniqueValuesFig uniqueValuesFig;
 
     @Inject
-    public UniqueValuesTableImpl( final UniqueValueSerializationStrategy strat, ActorSystemFig actorSystemFig) {
+    public UniqueValuesTableImpl( final UniqueValueSerializationStrategy strat, UniqueValuesFig uniqueValuesFig) {
         this.strat = strat;
-        this.actorSystemFig = actorSystemFig;
+        this.uniqueValuesFig = uniqueValuesFig;
     }
 
 
@@ -63,7 +63,7 @@ public class UniqueValuesTableImpl implements UniqueValuesTable {
     public void reserve( ApplicationScope scope, Id owner, UUID version, Field field ) throws ConnectionException {
 
         UniqueValue uv = new UniqueValueImpl( field, owner, version);
-        final MutationBatch write = strat.write( scope, uv, actorSystemFig.getUniqueValueReservationTtl() );
+        final MutationBatch write = strat.write( scope, uv, uniqueValuesFig.getUniqueValueReservationTtl() );
         write.execute();
     }
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/fb1d78d0/stack/corepersistence/collection/src/test/resources/usergrid.properties
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/resources/usergrid.properties b/stack/corepersistence/collection/src/test/resources/usergrid.properties
index f20dfe8..759a3b3 100644
--- a/stack/corepersistence/collection/src/test/resources/usergrid.properties
+++ b/stack/corepersistence/collection/src/test/resources/usergrid.properties
@@ -7,7 +7,7 @@ collection.akka.hostname=localhost
 collection.akka.port=2551
 collection.akka.region=us-east
 usergrid.queue.regionList=us-east
-collection.akka.uniquevalue.authoritative.region=us-east
+collection.akka.authoritative.region=us-east
 collection.akka.region.seeds=us-east\:localhost\:2551
 
 collection.akka.uniquevalue.actors=300


[2/8] usergrid git commit: Unique values test passes with new "actor system" module

Posted by sn...@apache.org.
http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/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 3cc4a07..dea0b0c 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
@@ -27,6 +27,7 @@ import java.util.List;
 import java.util.UUID;
 
 import com.netflix.astyanax.model.ConsistencyLevel;
+import org.apache.usergrid.persistence.actorsystem.ActorSystemManager;
 import org.apache.usergrid.persistence.collection.uniquevalues.UniqueValuesService;
 import org.apache.usergrid.persistence.collection.serialization.impl.LogEntryIterator;
 import org.slf4j.Logger;
@@ -125,6 +126,7 @@ public class EntityCollectionManagerImpl implements EntityCollectionManager {
     private final RxTaskScheduler rxTaskScheduler;
 
     private final UniqueValuesService uniqueValuesService;
+    private final ActorSystemManager actorSystemManager;
 
 
     @Inject
@@ -144,6 +146,7 @@ public class EntityCollectionManagerImpl implements EntityCollectionManager {
                                         final MetricsFactory metricsFactory,
                                         final SerializationFig serializationFig,
                                         final RxTaskScheduler rxTaskScheduler,
+                                        ActorSystemManager actorSystemManager,
                                         UniqueValuesService uniqueValuesService,
                                         @Assisted final ApplicationScope applicationScope ) {
 
@@ -154,6 +157,7 @@ public class EntityCollectionManagerImpl implements EntityCollectionManager {
         this.serializationFig = serializationFig;
         this.rxTaskScheduler = rxTaskScheduler;
 
+        this.actorSystemManager = actorSystemManager;
         this.uniqueValuesService = uniqueValuesService;
 
         ValidationUtils.validateApplicationScope( applicationScope );
@@ -255,7 +259,8 @@ public class EntityCollectionManagerImpl implements EntityCollectionManager {
 
         Preconditions.checkNotNull( entityIds, "entityIds cannot be null" );
 
-        final Observable<EntitySet> entitySetObservable = Observable.create( new Observable.OnSubscribe<EntitySet>() {
+        final Observable<EntitySet> entitySetObservable =
+            Observable.create( new Observable.OnSubscribe<EntitySet>() {
 
             @Override
             public void call( final Subscriber<? super EntitySet> subscriber ) {
@@ -461,7 +466,8 @@ public class EntityCollectionManagerImpl implements EntityCollectionManager {
     public Observable<VersionSet> getLatestVersion( final Collection<Id> entityIds ) {
 
 
-        final Observable<VersionSet> observable =  Observable.create( new Observable.OnSubscribe<VersionSet>() {
+        final Observable<VersionSet> observable =
+            Observable.create( new Observable.OnSubscribe<VersionSet>() {
 
             @Override
             public void call( final Subscriber<? super VersionSet> subscriber ) {
@@ -506,17 +512,4 @@ public class EntityCollectionManagerImpl implements EntityCollectionManager {
 
         return Health.RED;
     }
-
-
-    @Override
-    public void startAkkaForTesting( String hostname, int port, String region ) {
-        try {
-            uniqueValuesService.start( hostname, port, region );
-            uniqueValuesService.waitForRequestActors();
-
-        } catch (Throwable t) {
-            logger.error("Error starting Akka", t);
-            throw t;
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteCommit.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteCommit.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteCommit.java
index 44028ae..267e793 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteCommit.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteCommit.java
@@ -22,8 +22,8 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
 
+import org.apache.usergrid.persistence.actorsystem.ActorSystemFig;
 import org.apache.usergrid.persistence.collection.exception.WriteUniqueVerifyException;
-import org.apache.usergrid.persistence.collection.uniquevalues.AkkaFig;
 import org.apache.usergrid.persistence.collection.uniquevalues.UniqueValueException;
 import org.apache.usergrid.persistence.collection.uniquevalues.UniqueValuesService;
 import org.slf4j.Logger;
@@ -66,7 +66,7 @@ public class WriteCommit implements Func1<CollectionIoEvent<MvccEntity>, Collect
 
     private static final Logger logger = LoggerFactory.getLogger( WriteCommit.class );
 
-    AkkaFig akkaFig;
+    ActorSystemFig actorSystemFig;
     UniqueValuesService akkaUvService;
 
     @Inject
@@ -81,7 +81,7 @@ public class WriteCommit implements Func1<CollectionIoEvent<MvccEntity>, Collect
     public WriteCommit( final MvccLogEntrySerializationStrategy logStrat,
                         final MvccEntitySerializationStrategy entryStrat,
                         final UniqueValueSerializationStrategy uniqueValueStrat,
-                        final AkkaFig akkaFig,
+                        final ActorSystemFig actorSystemFig,
                         final UniqueValuesService akkaUvService ) {
 
         Preconditions.checkNotNull( logStrat, "MvccLogEntrySerializationStrategy is required" );
@@ -91,7 +91,7 @@ public class WriteCommit implements Func1<CollectionIoEvent<MvccEntity>, Collect
         this.logEntryStrat = logStrat;
         this.entityStrat = entryStrat;
         this.uniqueValueStrat = uniqueValueStrat;
-        this.akkaFig = akkaFig;
+        this.actorSystemFig = actorSystemFig;
         this.akkaUvService = akkaUvService;
     }
 
@@ -130,10 +130,10 @@ public class WriteCommit implements Func1<CollectionIoEvent<MvccEntity>, Collect
         logMutation.mergeShallow( entityMutation );
 
         // akkaFig may be null when this is called from JUnit tests
-        if ( akkaFig != null && akkaFig.getAkkaEnabled() ) {
+        if ( actorSystemFig != null && actorSystemFig.getAkkaEnabled() ) {
             String region = ioEvent.getRegion();
             if ( region == null ) {
-                region = akkaFig.getAkkaAuthoritativeRegion();
+                region = actorSystemFig.getAkkaAuthoritativeRegion();
             }
             confirmUniqueFieldsAkka( mvccEntity, version, applicationScope, region );
         } else {

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerify.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerify.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerify.java
index da394f7..848ed2e 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerify.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerify.java
@@ -29,6 +29,7 @@ import com.netflix.hystrix.HystrixCommand;
 import com.netflix.hystrix.HystrixCommandGroupKey;
 import com.netflix.hystrix.HystrixCommandProperties;
 import com.netflix.hystrix.HystrixThreadPoolProperties;
+import org.apache.usergrid.persistence.actorsystem.ActorSystemFig;
 import org.apache.usergrid.persistence.collection.MvccEntity;
 import org.apache.usergrid.persistence.collection.exception.WriteUniqueVerifyException;
 import org.apache.usergrid.persistence.collection.mvcc.entity.MvccValidationUtils;
@@ -38,7 +39,6 @@ import org.apache.usergrid.persistence.collection.serialization.UniqueValue;
 import org.apache.usergrid.persistence.collection.serialization.UniqueValueSerializationStrategy;
 import org.apache.usergrid.persistence.collection.serialization.UniqueValueSet;
 import org.apache.usergrid.persistence.collection.serialization.impl.UniqueValueImpl;
-import org.apache.usergrid.persistence.collection.uniquevalues.AkkaFig;
 import org.apache.usergrid.persistence.collection.uniquevalues.UniqueValueException;
 import org.apache.usergrid.persistence.collection.uniquevalues.UniqueValuesService;
 import org.apache.usergrid.persistence.core.astyanax.CassandraConfig;
@@ -65,7 +65,7 @@ public class WriteUniqueVerify implements Action1<CollectionIoEvent<MvccEntity>>
 
     private static final Logger logger = LoggerFactory.getLogger( WriteUniqueVerify.class );
 
-    AkkaFig akkaFig;
+    ActorSystemFig actorSystemFig;
     UniqueValuesService akkaUvService;
 
     private final UniqueValueSerializationStrategy uniqueValueStrat;
@@ -85,12 +85,12 @@ public class WriteUniqueVerify implements Action1<CollectionIoEvent<MvccEntity>>
                              final SerializationFig serializationFig,
                              final Keyspace keyspace,
                              final CassandraConfig cassandraFig,
-                             final AkkaFig akkaFig,
+                             final ActorSystemFig actorSystemFig,
                              final UniqueValuesService akkaUvService ) {
 
         this.keyspace = keyspace;
         this.cassandraFig = cassandraFig;
-        this.akkaFig = akkaFig;
+        this.actorSystemFig = actorSystemFig;
         this.akkaUvService = akkaUvService;
 
         Preconditions.checkNotNull( uniqueValueSerializiationStrategy, "uniqueValueSerializationStrategy is required" );
@@ -105,7 +105,7 @@ public class WriteUniqueVerify implements Action1<CollectionIoEvent<MvccEntity>>
 
     @Override
     public void call( final CollectionIoEvent<MvccEntity> ioevent ) {
-        if ( akkaFig != null && akkaFig.getAkkaEnabled() ) {
+        if ( actorSystemFig != null && actorSystemFig.getAkkaEnabled() ) {
             verifyUniqueFieldsAkka( ioevent );
         } else {
             verifyUniqueFields( ioevent );
@@ -124,7 +124,7 @@ public class WriteUniqueVerify implements Action1<CollectionIoEvent<MvccEntity>>
 
         String region = ioevent.getRegion();
         if ( region == null ) {
-            region = akkaFig.getAkkaAuthoritativeRegion();
+            region = actorSystemFig.getAkkaAuthoritativeRegion();
         }
         try {
             akkaUvService.reserveUniqueValues( applicationScope, entity, mvccEntity.getVersion(), region );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/AkkaFig.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/AkkaFig.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/AkkaFig.java
deleted file mode 100644
index 0f97403..0000000
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/AkkaFig.java
+++ /dev/null
@@ -1,116 +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.persistence.collection.uniquevalues;
-
-
-import org.safehaus.guicyfig.Default;
-import org.safehaus.guicyfig.FigSingleton;
-import org.safehaus.guicyfig.GuicyFig;
-import org.safehaus.guicyfig.Key;
-
-import java.io.Serializable;
-
-@FigSingleton
-public interface AkkaFig extends GuicyFig, Serializable {
-
-    String AKKA_ENABLED = "collection.akka.enabled";
-
-    String AKKA_HOSTNAME = "collection.akka.hostname";
-
-    String AKKA_PORT = "collection.akka.port";
-
-    String AKKA_REGION = "collection.akka.region";
-
-    String AKKA_REGION_LIST = "usergrid.queue.regionList"; // same region list used by queues
-
-    String AKKA_REGION_SEEDS = "collection.akka.region.seeds";
-
-    String AKKA_UNIQUEVALUE_ACTORS = "collection.akka.uniquevalue.actors";
-
-    String AKKA_UNIQUEVALUE_CACHE_TTL = "collection.akka.uniquevalue.cache.ttl";
-
-    String AKKA_UNIQUEVALUE_RESERVATION_TTL= "collection.akka.uniquevalue.reservation.ttl";
-
-    String AKKA_AUTHORITATIVE_REGION = "collection.akka.uniquevalue.authoritative.region";
-
-    /**
-     * Use Akka or nah
-     */
-    @Key(AKKA_ENABLED)
-    @Default("true")
-    boolean getAkkaEnabled();
-
-    /**
-     * Hostname to be used in Akka configuration.
-     */
-    @Key(AKKA_HOSTNAME)
-    String getHostname();
-
-    /**
-     * local port to be used in Akka configuration.
-     */
-    @Key(AKKA_PORT)
-    int getPort();
-
-    /**
-     * Local region to be used in Akka configuration.
-     */
-    @Key(AKKA_REGION)
-    String getRegion();
-
-    /**
-     * Comma separated list of regions known to cluster.
-     */
-    @Key(AKKA_REGION_LIST)
-    String getRegionList();
-
-    /**
-     * Number of UniqueValueActors to be started on each node
-     */
-    @Key(AKKA_UNIQUEVALUE_ACTORS)
-    @Default("300")
-    int getUniqueValueActors();
-
-    /**
-     * Comma-separated lists of seeds each with format {region}:{hostname}:{port}.
-     * Regions MUST be listed in the 'usergrid.queue.regionList'
-     */
-    @Key(AKKA_REGION_SEEDS)
-    String getRegionSeeds();
-
-    /**
-     * If no region specified for type, use the authoritative region
-     */
-    @Key(AKKA_AUTHORITATIVE_REGION)
-    String getAkkaAuthoritativeRegion();
-
-    /**
-     * Unique Value cache TTL in seconds.
-     */
-    @Key(AKKA_UNIQUEVALUE_CACHE_TTL)
-    @Default("10")
-    int getUniqueValueCacheTtl();
-
-    /**
-     * Unique Value Reservation TTL in seconds.
-     */
-    @Key(AKKA_UNIQUEVALUE_RESERVATION_TTL)
-    @Default("10")
-    int getUniqueValueReservationTtl();
-}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/ClusterSingletonRouter.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/ClusterSingletonRouter.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/ClusterSingletonRouter.java
deleted file mode 100644
index f2f80bf..0000000
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/ClusterSingletonRouter.java
+++ /dev/null
@@ -1,70 +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.persistence.collection.uniquevalues;
-
-import akka.actor.ActorRef;
-import akka.actor.Props;
-import akka.actor.UntypedActor;
-import akka.routing.ConsistentHashingRouter;
-import akka.routing.FromConfig;
-import com.google.inject.Inject;
-import com.google.inject.Injector;
-import org.apache.commons.lang.RandomStringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * Uses a consistent hash to route Unique Value requests to UniqueValueActors.
- */
-public class ClusterSingletonRouter extends UntypedActor {
-    private static final Logger logger = LoggerFactory.getLogger( UniqueValueActor.class );
-
-    private final String name = RandomStringUtils.randomAlphanumeric( 4 );
-
-    private final ActorRef router;
-
-    @Inject
-    public ClusterSingletonRouter( Injector injector ) {
-
-        router = getContext().actorOf(
-            FromConfig.getInstance().props(Props.create(UniqueValueActor.class)), "router");
-
-        // TODO: is there some way to pass the injector here without getting this exception:
-        // NotSerializableException: No configured serialization-bindings for class [InjectorImpl]
-        //router = getContext().actorOf(
-            //FromConfig.getInstance().props( Props.create( GuiceActorProducer.class, injector, UniqueValueActor.class)),
-            //"router" );
-
-        logger.info("ClusterSingletonRouter {} is live with injector {}", name, injector);
-    }
-
-    @Override
-    public void onReceive(Object message) {
-
-        if ( message instanceof UniqueValueActor.Request) {
-            UniqueValueActor.Request request = (UniqueValueActor.Request)message;
-
-            ConsistentHashingRouter.ConsistentHashableEnvelope envelope =
-                new ConsistentHashingRouter.ConsistentHashableEnvelope( message, request.getConsistentHashKey() );
-            router.tell( envelope, getSender());
-
-        } else {
-            unhandled(message);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/GuiceActorProducer.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/GuiceActorProducer.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/GuiceActorProducer.java
deleted file mode 100644
index 0e99bca..0000000
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/GuiceActorProducer.java
+++ /dev/null
@@ -1,46 +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.persistence.collection.uniquevalues;
-
-import akka.actor.Actor;
-import akka.actor.IndirectActorProducer;
-import com.google.inject.Injector;
-
-
-public class GuiceActorProducer implements IndirectActorProducer {
-
-    final Injector injector;
-    final Class<? extends Actor> actorClass;
-
-    public GuiceActorProducer(Injector injector, Class<? extends Actor> actorClass) {
-        this.injector = injector;
-        this.actorClass = actorClass;
-    }
-
-    @Override
-    public Class<? extends Actor> actorClass() {
-        return actorClass;
-    }
-
-    @Override
-    public Actor produce() {
-        return injector.getInstance( actorClass );
-    }
-}
-

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/RequestActor.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/RequestActor.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/RequestActor.java
deleted file mode 100644
index c451c61..0000000
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/RequestActor.java
+++ /dev/null
@@ -1,186 +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.persistence.collection.uniquevalues;
-
-import akka.actor.ActorSelection;
-import akka.actor.Address;
-import akka.actor.UntypedActor;
-import akka.cluster.Cluster;
-import akka.cluster.ClusterEvent;
-import akka.cluster.Member;
-import akka.cluster.MemberStatus;
-import org.apache.commons.lang3.RandomStringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.ThreadLocalRandom;
-
-
-/**
- * Once notified of nodes, sends unique propertyValue requests to ClusterSingletonRouter via it's local proxy.
- */
-class RequestActor extends UntypedActor {
-    private static final Logger logger = LoggerFactory.getLogger( RequestActor.class );
-
-    private final String name = RandomStringUtils.randomAlphanumeric( 4 );
-
-    private final Set<Address> nodes = new HashSet<>();
-
-    private final Cluster cluster = Cluster.get(getContext().system());
-    private final String routerProxyPath;
-
-    private boolean ready = false;
-
-
-    public RequestActor(String routerProxyPath ) {
-        this.routerProxyPath = routerProxyPath;
-    }
-
-    // subscribe to cluster changes, MemberEvent
-    @Override
-    public void preStart() {
-        logger.debug("{} role {} address {}:{} starting up, subscribing to cluster events...", name,
-            cluster.getSelfRoles().iterator().next(),
-            cluster.readView().selfAddress().host(),
-            cluster.readView().selfAddress().hostPort());
-        cluster.subscribe(getSelf(), ClusterEvent.MemberEvent.class, ClusterEvent.ReachabilityEvent.class);
-    }
-
-    // re-subscribe when restart
-    @Override
-    public void postStop() {
-        cluster.unsubscribe(getSelf());
-    }
-
-    @Override
-    public void onReceive(Object message) {
-
-        int startSize = nodes.size();
-
-        if ( message instanceof UniqueValueActor.Request && ready ) {
-
-            // just pick any node, the ClusterSingletonRouter will do the consistent hash routing
-            List<Address> nodesList = new ArrayList<>( nodes );
-            Address address = nodesList.get( ThreadLocalRandom.current().nextInt( nodesList.size() ) );
-            ActorSelection service = getContext().actorSelection( address + routerProxyPath );
-            service.tell( message, getSender() );
-
-        } else if ( message instanceof UniqueValueActor.Request && !ready ) {
-            logger.debug("{} responding with status unknown", name);
-
-            getSender().tell( new UniqueValueActor.Response(
-                    UniqueValueActor.Response.Status.ERROR ) , getSender() );
-
-        } else if ( message instanceof StatusRequest ) {
-            if ( ready ) {
-                getSender().tell( new StatusMessage( name, StatusMessage.Status.READY ), getSender() );
-            } else {
-                getSender().tell( new StatusMessage( name, StatusMessage.Status.INITIALIZING), getSender() );
-            }
-            return;
-
-        } else {
-            processAsClusterEvent( message );
-        }
-
-        if ( logger.isDebugEnabled() && startSize != nodes.size() ) {
-            logger.debug( "{} now knows {} nodes", name, nodes.size() );
-        }
-
-        if (!nodes.isEmpty() && !ready) {
-            logger.debug( name + " is ready" );
-            ready = true;
-
-        } else if (nodes.isEmpty() && ready) {
-            ready = false;
-        }
-    }
-
-    /**
-     * Process messages about nodes up, down, reachable and unreachable.
-     */
-    private void processAsClusterEvent(Object message) {
-
-        if (message instanceof ClusterEvent.CurrentClusterState) {
-            ClusterEvent.CurrentClusterState state = (ClusterEvent.CurrentClusterState) message;
-            nodes.clear();
-            for (Member member : state.getMembers()) {
-                if (member.hasRole("io") && member.status().equals( MemberStatus.up())) {
-                    nodes.add(member.address());
-                    logger.debug("RequestActor {} received cluster-state member-up for {}", name, member.address());
-                }
-            }
-
-        } else if (message instanceof ClusterEvent.MemberUp) {
-            ClusterEvent.MemberUp mUp = (ClusterEvent.MemberUp) message;
-            if (mUp.member().hasRole("io")) {
-                nodes.add( mUp.member().address() );
-            }
-            logger.debug("{} received member-up for {}", name, mUp.member().address());
-
-        } else if (message instanceof ClusterEvent.MemberEvent) {
-            ClusterEvent.MemberEvent other = (ClusterEvent.MemberEvent) message;
-            nodes.remove(other.member().address());
-
-        } else if (message instanceof ClusterEvent.UnreachableMember) {
-            ClusterEvent.UnreachableMember unreachable = (ClusterEvent.UnreachableMember) message;
-            nodes.remove(unreachable.member().address());
-            logger.debug("{} received un-reachable for {}", name, unreachable.member().address());
-
-        } else if (message instanceof ClusterEvent.ReachableMember) {
-            ClusterEvent.ReachableMember reachable = (ClusterEvent.ReachableMember) message;
-            if (reachable.member().hasRole("io")) {
-                nodes.add( reachable.member().address() );
-            }
-            logger.debug("{} received reachable for {}", name, reachable.member().address());
-
-        } else {
-            logger.error("{}: unhandled message: {}", name, message.toString());
-            unhandled(message);
-        }
-    }
-
-    /**
-     * RequestAction responds to StatusRequests.
-     */
-    static class StatusRequest implements Serializable { }
-
-    /**
-     * RequestActor responds with, and some times unilaterally sends StatusMessages.
-     */
-    static class StatusMessage implements Serializable {
-        final String name;
-        public enum Status { INITIALIZING, READY }
-        final Status status;
-        public StatusMessage(String name, Status status) {
-            this.name = name;
-            this.status = status;
-        }
-        public String getName() {
-            return name;
-        }
-        public boolean isReady() {
-            return status.equals( Status.READY );
-        }
-    }
-}
-

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/ReservationCache.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/ReservationCache.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/ReservationCache.java
index 24b7f6e..f1e68b2 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/ReservationCache.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/ReservationCache.java
@@ -19,6 +19,7 @@ package org.apache.usergrid.persistence.collection.uniquevalues;
 import com.google.common.cache.Cache;
 import com.google.common.cache.CacheBuilder;
 import com.google.common.cache.CacheStats;
+import org.apache.usergrid.persistence.actorsystem.ClientActor;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -26,7 +27,7 @@ import java.util.concurrent.TimeUnit;
 
 
 public class ReservationCache {
-    private static final Logger logger = LoggerFactory.getLogger( RequestActor.class );
+    private static final Logger logger = LoggerFactory.getLogger( ClientActor.class );
 
     Cache<String, UniqueValueActor.Reservation> cache;
     long ttl;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValueActor.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValueActor.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValueActor.java
index 1e7879a..bb30b92 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValueActor.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValueActor.java
@@ -48,7 +48,7 @@ public class UniqueValueActor extends UntypedActor {
 
         // TODO: is there a way to avoid this ugly kludge? see also: ClusterSingletonRouter
         this.table = UniqueValuesServiceImpl.injector.getInstance( UniqueValuesTable.class );
-        logger.info("UniqueValueActor {} is live with table {}", name, table);
+        //logger.info("UniqueValueActor {} is live with table {}", name, table);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesRouter.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesRouter.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesRouter.java
new file mode 100644
index 0000000..376af66
--- /dev/null
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesRouter.java
@@ -0,0 +1,70 @@
+/*
+ * 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.persistence.collection.uniquevalues;
+
+import akka.actor.ActorRef;
+import akka.actor.Props;
+import akka.actor.UntypedActor;
+import akka.routing.ConsistentHashingRouter;
+import akka.routing.FromConfig;
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+import org.apache.commons.lang.RandomStringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Uses a consistent hash to route Unique Value requests to UniqueValueActors.
+ */
+public class UniqueValuesRouter extends UntypedActor {
+    private static final Logger logger = LoggerFactory.getLogger( UniqueValueActor.class );
+
+    private final String name = RandomStringUtils.randomAlphanumeric( 4 );
+
+    private final ActorRef router;
+
+    @Inject
+    public UniqueValuesRouter(Injector injector ) {
+
+        router = getContext().actorOf(
+            FromConfig.getInstance().props(Props.create(UniqueValueActor.class)), "router");
+
+        // TODO: is there some way to pass the injector here without getting this exception:
+        // NotSerializableException: No configured serialization-bindings for class [InjectorImpl]
+        //router = getContext().actorOf(
+            //FromConfig.getInstance().props( Props.create( GuiceActorProducer.class, injector, UniqueValueActor.class)),
+            //"router" );
+
+        //logger.info("UniqueValuesRouter {} is live with injector {}", name, injector);
+    }
+
+    @Override
+    public void onReceive(Object message) {
+
+        if ( message instanceof UniqueValueActor.Request) {
+            UniqueValueActor.Request request = (UniqueValueActor.Request)message;
+
+            ConsistentHashingRouter.ConsistentHashableEnvelope envelope =
+                new ConsistentHashingRouter.ConsistentHashableEnvelope( message, request.getConsistentHashKey() );
+            router.tell( envelope, getSender());
+
+        } else {
+            unhandled(message);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesService.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesService.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesService.java
index 744c5b9..e9a9f50 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesService.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesService.java
@@ -19,20 +19,17 @@
 package org.apache.usergrid.persistence.collection.uniquevalues;
 
 
+import org.apache.usergrid.persistence.actorsystem.RouterProducer;
 import org.apache.usergrid.persistence.core.scope.ApplicationScope;
 import org.apache.usergrid.persistence.model.entity.Entity;
 
 import java.util.UUID;
 
+
 /**
  * Service that reserves and confirms unique values.
  */
-public interface UniqueValuesService {
-
-    /**
-     * Initialize and start service.
-     */
-    void start();
+public interface UniqueValuesService extends RouterProducer {
 
     /**
      * Check that unique values are unique and reserve them for a limited time.
@@ -58,15 +55,4 @@ public interface UniqueValuesService {
      */
     void confirmUniqueValues( ApplicationScope scope, Entity entity, UUID version , String region )
         throws UniqueValueException;
-
-
-    /**
-     * For test purposes only.
-     */
-    void start( String hostname, Integer port, String region );
-
-    /**
-     * For test purposes only.
-     */
-    void waitForRequestActors();
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesServiceImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesServiceImpl.java
index 670fffd..85b9d1a 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesServiceImpl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesServiceImpl.java
@@ -28,15 +28,12 @@ import akka.cluster.singleton.ClusterSingletonProxy;
 import akka.cluster.singleton.ClusterSingletonProxySettings;
 import akka.pattern.Patterns;
 import akka.util.Timeout;
-import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.ListMultimap;
 import com.google.inject.Inject;
 import com.google.inject.Injector;
 import com.google.inject.Singleton;
-import com.typesafe.config.Config;
-import com.typesafe.config.ConfigFactory;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.usergrid.persistence.collection.exception.CollectionRuntimeException;
+import org.apache.usergrid.persistence.actorsystem.ActorSystemFig;
+import org.apache.usergrid.persistence.actorsystem.ActorSystemManager;
+import org.apache.usergrid.persistence.actorsystem.GuiceActorProducer;
 import org.apache.usergrid.persistence.core.scope.ApplicationScope;
 import org.apache.usergrid.persistence.model.entity.Entity;
 import org.apache.usergrid.persistence.model.field.Field;
@@ -45,7 +42,8 @@ import org.slf4j.LoggerFactory;
 import scala.concurrent.Await;
 import scala.concurrent.Future;
 
-import java.util.*;
+import java.util.Map;
+import java.util.UUID;
 import java.util.concurrent.TimeUnit;
 
 
@@ -53,157 +51,30 @@ import java.util.concurrent.TimeUnit;
 public class UniqueValuesServiceImpl implements UniqueValuesService {
     private static final Logger logger = LoggerFactory.getLogger( UniqueValuesServiceImpl.class );
 
-    static Injector injector;
-
-    AkkaFig akkaFig;
-    UniqueValuesTable table;
-    private String hostname;
-    private Integer port = null;
-    private String currentRegion;
-
-    private Map<String, ActorRef> requestActorsByRegion;
-
-    //private Map<String, String> regionsByType = new HashMap<>();
-
-//    private final MetricRegistry metrics = new MetricRegistry();
-//
-//    private final Timer getTimer     = metrics.timer( "get" );
-//    private final Timer   saveTimer    = metrics.timer( "save" );
-//
-//    private final Counter cacheCounter = metrics.counter( "cache" );
-//    private final Counter dupCounter   = metrics.counter( "duplicates" );
-//
-//    private final Timer   reservationTimer = metrics.timer( "reservation" );
-//    private final Timer   commitmentTimer  = metrics.timer( "commitment" );
-
+    static Injector          injector;
+    ActorSystemFig           actorSystemFig;
+    ActorSystemManager       actorSystemManager;
+    UniqueValuesTable        table;
     private ReservationCache reservationCache;
 
 
     @Inject
-    public UniqueValuesServiceImpl(Injector inj, AkkaFig akkaFig, UniqueValuesTable table ) {
+    public UniqueValuesServiceImpl(
+        Injector inj,
+        ActorSystemFig actorSystemFig,
+        ActorSystemManager actorSystemManager,
+        UniqueValuesTable table ) {
+
         injector = inj;
-        this.akkaFig = akkaFig;
+        this.actorSystemManager = actorSystemManager;
+        this.actorSystemFig = actorSystemFig;
         this.table = table;
 
-        ReservationCache.init( akkaFig.getUniqueValueCacheTtl() );
+        ReservationCache.init( actorSystemFig.getUniqueValueCacheTtl() );
         this.reservationCache = ReservationCache.getInstance();
     }
 
 
-    /**
-     * Init Akka ActorSystems and wait for request actors to start.
-     */
-    public void start() {
-
-        this.hostname = akkaFig.getHostname();
-        this.currentRegion = akkaFig.getRegion();
-        this.port = null;
-
-        initAkka();
-        waitForRequestActors();
-    }
-
-
-    /**
-     * For testing purposes only; does not wait for request actors to start.
-     */
-    public void start( String hostname, Integer port, String currentRegion ) {
-
-        this.hostname = hostname;
-        this.currentRegion = currentRegion;
-        this.port = port;
-
-        initAkka();
-    }
-
-
-    private Map<String, ActorRef> getRequestActorsByRegion() {
-        return requestActorsByRegion;
-    }
-
-
-//    private Map<String, String> getRegionsByType() {
-//        return regionsByType;
-//    }
-
-//    public Counter getDupCounter() {
-//        return dupCounter;
-//    }
-//
-//    public Counter getCacheCounter() {
-//        return cacheCounter;
-//    }
-//
-//    public Timer getReservationTimer() {
-//        return reservationTimer;
-//    }
-//
-//    public Timer getCommitmentTimer() {
-//        return commitmentTimer;
-//    }
-//
-//    public Timer getSaveTimer() {
-//        return saveTimer;
-//    }
-//
-//    public Timer getGetTimer() {
-//        return getTimer;
-//    }
-
-    private void initAkka() {
-        logger.info("Initializing Akka");
-
-        // Create one actor system with request actor for each region
-
-        if ( StringUtils.isEmpty( hostname )) {
-            throw new RuntimeException( "No value specified for " + AkkaFig.AKKA_HOSTNAME );
-        }
-
-        if ( StringUtils.isEmpty( currentRegion )) {
-            throw new RuntimeException( "No value specified for " + AkkaFig.AKKA_REGION );
-        }
-
-        if ( StringUtils.isEmpty( akkaFig.getRegionList() )) {
-            throw new RuntimeException( "No value specified for " + AkkaFig.AKKA_REGION_LIST );
-        }
-
-        if ( StringUtils.isEmpty( akkaFig.getRegionSeeds() )) {
-            throw new RuntimeException( "No value specified for " + AkkaFig.AKKA_REGION_SEEDS);
-        }
-
-        if ( StringUtils.isEmpty( akkaFig.getAkkaAuthoritativeRegion() )) {
-            throw new RuntimeException( "No value specified for " + AkkaFig.AKKA_AUTHORITATIVE_REGION);
-        }
-
-        List regionList = Arrays.asList( akkaFig.getRegionList().toLowerCase().split(",") );
-
-        logger.info("Initializing Akka for hostname {} region {} regionList {} seeds {}",
-            hostname, currentRegion, regionList, akkaFig.getRegionSeeds() );
-
-//        String typesValue = akkaFig.getRegionTypes();
-//        String[] regionTypes = StringUtils.isEmpty( typesValue ) ? new String[0] : typesValue.split(",");
-//        for ( String regionType : regionTypes ) {
-//            String[] parts = regionType.toLowerCase().split(":");
-//            String typeRegion = parts[0];
-//            String type = parts[1];
-//
-//            if ( !regionList.contains( typeRegion) ) {
-//                throw new RuntimeException(
-//                    "'collection.akka.region.seeds' references unknown region: " + typeRegion );
-//            }
-//            this.regionsByType.put( type, typeRegion );
-//        }
-
-        final Map<String, ActorSystem> systemMap = new HashMap<>();
-
-        ActorSystem localSystem = createClusterSingletonProxies( readClusterSingletonConfigs(), systemMap );
-
-        createRequestActors( systemMap );
-
-        subscribeToReservations( localSystem, systemMap );
-    }
-
-
     private void subscribeToReservations( ActorSystem localSystem, Map<String, ActorSystem> systemMap ) {
 
         for ( String region : systemMap.keySet() ) {
@@ -216,246 +87,11 @@ public class UniqueValuesServiceImpl implements UniqueValuesService {
     }
 
 
-    /**
-     * Create ActorSystem and ClusterSingletonProxy for every region.
-     * Create ClusterSingletonManager for the current region.
-     *
-     * @param configMap Configurations to be used to create ActorSystems
-     * @param systemMap Map of ActorSystems created by this method
-     *
-     * @return ActorSystem for this region.
-     */
-    private ActorSystem createClusterSingletonProxies(
-            Map<String, Config> configMap, Map<String, ActorSystem> systemMap ) {
-
-        ActorSystem localSystem = null;
-
-        for ( String region : configMap.keySet() ) {
-            Config config = configMap.get( region );
-
-            ActorSystem system = ActorSystem.create( "ClusterSystem", config );
-            systemMap.put( region, system );
-
-            // cluster singletons only run role "io" nodes and NOT on "client" nodes of other regions
-            if ( currentRegion.equals( region ) ) {
-
-                localSystem = system;
-
-                // create cluster singleton supervisor for actor system
-                ClusterSingletonManagerSettings settings =
-                        ClusterSingletonManagerSettings.create( system ).withRole("io");
-
-                // Akka.system().actorOf(Props.create(GuiceInjectedActor.class, INJECTOR,Retreiver.class))
-
-                system.actorOf( ClusterSingletonManager.props(
-                    //Props.create( ClusterSingletonRouter.class, table ),
-                    Props.create( GuiceActorProducer.class, injector, ClusterSingletonRouter.class),
-                    PoisonPill.getInstance(), settings ), "uvRouter");
-            }
-
-            // create proxy for sending messages to singleton
-            ClusterSingletonProxySettings proxySettings =
-                    ClusterSingletonProxySettings.create( system ).withRole("io");
-            system.actorOf( ClusterSingletonProxy.props( "/user/uvRouter", proxySettings ), "uvProxy" );
-        }
-
-        return localSystem;
-    }
-
-
-    /**
-     * Create RequestActor for each region.
-     *
-     * @param systemMap Map of regions to ActorSystems.
-     */
-    private void createRequestActors( Map<String, ActorSystem> systemMap ) {
-
-        requestActorsByRegion = new HashMap<>();
-
-        for ( String region : systemMap.keySet() ) {
-
-            logger.info("Creating request actor for region {}", region);
-
-            // Each RequestActor needs to know path to ClusterSingletonProxy and region
-            ActorRef requestActor = systemMap.get( region ).actorOf(
-                    Props.create( RequestActor.class, "/user/uvProxy" ), "requestActor" );
-
-            requestActorsByRegion.put( region, requestActor );
-        }
-    }
-
-
-    public void waitForRequestActors() {
-
-        for ( String region : requestActorsByRegion.keySet() ) {
-            ActorRef ra = requestActorsByRegion.get( region );
-            waitForRequestActor( ra );
-        }
-    }
-
-
-    private void waitForRequestActor( ActorRef ra ) {
-
-        logger.info( "Waiting on request actor {}...", ra.path() );
-
-        boolean started = false;
-        int retries = 0;
-        int maxRetries = 60;
-        while (retries < maxRetries) {
-            Timeout t = new Timeout( 10, TimeUnit.SECONDS );
-
-            Future<Object> fut = Patterns.ask( ra, new RequestActor.StatusRequest(), t );
-            try {
-                RequestActor.StatusMessage result = (RequestActor.StatusMessage) Await.result( fut, t.duration() );
-
-                if (result.status.equals( RequestActor.StatusMessage.Status.READY )) {
-                    started = true;
-                    break;
-                }
-                logger.info( "Waiting for request actor {} region {} ({}s)", ra.path(), currentRegion, retries );
-                Thread.sleep( 1000 );
-
-            } catch (Exception e) {
-                logger.error( "Error: Timeout waiting for requestActor" );
-            }
-            retries++;
-        }
-
-        if (started) {
-            logger.info( "RequestActor has started" );
-        } else {
-            throw new RuntimeException( "RequestActor did not start in time" );
-        }
-    }
-
-
-    /**
-     * Read configuration and create a Config for each region.
-     *
-     * @return Map of regions to Configs.
-     */
-    private Map<String, Config> readClusterSingletonConfigs() {
-
-        Map<String, Config> configs = new HashMap<>();
-
-        ListMultimap<String, String> seedsByRegion = ArrayListMultimap.create();
-
-        String[] regionSeeds = akkaFig.getRegionSeeds().split( "," );
-
-        logger.info("Found region {} seeds {}", regionSeeds.length, regionSeeds);
-
-        try {
-
-            if ( port != null ) {
-
-                // we are testing
-                String seed = "akka.tcp://ClusterSystem@" + hostname + ":" + port;
-                seedsByRegion.put( currentRegion, seed );
-                logger.info("Akka testing, only starting one seed");
-
-            } else {
-
-                for (String regionSeed : regionSeeds) {
-
-                    String[] parts = regionSeed.split( ":" );
-                    String region = parts[0];
-                    String hostname = parts[1];
-                    String regionPortString = parts[2];
-
-                    // all seeds in same region must use same port
-                    // we assume 0th seed has the right port
-                    final Integer regionPort;
-
-                    if (port == null) {
-                        regionPort = Integer.parseInt( regionPortString );
-                    } else {
-                        regionPort = port; // unless we are testing
-                    }
-
-                    String seed = "akka.tcp://ClusterSystem@" + hostname + ":" + regionPort;
-
-                    logger.info("Adding seed {} for region {}", seed, region );
-
-                    seedsByRegion.put( region, seed );
-                }
-
-                if (seedsByRegion.keySet().isEmpty()) {
-                    throw new RuntimeException(
-                        "No seeds listed in 'parsing collection.akka.region.seeds' property." );
-                }
-            }
-
-            int numInstancesPerNode = akkaFig.getUniqueValueActors();
-
-            for ( String region : seedsByRegion.keySet() ) {
-
-                List<String> seeds = seedsByRegion.get( region );
-                int lastColon = seeds.get(0).lastIndexOf(":") + 1;
-                final Integer regionPort = Integer.parseInt( seeds.get(0).substring( lastColon ));
-
-                // cluster singletons only run role "io" nodes and NOT on "client" nodes of other regions
-                String clusterRole = currentRegion.equals( region ) ? "io" : "client";
-
-                logger.info( "Config for region {} is:\n" +
-                    "   AkkaUV Hostname {}\n" +
-                    "   AkkaUV Seeds {}\n" +
-                    "   AkkaUV Port {}\n" +
-                    "   AkkaUV UniqueValueActors per node {}\n" +
-                    "   AkkaUV Authoritative Region {}",
-                    region, hostname, seeds, port, numInstancesPerNode, akkaFig.getAkkaAuthoritativeRegion() );
-
-                Map<String, Object> configMap = new HashMap<String, Object>() {{
-                    put( "akka", new HashMap<String, Object>() {{
-                        put( "remote", new HashMap<String, Object>() {{
-                            put( "netty.tcp", new HashMap<String, Object>() {{
-                                put( "hostname", hostname );
-                                put( "bind-hostname", hostname );
-                                put( "port", regionPort );
-                            }} );
-                        }} );
-                        put( "cluster", new HashMap<String, Object>() {{
-                            put( "max-nr-of-instances-per-node", numInstancesPerNode );
-                            put( "roles", Collections.singletonList(clusterRole) );
-                            put( "seed-nodes", new ArrayList<String>() {{
-                                for (String seed : seeds) {
-                                    add( seed );
-                                }
-                            }} );
-                        }} );
-                        put( "actor", new HashMap<String, Object>() {{
-                            put( "deployment", new HashMap<String, Object>() {{
-                                put( "/uvRouter/singleton/router", new HashMap<String, Object>() {{
-                                    put( "cluster", new HashMap<String, Object>() {{
-                                        //put( "roles", Collections.singletonList(role) );
-                                        put( "max-nr-of-instances-per-node", numInstancesPerNode );
-                                    }} );
-                                }} );
-                            }} );
-                        }} );
-                    }} );
-                }};
-
-                Config config = ConfigFactory
-                        .parseMap( configMap )
-                        .withFallback( ConfigFactory.parseString( "akka.cluster.roles = [io]" ) )
-                        .withFallback( ConfigFactory.load( "cluster-singleton" ) );
-
-                configs.put( region, config );
-            }
-
-        } catch ( Exception e ) {
-            throw new RuntimeException("Error 'parsing collection.akka.region.seeds' property", e );
-        }
-
-        return configs;
-    }
-
-
     @Override
     public void reserveUniqueValues(
         ApplicationScope scope, Entity entity, UUID version, String region ) throws UniqueValueException {
 
-        if ( this.getRequestActorsByRegion().isEmpty() ) {
+        if ( !actorSystemManager.isReady() ) {
             throw new RuntimeException("Unique values service not initialized, no request actors ready");
         }
 
@@ -487,7 +123,7 @@ public class UniqueValuesServiceImpl implements UniqueValuesService {
     public void confirmUniqueValues(
         ApplicationScope scope, Entity entity, UUID version, String region ) throws UniqueValueException {
 
-        if ( this.getRequestActorsByRegion().isEmpty() ) {
+        if ( !actorSystemManager.isReady() ) {
             throw new RuntimeException("Unique values service not initialized, no request actors ready");
         }
 
@@ -518,7 +154,7 @@ public class UniqueValuesServiceImpl implements UniqueValuesService {
     private void reserveUniqueField(
         ApplicationScope scope, Entity entity, UUID version, Field field, String region ) throws UniqueValueException {
 
-        final ActorRef requestActor = getRequestActorsByRegion().get( region );
+        final ActorRef requestActor = actorSystemManager.getClientActor( region );
 
         if ( requestActor == null ) {
             throw new RuntimeException( "No request actor for region " + region);
@@ -542,7 +178,7 @@ public class UniqueValuesServiceImpl implements UniqueValuesService {
     private void confirmUniqueField(
         ApplicationScope scope, Entity entity, UUID version, Field field, String region) throws UniqueValueException {
 
-        final ActorRef requestActor = getRequestActorsByRegion().get( region );
+        final ActorRef requestActor = actorSystemManager.getClientActor( region );
 
         if ( requestActor == null ) {
             throw new RuntimeException( "No request actor for type, cannot verify unique fields!" );
@@ -558,7 +194,7 @@ public class UniqueValuesServiceImpl implements UniqueValuesService {
     private void cancelUniqueField(
         ApplicationScope scope, Entity entity, UUID version, Field field, String region ) throws UniqueValueException {
 
-        final ActorRef requestActor = getRequestActorsByRegion().get( region );
+        final ActorRef requestActor = actorSystemManager.getClientActor( region );
 
         if ( requestActor == null ) {
             throw new RuntimeException( "No request actor for type, cannot verify unique fields!" );
@@ -616,7 +252,7 @@ public class UniqueValuesServiceImpl implements UniqueValuesService {
 
             } catch ( Exception e ) {
                 logger.debug("{} caused retry {} for entity {} rowkey {}",
-                        e.getClass().getSimpleName(), retries, entity.getId().getUuid(), request.getConsistentHashKey());
+                    e.getClass().getSimpleName(), retries, entity.getId().getUuid(), request.getConsistentHashKey());
             }
         }
 
@@ -634,4 +270,34 @@ public class UniqueValuesServiceImpl implements UniqueValuesService {
             throw new UniqueValueException( "Error property not unique", request.getField() );
         }
     }
+
+
+    @Override
+    public void createClusterSingletonManager(ActorSystem system) {
+
+        // create cluster singleton supervisor for actor system
+        ClusterSingletonManagerSettings settings =
+            ClusterSingletonManagerSettings.create( system ).withRole("io");
+
+        system.actorOf( ClusterSingletonManager.props(
+            //Props.create( ClusterSingletonRouter.class, table ),
+            Props.create( GuiceActorProducer.class, injector, UniqueValuesRouter.class),
+            PoisonPill.getInstance(), settings ), "uvRouter");
+    }
+
+
+    @Override
+    public void createClusterSingletonProxy(ActorSystem system) {
+
+        ClusterSingletonProxySettings proxySettings =
+            ClusterSingletonProxySettings.create( system ).withRole("io");
+
+        system.actorOf( ClusterSingletonProxy.props( "/user/uvRouter", proxySettings ), "uvProxy" );
+    }
+
+
+    @Override
+    public void createLocalSystemActors( ActorSystem localSystem, Map<String, ActorSystem> systemMap ) {
+        subscribeToReservations( localSystem, systemMap );
+    }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesTableImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesTableImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesTableImpl.java
index c0fa390..de326dd 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesTableImpl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesTableImpl.java
@@ -22,6 +22,7 @@ import com.google.inject.Inject;
 import com.google.inject.Singleton;
 import com.netflix.astyanax.MutationBatch;
 import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
+import org.apache.usergrid.persistence.actorsystem.ActorSystemFig;
 import org.apache.usergrid.persistence.collection.serialization.UniqueValue;
 import org.apache.usergrid.persistence.collection.serialization.UniqueValueSerializationStrategy;
 import org.apache.usergrid.persistence.collection.serialization.UniqueValueSet;
@@ -41,12 +42,12 @@ public class UniqueValuesTableImpl implements UniqueValuesTable {
     private static final Logger logger = LoggerFactory.getLogger( UniqueValuesTableImpl.class );
 
     final UniqueValueSerializationStrategy strat;
-    final AkkaFig akkaFig;
+    final ActorSystemFig actorSystemFig;
 
     @Inject
-    public UniqueValuesTableImpl( final UniqueValueSerializationStrategy strat, AkkaFig akkaFig ) {
+    public UniqueValuesTableImpl( final UniqueValueSerializationStrategy strat, ActorSystemFig actorSystemFig) {
         this.strat = strat;
-        this.akkaFig = akkaFig;
+        this.actorSystemFig = actorSystemFig;
     }
 
 
@@ -62,7 +63,7 @@ public class UniqueValuesTableImpl implements UniqueValuesTable {
     public void reserve( ApplicationScope scope, Id owner, UUID version, Field field ) throws ConnectionException {
 
         UniqueValue uv = new UniqueValueImpl( field, owner, version);
-        final MutationBatch write = strat.write( scope, uv, akkaFig.getUniqueValueReservationTtl() );
+        final MutationBatch write = strat.write( scope, uv, actorSystemFig.getUniqueValueReservationTtl() );
         write.execute();
     }
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/stack/corepersistence/collection/src/main/resources/application.conf
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/resources/application.conf b/stack/corepersistence/collection/src/main/resources/application.conf
deleted file mode 100644
index 93854f9..0000000
--- a/stack/corepersistence/collection/src/main/resources/application.conf
+++ /dev/null
@@ -1,28 +0,0 @@
-akka {
-  
-  loggers = ["akka.event.slf4j.Slf4jLogger"]
-  loglevel = "ERROR"
-  logging-filter = "akka.event.slf4j.Slf4jLoggingFilter"
-  
-  actor {
-    provider = "akka.cluster.ClusterActorRefProvider"
-  }
-  
-  remote {
-    log-remote-lifecycle-events = off
-    netty.tcp {
-      hostname = "127.0.0.1"
-      port = 0
-    }
-  }
-}
-
-# Disable legacy metrics in akka-cluster.
-akka.cluster.metrics.enabled=off
-
-# Enable metrics extension in akka-cluster-metrics.
-akka.extensions=["akka.cluster.metrics.ClusterMetricsExtension", "akka.cluster.pubsub.DistributedPubSub"]
-
-# Sigar native library extract location during tests.
-# Note: use per-jvm-instance folder when running multiple jvm on one host. 
-akka.cluster.metrics.native-library-extract-folder=${user.dir}/target/native

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/stack/corepersistence/collection/src/main/resources/cluster-singleton.conf
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/resources/cluster-singleton.conf b/stack/corepersistence/collection/src/main/resources/cluster-singleton.conf
deleted file mode 100644
index 907aebb..0000000
--- a/stack/corepersistence/collection/src/main/resources/cluster-singleton.conf
+++ /dev/null
@@ -1,25 +0,0 @@
-include "application"
-
-akka.actor.deployment {
-  /uvRouter/singleton/router {
-    router = consistent-hashing-pool
-    cluster {
-      enabled = on
-      allow-local-routees = on
-      
-      # singleton will only run on nodes with role "io"
-      use-role = io
-
-      # more forgiving failure detector
-      failure-detector {
-        threshold = 10
-        acceptable-heartbeat-pause = 3 s
-        heartbeat-interval = 1 s
-        heartbeat-request {
-          expected-response-after = 3 s
-        }
-      }
-
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java
index d94b7b5..6c3cfe7 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java
@@ -21,6 +21,7 @@ package org.apache.usergrid.persistence.collection;
 import com.fasterxml.uuid.UUIDComparator;
 import com.google.inject.Inject;
 import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
+import org.apache.usergrid.persistence.actorsystem.ActorSystemManager;
 import org.apache.usergrid.persistence.collection.exception.WriteUniqueVerifyException;
 import org.apache.usergrid.persistence.collection.guice.TestCollectionModule;
 import org.apache.usergrid.persistence.collection.mvcc.entity.Stage;
@@ -28,6 +29,8 @@ import org.apache.usergrid.persistence.collection.serialization.MvccEntitySerial
 import org.apache.usergrid.persistence.collection.serialization.SerializationFig;
 import org.apache.usergrid.persistence.collection.serialization.UniqueValueSerializationStrategy;
 import org.apache.usergrid.persistence.collection.serialization.UniqueValueSet;
+import org.apache.usergrid.persistence.collection.uniquevalues.UniqueValueActor;
+import org.apache.usergrid.persistence.collection.uniquevalues.UniqueValuesService;
 import org.apache.usergrid.persistence.collection.util.EntityHelper;
 import org.apache.usergrid.persistence.core.guice.MigrationManagerRule;
 import org.apache.usergrid.persistence.core.guicyfig.SetConfigTestBypass;
@@ -73,21 +76,30 @@ public class EntityCollectionManagerIT {
     @Inject
     private SerializationFig serializationFig;
 
-
     @Inject
     private UniqueValueSerializationStrategy uniqueValueSerializationStrategy;
 
     @Inject
     private MvccEntitySerializationStrategy entitySerializationStrategy;
 
+    @Inject
+    ActorSystemManager actorSystemManager;
+
+    @Inject
+    UniqueValuesService uniqueValuesService;
+
     private static AtomicBoolean startedAkka = new AtomicBoolean( false );
 
     @Before
     public void initAkka() {
         if ( !startedAkka.getAndSet( true ) ) {
-            ApplicationScope context = new ApplicationScopeImpl( new SimpleId( "organization" ) );
-            EntityCollectionManager manager = factory.createCollectionManager( context );
-            manager.startAkkaForTesting( "127.0.0.1", 2551, "us-east" );
+            actorSystemManager.registerRouterProducer( uniqueValuesService );
+            actorSystemManager.registerMessageType( UniqueValueActor.Request.class, "/user/uvProxy" );
+            actorSystemManager.registerMessageType( UniqueValueActor.Reservation.class, "/user/uvProxy" );
+            actorSystemManager.registerMessageType( UniqueValueActor.Cancellation.class, "/user/uvProxy" );
+            actorSystemManager.registerMessageType( UniqueValueActor.Confirmation.class, "/user/uvProxy" );
+            actorSystemManager.start( "127.0.0.1", 2554, "us-east" );
+            actorSystemManager.waitForRequestActors();
         }
     }
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerifyIT.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerifyIT.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerifyIT.java
index ee610a9..9e29f44 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerifyIT.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerifyIT.java
@@ -18,6 +18,9 @@
 package org.apache.usergrid.persistence.collection.mvcc.stage.write;
 
 
+import org.apache.usergrid.persistence.actorsystem.ActorSystemManager;
+import org.apache.usergrid.persistence.collection.uniquevalues.UniqueValueActor;
+import org.apache.usergrid.persistence.collection.uniquevalues.UniqueValuesService;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
@@ -69,14 +72,24 @@ public class WriteUniqueVerifyIT {
     @Inject
     public EntityCollectionManagerFactory cmf;
 
+    @Inject
+    ActorSystemManager actorSystemManager;
+
+    @Inject
+    UniqueValuesService uniqueValuesService;
+
     private static AtomicBoolean startedAkka = new AtomicBoolean( false );
 
     @Before
     public void initAkka() {
         if ( !startedAkka.getAndSet( true ) ) {
-            ApplicationScope context = new ApplicationScopeImpl( new SimpleId( "organization" ) );
-            EntityCollectionManager manager = factory.createCollectionManager( context );
-            manager.startAkkaForTesting( "127.0.0.1", 2552, "us-east" );
+            actorSystemManager.registerRouterProducer( uniqueValuesService );
+            actorSystemManager.registerMessageType( UniqueValueActor.Request.class, "/user/uvProxy" );
+            actorSystemManager.registerMessageType( UniqueValueActor.Reservation.class, "/user/uvProxy" );
+            actorSystemManager.registerMessageType( UniqueValueActor.Cancellation.class, "/user/uvProxy" );
+            actorSystemManager.registerMessageType( UniqueValueActor.Confirmation.class, "/user/uvProxy" );
+            actorSystemManager.start( "127.0.0.1", 2554, "us-east" );
+            actorSystemManager.waitForRequestActors();
         }
     }
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerifyTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerifyTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerifyTest.java
index 196f531..6daef08 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerifyTest.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerifyTest.java
@@ -18,8 +18,11 @@
 package org.apache.usergrid.persistence.collection.mvcc.stage.write;
 
 
+import org.apache.usergrid.persistence.actorsystem.ActorSystemManager;
 import org.apache.usergrid.persistence.collection.EntityCollectionManager;
 import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory;
+import org.apache.usergrid.persistence.collection.uniquevalues.UniqueValueActor;
+import org.apache.usergrid.persistence.collection.uniquevalues.UniqueValuesService;
 import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
 import org.apache.usergrid.persistence.model.entity.SimpleId;
 import org.junit.Before;
@@ -74,15 +77,25 @@ public class WriteUniqueVerifyTest {
     @Inject
     private CassandraConfig cassandraConfig;
 
+    @Inject
+    ActorSystemManager actorSystemManager;
+
+    @Inject
+    UniqueValuesService uniqueValuesService;
+
 
     private static AtomicBoolean startedAkka = new AtomicBoolean( false );
 
     @Before
     public void initAkka() {
         if ( !startedAkka.getAndSet( true ) ) {
-            ApplicationScope context = new ApplicationScopeImpl( new SimpleId( "organization" ) );
-            EntityCollectionManager manager = factory.createCollectionManager( context );
-            manager.startAkkaForTesting( "127.0.0.1", 2553, "us-east" );
+            actorSystemManager.registerRouterProducer( uniqueValuesService );
+            actorSystemManager.registerMessageType( UniqueValueActor.Request.class, "/user/uvProxy" );
+            actorSystemManager.registerMessageType( UniqueValueActor.Reservation.class, "/user/uvProxy" );
+            actorSystemManager.registerMessageType( UniqueValueActor.Cancellation.class, "/user/uvProxy" );
+            actorSystemManager.registerMessageType( UniqueValueActor.Confirmation.class, "/user/uvProxy" );
+            actorSystemManager.start( "127.0.0.1", 2554, "us-east" );
+            actorSystemManager.waitForRequestActors();
         }
     }
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesServiceTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesServiceTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesServiceTest.java
index 94d98f5..8db582e 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesServiceTest.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesServiceTest.java
@@ -1,9 +1,29 @@
+/**
+ * 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.persistence.collection.uniquevalues;
 
 import com.google.common.collect.ArrayListMultimap;
 import com.google.common.collect.Multimap;
 import com.google.common.collect.Multimaps;
 import com.google.inject.Inject;
+import org.apache.usergrid.persistence.actorsystem.ActorSystemFig;
+import org.apache.usergrid.persistence.actorsystem.ActorSystemManager;
 import org.apache.usergrid.persistence.collection.EntityCollectionManager;
 import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory;
 import org.apache.usergrid.persistence.collection.exception.WriteUniqueVerifyException;
@@ -49,7 +69,10 @@ public class UniqueValuesServiceTest {
     public MigrationManagerRule migrationManagerRule;
 
     @Inject
-    AkkaFig akkaFig;
+    ActorSystemFig actorSystemFig;
+
+    @Inject
+    ActorSystemManager actorSystemManager;
 
     @Inject
     UniqueValuesService uniqueValuesService;
@@ -58,14 +81,19 @@ public class UniqueValuesServiceTest {
 
     int numThreads = 6;
     int poolSize = 5;
-    int numUsers = 100;
+    int numUsers = 1;
+
 
     @Before
     public void initAkka() {
         if ( !startedAkka.getAndSet( true ) ) {
-            ApplicationScope context = new ApplicationScopeImpl( new SimpleId( "organization" ) );
-            EntityCollectionManager manager = factory.createCollectionManager( context );
-            manager.startAkkaForTesting( "127.0.0.1", 2554, "us-east" );
+            actorSystemManager.registerRouterProducer( uniqueValuesService );
+            actorSystemManager.registerMessageType( UniqueValueActor.Request.class, "/user/uvProxy" );
+            actorSystemManager.registerMessageType( UniqueValueActor.Reservation.class, "/user/uvProxy" );
+            actorSystemManager.registerMessageType( UniqueValueActor.Cancellation.class, "/user/uvProxy" );
+            actorSystemManager.registerMessageType( UniqueValueActor.Confirmation.class, "/user/uvProxy" );
+            actorSystemManager.start( "127.0.0.1", 2554, "us-east" );
+            actorSystemManager.waitForRequestActors();
         }
     }
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/stack/corepersistence/common/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/pom.xml b/stack/corepersistence/common/pom.xml
index 897bb38..a0488b2 100644
--- a/stack/corepersistence/common/pom.xml
+++ b/stack/corepersistence/common/pom.xml
@@ -1,4 +1,20 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
 <project xmlns="http://maven.apache.org/POM/4.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
@@ -83,7 +99,6 @@
             <version>${guicyfig.version}</version>
         </dependency>
 
-
         <dependency>
             <groupId>org.apache.commons</groupId>
             <artifactId>commons-collections4</artifactId>

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/stack/corepersistence/model/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/model/pom.xml b/stack/corepersistence/model/pom.xml
index ddf301d..2c2b557 100644
--- a/stack/corepersistence/model/pom.xml
+++ b/stack/corepersistence/model/pom.xml
@@ -1,4 +1,20 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
 <project xmlns="http://maven.apache.org/POM/4.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/stack/corepersistence/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/pom.xml b/stack/corepersistence/pom.xml
index f2bbbcd..5d4ccac 100644
--- a/stack/corepersistence/pom.xml
+++ b/stack/corepersistence/pom.xml
@@ -110,6 +110,7 @@ limitations under the License.
         <module>map</module>
         <module>queue</module>
         <module>cache</module>
+        <module>actorsystem</module>
     </modules>
 
     <build>

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/stack/corepersistence/queryindex/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/pom.xml b/stack/corepersistence/queryindex/pom.xml
index 003281e..ff032da 100644
--- a/stack/corepersistence/queryindex/pom.xml
+++ b/stack/corepersistence/queryindex/pom.xml
@@ -1,4 +1,20 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
 <project xmlns="http://maven.apache.org/POM/4.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
@@ -13,7 +29,7 @@
     <description>Module provates indexing and query of Entities via ElasticSearch</description>
 
     <artifactId>queryindex</artifactId>
-    <name>Usergrid Queryindex</name>
+    <name>Usergrid QueryIndex</name>
 
     <build>
 


[8/8] usergrid git commit: Merge branch 'akka-common' into usergrid-1268-akka-211

Posted by sn...@apache.org.
Merge branch 'akka-common' into usergrid-1268-akka-211

Conflicts:
	stack/corepersistence/collection/src/test/resources/usergrid.properties


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

Branch: refs/heads/usergrid-1268-akka-211
Commit: 4fb807f8149f264d34b51e83e19d7fda64868c14
Parents: 6455120 96ae317
Author: Dave Johnson <sn...@apache.org>
Authored: Wed Jun 22 11:26:09 2016 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Wed Jun 22 11:26:09 2016 -0400

----------------------------------------------------------------------
 .../main/resources/usergrid-default.properties  |   7 +-
 stack/core/pom.xml                              | 821 ++++++++++---------
 .../corepersistence/CpEntityManager.java        |   8 +-
 .../corepersistence/CpEntityManagerFactory.java |  25 +-
 .../service/ApplicationServiceImpl.java         |   8 +-
 stack/corepersistence/actorsystem/pom.xml       |  99 +++
 .../persistence/actorsystem/ActorSystemFig.java |  93 +++
 .../actorsystem/ActorSystemManager.java         |  39 +
 .../actorsystem/ActorSystemManagerImpl.java     | 393 +++++++++
 .../actorsystem/ActorSystemModule.java          |  34 +
 .../persistence/actorsystem/ClientActor.java    | 205 +++++
 .../actorsystem/GuiceActorProducer.java         |  46 ++
 .../persistence/actorsystem/RouterProducer.java |  49 ++
 .../src/main/resources/application.conf         |  45 +
 .../src/main/resources/cluster-singleton.conf   |  25 +
 .../actorsystem/ActorServiceServiceTest.java    |  57 ++
 stack/corepersistence/collection/pom.xml        |  22 +
 .../collection/EntityCollectionManager.java     |   6 -
 .../collection/guice/CollectionModule.java      |   5 +-
 .../EntityCollectionManagerFactoryImpl.java     |   5 +
 .../impl/EntityCollectionManagerImpl.java       |  23 +-
 .../mvcc/stage/write/WriteCommit.java           |  12 +-
 .../mvcc/stage/write/WriteUniqueVerify.java     |  12 +-
 .../collection/uniquevalues/AkkaFig.java        | 116 ---
 .../uniquevalues/ClusterSingletonRouter.java    |  70 --
 .../uniquevalues/GuiceActorProducer.java        |  46 --
 .../collection/uniquevalues/RequestActor.java   | 186 -----
 .../uniquevalues/ReservationCache.java          |   3 +-
 .../uniquevalues/UniqueValueActor.java          |   2 +-
 .../uniquevalues/UniqueValuesFig.java           |  67 ++
 .../uniquevalues/UniqueValuesRouter.java        |  70 ++
 .../uniquevalues/UniqueValuesService.java       |  20 +-
 .../uniquevalues/UniqueValuesServiceImpl.java   | 475 ++---------
 .../uniquevalues/UniqueValuesTableImpl.java     |   9 +-
 .../src/main/resources/application.conf         |  28 -
 .../src/main/resources/cluster-singleton.conf   |  25 -
 .../collection/AbstractUniqueValueTest.java     |  50 ++
 .../collection/EntityCollectionManagerIT.java   |  19 +-
 .../mvcc/stage/write/WriteUniqueVerifyIT.java   |  21 +-
 .../mvcc/stage/write/WriteUniqueVerifyTest.java |  48 +-
 .../uniquevalues/UniqueValuesServiceTest.java   |  38 +-
 .../src/test/resources/usergrid.properties      |   2 +-
 stack/corepersistence/common/pom.xml            |  17 +-
 .../core/guice/SettingsValidationCluster.java   |  18 +
 .../core/guice/MigrationManagerRule.java        |  18 +
 .../guice/SettingsValidationClusterTest.java    |  19 +
 .../src/test/resources/usergrid-UNIT.properties |  19 +
 .../src/test/resources/usergrid.properties      |  19 +
 stack/corepersistence/model/pom.xml             |  16 +
 .../persistence/model/entity/EntityMap.java     |  18 +
 .../persistence/model/util/EntityUtils.java     |  18 +
 .../persistence/model/util/UUIDGenerator.java   |  18 +
 .../persistence/model/field/EntityTest.java     |  18 +
 .../model/util/UUIDGeneratorTest.java           |  18 +
 stack/corepersistence/pom.xml                   |  72 ++
 stack/corepersistence/queryindex/pom.xml        |  18 +-
 .../resources/corepersistence-UNIT.properties   |   2 +
 .../resources/usergrid-custom-test.properties   |   7 +-
 .../resources/usergrid-rest-deploy-context.xml  |  34 +-
 59 files changed, 2281 insertions(+), 1402 deletions(-)
----------------------------------------------------------------------



[4/8] usergrid git commit: Getting more tests working with new actorsystem module.

Posted by sn...@apache.org.
Getting more tests working with new actorsystem module.


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

Branch: refs/heads/usergrid-1268-akka-211
Commit: 50312ba058f614dc4cc281243301e2992a5802e5
Parents: ee18950
Author: Dave Johnson <sn...@apache.org>
Authored: Tue Jun 21 08:51:38 2016 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Tue Jun 21 08:51:38 2016 -0400

----------------------------------------------------------------------
 .../persistence/actorsystem/ClientActor.java    |  2 +-
 .../collection/AbstractUniqueValueTest.java     | 50 ++++++++++++++++++++
 .../collection/EntityCollectionManagerIT.java   | 13 +----
 .../mvcc/stage/write/WriteUniqueVerifyIT.java   | 16 ++-----
 .../mvcc/stage/write/WriteUniqueVerifyTest.java | 49 ++++++-------------
 .../uniquevalues/UniqueValuesServiceTest.java   | 17 ++-----
 6 files changed, 78 insertions(+), 69 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/50312ba0/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ClientActor.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ClientActor.java b/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ClientActor.java
index c495608..c553a31 100644
--- a/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ClientActor.java
+++ b/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ClientActor.java
@@ -87,7 +87,7 @@ public class ClientActor extends UntypedActor {
             logger.debug("{} responding with status unknown", name);
             getSender().tell( new ErrorResponse("ClientActor not ready"), getSender() );
 
-        } if ( message instanceof StatusRequest ) {
+        } else if ( message instanceof StatusRequest ) {
             if ( ready ) {
                 getSender().tell( new StatusMessage( name, StatusMessage.Status.READY ), getSender() );
             } else {

http://git-wip-us.apache.org/repos/asf/usergrid/blob/50312ba0/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/AbstractUniqueValueTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/AbstractUniqueValueTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/AbstractUniqueValueTest.java
new file mode 100644
index 0000000..041835b
--- /dev/null
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/AbstractUniqueValueTest.java
@@ -0,0 +1,50 @@
+/**
+ * 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.persistence.collection;
+
+import org.apache.usergrid.persistence.actorsystem.ActorSystemManager;
+import org.apache.usergrid.persistence.collection.uniquevalues.UniqueValueActor;
+import org.apache.usergrid.persistence.collection.uniquevalues.UniqueValuesService;
+import java.util.HashMap;
+import java.util.Map;
+
+
+public class AbstractUniqueValueTest {
+
+    private static Map<Integer, Boolean> startedAkka = new HashMap<>();
+
+
+    protected synchronized void initAkka(
+        int port, ActorSystemManager actorSystemManager, UniqueValuesService uniqueValuesService ) {
+
+        if ( startedAkka.get(port) == null ) {
+
+            actorSystemManager.registerRouterProducer( uniqueValuesService );
+            actorSystemManager.registerMessageType( UniqueValueActor.Request.class, "/user/uvProxy" );
+            actorSystemManager.registerMessageType( UniqueValueActor.Reservation.class, "/user/uvProxy" );
+            actorSystemManager.registerMessageType( UniqueValueActor.Cancellation.class, "/user/uvProxy" );
+            actorSystemManager.registerMessageType( UniqueValueActor.Confirmation.class, "/user/uvProxy" );
+            actorSystemManager.start( "127.0.0.1", port, "us-east" );
+            actorSystemManager.waitForRequestActors();
+
+            startedAkka.put( port, true );
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/50312ba0/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java
index 6c3cfe7..bb2377a 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java
@@ -64,7 +64,7 @@ import static org.junit.Assert.*;
 /** @author tnine */
 @RunWith( ITRunner.class )
 @UseModules( TestCollectionModule.class )
-public class EntityCollectionManagerIT {
+public class EntityCollectionManagerIT extends AbstractUniqueValueTest {
 
     @Inject
     private EntityCollectionManagerFactory factory;
@@ -88,19 +88,10 @@ public class EntityCollectionManagerIT {
     @Inject
     UniqueValuesService uniqueValuesService;
 
-    private static AtomicBoolean startedAkka = new AtomicBoolean( false );
 
     @Before
     public void initAkka() {
-        if ( !startedAkka.getAndSet( true ) ) {
-            actorSystemManager.registerRouterProducer( uniqueValuesService );
-            actorSystemManager.registerMessageType( UniqueValueActor.Request.class, "/user/uvProxy" );
-            actorSystemManager.registerMessageType( UniqueValueActor.Reservation.class, "/user/uvProxy" );
-            actorSystemManager.registerMessageType( UniqueValueActor.Cancellation.class, "/user/uvProxy" );
-            actorSystemManager.registerMessageType( UniqueValueActor.Confirmation.class, "/user/uvProxy" );
-            actorSystemManager.start( "127.0.0.1", 2554, "us-east" );
-            actorSystemManager.waitForRequestActors();
-        }
+        initAkka( 2555, actorSystemManager, uniqueValuesService );
     }
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/50312ba0/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerifyIT.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerifyIT.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerifyIT.java
index 9e29f44..ccae9be 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerifyIT.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerifyIT.java
@@ -19,6 +19,7 @@ package org.apache.usergrid.persistence.collection.mvcc.stage.write;
 
 
 import org.apache.usergrid.persistence.actorsystem.ActorSystemManager;
+import org.apache.usergrid.persistence.collection.AbstractUniqueValueTest;
 import org.apache.usergrid.persistence.collection.uniquevalues.UniqueValueActor;
 import org.apache.usergrid.persistence.collection.uniquevalues.UniqueValuesService;
 import org.junit.Before;
@@ -57,7 +58,7 @@ import static org.junit.Assert.fail;
  */
 @RunWith( ITRunner.class )
 @UseModules( TestCollectionModule.class )
-public class WriteUniqueVerifyIT {
+public class WriteUniqueVerifyIT extends AbstractUniqueValueTest {
 
     @Inject
     private EntityCollectionManagerFactory factory;
@@ -78,21 +79,14 @@ public class WriteUniqueVerifyIT {
     @Inject
     UniqueValuesService uniqueValuesService;
 
-    private static AtomicBoolean startedAkka = new AtomicBoolean( false );
 
     @Before
     public void initAkka() {
-        if ( !startedAkka.getAndSet( true ) ) {
-            actorSystemManager.registerRouterProducer( uniqueValuesService );
-            actorSystemManager.registerMessageType( UniqueValueActor.Request.class, "/user/uvProxy" );
-            actorSystemManager.registerMessageType( UniqueValueActor.Reservation.class, "/user/uvProxy" );
-            actorSystemManager.registerMessageType( UniqueValueActor.Cancellation.class, "/user/uvProxy" );
-            actorSystemManager.registerMessageType( UniqueValueActor.Confirmation.class, "/user/uvProxy" );
-            actorSystemManager.start( "127.0.0.1", 2554, "us-east" );
-            actorSystemManager.waitForRequestActors();
-        }
+        // each test class needs unique port number
+        initAkka( 2551, actorSystemManager, uniqueValuesService );
     }
 
+
     @Test
     public void testConflict() {
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/50312ba0/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerifyTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerifyTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerifyTest.java
index 6daef08..635e262 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerifyTest.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerifyTest.java
@@ -18,48 +18,38 @@
 package org.apache.usergrid.persistence.collection.mvcc.stage.write;
 
 
+import com.google.inject.Inject;
+import com.netflix.astyanax.Keyspace;
+import com.netflix.astyanax.MutationBatch;
+import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
 import org.apache.usergrid.persistence.actorsystem.ActorSystemManager;
-import org.apache.usergrid.persistence.collection.EntityCollectionManager;
+import org.apache.usergrid.persistence.collection.AbstractUniqueValueTest;
 import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory;
-import org.apache.usergrid.persistence.collection.uniquevalues.UniqueValueActor;
-import org.apache.usergrid.persistence.collection.uniquevalues.UniqueValuesService;
-import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
-import org.apache.usergrid.persistence.model.entity.SimpleId;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
 import org.apache.usergrid.persistence.collection.MvccEntity;
 import org.apache.usergrid.persistence.collection.guice.TestCollectionModule;
 import org.apache.usergrid.persistence.collection.mvcc.stage.CollectionIoEvent;
 import org.apache.usergrid.persistence.collection.serialization.SerializationFig;
 import org.apache.usergrid.persistence.collection.serialization.UniqueValueSerializationStrategy;
+import org.apache.usergrid.persistence.collection.uniquevalues.UniqueValuesService;
 import org.apache.usergrid.persistence.core.astyanax.CassandraConfig;
 import org.apache.usergrid.persistence.core.guice.MigrationManagerRule;
 import org.apache.usergrid.persistence.core.scope.ApplicationScope;
 import org.apache.usergrid.persistence.core.test.ITRunner;
 import org.apache.usergrid.persistence.core.test.UseModules;
 import org.apache.usergrid.persistence.model.entity.Entity;
-
-import com.google.inject.Inject;
-import com.netflix.astyanax.Keyspace;
-import com.netflix.astyanax.MutationBatch;
-import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
-
-import java.util.concurrent.atomic.AtomicBoolean;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
 
 import static org.apache.usergrid.persistence.collection.mvcc.stage.TestEntityGenerator.fromEntity;
 import static org.apache.usergrid.persistence.collection.mvcc.stage.TestEntityGenerator.generateEntity;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.*;
 
 
 @RunWith( ITRunner.class )
 @UseModules( TestCollectionModule.class )
-public class WriteUniqueVerifyTest {
+public class WriteUniqueVerifyTest extends AbstractUniqueValueTest {
 
     @Inject
     private EntityCollectionManagerFactory factory;
@@ -84,19 +74,10 @@ public class WriteUniqueVerifyTest {
     UniqueValuesService uniqueValuesService;
 
 
-    private static AtomicBoolean startedAkka = new AtomicBoolean( false );
-
     @Before
     public void initAkka() {
-        if ( !startedAkka.getAndSet( true ) ) {
-            actorSystemManager.registerRouterProducer( uniqueValuesService );
-            actorSystemManager.registerMessageType( UniqueValueActor.Request.class, "/user/uvProxy" );
-            actorSystemManager.registerMessageType( UniqueValueActor.Reservation.class, "/user/uvProxy" );
-            actorSystemManager.registerMessageType( UniqueValueActor.Cancellation.class, "/user/uvProxy" );
-            actorSystemManager.registerMessageType( UniqueValueActor.Confirmation.class, "/user/uvProxy" );
-            actorSystemManager.start( "127.0.0.1", 2554, "us-east" );
-            actorSystemManager.waitForRequestActors();
-        }
+        // each test class needs unique port number
+        initAkka( 2552, actorSystemManager, uniqueValuesService );
     }
 
 
@@ -119,7 +100,7 @@ public class WriteUniqueVerifyTest {
 
        newStage.call( new CollectionIoEvent<>( collectionScope, mvccEntity ) ) ;
 
-       //if we get here, it's a success.  We want to test no exceptions are thrown
+       // if we get here, it's a success.  We want to test no exceptions are thrown
 
         verify(batch, never()).execute();
     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/50312ba0/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesServiceTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesServiceTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesServiceTest.java
index 8db582e..3cba9c8 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesServiceTest.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesServiceTest.java
@@ -24,6 +24,7 @@ import com.google.common.collect.Multimaps;
 import com.google.inject.Inject;
 import org.apache.usergrid.persistence.actorsystem.ActorSystemFig;
 import org.apache.usergrid.persistence.actorsystem.ActorSystemManager;
+import org.apache.usergrid.persistence.collection.AbstractUniqueValueTest;
 import org.apache.usergrid.persistence.collection.EntityCollectionManager;
 import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory;
 import org.apache.usergrid.persistence.collection.exception.WriteUniqueVerifyException;
@@ -58,7 +59,7 @@ import java.util.concurrent.atomic.AtomicInteger;
  */
 @RunWith( ITRunner.class )
 @UseModules( TestCollectionModule.class )
-public class UniqueValuesServiceTest {
+public class UniqueValuesServiceTest extends AbstractUniqueValueTest {
     private static final Logger logger = LoggerFactory.getLogger( UniqueValuesServiceTest.class );
 
     @Inject
@@ -77,24 +78,16 @@ public class UniqueValuesServiceTest {
     @Inject
     UniqueValuesService uniqueValuesService;
 
-    private static AtomicBoolean startedAkka = new AtomicBoolean( false );
 
     int numThreads = 6;
     int poolSize = 5;
-    int numUsers = 1;
+    int numUsers = 100;
 
 
     @Before
     public void initAkka() {
-        if ( !startedAkka.getAndSet( true ) ) {
-            actorSystemManager.registerRouterProducer( uniqueValuesService );
-            actorSystemManager.registerMessageType( UniqueValueActor.Request.class, "/user/uvProxy" );
-            actorSystemManager.registerMessageType( UniqueValueActor.Reservation.class, "/user/uvProxy" );
-            actorSystemManager.registerMessageType( UniqueValueActor.Cancellation.class, "/user/uvProxy" );
-            actorSystemManager.registerMessageType( UniqueValueActor.Confirmation.class, "/user/uvProxy" );
-            actorSystemManager.start( "127.0.0.1", 2554, "us-east" );
-            actorSystemManager.waitForRequestActors();
-        }
+        // each test class needs unique port number
+        initAkka( 2553, actorSystemManager, uniqueValuesService );
     }
 
 


[3/8] usergrid git commit: Unique values test passes with new "actor system" module

Posted by sn...@apache.org.
Unique values test passes with new "actor system" module


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

Branch: refs/heads/usergrid-1268-akka-211
Commit: ee18950f6e605dc114257b4678802ba80039e959
Parents: 97aec4d
Author: Dave Johnson <sn...@apache.org>
Authored: Tue Jun 21 08:02:26 2016 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Tue Jun 21 08:02:26 2016 -0400

----------------------------------------------------------------------
 stack/core/pom.xml                              | 821 ++++++++++---------
 .../corepersistence/CpEntityManager.java        |   8 +-
 .../corepersistence/CpEntityManagerFactory.java |  12 +-
 .../service/ApplicationServiceImpl.java         |   8 +-
 stack/corepersistence/actorsystem/pom.xml       |  99 +++
 .../persistence/actorsystem/ActorSystemFig.java | 116 +++
 .../actorsystem/ActorSystemManager.java         |  39 +
 .../actorsystem/ActorSystemManagerImpl.java     | 398 +++++++++
 .../actorsystem/ActorSystemModule.java          |  34 +
 .../persistence/actorsystem/ClientActor.java    | 205 +++++
 .../actorsystem/GuiceActorProducer.java         |  46 ++
 .../persistence/actorsystem/RouterProducer.java |  45 +
 .../src/main/resources/application.conf         |  28 +
 .../src/main/resources/cluster-singleton.conf   |  25 +
 .../actorsystem/ActorServiceServiceTest.java    |  57 ++
 stack/corepersistence/collection/pom.xml        |  22 +
 .../collection/EntityCollectionManager.java     |   6 -
 .../collection/guice/CollectionModule.java      |   4 +-
 .../EntityCollectionManagerFactoryImpl.java     |   5 +
 .../impl/EntityCollectionManagerImpl.java       |  23 +-
 .../mvcc/stage/write/WriteCommit.java           |  12 +-
 .../mvcc/stage/write/WriteUniqueVerify.java     |  12 +-
 .../collection/uniquevalues/AkkaFig.java        | 116 ---
 .../uniquevalues/ClusterSingletonRouter.java    |  70 --
 .../uniquevalues/GuiceActorProducer.java        |  46 --
 .../collection/uniquevalues/RequestActor.java   | 186 -----
 .../uniquevalues/ReservationCache.java          |   3 +-
 .../uniquevalues/UniqueValueActor.java          |   2 +-
 .../uniquevalues/UniqueValuesRouter.java        |  70 ++
 .../uniquevalues/UniqueValuesService.java       |  20 +-
 .../uniquevalues/UniqueValuesServiceImpl.java   | 442 ++--------
 .../uniquevalues/UniqueValuesTableImpl.java     |   9 +-
 .../src/main/resources/application.conf         |  28 -
 .../src/main/resources/cluster-singleton.conf   |  25 -
 .../collection/EntityCollectionManagerIT.java   |  20 +-
 .../mvcc/stage/write/WriteUniqueVerifyIT.java   |  19 +-
 .../mvcc/stage/write/WriteUniqueVerifyTest.java |  19 +-
 .../uniquevalues/UniqueValuesServiceTest.java   |  38 +-
 stack/corepersistence/common/pom.xml            |  17 +-
 stack/corepersistence/model/pom.xml             |  16 +
 stack/corepersistence/pom.xml                   |   1 +
 stack/corepersistence/queryindex/pom.xml        |  18 +-
 42 files changed, 1835 insertions(+), 1355 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/stack/core/pom.xml
----------------------------------------------------------------------
diff --git a/stack/core/pom.xml b/stack/core/pom.xml
index 090f46b..9c6497e 100644
--- a/stack/core/pom.xml
+++ b/stack/core/pom.xml
@@ -17,30 +17,30 @@
 -->
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-  <parent>
-    <groupId>org.apache.usergrid</groupId>
-    <artifactId>usergrid</artifactId>
-    <version>2.1.1-SNAPSHOT</version>
-    <relativePath>../</relativePath>
-  </parent>
-
-  <artifactId>usergrid-core</artifactId>
-  <name>Usergrid Core</name>
-  <description>Core services for Usergrid system.</description>
-  <packaging>jar</packaging>
-
-  <reporting>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-javadoc-plugin</artifactId>
-      </plugin>
-    </plugins>
-  </reporting>
-
-
-  <build>
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.usergrid</groupId>
+        <artifactId>usergrid</artifactId>
+        <version>2.1.1-SNAPSHOT</version>
+        <relativePath>../</relativePath>
+    </parent>
+
+    <artifactId>usergrid-core</artifactId>
+    <name>Usergrid Core</name>
+    <description>Core services for Usergrid system.</description>
+    <packaging>jar</packaging>
+
+    <reporting>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-javadoc-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </reporting>
+
+
+    <build>
 
         <resources>
             <resource>
@@ -55,390 +55,395 @@
                 </includes>
             </resource>
         </resources>
-    <testResources>
-      <testResource>
-        <directory>src/test/resources</directory>
-        <filtering>true</filtering>
-        <includes>
-          <include>**/*.yaml</include>
-          <include>**/*.properties</include>
-          <include>**/*.xml</include>
-        </includes>
-      </testResource>
-      <testResource>
-        <directory>src/test/resources</directory>
-        <filtering>true</filtering>
-        <includes>
-          <include>largeentity.json</include>
-        </includes>
-      </testResource>
-    </testResources>
-
-    <plugins>
-
-      <!--
-      Do not need to configure surefire plugin here, parent POM configuration is sufficient.
-      -->
-
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-jar-plugin</artifactId>
-        <executions>
-          <execution>
-            <id>test-jar-execution</id>
-            <phase>package</phase>
-            <goals>
-              <goal>test-jar</goal>
-            </goals>
-            <configuration>
-              <includes>
-                <include>**/org/apache/usergrid/**</include>
-              </includes>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
-
-    </plugins>
-  </build>
-
-  <dependencies>
-
-
-      <!-- dependent on wiring guice and spring -->
-      <dependency>
-          <groupId>com.google.inject.extensions</groupId>
-          <artifactId>guice-spring</artifactId>
-          <version>4.0-beta5</version>
-      </dependency>
-
-    <!-- Apache Dependencies -->
-
-    <dependency>
-      <groupId>org.apache.cassandra</groupId>
-      <artifactId>cassandra-all</artifactId>
-      <!-- Exclude the old and problematic Snappy -->
-      <exclusions>
-        <exclusion>
-          <artifactId>snappy-java</artifactId>
-          <groupId>org.xerial.snappy</groupId>
-        </exclusion>
-        <exclusion>
-          <artifactId>antlr</artifactId>
-          <groupId>org.antlr</groupId>
-        </exclusion>
-          <exclusion>
+        <testResources>
+            <testResource>
+                <directory>src/test/resources</directory>
+                <filtering>true</filtering>
+                <includes>
+                    <include>**/*.yaml</include>
+                    <include>**/*.properties</include>
+                    <include>**/*.xml</include>
+                </includes>
+            </testResource>
+            <testResource>
+                <directory>src/test/resources</directory>
+                <filtering>true</filtering>
+                <includes>
+                    <include>largeentity.json</include>
+                </includes>
+            </testResource>
+        </testResources>
+
+        <plugins>
+
+            <!--
+            Do not need to configure surefire plugin here, parent POM configuration is sufficient.
+            -->
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>test-jar-execution</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>test-jar</goal>
+                        </goals>
+                        <configuration>
+                            <includes>
+                                <include>**/org/apache/usergrid/**</include>
+                            </includes>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+
+        </plugins>
+    </build>
+
+    <dependencies>
+
+
+        <!-- dependent on wiring guice and spring -->
+        <dependency>
+            <groupId>com.google.inject.extensions</groupId>
+            <artifactId>guice-spring</artifactId>
+            <version>4.0-beta5</version>
+        </dependency>
+
+        <!-- Apache Dependencies -->
+
+        <dependency>
+            <groupId>org.apache.cassandra</groupId>
+            <artifactId>cassandra-all</artifactId>
+            <!-- Exclude the old and problematic Snappy -->
+            <exclusions>
+                <exclusion>
+                    <artifactId>snappy-java</artifactId>
+                    <groupId>org.xerial.snappy</groupId>
+                </exclusion>
+                <exclusion>
+                    <artifactId>antlr</artifactId>
+                    <groupId>org.antlr</groupId>
+                </exclusion>
+                <exclusion>
+                    <artifactId>netty</artifactId>
+                    <groupId>io.netty</groupId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.cassandra</groupId>
+            <artifactId>cassandra-thrift</artifactId>
+        </dependency>
+
+        <!-- Include the slighly newer and less problematic snappy -->
+        <dependency>
+            <artifactId>snappy-java</artifactId>
+            <groupId>org.xerial.snappy</groupId>
+            <version>1.0.5</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>commons-collections</groupId>
+            <artifactId>commons-collections</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>commons-codec</groupId>
+            <artifactId>commons-codec</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>commons-lang</groupId>
+            <artifactId>commons-lang</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>commons-cli</groupId>
+            <artifactId>commons-cli</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>commons-beanutils</groupId>
+            <artifactId>commons-beanutils</artifactId>
+        </dependency>
+
+        <!-- SUN, Javax Package, and Other Commercial Dependencies -->
+
+        <dependency>
+            <groupId>com.beust</groupId>
+            <artifactId>jcommander</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.sun.mail</groupId>
+            <artifactId>javax.mail</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>javax.activation</groupId>
+            <artifactId>activation</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>javax.persistence</groupId>
+            <artifactId>persistence-api</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.fasterxml.uuid</groupId>
+            <artifactId>java-uuid-generator</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.hazelcast</groupId>
+            <artifactId>hazelcast-all</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.netflix.curator</groupId>
+            <artifactId>curator-recipes</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.netflix.astyanax</groupId>
+            <artifactId>astyanax-recipes</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+        </dependency>
+
+        <!-- Codehaus, Spring and Other Org Dependencies -->
+
+        <dependency>
+            <groupId>org.hectorclient</groupId>
+            <artifactId>hector-core</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-core</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-expression</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-beans</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-aop</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>aopalliance</groupId>
+            <artifactId>aopalliance</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-context</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-context-support</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-web</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.yaml</groupId>
+            <artifactId>snakeyaml</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.jsoup</groupId>
+            <artifactId>jsoup</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.perf4j</groupId>
+            <artifactId>perf4j</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.aspectj</groupId>
+            <artifactId>aspectjweaver</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.aspectj</groupId>
+            <artifactId>aspectjrt</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>cglib</groupId>
+            <artifactId>cglib-nodep</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>jline</groupId>
+            <artifactId>jline</artifactId>
+        </dependency>
+
+        <!--
+            <dependency>
+              <groupId>org.jboss.netty</groupId>
               <artifactId>netty</artifactId>
-              <groupId>io.netty</groupId>
-          </exclusion>
-      </exclusions>
-    </dependency>
-
-    <dependency>
-      <groupId>org.apache.cassandra</groupId>
-      <artifactId>cassandra-thrift</artifactId>
-    </dependency>
-
-    <!-- Include the slighly newer and less problematic snappy -->
-    <dependency>
-      <artifactId>snappy-java</artifactId>
-      <groupId>org.xerial.snappy</groupId>
-      <version>1.0.5</version>
-    </dependency>
-
-    <dependency>
-      <groupId>org.apache.httpcomponents</groupId>
-      <artifactId>httpclient</artifactId>
-    </dependency>
-
-    <dependency>
-      <groupId>commons-collections</groupId>
-      <artifactId>commons-collections</artifactId>
-    </dependency>
-
-    <dependency>
-      <groupId>commons-io</groupId>
-      <artifactId>commons-io</artifactId>
-    </dependency>
-
-    <dependency>
-      <groupId>commons-codec</groupId>
-      <artifactId>commons-codec</artifactId>
-    </dependency>
-
-    <dependency>
-      <groupId>commons-lang</groupId>
-      <artifactId>commons-lang</artifactId>
-    </dependency>
-
-    <dependency>
-      <groupId>commons-cli</groupId>
-      <artifactId>commons-cli</artifactId>
-    </dependency>
-
-    <dependency>
-      <groupId>commons-beanutils</groupId>
-      <artifactId>commons-beanutils</artifactId>
-    </dependency>
-
-    <!-- SUN, Javax Package, and Other Commercial Dependencies -->
-
-    <dependency>
-      <groupId>com.beust</groupId>
-      <artifactId>jcommander</artifactId>
-    </dependency>
-
-    <dependency>
-      <groupId>com.sun.mail</groupId>
-      <artifactId>javax.mail</artifactId>
-    </dependency>
-
-    <dependency>
-      <groupId>javax.activation</groupId>
-      <artifactId>activation</artifactId>
-    </dependency>
-
-    <dependency>
-      <groupId>javax.persistence</groupId>
-      <artifactId>persistence-api</artifactId>
-    </dependency>
-
-    <dependency>
-      <groupId>com.fasterxml.uuid</groupId>
-      <artifactId>java-uuid-generator</artifactId>
-    </dependency>
-
-    <dependency>
-      <groupId>com.hazelcast</groupId>
-      <artifactId>hazelcast-all</artifactId>
-    </dependency>
-
-    <dependency>
-      <groupId>com.netflix.curator</groupId>
-      <artifactId>curator-recipes</artifactId>
-    </dependency>
-
-      <dependency>
-          <groupId>com.netflix.astyanax</groupId>
-          <artifactId>astyanax-recipes</artifactId>
-      </dependency>
-
-    <dependency>
-      <groupId>com.google.guava</groupId>
-      <artifactId>guava</artifactId>
-    </dependency>
-
-    <!-- Codehaus, Spring and Other Org Dependencies -->
-
-    <dependency>
-      <groupId>org.hectorclient</groupId>
-      <artifactId>hector-core</artifactId>
-    </dependency>
-
-    <dependency>
-      <groupId>org.springframework</groupId>
-      <artifactId>spring-core</artifactId>
-    </dependency>
-
-    <dependency>
-      <groupId>org.springframework</groupId>
-      <artifactId>spring-expression</artifactId>
-    </dependency>
-
-    <dependency>
-      <groupId>org.springframework</groupId>
-      <artifactId>spring-beans</artifactId>
-    </dependency>
-
-    <dependency>
-      <groupId>org.springframework</groupId>
-      <artifactId>spring-aop</artifactId>
-    </dependency>
-
-    <dependency>
-      <groupId>aopalliance</groupId>
-      <artifactId>aopalliance</artifactId>
-    </dependency>
-
-    <dependency>
-      <groupId>org.springframework</groupId>
-      <artifactId>spring-context</artifactId>
-    </dependency>
-
-    <dependency>
-      <groupId>org.springframework</groupId>
-      <artifactId>spring-context-support</artifactId>
-    </dependency>
-
-    <dependency>
-      <groupId>org.springframework</groupId>
-      <artifactId>spring-web</artifactId>
-    </dependency>
-
-    <dependency>
-      <groupId>org.yaml</groupId>
-      <artifactId>snakeyaml</artifactId>
-    </dependency>
-
-    <dependency>
-      <groupId>org.jsoup</groupId>
-      <artifactId>jsoup</artifactId>
-    </dependency>
-
-    <dependency>
-      <groupId>org.perf4j</groupId>
-      <artifactId>perf4j</artifactId>
-    </dependency>
-
-    <dependency>
-      <groupId>org.aspectj</groupId>
-      <artifactId>aspectjweaver</artifactId>
-    </dependency>
-
-    <dependency>
-      <groupId>org.aspectj</groupId>
-      <artifactId>aspectjrt</artifactId>
-    </dependency>
-
-    <dependency>
-      <groupId>cglib</groupId>
-      <artifactId>cglib-nodep</artifactId>
-    </dependency>
-
-    <dependency>
-      <groupId>jline</groupId>
-      <artifactId>jline</artifactId>
-    </dependency>
-
-<!--
-    <dependency>
-      <groupId>org.jboss.netty</groupId>
-      <artifactId>netty</artifactId>
-    </dependency>
--->
-
-    <!-- Test and Logging Dependencies -->
-
-    <dependency>
-      <groupId>org.apache.usergrid</groupId>
-      <artifactId>usergrid-config</artifactId>
-      <version>${project.version}</version>
-      <scope>test</scope>
-      <classifier>tests</classifier>
-    </dependency>
-
-    <dependency>
-      <groupId>org.hectorclient</groupId>
-      <artifactId>hector-test</artifactId>
-      <scope>test</scope>
-    </dependency>
-
-
-    <dependency>
-      <groupId>org.mockito</groupId>
-      <artifactId>mockito-core</artifactId>
-      <version>${mockito.version}</version>
-      <scope>test</scope>
-    </dependency>
-
-    <dependency>
-      <groupId>org.jvnet.mock-javamail</groupId>
-      <artifactId>mock-javamail</artifactId>
-      <scope>test</scope>
-    </dependency>
-
-    <dependency>
-      <groupId>org.apache.usergrid</groupId>
-      <artifactId>usergrid-test-utils</artifactId>
-      <version>${project.version}</version>
-      <scope>test</scope>
-    </dependency>
-
-    <dependency>
-      <groupId>org.springframework</groupId>
-      <artifactId>spring-test</artifactId>
-      <scope>test</scope>
-    </dependency>
-
-
-       <dependency>
-        <groupId>org.apache.usergrid</groupId>
-        <artifactId>common</artifactId>
-        <version>2.1.1-SNAPSHOT</version>
-        <type>test-jar</type>
-           <scope>test</scope>
-       </dependency>
-
-
-    <!-- Core Persistence deps -->
-    <dependency>
-	    <groupId>org.apache.usergrid</groupId>
-	    <artifactId>collection</artifactId>
-	    <version>2.1.1-SNAPSHOT</version>
-	    <type>jar</type>
-      <exclusions>
-        <exclusion>
-          <artifactId>antlr</artifactId>
-          <groupId>org.antlr</groupId>
-        </exclusion>
-        <exclusion>
-          <artifactId>antlr</artifactId>
-          <groupId>antlr</groupId>
-        </exclusion>
-      </exclusions>
-    </dependency>
-
-
-    <dependency>
-	    <groupId>org.apache.usergrid</groupId>
-	    <artifactId>queryindex</artifactId>
-	    <version>2.1.1-SNAPSHOT</version>
-	    <type>jar</type>
-    </dependency>
-
-    <dependency>
-	    <groupId>org.apache.usergrid</groupId>
-	    <artifactId>graph</artifactId>
-	    <version>2.1.1-SNAPSHOT</version>
-	    <type>jar</type>
-    </dependency>
-
-    <dependency>
-      <groupId>org.apache.usergrid</groupId>
-      <artifactId>map</artifactId>
-      <version>2.1.1-SNAPSHOT</version>
-      <type>jar</type>
-    </dependency>
-
-      <dependency>
-          <groupId>org.apache.usergrid</groupId>
-          <artifactId>cache</artifactId>
-          <version>2.1.1-SNAPSHOT</version>
-      </dependency>
-
-      <dependency>
-      <groupId>org.apache.usergrid</groupId>
-      <artifactId>queue</artifactId>
-      <version>2.1.1-SNAPSHOT</version>
-      <type>jar</type>
-    </dependency>
-
-    <dependency>
-      <groupId>com.codahale.metrics</groupId>
-      <artifactId>metrics-core</artifactId>
-      <version>${metrics.version}</version>
-    </dependency>
-
-    <dependency>
-      <groupId>com.codahale.metrics</groupId>
-      <artifactId>metrics-graphite</artifactId>
-      <version>${metrics.version}</version>
-    </dependency>
-
-  </dependencies>
-
-  <!--
-  Do not need jacoco profile here because we do not override the surefire plugin in this POM
-  -->
+            </dependency>
+        -->
+
+        <!-- Test and Logging Dependencies -->
+
+        <dependency>
+            <groupId>org.apache.usergrid</groupId>
+            <artifactId>usergrid-config</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+            <classifier>tests</classifier>
+        </dependency>
+
+        <dependency>
+            <groupId>org.hectorclient</groupId>
+            <artifactId>hector-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-core</artifactId>
+            <version>${mockito.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.jvnet.mock-javamail</groupId>
+            <artifactId>mock-javamail</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.usergrid</groupId>
+            <artifactId>usergrid-test-utils</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+
+        <dependency>
+            <groupId>org.apache.usergrid</groupId>
+            <artifactId>common</artifactId>
+            <version>${project.version}</version>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+
+
+        <!-- Core Persistence deps -->
+        <dependency>
+            <groupId>org.apache.usergrid</groupId>
+            <artifactId>collection</artifactId>
+            <version>${project.version}</version>
+            <type>jar</type>
+            <exclusions>
+                <exclusion>
+                    <artifactId>antlr</artifactId>
+                    <groupId>org.antlr</groupId>
+                </exclusion>
+                <exclusion>
+                    <artifactId>antlr</artifactId>
+                    <groupId>antlr</groupId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.usergrid</groupId>
+            <artifactId>queryindex</artifactId>
+            <version>${project.version}</version>
+            <type>jar</type>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.usergrid</groupId>
+            <artifactId>graph</artifactId>
+            <version>${project.version}</version>
+            <type>jar</type>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.usergrid</groupId>
+            <artifactId>map</artifactId>
+            <version>${project.version}</version>
+            <type>jar</type>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.usergrid</groupId>
+            <artifactId>cache</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.usergrid</groupId>
+            <artifactId>actorsystem</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.usergrid</groupId>
+            <artifactId>queue</artifactId>
+            <version>${project.version}</version>
+            <type>jar</type>
+        </dependency>
+
+        <dependency>
+            <groupId>com.codahale.metrics</groupId>
+            <artifactId>metrics-core</artifactId>
+            <version>${metrics.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.codahale.metrics</groupId>
+            <artifactId>metrics-graphite</artifactId>
+            <version>${metrics.version}</version>
+        </dependency>
+
+    </dependencies>
+
+    <!--
+    Do not need jacoco profile here because we do not override the surefire plugin in this POM
+    -->
 
 </project>

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
index b0d3f59..6c06104 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
@@ -37,13 +37,13 @@ import org.apache.usergrid.corepersistence.util.CpEntityMapUtils;
 import org.apache.usergrid.corepersistence.util.CpNamingUtils;
 import org.apache.usergrid.persistence.*;
 import org.apache.usergrid.persistence.Query.Level;
+import org.apache.usergrid.persistence.actorsystem.ActorSystemFig;
 import org.apache.usergrid.persistence.cassandra.*;
 import org.apache.usergrid.persistence.cassandra.util.TraceParticipant;
 import org.apache.usergrid.persistence.collection.EntityCollectionManager;
 import org.apache.usergrid.persistence.collection.EntitySet;
 import org.apache.usergrid.persistence.collection.FieldSet;
 import org.apache.usergrid.persistence.collection.exception.WriteUniqueVerifyException;
-import org.apache.usergrid.persistence.collection.uniquevalues.AkkaFig;
 import org.apache.usergrid.persistence.core.metrics.MetricsFactory;
 import org.apache.usergrid.persistence.core.scope.ApplicationScope;
 import org.apache.usergrid.persistence.entities.*;
@@ -105,7 +105,7 @@ public class CpEntityManager implements EntityManager {
 
     private final UUID applicationId;
     private final EntityManagerFig entityManagerFig;
-    private final AkkaFig akkaFig;
+    private final ActorSystemFig actorSystemFig;
 
     private Application application;
 
@@ -171,7 +171,7 @@ public class CpEntityManager implements EntityManager {
                             final AsyncEventService indexService,
                             final ManagerCache managerCache,
                             final MetricsFactory metricsFactory,
-                            final AkkaFig akkaFig,
+                            final ActorSystemFig actorSystemFig,
                             final EntityManagerFig entityManagerFig,
                             final GraphManagerFactory graphManagerFactory,
                             final CollectionService collectionService,
@@ -180,7 +180,7 @@ public class CpEntityManager implements EntityManager {
                             final UUID applicationId ) {
 
         this.entityManagerFig = entityManagerFig;
-        this.akkaFig = akkaFig;
+        this.actorSystemFig = actorSystemFig;
 
         Preconditions.checkNotNull( cass, "cass must not be null" );
         Preconditions.checkNotNull( counterUtils, "counterUtils must not be null" );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/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 bc1b335..99bf1e0 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
@@ -35,13 +35,13 @@ import org.apache.usergrid.corepersistence.util.CpNamingUtils;
 import org.apache.usergrid.exception.ConflictException;
 import org.apache.usergrid.locking.LockManager;
 import org.apache.usergrid.persistence.*;
+import org.apache.usergrid.persistence.actorsystem.ActorSystemFig;
 import org.apache.usergrid.persistence.cassandra.CassandraService;
 import org.apache.usergrid.persistence.cassandra.CounterUtils;
 import org.apache.usergrid.persistence.cassandra.Setup;
 import org.apache.usergrid.persistence.collection.EntityCollectionManager;
 import org.apache.usergrid.persistence.collection.exception.CollectionRuntimeException;
 import org.apache.usergrid.persistence.collection.serialization.impl.migration.EntityIdScope;
-import org.apache.usergrid.persistence.collection.uniquevalues.AkkaFig;
 import org.apache.usergrid.persistence.collection.uniquevalues.UniqueValuesService;
 import org.apache.usergrid.persistence.core.metrics.MetricsFactory;
 import org.apache.usergrid.persistence.core.migration.data.MigrationDataProvider;
@@ -82,7 +82,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
     private static final Logger logger = LoggerFactory.getLogger( CpEntityManagerFactory.class );
 
     private final EntityManagerFig entityManagerFig;
-    private final AkkaFig akkaFig;
+    private final ActorSystemFig actorSystemFig;
 
     private ApplicationContext applicationContext;
 
@@ -125,7 +125,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
         this.injector = injector;
         this.reIndexService = injector.getInstance(ReIndexService.class);
         this.entityManagerFig = injector.getInstance(EntityManagerFig.class);
-        this.akkaFig = injector.getInstance( AkkaFig.class );
+        this.actorSystemFig = injector.getInstance( ActorSystemFig.class );
         this.managerCache = injector.getInstance( ManagerCache.class );
         this.metricsFactory = injector.getInstance( MetricsFactory.class );
         this.indexService = injector.getInstance( AsyncEventService.class );
@@ -139,11 +139,11 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
 
         logger.info("EntityManagerFactoring starting...");
 
-        if ( akkaFig.getAkkaEnabled() ) {
+        if ( actorSystemFig.getAkkaEnabled() ) {
             try {
                 logger.info("Akka cluster starting...");
                 this.uniqueValuesService = injector.getInstance( UniqueValuesService.class );
-                this.uniqueValuesService.start();
+                // TODO: this.uniqueValuesService.start();
             } catch (Throwable t) {
                 logger.error("Error starting Akka", t);
                 throw t;
@@ -360,7 +360,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
             indexService,
             managerCache,
             metricsFactory,
-            akkaFig,
+            actorSystemFig,
             entityManagerFig,
             graphManagerFactory,
             collectionService,

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ApplicationServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ApplicationServiceImpl.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ApplicationServiceImpl.java
index c6b3b15..ea16d8b 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ApplicationServiceImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ApplicationServiceImpl.java
@@ -28,10 +28,10 @@ import org.apache.usergrid.corepersistence.index.CollectionSettingsCacheFactory;
 import org.apache.usergrid.corepersistence.rx.impl.AllEntityIdsObservable;
 import org.apache.usergrid.corepersistence.util.CpNamingUtils;
 import org.apache.usergrid.persistence.Schema;
+import org.apache.usergrid.persistence.actorsystem.ActorSystemFig;
 import org.apache.usergrid.persistence.collection.EntityCollectionManager;
 import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory;
 import org.apache.usergrid.persistence.collection.serialization.impl.migration.EntityIdScope;
-import org.apache.usergrid.persistence.collection.uniquevalues.AkkaFig;
 import org.apache.usergrid.persistence.core.scope.ApplicationScope;
 import org.apache.usergrid.persistence.graph.GraphManager;
 import org.apache.usergrid.persistence.graph.GraphManagerFactory;
@@ -61,7 +61,7 @@ public class ApplicationServiceImpl  implements ApplicationService{
     private final MapManagerFactory mapManagerFactory;
     private final GraphManagerFactory graphManagerFactory;
     private final CollectionSettingsCacheFactory collectionSettingsCacheFactory;
-    private final AkkaFig akkaFig;
+    private final ActorSystemFig actorSystemFig;
 
 
     @Inject
@@ -72,7 +72,7 @@ public class ApplicationServiceImpl  implements ApplicationService{
                                   MapManagerFactory mapManagerFactory,
                                   GraphManagerFactory graphManagerFactory,
                                   CollectionSettingsCacheFactory collectionSettingsCacheFactory,
-                                  AkkaFig akkaFig
+                                  ActorSystemFig actorSystemFig
     ){
 
         this.allEntityIdsObservable = allEntityIdsObservable;
@@ -82,7 +82,7 @@ public class ApplicationServiceImpl  implements ApplicationService{
         this.mapManagerFactory = mapManagerFactory;
         this.graphManagerFactory = graphManagerFactory;
         this.collectionSettingsCacheFactory = collectionSettingsCacheFactory;
-        this.akkaFig = akkaFig;
+        this.actorSystemFig = actorSystemFig;
     }
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/stack/corepersistence/actorsystem/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/actorsystem/pom.xml b/stack/corepersistence/actorsystem/pom.xml
new file mode 100644
index 0000000..85c0d60
--- /dev/null
+++ b/stack/corepersistence/actorsystem/pom.xml
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <parent>
+        <artifactId>persistence</artifactId>
+        <groupId>org.apache.usergrid</groupId>
+        <version>2.1.1-SNAPSHOT</version>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <name>Usergrid ActorSystem</name>
+    <artifactId>actorsystem</artifactId>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>com.typesafe.akka</groupId>
+            <artifactId>akka-actor_2.11</artifactId>
+            <version>2.4.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.typesafe.akka</groupId>
+            <artifactId>akka-remote_2.11</artifactId>
+            <version>2.4.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.typesafe.akka</groupId>
+            <artifactId>akka-cluster_2.11</artifactId>
+            <version>2.4.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.typesafe.akka</groupId>
+            <artifactId>akka-cluster-tools_2.11</artifactId>
+            <version>2.4.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.typesafe.akka</groupId>
+            <artifactId>akka-cluster-metrics_2.11</artifactId>
+            <version>2.4.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.typesafe.akka</groupId>
+            <artifactId>akka-slf4j_2.11</artifactId>
+            <version>2.4.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-collections4</artifactId>
+            <version>4.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>com.google.inject</groupId>
+            <artifactId>guice</artifactId>
+            <version>${guice.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.safehaus.guicyfig</groupId>
+            <artifactId>guicyfig</artifactId>
+            <version>${guicyfig.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.usergrid</groupId>
+            <artifactId>common</artifactId>
+            <version>${project.version}</version>
+            <classifier>tests</classifier>
+            <scope>test</scope>
+        </dependency>
+
+    </dependencies>
+
+</project>

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ActorSystemFig.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ActorSystemFig.java b/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ActorSystemFig.java
new file mode 100644
index 0000000..7af510c
--- /dev/null
+++ b/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ActorSystemFig.java
@@ -0,0 +1,116 @@
+/*
+ * 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.persistence.actorsystem;
+
+
+import org.safehaus.guicyfig.Default;
+import org.safehaus.guicyfig.FigSingleton;
+import org.safehaus.guicyfig.GuicyFig;
+import org.safehaus.guicyfig.Key;
+
+import java.io.Serializable;
+
+@FigSingleton
+public interface ActorSystemFig extends GuicyFig, Serializable {
+
+    String AKKA_ENABLED = "collection.akka.enabled";
+
+    String AKKA_HOSTNAME = "collection.akka.hostname";
+
+    String AKKA_PORT = "collection.akka.port";
+
+    String AKKA_REGION = "collection.akka.region";
+
+    String AKKA_REGION_LIST = "usergrid.queue.regionList"; // same region list used by queues
+
+    String AKKA_REGION_SEEDS = "collection.akka.region.seeds";
+
+    String AKKA_UNIQUEVALUE_ACTORS = "collection.akka.uniquevalue.actors";
+
+    String AKKA_UNIQUEVALUE_CACHE_TTL = "collection.akka.uniquevalue.cache.ttl";
+
+    String AKKA_UNIQUEVALUE_RESERVATION_TTL= "collection.akka.uniquevalue.reservation.ttl";
+
+    String AKKA_AUTHORITATIVE_REGION = "collection.akka.uniquevalue.authoritative.region";
+
+    /**
+     * Use Akka or nah
+     */
+    @Key(AKKA_ENABLED)
+    @Default("true")
+    boolean getAkkaEnabled();
+
+    /**
+     * Hostname to be used in Akka configuration.
+     */
+    @Key(AKKA_HOSTNAME)
+    String getHostname();
+
+    /**
+     * local port to be used in Akka configuration.
+     */
+    @Key(AKKA_PORT)
+    int getPort();
+
+    /**
+     * Local region to be used in Akka configuration.
+     */
+    @Key(AKKA_REGION)
+    String getRegion();
+
+    /**
+     * Comma separated list of regions known to cluster.
+     */
+    @Key(AKKA_REGION_LIST)
+    String getRegionList();
+
+    /**
+     * Number of UniqueValueActors to be started on each node
+     */
+    @Key(AKKA_UNIQUEVALUE_ACTORS)
+    @Default("300")
+    int getUniqueValueActors();
+
+    /**
+     * Comma-separated lists of seeds each with format {region}:{hostname}:{port}.
+     * Regions MUST be listed in the 'usergrid.queue.regionList'
+     */
+    @Key(AKKA_REGION_SEEDS)
+    String getRegionSeeds();
+
+    /**
+     * If no region specified for type, use the authoritative region
+     */
+    @Key(AKKA_AUTHORITATIVE_REGION)
+    String getAkkaAuthoritativeRegion();
+
+    /**
+     * Unique Value cache TTL in seconds.
+     */
+    @Key(AKKA_UNIQUEVALUE_CACHE_TTL)
+    @Default("10")
+    int getUniqueValueCacheTtl();
+
+    /**
+     * Unique Value Reservation TTL in seconds.
+     */
+    @Key(AKKA_UNIQUEVALUE_RESERVATION_TTL)
+    @Default("10")
+    int getUniqueValueReservationTtl();
+}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ActorSystemManager.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ActorSystemManager.java b/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ActorSystemManager.java
new file mode 100644
index 0000000..e2c2913
--- /dev/null
+++ b/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ActorSystemManager.java
@@ -0,0 +1,39 @@
+/*
+ * 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.persistence.actorsystem;
+
+
+import akka.actor.ActorRef;
+
+public interface ActorSystemManager {
+
+    void start();
+
+    void start(String hostname, Integer port, String currentRegion);
+
+    void waitForRequestActors();
+
+    boolean isReady();
+
+    void registerRouterProducer( RouterProducer routerProducer );
+
+    void registerMessageType( Class messageType, String routerPath );
+
+    ActorRef getClientActor(String region );
+}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ActorSystemManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ActorSystemManagerImpl.java b/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ActorSystemManagerImpl.java
new file mode 100644
index 0000000..0622b1b
--- /dev/null
+++ b/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ActorSystemManagerImpl.java
@@ -0,0 +1,398 @@
+/*
+ * 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.persistence.actorsystem;
+
+
+import akka.actor.ActorRef;
+import akka.actor.ActorSystem;
+import akka.actor.Props;
+import akka.pattern.Patterns;
+import akka.util.Timeout;
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.ListMultimap;
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+import com.google.inject.Singleton;
+import com.typesafe.config.Config;
+import com.typesafe.config.ConfigFactory;
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import scala.concurrent.Await;
+import scala.concurrent.Future;
+
+import java.util.*;
+import java.util.concurrent.TimeUnit;
+
+
+@Singleton
+public class ActorSystemManagerImpl implements ActorSystemManager {
+    private static final Logger logger = LoggerFactory.getLogger( ActorSystemManagerImpl.class );
+
+    private String  hostname;
+    private Integer port;
+    private String  currentRegion;
+
+    private static Injector             injector;
+    private final ActorSystemFig        actorSystemFig;
+    private final Map<String, ActorRef> requestActorsByRegion;
+    private final List<RouterProducer>  routerProducers = new ArrayList<>();
+    private final Map<Class, String>    routersByMessageType = new HashMap<>();
+
+
+    @Inject
+    public ActorSystemManagerImpl(Injector inj, ActorSystemFig actorSystemFig) {
+        injector = inj;
+        this.actorSystemFig = actorSystemFig;
+        this.requestActorsByRegion = new HashMap<>();
+    }
+
+
+    /**
+     * Init Akka ActorSystems and wait for request actors to start.
+     */
+    @Override
+    public void start() {
+
+        this.hostname = actorSystemFig.getHostname();
+        this.currentRegion = actorSystemFig.getRegion();
+        this.port = null;
+
+        initAkka();
+        waitForRequestActors();
+    }
+
+
+    /**
+     * For testing purposes only; does not wait for request actors to start.
+     */
+    @Override
+    public void start(String hostname, Integer port, String currentRegion) {
+
+        this.hostname = hostname;
+        this.currentRegion = currentRegion;
+        this.port = port;
+
+        initAkka();
+    }
+
+
+    @Override
+    public boolean isReady() {
+        return !getRequestActorsByRegion().isEmpty();
+    }
+
+
+    @Override
+    public void registerRouterProducer(RouterProducer routerProducer) {
+        routerProducers.add( routerProducer );
+    }
+
+
+    @Override
+    public void registerMessageType(Class messageType, String routerPath) {
+        routersByMessageType.put( messageType, routerPath );
+    }
+
+
+    @Override
+    public ActorRef getClientActor(String region) {
+        return getRequestActorsByRegion().get( region );
+    }
+
+
+    private Map<String, ActorRef> getRequestActorsByRegion() {
+        return requestActorsByRegion;
+    }
+
+
+    private void initAkka() {
+        logger.info("Initializing Akka");
+
+        // Create one actor system with request actor for each region
+
+        if ( StringUtils.isEmpty( hostname )) {
+            throw new RuntimeException( "No value specified for " + ActorSystemFig.AKKA_HOSTNAME );
+        }
+
+        if ( StringUtils.isEmpty( currentRegion )) {
+            throw new RuntimeException( "No value specified for " + ActorSystemFig.AKKA_REGION );
+        }
+
+        if ( StringUtils.isEmpty( actorSystemFig.getRegionList() )) {
+            throw new RuntimeException( "No value specified for " + ActorSystemFig.AKKA_REGION_LIST );
+        }
+
+        if ( StringUtils.isEmpty( actorSystemFig.getRegionSeeds() )) {
+            throw new RuntimeException( "No value specified for " + ActorSystemFig.AKKA_REGION_SEEDS);
+        }
+
+        if ( StringUtils.isEmpty( actorSystemFig.getAkkaAuthoritativeRegion() )) {
+            throw new RuntimeException( "No value specified for " + ActorSystemFig.AKKA_AUTHORITATIVE_REGION);
+        }
+
+        List regionList = Arrays.asList( actorSystemFig.getRegionList().toLowerCase().split(",") );
+
+        logger.info("Initializing Akka for hostname {} region {} regionList {} seeds {}",
+            hostname, currentRegion, regionList, actorSystemFig.getRegionSeeds() );
+
+        final Map<String, ActorSystem> systemMap = new HashMap<>();
+
+        Map<String, Config> configMap = readClusterSingletonConfigs();
+
+        ActorSystem localSystem = createClusterSingletonProxies( configMap, systemMap );
+
+        createRequestActors( systemMap );
+
+        for ( RouterProducer routerProducer : routerProducers ) {
+            routerProducer.createLocalSystemActors( localSystem, systemMap );
+        }
+    }
+
+
+    /**
+     * Read configuration and create a Config for each region.
+     *
+     * @return Map of regions to Configs.
+     */
+    private Map<String, Config> readClusterSingletonConfigs() {
+
+        Map<String, Config> configs = new HashMap<>();
+
+        ListMultimap<String, String> seedsByRegion = ArrayListMultimap.create();
+
+        String[] regionSeeds = actorSystemFig.getRegionSeeds().split( "," );
+
+        logger.info("Found region {} seeds {}", regionSeeds.length, regionSeeds);
+
+        try {
+
+            if ( port != null ) {
+
+                // we are testing, create seeds-by-region map for one region, one seed
+
+                String seed = "akka.tcp://ClusterSystem@" + hostname + ":" + port;
+                seedsByRegion.put( currentRegion, seed );
+                logger.info("Akka testing, only starting one seed");
+
+            } else { // create seeds-by-region map
+
+                for (String regionSeed : regionSeeds) {
+
+                    String[] parts = regionSeed.split( ":" );
+                    String region = parts[0];
+                    String hostname = parts[1];
+                    String regionPortString = parts[2];
+
+                    // all seeds in same region must use same port
+                    // we assume 0th seed has the right port
+                    final Integer regionPort;
+
+                    if (port == null) {
+                        regionPort = Integer.parseInt( regionPortString );
+                    } else {
+                        regionPort = port; // unless we are testing
+                    }
+
+                    String seed = "akka.tcp://ClusterSystem@" + hostname + ":" + regionPort;
+
+                    logger.info("Adding seed {} for region {}", seed, region );
+
+                    seedsByRegion.put( region, seed );
+                }
+
+                if (seedsByRegion.keySet().isEmpty()) {
+                    throw new RuntimeException(
+                        "No seeds listed in 'parsing collection.akka.region.seeds' property." );
+                }
+            }
+
+            int numInstancesPerNode = actorSystemFig.getUniqueValueActors();
+
+            // read config file once for each region
+
+            for ( String region : seedsByRegion.keySet() ) {
+
+                List<String> seeds = seedsByRegion.get( region );
+                int lastColon = seeds.get(0).lastIndexOf(":") + 1;
+                final Integer regionPort = Integer.parseInt( seeds.get(0).substring( lastColon ));
+
+                // cluster singletons only run role "io" nodes and NOT on "client" nodes of other regions
+                String clusterRole = currentRegion.equals( region ) ? "io" : "client";
+
+                logger.info( "Config for region {} is:\n" +
+                        "   Akka Hostname {}\n" +
+                        "   Akka Seeds {}\n" +
+                        "   Akka Port {}\n" +
+                        "   Akka UniqueValueActors per node {}\n" +
+                        "   Akka Authoritative Region {}",
+                    region, hostname, seeds, port, numInstancesPerNode, actorSystemFig.getAkkaAuthoritativeRegion() );
+
+                Map<String, Object> configMap = new HashMap<String, Object>() {{
+                    put( "akka", new HashMap<String, Object>() {{
+                        put( "remote", new HashMap<String, Object>() {{
+                            put( "netty.tcp", new HashMap<String, Object>() {{
+                                put( "hostname", hostname );
+                                put( "bind-hostname", hostname );
+                                put( "port", regionPort );
+                            }} );
+                        }} );
+                        put( "cluster", new HashMap<String, Object>() {{
+                            put( "max-nr-of-instances-per-node", numInstancesPerNode );
+                            put( "roles", Collections.singletonList(clusterRole) );
+                            put( "seed-nodes", new ArrayList<String>() {{
+                                for (String seed : seeds) {
+                                    add( seed );
+                                }
+                            }} );
+                        }} );
+                        put( "actor", new HashMap<String, Object>() {{
+                            put( "deployment", new HashMap<String, Object>() {{
+                                put( "/uvRouter/singleton/router", new HashMap<String, Object>() {{
+                                    put( "cluster", new HashMap<String, Object>() {{
+                                        //put( "roles", Collections.singletonList(role) );
+                                        put( "max-nr-of-instances-per-node", numInstancesPerNode );
+                                    }} );
+                                }} );
+                            }} );
+                        }} );
+                    }} );
+                }};
+
+                Config config = ConfigFactory
+                    .parseMap( configMap )
+                    .withFallback( ConfigFactory.parseString( "akka.cluster.roles = [io]" ) )
+                    .withFallback( ConfigFactory.load( "cluster-singleton" ) );
+
+                configs.put( region, config );
+            }
+
+        } catch ( Exception e ) {
+            throw new RuntimeException("Error 'parsing collection.akka.region.seeds' property", e );
+        }
+
+        return configs;
+    }
+
+
+    /**
+     * Create ActorSystem and ClusterSingletonProxy for every region.
+     * Create ClusterSingletonManager for the current region.
+     *
+     * @param configMap Configurations to be used to create ActorSystems
+     * @param systemMap Map of ActorSystems created by this method
+     *
+     * @return ActorSystem for this region.
+     */
+    private ActorSystem createClusterSingletonProxies(
+        Map<String, Config> configMap, Map<String, ActorSystem> systemMap ) {
+
+        ActorSystem localSystem = null;
+
+        for ( String region : configMap.keySet() ) {
+            Config config = configMap.get( region );
+
+            ActorSystem system = ActorSystem.create( "ClusterSystem", config );
+            systemMap.put( region, system );
+
+            // cluster singletons only run role "io" nodes and NOT on "client" nodes of other regions
+            if ( currentRegion.equals( region ) ) {
+
+                localSystem = system;
+
+                for ( RouterProducer routerProducer : routerProducers ) {
+                    routerProducer.createClusterSingletonManager( system );
+                }
+            }
+
+            for ( RouterProducer routerProducer : routerProducers ) {
+                routerProducer.createClusterSingletonProxy( system );
+            }
+        }
+
+        return localSystem;
+    }
+
+
+    /**
+     * Create RequestActor for each region.
+     *
+     * @param systemMap Map of regions to ActorSystems.
+     */
+    private void createRequestActors( Map<String, ActorSystem> systemMap ) {
+
+        for ( String region : systemMap.keySet() ) {
+
+            logger.info("Creating request actor for region {}", region);
+
+            // Each RequestActor needs to know path to ClusterSingletonProxy and region
+            ActorRef requestActor = systemMap.get( region ).actorOf(
+                //Props.create( ClientActor.class, "/user/uvProxy" ), "requestActor" );
+                Props.create( ClientActor.class, routersByMessageType ), "requestActor" );
+
+            requestActorsByRegion.put( region, requestActor );
+        }
+    }
+
+
+    @Override
+    public void waitForRequestActors() {
+
+        for ( String region : requestActorsByRegion.keySet() ) {
+            ActorRef ra = requestActorsByRegion.get( region );
+            waitForRequestActor( ra );
+        }
+    }
+
+
+    private void waitForRequestActor( ActorRef ra ) {
+
+        logger.info( "Waiting on request actor {}...", ra.path() );
+
+        boolean started = false;
+        int retries = 0;
+        int maxRetries = 60;
+        while (retries < maxRetries) {
+            Timeout t = new Timeout( 10, TimeUnit.SECONDS );
+
+            Future<Object> fut = Patterns.ask( ra, new ClientActor.StatusRequest(), t );
+            try {
+                ClientActor.StatusMessage result = (ClientActor.StatusMessage) Await.result( fut, t.duration() );
+
+                if (result.getStatus().equals( ClientActor.StatusMessage.Status.READY )) {
+                    started = true;
+                    break;
+                }
+                logger.info( "Waiting for request actor {} region {} ({}s)", ra.path(), currentRegion, retries );
+                Thread.sleep( 1000 );
+
+            } catch (Exception e) {
+                logger.error( "Error: Timeout waiting for requestActor" );
+            }
+            retries++;
+        }
+
+        if (started) {
+            logger.info( "RequestActor has started" );
+        } else {
+            throw new RuntimeException( "RequestActor did not start in time" );
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ActorSystemModule.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ActorSystemModule.java b/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ActorSystemModule.java
new file mode 100644
index 0000000..e501569
--- /dev/null
+++ b/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ActorSystemModule.java
@@ -0,0 +1,34 @@
+/*
+ * 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.persistence.actorsystem;
+
+import com.google.inject.AbstractModule;
+import org.safehaus.guicyfig.GuicyFigModule;
+
+
+public class ActorSystemModule extends AbstractModule {
+
+    @Override
+    protected void configure() {
+
+        install( new GuicyFigModule( ActorSystemFig.class ) );
+
+        bind( ActorSystemManager.class ).to( ActorSystemManagerImpl.class );
+    }
+}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ClientActor.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ClientActor.java b/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ClientActor.java
new file mode 100644
index 0000000..c495608
--- /dev/null
+++ b/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ClientActor.java
@@ -0,0 +1,205 @@
+/*
+ * 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.persistence.actorsystem;
+
+import akka.actor.ActorSelection;
+import akka.actor.Address;
+import akka.actor.UntypedActor;
+import akka.cluster.Cluster;
+import akka.cluster.ClusterEvent;
+import akka.cluster.Member;
+import akka.cluster.MemberStatus;
+import org.apache.commons.lang.RandomStringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.Serializable;
+import java.util.*;
+import java.util.concurrent.ThreadLocalRandom;
+
+
+/**
+ * Once notified of nodes, sends unique propertyValue requests to ClusterSingletonRouter via it's local proxy.
+ */
+public class ClientActor extends UntypedActor {
+    private static final Logger logger = LoggerFactory.getLogger( ClientActor.class );
+
+    private final String name = RandomStringUtils.randomAlphanumeric( 4 );
+
+    private final Set<Address>       nodes = new HashSet<>();
+    private final Cluster            cluster = Cluster.get(getContext().system());
+    private final Map<Class, String> routersByMessageType;
+
+    private boolean ready = false;
+
+
+    public ClientActor( Map<Class, String> routersByMessageType ) {
+        this.routersByMessageType = routersByMessageType;
+    }
+
+    // subscribe to cluster changes, MemberEvent
+    @Override
+    public void preStart() {
+        logger.debug("{} role {} address {}:{} starting up, subscribing to cluster events...", name,
+            cluster.getSelfRoles().iterator().next(),
+            cluster.readView().selfAddress().host(),
+            cluster.readView().selfAddress().hostPort());
+        cluster.subscribe(getSelf(), ClusterEvent.MemberEvent.class, ClusterEvent.ReachabilityEvent.class);
+    }
+
+    // re-subscribe when restart
+    @Override
+    public void postStop() {
+        cluster.unsubscribe(getSelf());
+    }
+
+    @Override
+    public void onReceive(Object message) {
+
+        int startSize = nodes.size();
+
+        String routerPath = routersByMessageType.get( message.getClass() );
+
+        if ( routerPath != null && ready ) {
+
+            // just pick any node, the ClusterSingletonRouter will do the consistent hash routing
+            List<Address> nodesList = new ArrayList<>( nodes );
+            Address address = nodesList.get( ThreadLocalRandom.current().nextInt( nodesList.size() ) );
+            ActorSelection service = getContext().actorSelection( address + routerPath );
+            service.tell( message, getSender() );
+
+        } else if ( routerPath != null && !ready ) {
+
+            logger.debug("{} responding with status unknown", name);
+            getSender().tell( new ErrorResponse("ClientActor not ready"), getSender() );
+
+        } if ( message instanceof StatusRequest ) {
+            if ( ready ) {
+                getSender().tell( new StatusMessage( name, StatusMessage.Status.READY ), getSender() );
+            } else {
+                getSender().tell( new StatusMessage( name, StatusMessage.Status.INITIALIZING), getSender() );
+            }
+            return;
+
+        } else {
+            processAsClusterEvent( message );
+        }
+
+        if ( logger.isDebugEnabled() && startSize != nodes.size() ) {
+            logger.debug( "{} now knows {} nodes", name, nodes.size() );
+        }
+
+        if (!nodes.isEmpty() && !ready) {
+            logger.debug( name + " is ready" );
+            ready = true;
+
+        } else if (nodes.isEmpty() && ready) {
+            ready = false;
+        }
+    }
+
+    /**
+     * Process messages about nodes up, down, reachable and unreachable.
+     */
+    private void processAsClusterEvent(Object message) {
+
+        if (message instanceof ClusterEvent.CurrentClusterState) {
+            ClusterEvent.CurrentClusterState state = (ClusterEvent.CurrentClusterState) message;
+            nodes.clear();
+            for (Member member : state.getMembers()) {
+                if (member.hasRole("io") && member.status().equals( MemberStatus.up())) {
+                    nodes.add(member.address());
+                    logger.debug("RequestActor {} received cluster-state member-up for {}", name, member.address());
+                }
+            }
+
+        } else if (message instanceof ClusterEvent.MemberUp) {
+            ClusterEvent.MemberUp mUp = (ClusterEvent.MemberUp) message;
+            if (mUp.member().hasRole("io")) {
+                nodes.add( mUp.member().address() );
+            }
+            logger.debug("{} received member-up for {}", name, mUp.member().address());
+
+        } else if (message instanceof ClusterEvent.MemberEvent) {
+            ClusterEvent.MemberEvent other = (ClusterEvent.MemberEvent) message;
+            nodes.remove(other.member().address());
+
+        } else if (message instanceof ClusterEvent.UnreachableMember) {
+            ClusterEvent.UnreachableMember unreachable = (ClusterEvent.UnreachableMember) message;
+            nodes.remove(unreachable.member().address());
+            logger.debug("{} received un-reachable for {}", name, unreachable.member().address());
+
+        } else if (message instanceof ClusterEvent.ReachableMember) {
+            ClusterEvent.ReachableMember reachable = (ClusterEvent.ReachableMember) message;
+            if (reachable.member().hasRole("io")) {
+                nodes.add( reachable.member().address() );
+            }
+            logger.debug("{} received reachable for {}", name, reachable.member().address());
+
+        } else {
+            logger.error("{}: unhandled message: {}", name, message.toString());
+            unhandled(message);
+        }
+    }
+
+    /**
+     * RequestAction responds to StatusRequests.
+     */
+    public static class StatusRequest implements Serializable { }
+
+    /**
+     * RequestActor responds with, and some times unilaterally sends StatusMessages.
+     */
+    public static class StatusMessage implements Serializable {
+        final String name;
+
+        public Status getStatus() {
+            return status;
+        }
+
+        public enum Status { INITIALIZING, READY }
+        private final Status status;
+        public StatusMessage(String name, Status status) {
+            this.name = name;
+            this.status = status;
+        }
+        public String getName() {
+            return name;
+        }
+        public boolean isReady() {
+            return status.equals( Status.READY );
+        }
+    }
+
+
+    public static class ErrorResponse implements Serializable {
+        private String message;
+        public ErrorResponse( String message ) {
+            this.message = message;
+        }
+
+        public String getMessage() {
+            return message;
+        }
+
+        public void setMessage(String message) {
+            this.message = message;
+        }
+    }
+
+}
+

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/GuiceActorProducer.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/GuiceActorProducer.java b/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/GuiceActorProducer.java
new file mode 100644
index 0000000..9304c4c
--- /dev/null
+++ b/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/GuiceActorProducer.java
@@ -0,0 +1,46 @@
+/*
+ * 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.persistence.actorsystem;
+
+import akka.actor.Actor;
+import akka.actor.IndirectActorProducer;
+import com.google.inject.Injector;
+
+
+public class GuiceActorProducer implements IndirectActorProducer {
+
+    final Injector injector;
+    final Class<? extends Actor> actorClass;
+
+    public GuiceActorProducer(Injector injector, Class<? extends Actor> actorClass) {
+        this.injector = injector;
+        this.actorClass = actorClass;
+    }
+
+    @Override
+    public Class<? extends Actor> actorClass() {
+        return actorClass;
+    }
+
+    @Override
+    public Actor produce() {
+        return injector.getInstance( actorClass );
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/RouterProducer.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/RouterProducer.java b/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/RouterProducer.java
new file mode 100644
index 0000000..ac2c7ee
--- /dev/null
+++ b/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/RouterProducer.java
@@ -0,0 +1,45 @@
+/*
+ * 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.persistence.actorsystem;
+
+import akka.actor.ActorSystem;
+
+import java.util.Map;
+
+
+public interface RouterProducer {
+
+    /**
+     * Create cluster single manager for current region.
+     * Will be called once per router per JVM.
+     */
+    void createClusterSingletonManager( ActorSystem system );
+
+    /**
+     * Create cluster singleton proxy for region.
+     * Will be called once per router per JVM per region.
+     */
+    void createClusterSingletonProxy( ActorSystem system );
+
+    /**
+     * Create other actors needed to support the router produced by the implementation.
+     */
+    void createLocalSystemActors( ActorSystem localSystem, Map<String, ActorSystem> systemMap );
+
+}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/stack/corepersistence/actorsystem/src/main/resources/application.conf
----------------------------------------------------------------------
diff --git a/stack/corepersistence/actorsystem/src/main/resources/application.conf b/stack/corepersistence/actorsystem/src/main/resources/application.conf
new file mode 100644
index 0000000..93854f9
--- /dev/null
+++ b/stack/corepersistence/actorsystem/src/main/resources/application.conf
@@ -0,0 +1,28 @@
+akka {
+  
+  loggers = ["akka.event.slf4j.Slf4jLogger"]
+  loglevel = "ERROR"
+  logging-filter = "akka.event.slf4j.Slf4jLoggingFilter"
+  
+  actor {
+    provider = "akka.cluster.ClusterActorRefProvider"
+  }
+  
+  remote {
+    log-remote-lifecycle-events = off
+    netty.tcp {
+      hostname = "127.0.0.1"
+      port = 0
+    }
+  }
+}
+
+# Disable legacy metrics in akka-cluster.
+akka.cluster.metrics.enabled=off
+
+# Enable metrics extension in akka-cluster-metrics.
+akka.extensions=["akka.cluster.metrics.ClusterMetricsExtension", "akka.cluster.pubsub.DistributedPubSub"]
+
+# Sigar native library extract location during tests.
+# Note: use per-jvm-instance folder when running multiple jvm on one host. 
+akka.cluster.metrics.native-library-extract-folder=${user.dir}/target/native

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/stack/corepersistence/actorsystem/src/main/resources/cluster-singleton.conf
----------------------------------------------------------------------
diff --git a/stack/corepersistence/actorsystem/src/main/resources/cluster-singleton.conf b/stack/corepersistence/actorsystem/src/main/resources/cluster-singleton.conf
new file mode 100644
index 0000000..907aebb
--- /dev/null
+++ b/stack/corepersistence/actorsystem/src/main/resources/cluster-singleton.conf
@@ -0,0 +1,25 @@
+include "application"
+
+akka.actor.deployment {
+  /uvRouter/singleton/router {
+    router = consistent-hashing-pool
+    cluster {
+      enabled = on
+      allow-local-routees = on
+      
+      # singleton will only run on nodes with role "io"
+      use-role = io
+
+      # more forgiving failure detector
+      failure-detector {
+        threshold = 10
+        acceptable-heartbeat-pause = 3 s
+        heartbeat-interval = 1 s
+        heartbeat-request {
+          expected-response-after = 3 s
+        }
+      }
+
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/stack/corepersistence/actorsystem/src/test/java/org/apache/usergrid/persistence/actorsystem/ActorServiceServiceTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/actorsystem/src/test/java/org/apache/usergrid/persistence/actorsystem/ActorServiceServiceTest.java b/stack/corepersistence/actorsystem/src/test/java/org/apache/usergrid/persistence/actorsystem/ActorServiceServiceTest.java
new file mode 100644
index 0000000..a12c5e1
--- /dev/null
+++ b/stack/corepersistence/actorsystem/src/test/java/org/apache/usergrid/persistence/actorsystem/ActorServiceServiceTest.java
@@ -0,0 +1,57 @@
+/*
+ * 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.persistence.actorsystem;
+
+import com.google.inject.Inject;
+import org.apache.usergrid.persistence.core.test.ITRunner;
+import org.apache.usergrid.persistence.core.test.UseModules;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+
+
+@RunWith( ITRunner.class )
+@UseModules( ActorSystemModule.class )
+public class ActorServiceServiceTest {
+    private static final Logger logger = LoggerFactory.getLogger( ActorServiceServiceTest.class );
+
+    @Inject
+    ActorSystemFig actorSystemFig;
+
+    private static AtomicBoolean startedAkka = new AtomicBoolean( false );
+
+
+    @Before
+    public void initAkka() {
+        if ( !startedAkka.getAndSet( true ) ) {
+        }
+    }
+
+
+    @Test
+    public void testBasicOperation() throws Exception {
+        initAkka();
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/stack/corepersistence/collection/pom.xml
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/pom.xml b/stack/corepersistence/collection/pom.xml
index ad9cefd..88b96b1 100644
--- a/stack/corepersistence/collection/pom.xml
+++ b/stack/corepersistence/collection/pom.xml
@@ -1,4 +1,20 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
 <project xmlns="http://maven.apache.org/POM/4.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
@@ -26,6 +42,12 @@
         </dependency>
 
         <dependency>
+            <groupId>org.apache.usergrid</groupId>
+            <artifactId>actorsystem</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
             <groupId>com.typesafe.akka</groupId>
             <artifactId>akka-actor_2.11</artifactId>
             <version>2.4.0</version>

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManager.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManager.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManager.java
index b6056b5..dff4a12 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManager.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/EntityCollectionManager.java
@@ -126,10 +126,4 @@ public interface EntityCollectionManager {
      * Returns health of entity data store.
      */
     Health getHealth();
-
-    /**
-     * For testing purposes only.
-     */
-    void startAkkaForTesting( String hostname, int port, String region );
-
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/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 45e519e..ae73e47 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
@@ -20,6 +20,8 @@ package org.apache.usergrid.persistence.collection.guice;
 
 import java.util.concurrent.ThreadPoolExecutor;
 
+import org.apache.usergrid.persistence.actorsystem.ActorSystemFig;
+import org.apache.usergrid.persistence.actorsystem.ActorSystemModule;
 import org.apache.usergrid.persistence.collection.uniquevalues.*;
 import org.safehaus.guicyfig.GuicyFigModule;
 
@@ -55,11 +57,11 @@ public abstract class CollectionModule extends AbstractModule {
     protected void configure() {
 
         // noinspection unchecked
-        install( new GuicyFigModule( AkkaFig.class ) );
         install( new GuicyFigModule( SerializationFig.class ) );
         install( new GuicyFigModule( CollectionSchedulerFig.class ) );
         install( new SerializationModule() );
         install( new ServiceModule() );
+        install( new ActorSystemModule() );
 
         // users of this module can add their own implemementations
         // create a guice factor for getting our collection manager

http://git-wip-us.apache.org/repos/asf/usergrid/blob/ee18950f/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerFactoryImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerFactoryImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerFactoryImpl.java
index 18a07ac..3877fe3 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerFactoryImpl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerFactoryImpl.java
@@ -21,6 +21,7 @@ package org.apache.usergrid.persistence.collection.impl;
 
 import java.util.concurrent.ExecutionException;
 
+import org.apache.usergrid.persistence.actorsystem.ActorSystemManager;
 import org.apache.usergrid.persistence.collection.EntityCollectionManager;
 import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory;
 import org.apache.usergrid.persistence.collection.cache.EntityCacheFig;
@@ -76,6 +77,7 @@ public class EntityCollectionManagerFactoryImpl implements EntityCollectionManag
     private final Keyspace keyspace;
     private final MetricsFactory metricsFactory;
     private final RxTaskScheduler rxTaskScheduler;
+    private final ActorSystemManager actorSystemManager;
     private final UniqueValuesService uniqueValuesService;
 
 
@@ -101,6 +103,7 @@ public class EntityCollectionManagerFactoryImpl implements EntityCollectionManag
                                 metricsFactory,
                                 serializationFig,
                                 rxTaskScheduler,
+                                actorSystemManager,
                                 uniqueValuesService,
                                 scope );
 
@@ -128,6 +131,7 @@ public class EntityCollectionManagerFactoryImpl implements EntityCollectionManag
             final EntityCacheFig entityCacheFig,
             final MetricsFactory metricsFactory, @CollectionExecutorScheduler
             final RxTaskScheduler rxTaskScheduler,
+            final ActorSystemManager actorSystemManager,
             final UniqueValuesService uniqueValuesService ) {
 
         this.writeStart = writeStart;
@@ -146,6 +150,7 @@ public class EntityCollectionManagerFactoryImpl implements EntityCollectionManag
         this.keyspace = keyspace;
         this.metricsFactory = metricsFactory;
         this.rxTaskScheduler = rxTaskScheduler;
+        this.actorSystemManager = actorSystemManager;
         this.uniqueValuesService = uniqueValuesService;
     }
 


[5/8] usergrid git commit: Separate configs for JUnit test JVM and Tomcat JVM, and remove some unnecessary properties.

Posted by sn...@apache.org.
Separate configs for JUnit test JVM and Tomcat JVM, and remove some unnecessary properties.


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

Branch: refs/heads/usergrid-1268-akka-211
Commit: 343ac516cb498bfdec9f64a961197b7e1b0a4c41
Parents: 50312ba
Author: Dave Johnson <sn...@apache.org>
Authored: Tue Jun 21 13:26:20 2016 -0400
Committer: Dave Johnson <sn...@apache.org>
Committed: Tue Jun 21 13:26:20 2016 -0400

----------------------------------------------------------------------
 .../main/resources/usergrid-default.properties  |  7 ++--
 .../corepersistence/CpEntityManagerFactory.java | 15 ++++++++-
 .../persistence/actorsystem/ActorSystemFig.java |  8 -----
 .../actorsystem/ActorSystemManagerImpl.java     |  3 +-
 .../uniquevalues/UniqueValuesServiceTest.java   |  1 -
 .../resources/corepersistence-UNIT.properties   |  2 ++
 .../resources/usergrid-custom-test.properties   |  7 ++--
 .../resources/usergrid-rest-deploy-context.xml  | 34 +++++++++++++++++++-
 8 files changed, 56 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/343ac516/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 ffe5fc1..bc5d8c9 100644
--- a/stack/config/src/main/resources/usergrid-default.properties
+++ b/stack/config/src/main/resources/usergrid-default.properties
@@ -430,15 +430,12 @@ collection.akka.enabled=false
 # host name of this machine
 collection.akka.hostname=localhost
 
-# port to use for Akka. In multi-region setup, each region MUST use its own unique port.
-collection.akka.port=2551
-
 # the region MUST be in the region list specified in the 'usergrid.queue.regionList' property
-collection.akka.region=us-east-1
+#collection.akka.region=us-east-1
 
 # Comma-separated lists of seeds each with format {region}:{hostname}:{port}.
 # Regions MUST be listed in the 'usergrid.queue.regionList'
-collection.akka.region.seeds=us-east-1:localhost:2551
+#collection.akka.region.seeds=
 
 # The number of unique value actors to start on each Usergrid instance.
 collection.akka.uniquevalue.actors=300

http://git-wip-us.apache.org/repos/asf/usergrid/blob/343ac516/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 99bf1e0..9bd589a 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
@@ -36,12 +36,14 @@ import org.apache.usergrid.exception.ConflictException;
 import org.apache.usergrid.locking.LockManager;
 import org.apache.usergrid.persistence.*;
 import org.apache.usergrid.persistence.actorsystem.ActorSystemFig;
+import org.apache.usergrid.persistence.actorsystem.ActorSystemManager;
 import org.apache.usergrid.persistence.cassandra.CassandraService;
 import org.apache.usergrid.persistence.cassandra.CounterUtils;
 import org.apache.usergrid.persistence.cassandra.Setup;
 import org.apache.usergrid.persistence.collection.EntityCollectionManager;
 import org.apache.usergrid.persistence.collection.exception.CollectionRuntimeException;
 import org.apache.usergrid.persistence.collection.serialization.impl.migration.EntityIdScope;
+import org.apache.usergrid.persistence.collection.uniquevalues.UniqueValueActor;
 import org.apache.usergrid.persistence.collection.uniquevalues.UniqueValuesService;
 import org.apache.usergrid.persistence.core.metrics.MetricsFactory;
 import org.apache.usergrid.persistence.core.migration.data.MigrationDataProvider;
@@ -110,6 +112,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
     private final ConnectionService connectionService;
     private final GraphManagerFactory graphManagerFactory;
     private final CollectionSettingsCacheFactory collectionSettingsCacheFactory;
+    private ActorSystemManager actorSystemManager;
     private UniqueValuesService uniqueValuesService;
     private final LockManager lockManager;
 
@@ -142,8 +145,18 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
         if ( actorSystemFig.getAkkaEnabled() ) {
             try {
                 logger.info("Akka cluster starting...");
+
                 this.uniqueValuesService = injector.getInstance( UniqueValuesService.class );
-                // TODO: this.uniqueValuesService.start();
+                this.actorSystemManager = injector.getInstance( ActorSystemManager.class );
+
+                actorSystemManager.registerRouterProducer( uniqueValuesService );
+                actorSystemManager.registerMessageType( UniqueValueActor.Request.class, "/user/uvProxy" );
+                actorSystemManager.registerMessageType( UniqueValueActor.Reservation.class, "/user/uvProxy" );
+                actorSystemManager.registerMessageType( UniqueValueActor.Cancellation.class, "/user/uvProxy" );
+                actorSystemManager.registerMessageType( UniqueValueActor.Confirmation.class, "/user/uvProxy" );
+                actorSystemManager.start();
+                actorSystemManager.waitForRequestActors();
+
             } catch (Throwable t) {
                 logger.error("Error starting Akka", t);
                 throw t;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/343ac516/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ActorSystemFig.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ActorSystemFig.java b/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ActorSystemFig.java
index 7af510c..50e860b 100644
--- a/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ActorSystemFig.java
+++ b/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ActorSystemFig.java
@@ -33,8 +33,6 @@ public interface ActorSystemFig extends GuicyFig, Serializable {
 
     String AKKA_HOSTNAME = "collection.akka.hostname";
 
-    String AKKA_PORT = "collection.akka.port";
-
     String AKKA_REGION = "collection.akka.region";
 
     String AKKA_REGION_LIST = "usergrid.queue.regionList"; // same region list used by queues
@@ -63,12 +61,6 @@ public interface ActorSystemFig extends GuicyFig, Serializable {
     String getHostname();
 
     /**
-     * local port to be used in Akka configuration.
-     */
-    @Key(AKKA_PORT)
-    int getPort();
-
-    /**
      * Local region to be used in Akka configuration.
      */
     @Key(AKKA_REGION)

http://git-wip-us.apache.org/repos/asf/usergrid/blob/343ac516/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ActorSystemManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ActorSystemManagerImpl.java b/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ActorSystemManagerImpl.java
index 0622b1b..b3af978 100644
--- a/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ActorSystemManagerImpl.java
+++ b/stack/corepersistence/actorsystem/src/main/java/org/apache/usergrid/persistence/actorsystem/ActorSystemManagerImpl.java
@@ -239,7 +239,6 @@ public class ActorSystemManagerImpl implements ActorSystemManager {
                 logger.info( "Config for region {} is:\n" +
                         "   Akka Hostname {}\n" +
                         "   Akka Seeds {}\n" +
-                        "   Akka Port {}\n" +
                         "   Akka UniqueValueActors per node {}\n" +
                         "   Akka Authoritative Region {}",
                     region, hostname, seeds, port, numInstancesPerNode, actorSystemFig.getAkkaAuthoritativeRegion() );
@@ -262,6 +261,8 @@ public class ActorSystemManagerImpl implements ActorSystemManager {
                                 }
                             }} );
                         }} );
+
+                        // TODO: allow RouterProducers to add in router-specific stuff like this:
                         put( "actor", new HashMap<String, Object>() {{
                             put( "deployment", new HashMap<String, Object>() {{
                                 put( "/uvRouter/singleton/router", new HashMap<String, Object>() {{

http://git-wip-us.apache.org/repos/asf/usergrid/blob/343ac516/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesServiceTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesServiceTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesServiceTest.java
index 3cba9c8..672e3bf 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesServiceTest.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/uniquevalues/UniqueValuesServiceTest.java
@@ -50,7 +50,6 @@ import java.util.Collection;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/343ac516/stack/rest/src/test/resources/corepersistence-UNIT.properties
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/resources/corepersistence-UNIT.properties b/stack/rest/src/test/resources/corepersistence-UNIT.properties
index 2383813..724884e 100644
--- a/stack/rest/src/test/resources/corepersistence-UNIT.properties
+++ b/stack/rest/src/test/resources/corepersistence-UNIT.properties
@@ -20,3 +20,5 @@ usergrid.notifications.listener.run=false
 
 # This property is required to be set and cannot be defaulted anywhere
 usergrid.cluster_name=usergrid
+
+collection.akka.region.seeds=us-east\:localhost\:2552

http://git-wip-us.apache.org/repos/asf/usergrid/blob/343ac516/stack/rest/src/test/resources/usergrid-custom-test.properties
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/resources/usergrid-custom-test.properties b/stack/rest/src/test/resources/usergrid-custom-test.properties
index 5c587f4..d2cb8a3 100644
--- a/stack/rest/src/test/resources/usergrid-custom-test.properties
+++ b/stack/rest/src/test/resources/usergrid-custom-test.properties
@@ -10,6 +10,9 @@
 #   See the License for the specific language governing permissions and
 #   limitations under the License. See accompanying LICENSE file.
 
+
+# properties used by Usergrid running in JUnit test JVM
+
 # REST module test properties
 
 cassandra.startup=external
@@ -56,7 +59,6 @@ usergrid.graph.shard.repair.chance=1.0
 collection.akka.enabled=true
 
 collection.akka.hostname=localhost
-collection.akka.port=2551
 collection.akka.region=us-east
 usergrid.queue.regionList=us-east
 collection.akka.uniquevalue.authoritative.region=us-east
@@ -65,6 +67,3 @@ collection.akka.region.seeds=us-east\:localhost\:2551
 collection.akka.uniquevalue.actors=300
 collection.akka.uniquevalue.cache.ttl=10
 collection.akka.uniquevalue.reservation.ttl=10
-
-collection.akka.uniquevalue.region.types
-

http://git-wip-us.apache.org/repos/asf/usergrid/blob/343ac516/stack/rest/src/test/resources/usergrid-rest-deploy-context.xml
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/resources/usergrid-rest-deploy-context.xml b/stack/rest/src/test/resources/usergrid-rest-deploy-context.xml
index 06d5de4..9cc5ea6 100644
--- a/stack/rest/src/test/resources/usergrid-rest-deploy-context.xml
+++ b/stack/rest/src/test/resources/usergrid-rest-deploy-context.xml
@@ -21,6 +21,38 @@
 	http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd
 	http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
 
-    <import resource="classpath:/usergrid-test-context.xml" />
+    <bean id="properties"
+          class="org.springframework.beans.factory.config.PropertiesFactoryBean">
+        <property name="singleton" value="true" />
+        <property name="ignoreResourceNotFound" value="true" />
+        <property name="locations">
+            <list>
+                <value>classpath:/usergrid-default.properties</value>
+                <value>classpath:/usergrid-test.properties</value>
+                <value>classpath:/usergrid-custom-test-rest.properties</value>
+            </list>
+        </property>
+    </bean>
+
+
+    <import resource="usergrid-rest-context.xml"/>
+
+    <bean id="traceTagManager" class="org.apache.usergrid.persistence.cassandra.util.TraceTagManager">
+        <property name="reportUnattached" value="false"/>
+        <property name="traceEnabled" value="false"/>
+    </bean>
+
+    <bean id="setup" class="org.apache.usergrid.corepersistence.CpSetup">
+        <constructor-arg ref="entityManagerFactory"/>
+        <constructor-arg ref="cassandraService"/>
+        <constructor-arg ref="injector"/>
+    </bean>
+
+    <!-- refer to a named schemaManager from the DataControl annotation thusly -->
+    <bean id="coreManager" class="org.apache.usergrid.persistence.CoreSchemaManager">
+        <constructor-arg ref="setup"/>
+        <constructor-arg ref="cassandraCluster"/>
+        <constructor-arg ref="injector"/>
+    </bean>
 
 </beans>