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

[1/6] incubator-usergrid git commit: move initialize index

Repository: incubator-usergrid
Updated Branches:
  refs/heads/USERGRID-405 a40fb8d57 -> 8fe72677b


move initialize index


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

Branch: refs/heads/USERGRID-405
Commit: f69bcebe4439a408a4d2baa87a3322142c506f93
Parents: 2af7489
Author: Shawn Feldman <sf...@apache.org>
Authored: Fri Mar 20 17:22:22 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Fri Mar 20 17:22:22 2015 -0600

----------------------------------------------------------------------
 .../corepersistence/CpEntityManagerFactory.java | 13 +++++++---
 .../usergrid/corepersistence/CpSetup.java       | 13 +++++++++-
 .../index/ApplicationEntityIndex.java           |  5 ++++
 .../usergrid/persistence/index/EntityIndex.java |  6 +----
 .../impl/EsApplicationEntityIndexImpl.java      | 12 +++++++++
 .../index/impl/EsEntityIndexImpl.java           |  9 -------
 .../persistence/index/impl/EntityIndexTest.java | 26 +++++++++++---------
 .../index/impl/IndexLoadTestsIT.java            |  4 +--
 8 files changed, 56 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f69bcebe/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 1388462..95ffbaa 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
@@ -25,7 +25,9 @@ import java.util.TreeMap;
 import java.util.UUID;
 import java.util.concurrent.atomic.AtomicBoolean;
 
+import com.hazelcast.core.IdGenerator;
 import org.apache.usergrid.persistence.index.ApplicationEntityIndex;
+import org.apache.usergrid.persistence.index.EntityIndexFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeansException;
@@ -92,6 +94,7 @@ import static org.apache.usergrid.persistence.Schema.TYPE_APPLICATION;
 public class CpEntityManagerFactory implements EntityManagerFactory, ApplicationContextAware {
 
     private static final Logger logger = LoggerFactory.getLogger( CpEntityManagerFactory.class );
+    private final EntityIndexFactory entityIndexFactory;
 
     private ApplicationContext applicationContext;
 
@@ -129,6 +132,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
         this.counterUtils = counterUtils;
         this.injector = injector;
         this.entityIndex = injector.getInstance(EntityIndex.class);
+        this.entityIndexFactory = injector.getInstance(EntityIndexFactory.class);
         this.managerCache = injector.getInstance( ManagerCache.class );
         this.metricsFactory = injector.getInstance( MetricsFactory.class );
 
@@ -160,7 +164,9 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
                 em.getApplication();
             }
 
-            entityIndex.initializeIndex();
+            ApplicationScope appScope = new ApplicationScopeImpl(new SimpleId( CpNamingUtils.SYSTEM_APP_ID, "application" ) );
+            ApplicationEntityIndex applicationEntityIndex = entityIndexFactory.createApplicationEntityIndex(appScope);
+            applicationEntityIndex.initializeIndex();
             entityIndex.refresh();
 
 
