usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sfeld...@apache.org
Subject [1/2] incubator-usergrid git commit: adding poll methodology for tests
Date Wed, 06 May 2015 19:29:42 GMT
Repository: incubator-usergrid
Updated Branches:
  refs/heads/two-dot-o-dev cc5f05d07 -> 738094b04


adding poll methodology for tests


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

Branch: refs/heads/two-dot-o-dev
Commit: 0ef6c24c022c2f9508749e10db2649f52bbd4ff4
Parents: cc5f05d
Author: Shawn Feldman <sfeldman@apache.org>
Authored: Wed May 6 08:24:35 2015 -0600
Committer: Shawn Feldman <sfeldman@apache.org>
Committed: Wed May 6 08:24:35 2015 -0600

----------------------------------------------------------------------
 .../usergrid/corepersistence/CoreModule.java    |  2 ++
 .../corepersistence/CpEntityManager.java        | 25 ++++---------
 .../corepersistence/CpEntityManagerFactory.java |  4 ++-
 .../corepersistence/CpRelationManager.java      | 17 ++++-----
 .../corepersistence/EntityManagerFig.java       | 38 ++++++++++++++++++++
 .../org/apache/usergrid/rest/IndexResource.java |  5 +--
 .../rest/test/RefreshIndexResource.java         |  2 +-
 7 files changed, 59 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0ef6c24c/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
index b5544cb..d7038cd 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
@@ -159,6 +159,8 @@ public class CoreModule  extends AbstractModule {
 
         install( new GuicyFigModule( ApplicationIdCacheFig.class ) );
 
+        install( new GuicyFigModule( EntityManagerFig.class ) );
+
         //install our pipeline modules
         install(new PipelineModule());
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0ef6c24c/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 d8721ea..e481906 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
@@ -17,21 +17,7 @@ package org.apache.usergrid.corepersistence;
 
 
 import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.TreeSet;
-import java.util.UUID;
+import java.util.*;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -165,6 +151,7 @@ public class CpEntityManager implements EntityManager {
     public static final long ONE_COUNT = 1L;
 
     private final UUID applicationId;
+    private final EntityManagerFig entityManagerFig;
     private Application application;
 
 
@@ -217,11 +204,11 @@ public class CpEntityManager implements EntityManager {
      * @param managerCache
      * @param metricsFactory
      * @param applicationId
-     * @param entityCollectionManagerFactory
-     * @param graphManagerFactory
      */
     public CpEntityManager( final CassandraService cass, final CounterUtils counterUtils,
final AsyncEventService indexService, final ManagerCache managerCache,
-                            final MetricsFactory metricsFactory,final PipelineBuilderFactory
pipelineBuilderFactory , final UUID applicationId ) {
+                            final MetricsFactory metricsFactory, final EntityManagerFig entityManagerFig,
+                            final PipelineBuilderFactory pipelineBuilderFactory , final UUID
applicationId ) {
+        this.entityManagerFig = entityManagerFig;
 
 
         Preconditions.checkNotNull( cass, "cass must not be null" );
@@ -745,7 +732,7 @@ public class CpEntityManager implements EntityManager {
         Preconditions.checkNotNull( entityRef, "entityRef cannot be null" );
 
         CpRelationManager relationManager =
-            new CpRelationManager( metricsFactory, managerCache, pipelineBuilderFactory,
indexService, this, applicationId, entityRef );
+            new CpRelationManager( metricsFactory, managerCache, pipelineBuilderFactory,
indexService, this, entityManagerFig, applicationId, entityRef );
         return relationManager;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0ef6c24c/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 6758977..f9bf12d 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
@@ -98,6 +98,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
 
     private static final Logger logger = LoggerFactory.getLogger( CpEntityManagerFactory.class
);
     private final EntityIndexFactory entityIndexFactory;
+    private final EntityManagerFig entityManagerFig;
 
     private ApplicationContext applicationContext;
 
@@ -132,6 +133,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
         this.cassandraService = cassandraService;
         this.counterUtils = counterUtils;
         this.injector = injector;
+        this.entityManagerFig = injector.getInstance(EntityManagerFig.class);
         this.entityIndex = injector.getInstance(EntityIndex.class);
         this.entityIndexFactory = injector.getInstance(EntityIndexFactory.class);
         this.managerCache = injector.getInstance( ManagerCache.class );
@@ -196,7 +198,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
 
 
     private EntityManager _getEntityManager( UUID applicationId ) {
-        EntityManager em = new CpEntityManager(cassandraService, counterUtils, indexService,
managerCache, metricsFactory, pipelineBuilderFactory,  applicationId );
+        EntityManager em = new CpEntityManager(cassandraService, counterUtils, indexService,
managerCache, metricsFactory, entityManagerFig, pipelineBuilderFactory,  applicationId );
         return em;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0ef6c24c/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
index 7d75eed..e76383f 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
@@ -17,14 +17,7 @@
 package org.apache.usergrid.corepersistence;
 
 
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
+import java.util.*;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -104,6 +97,7 @@ import static org.apache.usergrid.utils.MapUtils.addMapSet;
 public class CpRelationManager implements RelationManager {
 
     private static final Logger logger = LoggerFactory.getLogger( CpRelationManager.class
);
+    private final EntityManagerFig entityManagerFig;
 
     private ManagerCache managerCache;
     private final PipelineBuilderFactory pipelineBuilderFactory;
@@ -126,7 +120,7 @@ public class CpRelationManager implements RelationManager {
 
     public CpRelationManager( final MetricsFactory metricsFactory, final ManagerCache managerCache,
                               final PipelineBuilderFactory pipelineBuilderFactory, final
AsyncEventService indexService,
-                              final EntityManager em, final UUID applicationId, final EntityRef
headEntity ) {
+                              final EntityManager em, final EntityManagerFig entityManagerFig,
final UUID applicationId, final EntityRef headEntity) {
 
 
         Assert.notNull( em, "Entity manager cannot be null" );
@@ -134,6 +128,7 @@ public class CpRelationManager implements RelationManager {
         Assert.notNull( headEntity, "Head entity cannot be null" );
         Assert.notNull( headEntity.getUuid(), "Head entity uuid cannot be null" );
         Assert.notNull( indexService, "indexService cannot be null" );
+        this.entityManagerFig = entityManagerFig;
 
         // TODO: this assert should not be failing
         //Assert.notNull( indexBucketLocator, "indexBucketLocator cannot be null" );
@@ -655,8 +650,8 @@ public class CpRelationManager implements RelationManager {
     @Override
     public Results searchCollectionConsistent( String collName, Query query, int expectedResults
) throws Exception {
         Results results;
-        long maxLength = 5000;
-        long sleepTime = 250;
+        long maxLength = entityManagerFig.pollForRecordsTimeout();
+        long sleepTime = entityManagerFig.sleep();
         boolean found;
         long current = System.currentTimeMillis(), length = 0;
         do {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0ef6c24c/stack/core/src/main/java/org/apache/usergrid/corepersistence/EntityManagerFig.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/EntityManagerFig.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/EntityManagerFig.java
new file mode 100644
index 0000000..f5747af
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/EntityManagerFig.java
@@ -0,0 +1,38 @@
+/*
+ *
+ *  * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  *  contributor license agreements.  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.  For additional information regarding
+ *  * copyright in this work, please see the NOTICE file in the top level
+ *  * directory of this distribution.
+ *
+ */
+package org.apache.usergrid.corepersistence;
+
+import org.safehaus.guicyfig.Default;
+import org.safehaus.guicyfig.GuicyFig;
+import org.safehaus.guicyfig.Key;
+
+/**
+ * Classy class class.
+ */
+public interface EntityManagerFig extends GuicyFig {
+
+    @Key( "usergrid.entitymanager_poll_timeout_ms" )
+    @Default( "5000" )
+    int pollForRecordsTimeout();
+
+    @Key( "usergrid.entityManager_sleep_ms" )
+    @Default( "100" )
+    int sleep();
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0ef6c24c/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
index 86ba5f8..668c05c 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/IndexResource.java
@@ -20,6 +20,7 @@
 
 package org.apache.usergrid.rest;
 
+import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.sun.jersey.api.json.JSONWithPadding;
 import org.apache.usergrid.persistence.EntityManagerFactory;
@@ -297,8 +298,8 @@ public class IndexResource extends AbstractContextResource {
 
         logger.info( "Reindexing for app id: {} and collection {}", applicationId, collectionName
);
 
-        emf.rebuildCollectionIndex(applicationId, collectionName, reverse, po);
-        getEntityIndex().refreshAsync().toBlocking().last();
+        emf.rebuildCollectionIndex(Optional.of(applicationId),Optional.of(collectionName));
+        getEntityIndex().refreshAsync().toBlocking().first();
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0ef6c24c/stack/rest/src/main/java/org/apache/usergrid/rest/test/RefreshIndexResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/test/RefreshIndexResource.java
b/stack/rest/src/main/java/org/apache/usergrid/rest/test/RefreshIndexResource.java
index 41d5ef5..555d00c 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/test/RefreshIndexResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/test/RefreshIndexResource.java
@@ -66,7 +66,7 @@ public class RefreshIndexResource extends AbstractContextResource {
             }
 
             // refresh the system apps or app lookup below may fail
-            getEntityIndex().refreshAsync().toBlocking().last();
+            getEntityIndex().refreshAsync().toBlocking().first();
 
         } catch (Exception e) {
             logger.error("Error in refresh", e);


Mime
View raw message