@@ -722,9 +728,10 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
     public void rebuildApplicationIndexes( UUID appId, ProgressObserver po ) throws Exception {
 
         EntityManager em = getEntityManager( appId );
-
+        ApplicationScope applicationScope = new ApplicationScopeImpl( new SimpleId( CpNamingUtils.SYSTEM_APP_ID, "application" ));
         //explicitly invoke create index, we don't know if it exists or not in ES during a rebuild.
-        entityIndex.initializeIndex();
+        ApplicationEntityIndex applicationEntityIndex = entityIndexFactory.createApplicationEntityIndex(applicationScope);
+        applicationEntityIndex.initializeIndex();
         em.reindex(po);
 
         em.reindex( po );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f69bcebe/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
index a9e6cee..1d75e47 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
@@ -20,7 +20,13 @@ package org.apache.usergrid.corepersistence;
 import java.util.UUID;
 
 import com.google.inject.Binding;
+import org.apache.usergrid.corepersistence.util.CpNamingUtils;
+import org.apache.usergrid.persistence.core.scope.ApplicationScope;
+import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
+import org.apache.usergrid.persistence.index.ApplicationEntityIndex;
 import org.apache.usergrid.persistence.index.EntityIndex;
+import org.apache.usergrid.persistence.index.EntityIndexFactory;
+import org.apache.usergrid.persistence.model.entity.SimpleId;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -67,6 +73,7 @@ public class CpSetup implements Setup {
 
     private final EntityManagerFactory emf;
     private final EntityIndex entityIndex;
+    private final EntityIndexFactory entityIndexFactory;
 
 
     /**
@@ -79,6 +86,8 @@ public class CpSetup implements Setup {
         this.cass = cassandraService;
         this.injector = injector;
         this.entityIndex = injector.getInstance(EntityIndex.class);
+        this.entityIndexFactory = injector.getInstance(EntityIndexFactory.class);
+
     }
 
 
@@ -98,8 +107,10 @@ public class CpSetup implements Setup {
 
         setupStaticKeyspace();
 
+        ApplicationScope applicationScope = new ApplicationScopeImpl(new SimpleId( CpNamingUtils.SYSTEM_APP_ID,"application"));
+        ApplicationEntityIndex applicationEntityIndex = entityIndexFactory.createApplicationEntityIndex(applicationScope);
         //force the EMF creation of indexes before creating the default applications
-        entityIndex.initializeIndex();
+        applicationEntityIndex.initializeIndex();
 
         injector.getInstance( DataMigrationManager.class ).migrate();
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f69bcebe/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/ApplicationEntityIndex.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/ApplicationEntityIndex.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/ApplicationEntityIndex.java
index 34967bd..4808d8a 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/ApplicationEntityIndex.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/ApplicationEntityIndex.java
@@ -32,6 +32,11 @@ public interface ApplicationEntityIndex {
 
 
     /**
+     *
+     */
+    public void initializeIndex();
+
+    /**
      * Create the index batch.
      */
     public EntityIndexBatch createBatch();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f69bcebe/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java
index 854c976..af6b013 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/EntityIndex.java
@@ -38,11 +38,7 @@ import java.util.concurrent.Future;
  */
 public interface EntityIndex extends CPManager {
 
-    /**
-     * This should ONLY ever be called once on application create.
-     * Otherwise we're introducing slowness into our system
-     */
-    public void initializeIndex();
+
     /**
      * Create an index and add to alias, will create alias and remove any old index from write alias if alias already exists
      * @param indexSuffix index name

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f69bcebe/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsApplicationEntityIndexImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsApplicationEntityIndexImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsApplicationEntityIndexImpl.java
index 56f8030..2d01697 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsApplicationEntityIndexImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsApplicationEntityIndexImpl.java
@@ -126,6 +126,18 @@ public class EsApplicationEntityIndexImpl implements ApplicationEntityIndex{
     }
 
     @Override
+    public void initializeIndex() {
+        final int numberOfShards = indexFig.getNumberOfShards();
+        final int numberOfReplicas = indexFig.getNumberOfReplicas();
+        indexCache.invalidate(alias);
+        String[] indexes = entityIndex.getUniqueIndexes();
+        if(indexes == null || indexes.length==0) {
+            entityIndex.addIndex(null, numberOfShards, numberOfReplicas, indexFig.getWriteConsistencyLevel());
+        }
+
+    }
+
+    @Override
     public EntityIndexBatch createBatch() {
         EntityIndexBatch batch = new EsEntityIndexBatchImpl(
             applicationScope, indexBatchBufferProducer, entityIndex, indexIdentifier );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f69bcebe/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
index 4290f23..259fa55 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsEntityIndexImpl.java
@@ -139,16 +139,7 @@ public class EsEntityIndexImpl implements AliasedEntityIndex {
 
     }
 
-    @Override
-    public void initializeIndex() {
-        final int numberOfShards = config.getNumberOfShards();
-        final int numberOfReplicas = config.getNumberOfReplicas();
-        String[] indexes = getIndexesFromEs(AliasType.Write);
-        if(indexes == null || indexes.length==0) {
-            addIndex(null, numberOfShards, numberOfReplicas, config.getWriteConsistencyLevel());
-        }
 
-    }
 
     @Override
     public void addIndex(final String indexSuffix,final int numberOfShards, final int numberOfReplicas, final String writeConsistency) {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f69bcebe/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
index b562ccf..85570f1 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/EntityIndexTest.java
@@ -91,10 +91,10 @@ public class EntityIndexTest extends BaseIT {
     @Test
     public void testIndex() throws IOException, InterruptedException {
         Id appId = new SimpleId("application");
-        ei.initializeIndex();
 
         ApplicationScope applicationScope = new ApplicationScopeImpl(appId);
         ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex(applicationScope);
+        entityIndex.initializeIndex();
 
         final String entityType = "thing";
         IndexScope indexScope = new IndexScopeImpl(appId, "things");
@@ -158,7 +158,7 @@ public class EntityIndexTest extends BaseIT {
         final ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex(applicationScope);
         final IndexScope indexScope = new IndexScopeImpl(appId, "things");
         final String entityType = "thing";
-        ei.initializeIndex();
+        entityIndex.initializeIndex();
         final CountDownLatch latch = new CountDownLatch(threads);
         final AtomicLong failTime=new AtomicLong(0);
         InputStream is = this.getClass().getResourceAsStream(  "/sample-large.json" );
@@ -201,9 +201,9 @@ public class EntityIndexTest extends BaseIT {
         ApplicationScope applicationScope = new ApplicationScopeImpl( appId );
 
         ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex(applicationScope);
-        ei.initializeIndex();
+        entityIndex.initializeIndex();
         for(int i=0;i<10;i++) {
-            ei.initializeIndex();
+            entityIndex.initializeIndex();
         }
 
     }
@@ -215,7 +215,7 @@ public class EntityIndexTest extends BaseIT {
         ApplicationScope applicationScope = new ApplicationScopeImpl( appId );
 
         ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex(applicationScope);
-        ei.initializeIndex();
+        entityIndex.initializeIndex();
 
         final String entityType = "thing";
         IndexScope indexScope = new IndexScopeImpl( appId, "things" );
@@ -328,7 +328,7 @@ public class EntityIndexTest extends BaseIT {
         IndexScope indexScope = new IndexScopeImpl( appId, "fastcars" );
 
         ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex(applicationScope);
-        ei.initializeIndex();
+        entityIndex.initializeIndex();
 
         Map entityMap = new HashMap() {{
             put( "name", "Ferrari 212 Inter" );
@@ -459,7 +459,7 @@ public class EntityIndexTest extends BaseIT {
         IndexScope appScope = new IndexScopeImpl( ownerId, "user" );
 
         ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex(applicationScope);
-        ei.initializeIndex();
+        entityIndex.initializeIndex();
 
         final String middleName = "middleName" + UUIDUtils.newTimeUUID();
 
@@ -508,7 +508,7 @@ public class EntityIndexTest extends BaseIT {
         IndexScope appScope = new IndexScopeImpl( ownerId, "user" );
 
         ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex(applicationScope);
-        ei.initializeIndex();
+        entityIndex.initializeIndex();
         entityIndex.createBatch();
 
         // Bill has favorites as string, age as string and retirement goal as number
@@ -576,11 +576,13 @@ public class EntityIndexTest extends BaseIT {
 
     @Test
     public void healthTest() {
-
+        Id appId = new SimpleId( "entityindextest" );
+        Id ownerId = new SimpleId( "multivaluedtype" );
+        ApplicationScope applicationScope = new ApplicationScopeImpl( appId );
         assertNotEquals( "cluster should be ok", Health.RED, ei.getClusterHealth() );
         assertEquals( "index should be ready", Health.GREEN, ei.getIndexHealth() );
-
-        ei.initializeIndex();
+        ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex(applicationScope);
+        entityIndex.initializeIndex();
         ei.refresh();
 
         assertNotEquals( "cluster should be fine", Health.RED, ei.getIndexHealth() );
@@ -600,7 +602,7 @@ public class EntityIndexTest extends BaseIT {
 
 
         ApplicationEntityIndex entityIndex = eif.createApplicationEntityIndex(applicationScope);
-        ei.initializeIndex();
+        entityIndex.initializeIndex();
 
         final EntityIndexBatch batch = entityIndex.createBatch();
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f69bcebe/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java
index 623f9dd..44a9743 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java
@@ -81,12 +81,12 @@ public class IndexLoadTestsIT extends BaseIT {
 
         final Id applicationId = new SimpleId( applicationUUID, "application" );
         final ApplicationScope scope = new ApplicationScopeImpl( applicationId );
+        ApplicationEntityIndex applicationEntityIndex = entityIndexFactory.createApplicationEntityIndex(scope);
 
 
         //create our index if it doesn't exist
-        index.initializeIndex();
+        applicationEntityIndex.initializeIndex();
 
-        ApplicationEntityIndex applicationEntityIndex = entityIndexFactory.createApplicationEntityIndex(scope);
         final Observable<Entity> createEntities = createStreamFromWorkers( applicationEntityIndex, applicationId );
 
         //run them all


[2/6] incubator-usergrid git commit: move initialize index

Posted by sf...@apache.org.
move initialize index


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

Branch: refs/heads/USERGRID-405
Commit: e88167d3592afaed1964bd3605f1813399be1c01
Parents: f69bceb a40fb8d
Author: Shawn Feldman <sf...@apache.org>
Authored: Fri Mar 20 17:29:16 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Fri Mar 20 17:29:16 2015 -0600

----------------------------------------------------------------------
 stack/corepersistence/queryindex/pom.xml        |  57 +--
 .../persistence/index/EntityIndexBatch.java     |   5 +
 .../index/impl/EsEntityIndexBatchImpl.java      |  32 +-
 .../usergrid/persistence/index/query/Query.java |   6 +-
 .../persistence/index/guice/IndexTestFig.java   |   7 +-
 .../index/impl/IndexLoadTestsIT.java            | 344 ++++++++++++++++---
 6 files changed, 352 insertions(+), 99 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e88167d3/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java
----------------------------------------------------------------------
diff --cc stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java
index 44a9743,bfd713e..0275e53
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/IndexLoadTestsIT.java
@@@ -71,13 -104,67 +104,83 @@@ public class IndexLoadTestsIT extends B
      public EntityIndexFactory entityIndexFactory;
  
      @Inject
-     public EntityIndex index;
+     public EntityIndex entityIndex;
+ 
+     @Inject
+     public MetricsFactory metricsFactory;
+ 
+     private Meter batchWriteTPS;
+     private Timer batchWriteTimer;
+ 
+     private Meter queryTps;
+     private Timer queryTimer;
+ 
+     private Slf4jReporter reporter;
+ 
+ 
+     @Before
+     public void setupIndexAndMeters() {
++        final String userAppId = indexTestFig.getApplicationId();
+ 
 -        entityIndex.initializeIndex();
++
++        //if it's unset, generate one
++        final String uniqueIdentifier = UUIDGenerator.newTimeUUID().toString();
++
++        //use the appId supplied, or generate one
++        final UUID applicationUUID = UUID.fromString( userAppId );
++
++        final Id applicationId = new SimpleId( applicationUUID, "application" );
++        final ApplicationScope scope = new ApplicationScopeImpl( applicationId );
++
++
++        final IndexScope indexScope = new IndexScopeImpl( applicationId, "test" );
 +
++        final ApplicationEntityIndex appEntityIndex = entityIndexFactory.createApplicationEntityIndex( scope );
 +
++        appEntityIndex.initializeIndex();
+ 
+         batchWriteTPS = metricsFactory.getMeter( IndexLoadTestsIT.class, "write.tps" );
+ 
+         batchWriteTimer = metricsFactory.getTimer( IndexLoadTestsIT.class, "write.timer" );
+ 
+         queryTps = metricsFactory.getMeter( IndexLoadTestsIT.class, "query.tps" );
+ 
+         queryTimer = metricsFactory.getTimer( IndexLoadTestsIT.class, "query.timer" );
+ 
+         reporter =
+             Slf4jReporter.forRegistry( metricsFactory.getRegistry() ).outputTo( log ).convertRatesTo( TimeUnit.SECONDS )
+                          .convertDurationsTo( TimeUnit.MILLISECONDS ).build();
+ 
+         reporter.start( 30, TimeUnit.SECONDS );
+     }
+ 
+ 
+     @After
+     public void printMetricsBeforeShutdown() {
+         //stop the log reporter and print the last report
+         reporter.stop();
+         reporter.report();
+     }
+ 
+ 
+     /**
+      * Perform the following 1, spin up the specified number of workers For each worker, insert the specified number of
+      * elements
+      *
+      * Wait the wait time after buffer execution before beginning validate
+      *
+      * Validate every entity inserted is returned by a search.
+      */
      @Test
-     public void testHeavyLoad() {
+     public void testHeavyLoadValidate() {
+         final String userAppId = indexTestFig.getApplicationId();
+ 
+ 
+         //if it's unset, generate one
+         final String uniqueIdentifier = UUIDGenerator.newTimeUUID().toString();
  
-         final UUID applicationUUID = UUID.fromString( indexTestFig.getApplicationId() );
+         //use the appId supplied, or generate one
+         final UUID applicationUUID = UUID.fromString( userAppId );
  
          final Id applicationId = new SimpleId( applicationUUID, "application" );
          final ApplicationScope scope = new ApplicationScopeImpl( applicationId );


[3/6] incubator-usergrid git commit: move initialize index

Posted by sf...@apache.org.
move initialize index


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

Branch: refs/heads/USERGRID-405
Commit: 81f9170815f26bf4495f2a8b40bfde9096100570
Parents: e88167d
Author: Shawn Feldman <sf...@apache.org>
Authored: Fri Mar 20 17:48:37 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Fri Mar 20 17:48:37 2015 -0600

----------------------------------------------------------------------
 .../usergrid/corepersistence/CpEntityManagerFactory.java       | 6 ++++--
 .../main/java/org/apache/usergrid/corepersistence/CpSetup.java | 5 -----
 2 files changed, 4 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/81f91708/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 95ffbaa..3cfc1a4 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
@@ -253,7 +253,6 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
                                        Map<String, Object> properties ) throws Exception {
 
 
-
         //Ensure our management system exists before creating our application
         init();
 
@@ -266,8 +265,11 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
             throw new ApplicationAlreadyExistsException( appName );
         }
 
-        getSetup().setupApplicationKeyspace( applicationId, appName );
+        ApplicationScope applicationScope = new ApplicationScopeImpl(new SimpleId( applicationId,"application"));
+        ApplicationEntityIndex applicationEntityIndex = entityIndexFactory.createApplicationEntityIndex(applicationScope);
+        applicationEntityIndex.initializeIndex();
 
+        getSetup().setupApplicationKeyspace( applicationId, appName );
 
         final Optional<UUID> cachedValue = orgApplicationCache.getOrganizationId( organizationName );
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/81f91708/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
index 1d75e47..040f60f 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
@@ -107,11 +107,6 @@ public class CpSetup implements Setup {
 
         setupStaticKeyspace();
 
-        ApplicationScope applicationScope = new ApplicationScopeImpl(new SimpleId( CpNamingUtils.SYSTEM_APP_ID,"application"));
-        ApplicationEntityIndex applicationEntityIndex = entityIndexFactory.createApplicationEntityIndex(applicationScope);
-        //force the EMF creation of indexes before creating the default applications
-        applicationEntityIndex.initializeIndex();
-
         injector.getInstance( DataMigrationManager.class ).migrate();
 
         logger.info( "Setting up default applications" );


[5/6] incubator-usergrid git commit: smaller queries

Posted by sf...@apache.org.
smaller queries


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

Branch: refs/heads/USERGRID-405
Commit: e009f4e806809ad2d47a6debface53e5b98790a2
Parents: cab669a
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Mar 23 09:56:39 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Mar 23 09:56:39 2015 -0600

----------------------------------------------------------------------
 .../org/apache/usergrid/persistence/query/IteratingQueryIT.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e009f4e8/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java
index aae60c8..7aec332 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java
@@ -916,7 +916,7 @@ public class IteratingQueryIT {
 
         int size = 10;
         int queryLimit = 10;
-        int startValue = 99;
+        int startValue = 1;
 
         long start = System.currentTimeMillis();
 


[6/6] incubator-usergrid git commit: undo smaller queries

Posted by sf...@apache.org.
undo smaller queries


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

Branch: refs/heads/USERGRID-405
Commit: 8fe72677b725e840110be624a2a162c0ece60308
Parents: e009f4e
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Mar 23 10:01:41 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Mar 23 10:01:41 2015 -0600

----------------------------------------------------------------------
 .../persistence/query/IteratingQueryIT.java     | 56 ++++++++++----------
 1 file changed, 28 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8fe72677/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java
index 7aec332..d5f2fe3 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java
@@ -407,7 +407,7 @@ public class IteratingQueryIT {
 
     protected void singleOrderByComplexIntersection( IoHelper io ) throws Exception {
 
-        int size = 10;
+        int size = 200;
         int queryLimit = Query.MAX_LIMIT;
 
         // the number of entities that should be written including an intersection
@@ -481,7 +481,7 @@ public class IteratingQueryIT {
     protected void singleOrderByNoIntersection( IoHelper io ) throws Exception {
         io.doSetup();
 
-        int size = 5;
+        int size = 200;
         int queryLimit = Query.MAX_LIMIT;
 
         // the number of entities that should be written including an intersection
@@ -529,7 +529,7 @@ public class IteratingQueryIT {
 
         io.doSetup();
 
-        int size = 10;
+        int size = 200;
         int queryLimit = Query.MAX_LIMIT;
 
         // the number of entities that should be written including an intersection
@@ -599,7 +599,7 @@ public class IteratingQueryIT {
 
         io.doSetup();
 
-        int size = 10;
+        int size = 200;
         int queryLimit = Query.MAX_LIMIT;
 
         // the number of entities that should be written including an intersection
@@ -669,7 +669,7 @@ public class IteratingQueryIT {
 
         io.doSetup();
 
-        int size = 10;
+        int size = 200;
         int queryLimit = Query.MAX_LIMIT;
 
         int matchMax = queryLimit - 1;
@@ -729,9 +729,9 @@ public class IteratingQueryIT {
 
         io.doSetup();
 
-        int size = 10;
-        int queryLimit = 10;
-        int startValue = 1;
+        int size = 200;
+        int queryLimit = 100;
+        int startValue = 100;
 
         long start = System.currentTimeMillis();
 
@@ -791,9 +791,9 @@ public class IteratingQueryIT {
 
         io.doSetup();
 
-        int size = 10;
+        int size = 200;
         int queryLimit = 50;
-        int startValue = 1;
+        int startValue = 100;
 
         long start = System.currentTimeMillis();
 
@@ -853,9 +853,9 @@ public class IteratingQueryIT {
 
         io.doSetup();
 
-        int size = 10;
-        int queryLimit = 10;
-        int startValue = 1;
+        int size = 200;
+        int queryLimit = 100;
+        int startValue = 100;
 
         long start = System.currentTimeMillis();
 
@@ -914,9 +914,9 @@ public class IteratingQueryIT {
 
         io.doSetup();
 
-        int size = 10;
-        int queryLimit = 10;
-        int startValue = 1;
+        int size = 200;
+        int queryLimit = 100;
+        int startValue = 99;
 
         long start = System.currentTimeMillis();
 
@@ -975,8 +975,8 @@ public class IteratingQueryIT {
 
         io.doSetup();
 
-        int size = 10;
-        int queryLimit = 10;
+        int size = 200;
+        int queryLimit = 100;
         int startValue = 50;
         int endValue = 150;
 
@@ -1002,8 +1002,8 @@ public class IteratingQueryIT {
         LOG.info( "Writes took {} ms", stop - start );
 
         Query query = Query.fromQL(
-                String.format( "select * where index >= %d AND index <= %d order by index desc", startValue,
-                        endValue ) );
+            String.format( "select * where index >= %d AND index <= %d order by index desc", startValue,
+                endValue ) );
         query.setLimit( queryLimit );
 
         int count = 0;
@@ -1038,8 +1038,8 @@ public class IteratingQueryIT {
 
         io.doSetup();
 
-        int size = 10;
-        int queryLimit = 10;
+        int size = 200;
+        int queryLimit = 100;
         int startValue = 50;
         int endValue = 150;
 
@@ -1065,8 +1065,8 @@ public class IteratingQueryIT {
         LOG.info( "Writes took {} ms", stop - start );
 
         Query query = Query.fromQL(
-                String.format( "select * where index >= %d AND index <= %d order by index asc", startValue,
-                        endValue ) );
+            String.format( "select * where index >= %d AND index <= %d order by index asc", startValue,
+                endValue ) );
         query.setLimit( queryLimit );
 
         int count = 0;
@@ -1159,7 +1159,7 @@ public class IteratingQueryIT {
 
         io.doSetup();
 
-        int size = 10;
+        int size = 200;
         int queryLimit = Query.MAX_LIMIT;
 
         // the number of entities that should be written including an intersection
@@ -1266,7 +1266,7 @@ public class IteratingQueryIT {
 
         io.doSetup();
 
-        int size = 10;
+        int size = 200;
         int queryLimit = Query.MAX_LIMIT;
 
         // the number of entities that should be written including an intersection
@@ -1333,7 +1333,7 @@ public class IteratingQueryIT {
         app.refreshIndex();
 
         Query query =
-                Query.fromQL( "select * where intersect = true OR intersect2 = true order by created, intersect desc" );
+            Query.fromQL( "select * where intersect = true OR intersect2 = true order by created, intersect desc" );
         query.setLimit( queryLimit );
 
         int count = 0;
@@ -1378,7 +1378,7 @@ public class IteratingQueryIT {
         /**
          * Leave this as a large size.  We have to write over 1k to reproduce this issue
          */
-        int size = 10;
+        int size = 200;
 
         long start = System.currentTimeMillis();
 


[4/6] incubator-usergrid git commit: smaller queries

Posted by sf...@apache.org.
smaller queries


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

Branch: refs/heads/USERGRID-405
Commit: cab669aa7743a3967c013ebeed241c91b7a027f7
Parents: 81f9170
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Mar 23 09:55:57 2015 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Mar 23 09:55:57 2015 -0600

----------------------------------------------------------------------
 .../persistence/query/IteratingQueryIT.java         | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cab669aa/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java
index c73b776..aae60c8 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/query/IteratingQueryIT.java
@@ -730,8 +730,8 @@ public class IteratingQueryIT {
         io.doSetup();
 
         int size = 10;
-        int queryLimit = 100;
-        int startValue = 100;
+        int queryLimit = 10;
+        int startValue = 1;
 
         long start = System.currentTimeMillis();
 
@@ -793,7 +793,7 @@ public class IteratingQueryIT {
 
         int size = 10;
         int queryLimit = 50;
-        int startValue = 100;
+        int startValue = 1;
 
         long start = System.currentTimeMillis();
 
@@ -854,8 +854,8 @@ public class IteratingQueryIT {
         io.doSetup();
 
         int size = 10;
-        int queryLimit = 100;
-        int startValue = 100;
+        int queryLimit = 10;
+        int startValue = 1;
 
         long start = System.currentTimeMillis();
 
@@ -915,7 +915,7 @@ public class IteratingQueryIT {
         io.doSetup();
 
         int size = 10;
-        int queryLimit = 100;
+        int queryLimit = 10;
         int startValue = 99;
 
         long start = System.currentTimeMillis();
@@ -976,7 +976,7 @@ public class IteratingQueryIT {
         io.doSetup();
 
         int size = 10;
-        int queryLimit = 100;
+        int queryLimit = 10;
         int startValue = 50;
         int endValue = 150;
 
@@ -1039,7 +1039,7 @@ public class IteratingQueryIT {
         io.doSetup();
 
         int size = 10;
-        int queryLimit = 100;
+        int queryLimit = 10;
         int startValue = 50;
         int endValue = 150;