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/02/25 18:08:46 UTC

[01/11] incubator-usergrid git commit: changes to get REST tests working with Arquillian: - Add setenv.sh to set memory and debug options for Tomcat - Make Arqillian profile active by default - Add shutdown hook to stop job service when Usergrid is under

Repository: incubator-usergrid
Updated Branches:
  refs/heads/USERGRID-273-indexbuffer 6276726cb -> 2145f21cc


changes to get REST tests working with Arquillian:
- Add setenv.sh to set memory and debug options for Tomcat
- Make Arqillian profile active by default
- Add shutdown hook to stop job service when Usergrid is underplayed


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

Branch: refs/heads/USERGRID-273-indexbuffer
Commit: c9198a6c324e9bb159be41ac6cc07efe2a6d4dc2
Parents: 949c22a
Author: Dave Johnson <dm...@apigee.com>
Authored: Tue Feb 24 09:41:45 2015 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Tue Feb 24 09:41:45 2015 -0500

----------------------------------------------------------------------
 stack/rest/catalina_base/bin/setenv.sh          |  9 +++
 stack/rest/pom.xml                              |  3 +-
 .../usergrid/rest/JobServiceBoostrap.java       |  4 +-
 .../apache/usergrid/rest/ShutdownListener.java  | 73 ++++++++++++++++++++
 .../applications/ApplicationsResource.java      |  1 +
 stack/rest/src/main/webapp/WEB-INF/web.xml      | 13 ++--
 6 files changed, 93 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9198a6c/stack/rest/catalina_base/bin/setenv.sh
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/bin/setenv.sh b/stack/rest/catalina_base/bin/setenv.sh
new file mode 100644
index 0000000..dbcad13
--- /dev/null
+++ b/stack/rest/catalina_base/bin/setenv.sh
@@ -0,0 +1,9 @@
+
+JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.port=8089 "
+JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.ssl=false "
+JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.authenticate=false"
+JAVA_OPTS="$JAVA_OPTS -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000"
+JAVA_OPTS="$JAVA_OPTS -Xmx4000m -Xms4000m"
+
+CATALINA_PID="$CATALINA_BASE/tomcat.pid"
+

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9198a6c/stack/rest/pom.xml
----------------------------------------------------------------------
diff --git a/stack/rest/pom.xml b/stack/rest/pom.xml
index 7746b5d..b3c3663 100644
--- a/stack/rest/pom.xml
+++ b/stack/rest/pom.xml
@@ -45,7 +45,7 @@
             <id>arquillian-tomcat</id>
 
             <activation>
-                <activeByDefault>false</activeByDefault>
+                <activeByDefault>true</activeByDefault>
             </activation>
 
             <dependencies>
@@ -96,6 +96,7 @@
                     <groupId>org.jboss.arquillian.container</groupId>
                     <artifactId>arquillian-tomcat-remote-7</artifactId>
                     <version>1.0.0.CR7</version>
+                    <scope>test</scope>
                 </dependency>
 
             </dependencies>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9198a6c/stack/rest/src/main/java/org/apache/usergrid/rest/JobServiceBoostrap.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/JobServiceBoostrap.java b/stack/rest/src/main/java/org/apache/usergrid/rest/JobServiceBoostrap.java
index 6d31fac..c6721ea 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/JobServiceBoostrap.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/JobServiceBoostrap.java
@@ -31,13 +31,12 @@ import java.util.Properties;
  * Simple class that starts the job store after the application context has been fired up. We don't
  * want to start the service until all of spring has been initialized in our webapp context
  */
-//@Component( "jobServiceBoostrap" )
 public class JobServiceBoostrap implements
         ApplicationListener<ContextRefreshedEvent> {
 
     private static final Logger logger = LoggerFactory.getLogger( JobServiceBoostrap.class );
 
-    private static final String START_SCHEDULER_PROP = "usergrid.scheduler.enabled";
+    public static final String START_SCHEDULER_PROP = "usergrid.scheduler.enabled";
 
     @Autowired
     private JobSchedulerService schedulerService;
@@ -60,7 +59,6 @@ public class JobServiceBoostrap implements
         String start = properties.getProperty( START_SCHEDULER_PROP, "true" );
         if ( Boolean.parseBoolean( start ) ) {
             logger.info( "Starting Scheduler Service..." );
-            // start the scheduler service
             schedulerService.startAndWait();
 
         } else {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9198a6c/stack/rest/src/main/java/org/apache/usergrid/rest/ShutdownListener.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/ShutdownListener.java b/stack/rest/src/main/java/org/apache/usergrid/rest/ShutdownListener.java
new file mode 100644
index 0000000..7b038c2
--- /dev/null
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/ShutdownListener.java
@@ -0,0 +1,73 @@
+/*
+ * 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.rest;
+
+
+import org.apache.usergrid.batch.service.JobSchedulerService;
+import org.apache.usergrid.batch.service.SchedulerService;
+import org.apache.usergrid.persistence.cassandra.CassandraService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.web.context.support.WebApplicationContextUtils;
+
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import javax.servlet.http.HttpSessionAttributeListener;
+import javax.servlet.http.HttpSessionEvent;
+import javax.servlet.http.HttpSessionListener;
+import javax.servlet.http.HttpSessionBindingEvent;
+import java.util.Properties;
+
+
+/**
+ * Shutdown job service when context is destroyed (useful when testing).
+ */
+public class ShutdownListener implements ServletContextListener {
+    private static final Logger logger = LoggerFactory.getLogger(ShutdownListener.class);
+    JobSchedulerService schedulerService;
+    Properties properties;
+
+    public ShutdownListener() {
+    }
+
+    public void contextInitialized(ServletContextEvent sce) {
+
+        ApplicationContext ctx = WebApplicationContextUtils
+            .getWebApplicationContext(sce.getServletContext());
+
+        schedulerService = ctx.getBean( JobSchedulerService.class );
+        properties = (Properties)ctx.getBean("properties");
+
+        logger.info("ShutdownListener initialized");
+    }
+
+    public void contextDestroyed(ServletContextEvent sce) {
+
+        logger.info("ShutdownListener invoked");
+
+        boolean started = Boolean.parseBoolean(
+            properties.getProperty(JobServiceBoostrap.START_SCHEDULER_PROP, "true"));
+
+        if ( started ) {
+            schedulerService.stopAndWait();
+            logger.info( "Stopping Scheduler Service..." );
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9198a6c/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationsResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationsResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationsResource.java
index 56d2f98..0c8ee06 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationsResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationsResource.java
@@ -142,6 +142,7 @@ public class ApplicationsResource extends AbstractContextResource {
 
     @RequireOrganizationAccess
     @Path(RootResource.APPLICATION_ID_PATH)
+    @PUT
     public ApplicationResource restoreApplicationFromOrganizationByApplicationId(
         @Context UriInfo ui,
         @PathParam( "applicationId" )

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c9198a6c/stack/rest/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/webapp/WEB-INF/web.xml b/stack/rest/src/main/webapp/WEB-INF/web.xml
index 24a82ca..23c0751 100644
--- a/stack/rest/src/main/webapp/WEB-INF/web.xml
+++ b/stack/rest/src/main/webapp/WEB-INF/web.xml
@@ -27,11 +27,15 @@
     <listener>
         <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
     </listener>
-  
+
     <listener>
         <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
     </listener>
 
+    <listener>
+        <listener-class>org.apache.usergrid.rest.ShutdownListener</listener-class>
+    </listener>
+
     <filter>
         <filter-name>swaggerFilter</filter-name>
         <filter-class>org.apache.usergrid.rest.SwaggerServlet</filter-class>
@@ -59,7 +63,7 @@
         <filter-name>contentTypeFilter</filter-name>
         <url-pattern>/*</url-pattern>
     </filter-mapping>
-    
+
     <filter>
         <filter-name>shiroFilter</filter-name>
         <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
@@ -72,7 +76,7 @@
         <filter-name>shiroFilter</filter-name>
         <url-pattern>/*</url-pattern>
     </filter-mapping>
-	
+
     <filter>
         <filter-name>Usergrid REST API Server</filter-name>
         <filter-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</filter-class>
@@ -126,7 +130,4 @@
         </taglib>
     </jsp-config>
 
-
-
-
 </web-app>


[10/11] incubator-usergrid git commit: Merge branch 'USERGRID-273' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into USERGRID-273

Posted by sf...@apache.org.
Merge branch 'USERGRID-273' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into USERGRID-273


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

Branch: refs/heads/USERGRID-273-indexbuffer
Commit: 9b846c35a7e31d451a9bdfd64d4083ba17a8f0ec
Parents: d0e3782 f20c353
Author: Todd Nine <tn...@apigee.com>
Authored: Wed Feb 25 09:11:52 2015 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Wed Feb 25 09:11:52 2015 -0700

----------------------------------------------------------------------
 .../resources/usergrid-deployment.properties    | 111 -------------------
 1 file changed, 111 deletions(-)
----------------------------------------------------------------------



[03/11] incubator-usergrid git commit: Effort to use arquillian-suite-extension

Posted by sf...@apache.org.
Effort to use arquillian-suite-extension


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

Branch: refs/heads/USERGRID-273-indexbuffer
Commit: ec8e66642a4b45d17c0c4ddca96823b642d6f462
Parents: 35bff54
Author: Dave Johnson <dm...@apigee.com>
Authored: Tue Feb 24 15:16:23 2015 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Tue Feb 24 15:16:23 2015 -0500

----------------------------------------------------------------------
 stack/rest/pom.xml                              | 58 +++++---------------
 .../apache/usergrid/rest/AbstractRestIT.java    |  7 ++-
 .../java/org/apache/usergrid/rest/BasicIT.java  |  5 +-
 stack/rest/src/test/resources/arquillian.xml    | 14 +----
 4 files changed, 21 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ec8e6664/stack/rest/pom.xml
----------------------------------------------------------------------
diff --git a/stack/rest/pom.xml b/stack/rest/pom.xml
index 2959d6c..c1c8ea2 100644
--- a/stack/rest/pom.xml
+++ b/stack/rest/pom.xml
@@ -50,48 +50,6 @@
 
             <dependencies>
 
-                <!--embedded mode-->
-                <!--<dependency>-->
-                   <!--<groupId>org.apache.tomcat.embed</groupId>-->
-                   <!--<artifactId>tomcat-embed-core</artifactId>-->
-                   <!--<version>7.0.59</version>-->
-                   <!--<scope>provided</scope>-->
-                <!--</dependency>-->
-                <!--<dependency>-->
-                   <!--<groupId>org.apache.tomcat.embed</groupId>-->
-                   <!--<artifactId>tomcat-embed-jasper</artifactId>-->
-                   <!--<version>7.0.59</version>-->
-                   <!--<scope>provided</scope>-->
-                <!--</dependency>-->
-                <!--<dependency>-->
-                   <!--<groupId>org.apache.tomcat.embed</groupId>-->
-                   <!--<artifactId>tomcat-embed-logging-juli</artifactId>-->
-                   <!--<version>7.0.59</version>-->
-                   <!--<scope>provided</scope>-->
-                <!--</dependency>-->
-                <!--<dependency>-->
-                   <!--<groupId>org.eclipse.jdt.core.compiler</groupId>-->
-                   <!--<artifactId>ecj</artifactId>-->
-                   <!--<version>3.7</version>-->
-                   <!--<scope>test</scope>-->
-                <!--</dependency>-->
-
-                <!--&lt;!&ndash; Weld servlet for testing CDI injections &ndash;&gt;-->
-           <!--<dependency>-->
-               <!--<groupId>org.jboss.weld.servlet</groupId>-->
-               <!--<artifactId>weld-servlet</artifactId>-->
-               <!--<version>2.2.9.Final</version>-->
-           <!--</dependency>-->
-
-                <!-- managed -->
-                <!--<dependency>-->
-                      <!--<groupId>org.jboss.arquillian.container</groupId>-->
-                      <!--<artifactId>arquillian-tomcat-managed-7</artifactId>-->
-                      <!--<version>1.0.0.CR7</version>-->
-                      <!--<scope>test</scope>-->
-                    <!--</dependency>-->
-
-                <!-- remote -->
                 <dependency>
                     <groupId>org.jboss.arquillian.container</groupId>
                     <artifactId>arquillian-tomcat-remote-7</artifactId>
@@ -99,6 +57,14 @@
                     <scope>test</scope>
                 </dependency>
 
+                <!-- only deploy once during tests -->
+                <dependency>
+                    <groupId>org.eu.ingwar.tools</groupId>
+                    <artifactId>arquillian-suite-extension</artifactId>
+                    <version>1.1.2</version>
+                    <scope>test</scope>
+                </dependency>
+
             </dependencies>
 
 
@@ -152,12 +118,14 @@
                     </argLine>
                     <includes>
 
-                        <!--<include>**/*IT.java</include>-->
-                        <!--<include>**/*Test.java</include>-->
+                        <include>**/*IT.java</include>
+                        <include>**/*Test.java</include>
 
                         <!-- how many tests can we run before Tomcat JVM throws OOM / PermGen exceptions -->
 
-                        <include>**/org/apache/usergrid/rest/BasicIT.java</include>
+                        <!--<include>**/org/apache/usergrid/rest/BasicIT.java</include>-->
+                        <!--<include>**/org/apache/usergrid/rest/PartialUpdateTest.java</include>-->
+                        <!--<include>**/org/apache/usergrid/rest/applications/collection/**/CollectionsResourceIT.java</include>-->
 
                         <!--<include>**/org/apache/usergrid/rest/*IT.java</include>-->
                         <!--<include>**/org/apache/usergrid/rest/*Test.java</include>-->

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ec8e6664/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
index 9ce381d..fab1e55 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
@@ -40,6 +40,7 @@ import org.apache.usergrid.java.client.Client;
 import static org.apache.usergrid.utils.JsonUtils.mapToFormattedJsonString;
 import static org.apache.usergrid.utils.MapUtils.hashMap;
 
+import org.eu.ingwar.tools.arquillian.extension.suite.annotations.ArquillianSuiteDeployment;
 import org.jboss.arquillian.container.test.api.Deployment;
 import org.jboss.arquillian.junit.Arquillian;
 import org.jboss.shrinkwrap.api.Archive;
@@ -64,7 +65,8 @@ import org.slf4j.LoggerFactory;
  * following naming convention: test_[HTTP verb]_[action mapping]_[ok|fail][_[specific
  * failure condition if multiple]
  */
-@RunWith( Arquillian.class )
+@ArquillianSuiteDeployment
+@RunWith(Arquillian.class)
 public abstract class AbstractRestIT extends JerseyTest {
     private static final Logger LOG = LoggerFactory.getLogger( AbstractRestIT.class );
     private static boolean usersSetup = false;
@@ -111,14 +113,13 @@ public abstract class AbstractRestIT extends JerseyTest {
         // set maven to be in offline mode
 
         System.setProperty( "org.apache.maven.offline", "true" );
-        return ShrinkWrap.create( MavenImporter.class )
+        return ShrinkWrap.create(MavenImporter.class)
             .loadPomFromFile( "pom.xml", "arquillian-tomcat" )
             .importBuildOutput()
             .as( WebArchive.class );
     }
 
 
-
     @AfterClass
     public static void teardown() {
         access_token = null;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ec8e6664/stack/rest/src/test/java/org/apache/usergrid/rest/BasicIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/BasicIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/BasicIT.java
index f63df78..53b30a4 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/BasicIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/BasicIT.java
@@ -24,6 +24,7 @@ import javax.ws.rs.core.MultivaluedMap;
 
 import com.fasterxml.jackson.databind.JsonNode;
 
+import org.eu.ingwar.tools.arquillian.extension.suite.annotations.ArquillianSuiteDeployment;
 import org.junit.Rule;
 import org.junit.Test;
 import org.slf4j.Logger;
@@ -258,7 +259,7 @@ public class BasicIT extends AbstractRestIT {
             err_thrown = true;
         }
         assertTrue( "Error should have been thrown", err_thrown );
-        
+
         // test set app user pin
 
         MultivaluedMap<String, String> formData = new MultivaluedMapImpl();
@@ -270,7 +271,7 @@ public class BasicIT extends AbstractRestIT {
                 .post( String.class, formData ));
 
         refreshIndex(orgName, appName);
-        
+
         node = mapper.readTree( resource()
                 .path( "/"+orgName+"/"+appName+"/token" )
                 .queryParam( "grant_type", "pin" )

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ec8e6664/stack/rest/src/test/resources/arquillian.xml
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/resources/arquillian.xml b/stack/rest/src/test/resources/arquillian.xml
index 1e6177e..5e5fb6c 100644
--- a/stack/rest/src/test/resources/arquillian.xml
+++ b/stack/rest/src/test/resources/arquillian.xml
@@ -23,19 +23,7 @@
     xmlns="http://jboss.org/schema/arquillian"
     xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
 
-    <!--<container qualifier="tomcat" default="true">-->
-        <!--<configuration>-->
-            <!--<property name="bindHttpPort">8080</property>-->
-            <!--<property name="bindAddress">localhost</property>-->
-            <!--<property name="javaVmArguments">-Xmx512m -XX:MaxPermSize=128m</property>-->
-            <!--<property name="catalinaHome">${catalina.home}</property>-->
-            <!--<property name="user">usergrid</property>-->
-            <!--<property name="pass">testpassword</property>-->
-            <!--&lt;!&ndash;This is a workaround for this issue https://issues.jboss.org/browse/ARQ-1814&ndash;&gt;-->
-            <!--<property name="catalinaBase">${catalina.home}</property>-->
-            <!--<property name="allowConnectingToRunningServer">true</property>-->
-        <!--</configuration>-->
-    <!--</container>-->
+    <defaultProtocol type="Servlet 3.0"/>
 
     <container qualifier="tomcat" default="true">
         <configuration>


[08/11] incubator-usergrid git commit: Add jackson-xc back in.

Posted by sf...@apache.org.
Add jackson-xc back in.


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

Branch: refs/heads/USERGRID-273-indexbuffer
Commit: f20c3532e9ebad5d613da30b338168d1e25fac43
Parents: ba7a11a
Author: Dave Johnson <dm...@apigee.com>
Authored: Wed Feb 25 10:00:30 2015 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Wed Feb 25 10:00:30 2015 -0500

----------------------------------------------------------------------
 .../resources/usergrid-deployment.properties    | 111 -------------------
 1 file changed, 111 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f20c3532/stack/rest/src/test/resources/usergrid-deployment.properties
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/resources/usergrid-deployment.properties b/stack/rest/src/test/resources/usergrid-deployment.properties
deleted file mode 100644
index 34b0aa7..0000000
--- a/stack/rest/src/test/resources/usergrid-deployment.properties
+++ /dev/null
@@ -1,111 +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.
-#
-
-######################################################
-# Minimal Usergrid configuration properties for local Tomcat and Cassandra
-
-usergrid.test=true
-
-cassandra.url=localhost:9160
-cassandra.cluster=usergrid
-cassandra.keyspace.strategy=org.apache.cassandra.locator.SimpleStrategy
-cassandra.keyspace.replication=replication_factor:1
-#cassandra.keyspace.strategy=org.apache.cassandra.locator.NetworkTopologyStrategy
-#cassandra.keyspace.replication=us-east:3
-
-cassandra.timeout=5000
-cassandra.connections=10
-cassandra.discovery=NONE
-#usergrid.read.cl=ONE
-#usergrid.write.cl=ONE
-
-usergrid.notifications.listener.queueName=notifications/queuelistenerv1_31;notifications/queuelistenerv1_32;notifications/queuelistenerv1_33;notifications/queuelistenerv1_34;notifications/queuelistenerv1_35;notifications/queuelistenerv1_36
-usergrid.notifications.listener.maxThreads=0
-
-
-hystrix.threadpool.graph_user.coreSize=10
-hystrix.threadpool.graph_async.coreSize=10
-
-elasticsearch.cluster_name=usergrid
-elasticsearch.index_prefix=usergrid
-elasticsearch.hosts=127.0.0.1
-elasticsearch.port=9300
-elasticsearch.number_shards=1
-elasticsearch.number_replicas=0
-
-
-######################################################
-# Admin and test user setup
-
-usergrid.sysadmin.login.allowed=true
-usergrid.sysadmin.login.name=superuser
-usergrid.sysadmin.login.password=superuser
-usergrid.sysadmin.login.email=junk@nowhere.org
-
-usergrid.sysadmin.email=junk@nowhere.org
-usergrid.sysadmin.approve.users=false
-usergrid.sysadmin.approve.organizations=false
-
-# Base mailer account - default for all outgoing messages
-usergrid.management.mailer=Admin <ju...@nowhere.org>
-
-usergrid.setup-test-account=true
-
-usergrid.test-account.app=test-app
-usergrid.test-account.organization=test-organization
-usergrid.test-account.admin-user.username=test
-usergrid.test-account.admin-user.name=Test User
-usergrid.test-account.admin-user.email=junk@nowhere.org
-usergrid.test-account.admin-user.password=test
-
-######################################################
-# Auto-confirm and sign-up notifications settings
-
-usergrid.management.admin_users_require_confirmation=false
-usergrid.management.admin_users_require_activation=false
-
-usergrid.management.organizations_require_activation=false
-usergrid.management.notify_sysadmin_of_new_organizations=true
-usergrid.management.notify_sysadmin_of_new_admin_users=true
-
-######################################################
-# URLs
-
-# Redirect path when request come in for TLD
-usergrid.redirect_root=http://localhost:8080/status
-
-usergrid.view.management.organizations.organization.activate=http://localhost:8080/accounts/welcome
-usergrid.view.management.organizations.organization.confirm=http://localhost:8080/accounts/welcome
-
-usergrid.view.management.users.user.activate=http://localhost:8080/accounts/welcome
-usergrid.view.management.users.user.confirm=http://localhost:8080/accounts/welcome
-
-usergrid.admin.confirmation.url=http://localhost:8080/management/users/%s/confirm
-usergrid.user.confirmation.url=http://localhost:8080/%s/%s/users/%s/confirm
-
-usergrid.organization.activation.url=http://localhost:8080/management/organizations/%s/activate
-
-usergrid.admin.activation.url=http://localhost:8080/management/users/%s/activate
-usergrid.user.activation.url=http://localhost:8080%s/%s/users/%s/activate
-
-usergrid.admin.resetpw.url=http://localhost:8080/management/users/%s/resetpw
-usergrid.user.resetpw.url=http://localhost:8080/%s/%s/users/%s/resetpw
-
-
-#usergrid.metrics.graphite.host=


[02/11] incubator-usergrid git commit: Adding some JVM options to help with the OOM PermGen problems, and removing all tests from except for one (for now)

Posted by sf...@apache.org.
Adding some JVM options to help with the OOM PermGen problems, and removing all tests from except for one (for now)


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

Branch: refs/heads/USERGRID-273-indexbuffer
Commit: 35bff549b0df8147bd7b8ee007c9303a08a06502
Parents: c9198a6
Author: Dave Johnson <dm...@apigee.com>
Authored: Tue Feb 24 10:37:37 2015 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Tue Feb 24 10:37:37 2015 -0500

----------------------------------------------------------------------
 stack/rest/catalina_base/bin/setenv.sh |  3 +--
 stack/rest/pom.xml                     | 19 +++++++++++++++++--
 2 files changed, 18 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/35bff549/stack/rest/catalina_base/bin/setenv.sh
----------------------------------------------------------------------
diff --git a/stack/rest/catalina_base/bin/setenv.sh b/stack/rest/catalina_base/bin/setenv.sh
index dbcad13..ab2f736 100644
--- a/stack/rest/catalina_base/bin/setenv.sh
+++ b/stack/rest/catalina_base/bin/setenv.sh
@@ -3,7 +3,6 @@ JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.port=8089 "
 JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.ssl=false "
 JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.authenticate=false"
 JAVA_OPTS="$JAVA_OPTS -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000"
-JAVA_OPTS="$JAVA_OPTS -Xmx4000m -Xms4000m"
+JAVA_OPTS="$JAVA_OPTS -Xmx3000m -Xms1000m -XX:MaxPermSize=200m -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled"
 
 CATALINA_PID="$CATALINA_BASE/tomcat.pid"
-

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/35bff549/stack/rest/pom.xml
----------------------------------------------------------------------
diff --git a/stack/rest/pom.xml b/stack/rest/pom.xml
index b3c3663..2959d6c 100644
--- a/stack/rest/pom.xml
+++ b/stack/rest/pom.xml
@@ -151,8 +151,23 @@
                     <argLine>-Dtest.barrier.timestamp=${maven.build.timestamp} -Dtest.clean.storage=true -Xmx${ug.heapmax} -Xms${ug.heapmin} -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 -javaagent:${settings.localRepository}/com/github/stephenc/jamm/0.2.5/jamm-0.2.5.jar ${ug.argline}
                     </argLine>
                     <includes>
-                        <include>**/*IT.java</include>
-                        <include>**/*Test.java</include>
+
+                        <!--<include>**/*IT.java</include>-->
+                        <!--<include>**/*Test.java</include>-->
+
+                        <!-- how many tests can we run before Tomcat JVM throws OOM / PermGen exceptions -->
+
+                        <include>**/org/apache/usergrid/rest/BasicIT.java</include>
+
+                        <!--<include>**/org/apache/usergrid/rest/*IT.java</include>-->
+                        <!--<include>**/org/apache/usergrid/rest/*Test.java</include>-->
+
+                        <!--<include>**/org/apache/usergrid/rest/management/**/*IT.java</include>-->
+                        <!--<include>**/org/apache/usergrid/rest/management/**/*Test.java</include>-->
+
+                        <!--<include>**/org/apache/usergrid/rest/applications/collection/**/*IT.java</include>-->
+                        <!--<include>**/org/apache/usergrid/rest/applications/collection/**/*Test.java</include>-->
+
                     </includes>
 
                 </configuration>


[06/11] incubator-usergrid git commit: Moving back to embedded Tomcat instead of Arquillian.

Posted by sf...@apache.org.
Moving back to embedded Tomcat instead of Arquillian.


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

Branch: refs/heads/USERGRID-273-indexbuffer
Commit: e05800e450240603dd2b88584242f505b0990296
Parents: 4795355
Author: Dave Johnson <dm...@apigee.com>
Authored: Tue Feb 24 19:10:22 2015 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Tue Feb 24 19:10:22 2015 -0500

----------------------------------------------------------------------
 .../applications/ApplicationsResource.java      |  20 +-
 .../apache/usergrid/rest/AbstractRestIT.java    |  42 ++---
 .../java/org/apache/usergrid/rest/BasicIT.java  |  66 +++----
 .../java/org/apache/usergrid/rest/ITSetup.java  |  15 +-
 .../apache/usergrid/rest/TomcatResource.java    | 182 +++++++++++++++++++
 .../test/resource2point0/AbstractRestIT.java    |  75 ++++----
 6 files changed, 281 insertions(+), 119 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e05800e4/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationsResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationsResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationsResource.java
index 0c8ee06..2a5ce9d 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationsResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/management/organizations/applications/ApplicationsResource.java
@@ -140,16 +140,16 @@ public class ApplicationsResource extends AbstractContextResource {
     }
 
 
-    @RequireOrganizationAccess
-    @Path(RootResource.APPLICATION_ID_PATH)
-    @PUT
-    public ApplicationResource restoreApplicationFromOrganizationByApplicationId(
-        @Context UriInfo ui,
-        @PathParam( "applicationId" )
-        String applicationIdStr ) throws Exception {
-
-        return getSubResource( ApplicationResource.class ).init( organization, UUID.fromString( applicationIdStr ) );
-    }
+//    @RequireOrganizationAccess
+//    @Path(RootResource.APPLICATION_ID_PATH)
+//    @PUT
+//    public ApplicationResource restoreApplicationFromOrganizationByApplicationId(
+//        @Context UriInfo ui,
+//        @PathParam( "applicationId" )
+//        String applicationIdStr ) throws Exception {
+//
+//        return getSubResource( ApplicationResource.class ).init( organization, UUID.fromString( applicationIdStr ) );
+//    }
 
 
     @RequireOrganizationAccess

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e05800e4/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
index eb1f628..15b2882 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
@@ -27,35 +27,28 @@ import com.sun.jersey.test.framework.AppDescriptor;
 import com.sun.jersey.test.framework.JerseyTest;
 import com.sun.jersey.test.framework.WebAppDescriptor;
 import com.sun.jersey.test.framework.spi.container.TestContainerFactory;
+import org.apache.usergrid.java.client.Client;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.Rule;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriBuilder;
 import java.io.IOException;
 import java.net.URI;
+import java.net.URISyntaxException;
 import java.net.URLClassLoader;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.UriBuilder;
-import org.apache.usergrid.java.client.Client;
+
 import static org.apache.usergrid.utils.JsonUtils.mapToFormattedJsonString;
 import static org.apache.usergrid.utils.MapUtils.hashMap;
-
-import org.eu.ingwar.tools.arquillian.extension.suite.annotations.ArquillianSuiteDeployment;
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.shrinkwrap.api.Archive;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.jboss.shrinkwrap.resolver.api.maven.Maven;
-import org.jboss.shrinkwrap.resolver.api.maven.archive.importer.MavenImporter;
-import org.junit.AfterClass;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.runner.RunWith;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -82,9 +75,10 @@ public abstract class AbstractRestIT extends JerseyTest {
 
     protected static final AppDescriptor descriptor;
 
-    // TODO, this needs to be removed.  Instead we need to hook into the Arquillian event lifecycle
-    // to invoke /system/database/setup from the REST tier.
-    public static ITSetup setup = new ITSetup(  );
+    public static ITSetup setup = new ITSetup();
+
+    @Rule
+    public TomcatResource tomcatResource = new TomcatResource();
 
     //private static final URI baseURI = setup.getBaseURI();
 
@@ -211,7 +205,11 @@ public abstract class AbstractRestIT extends JerseyTest {
 
     @Override
     protected URI getBaseURI() {
-        return setup.getBaseURI();
+        try {
+            return new URI("http://localhost:" + tomcatResource.getPort());
+        } catch (URISyntaxException e) {
+            throw new RuntimeException("Error determining baseURI", e);
+        }
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e05800e4/stack/rest/src/test/java/org/apache/usergrid/rest/BasicIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/BasicIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/BasicIT.java
index 53b30a4..20d0a64 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/BasicIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/BasicIT.java
@@ -17,38 +17,26 @@
 package org.apache.usergrid.rest;
 
 
-import java.util.Map;
-
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-
 import com.fasterxml.jackson.databind.JsonNode;
-
-import org.eu.ingwar.tools.arquillian.extension.suite.annotations.ArquillianSuiteDeployment;
+import com.sun.jersey.api.client.UniformInterfaceException;
+import com.sun.jersey.api.client.WebResource;
+import com.sun.jersey.core.util.MultivaluedMapImpl;
+import org.apache.usergrid.persistence.index.utils.UUIDUtils;
+import org.apache.usergrid.rest.test.security.TestAppUser;
+import org.apache.usergrid.rest.test.security.TestUser;
 import org.junit.Rule;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.sun.jersey.api.client.UniformInterfaceException;
-import com.sun.jersey.api.client.WebResource;
-import com.sun.jersey.core.util.MultivaluedMapImpl;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
 import java.io.IOException;
-import java.util.UUID;
+import java.util.Map;
 
 import static org.apache.commons.lang.StringUtils.isNotBlank;
-
-import org.apache.usergrid.persistence.index.utils.UUIDUtils;
-import org.apache.usergrid.persistence.model.util.UUIDGenerator;
-import org.apache.usergrid.rest.management.organizations.OrganizationsResource;
-import org.apache.usergrid.rest.test.resource.app.UsersCollection;
-import org.apache.usergrid.rest.test.security.TestAppUser;
-import org.apache.usergrid.rest.test.security.TestUser;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
 import static org.apache.usergrid.utils.MapUtils.hashMap;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.*;
 
 
 public class BasicIT extends AbstractRestIT {
@@ -80,11 +68,12 @@ public class BasicIT extends AbstractRestIT {
     public void testGenericCollectionEntityNameUuid() throws Exception {
         JsonNode node = null;
         String orgAppPath = "/"+context.getOrgName()+"/"+context.getAppName();
-        TestUser testUser = new TestAppUser( "temp"+ UUIDUtils.newTimeUUID(),"password","temp"+UUIDUtils.newTimeUUID()+"@usergrid.com"  ).create( context );
+        TestUser testUser = new TestAppUser( "temp"+ UUIDUtils.newTimeUUID(),
+            "password","temp"+UUIDUtils.newTimeUUID()+"@usergrid.com"  ).create( context );
 
         //String token = userToken( "ed@anuff.com", "sesame" );
-        WebResource resource =
-                resource().path( orgAppPath+"/suspects" ).queryParam( "access_token", context.getActiveUser().getToken() );
+        WebResource resource = resource().path( orgAppPath+"/suspects" )
+            .queryParam( "access_token", context.getActiveUser().getToken() );
         node = mapper.readTree( resource.accept( MediaType.APPLICATION_JSON ).post( String.class ));
 
 
@@ -95,8 +84,9 @@ public class BasicIT extends AbstractRestIT {
         Map<String, String> payload = hashMap( "hair", "brown" ).map( "sex", "male" ).map( "eyes", "green" )
                 .map( "name", uuid.replace( '-', '0' ) ).map( "build", "thin" ).map( "height", "6 4" );
 
-        node = mapper.readTree( resource.queryParam( "access_token", context.getActiveUser().getToken() ).accept( MediaType.APPLICATION_JSON )
-                       .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, payload ));
+        node = mapper.readTree( resource.queryParam( "access_token",
+            context.getActiveUser().getToken() ).accept( MediaType.APPLICATION_JSON )
+            .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, payload ));
 
         logNode( node );
 
@@ -163,8 +153,8 @@ public class BasicIT extends AbstractRestIT {
 
         logNode( node );
 
-        assertEquals( username,
-                node.get( "data" ).get( "organizations" ).get( orgName.toLowerCase() ).get( "users" ).get( username ).get("name").textValue());
+        assertEquals( username, node.get( "data" ).get( "organizations" ).get( orgName.toLowerCase() )
+                    .get( "users" ).get( username ).get("name").textValue());
 
 
         // test login user with incorrect password
@@ -196,11 +186,13 @@ public class BasicIT extends AbstractRestIT {
         assertTrue( "Error should have been thrown", err_thrown );
 
         // test login user with correct password
-        TestUser testUser = new TestAppUser( "temp"+ UUIDUtils.newTimeUUID(),"password","temp"+UUIDUtils.newTimeUUID()+"@usergrid.com"  ).create( context );
+        TestUser testUser = new TestAppUser( "temp"+ UUIDUtils.newTimeUUID(),"password",
+            "temp"+UUIDUtils.newTimeUUID()+"@usergrid.com"  ).create( context );
 
-        node = mapper.readTree( resource().path( "/"+orgName+"/"+appName+"/token" ).queryParam( "grant_type", "password" )
-                .queryParam( "username", testUser.getUser() ).queryParam( "password", testUser.getPassword())
-                .accept( MediaType.APPLICATION_JSON ).get( String.class ));
+        node = mapper.readTree( resource().path( "/"+orgName+"/"+appName+"/token" )
+            .queryParam( "grant_type", "password" )
+            .queryParam( "username", testUser.getUser() ).queryParam( "password", testUser.getPassword())
+            .accept( MediaType.APPLICATION_JSON ).get( String.class ));
 
         logNode( node );
 
@@ -235,8 +227,9 @@ public class BasicIT extends AbstractRestIT {
 
         err_thrown = false;
         try {
-            node = mapper.readTree( resource().path( "/"+orgName+"/"+appName+"/users" ).queryParam( "access_token", "blahblahblah" )
-                    .accept( MediaType.APPLICATION_JSON ).get( String.class ));
+            node = mapper.readTree( resource().path( "/"+orgName+"/"+appName+"/users" )
+                .queryParam( "access_token", "blahblahblah" )
+                .accept( MediaType.APPLICATION_JSON ).get( String.class ));
         }
         catch ( UniformInterfaceException e ) {
             if ( e.getResponse().getStatus() != 401 ) {
@@ -341,7 +334,8 @@ public class BasicIT extends AbstractRestIT {
 
         err_thrown = false;
         try {
-            node = mapper.readTree( resource().path(  "/"+orgName+"/"+appName+"/items" ).accept( MediaType.APPLICATION_JSON )
+            node = mapper.readTree( resource().path(  "/"+orgName+"/"+appName+"/items" )
+                .accept( MediaType.APPLICATION_JSON )
                     .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, payload ));
         }
         catch ( UniformInterfaceException e ) {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e05800e4/stack/rest/src/test/java/org/apache/usergrid/rest/ITSetup.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/ITSetup.java b/stack/rest/src/test/java/org/apache/usergrid/rest/ITSetup.java
index 021f937..7888061 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/ITSetup.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/ITSetup.java
@@ -42,6 +42,7 @@ public class ITSetup  {
     private SignInProviderFactory providerFactory;
     private Properties properties;
     private ManagementService managementService;
+    private TomcatResource tomcatResource;
 
     private URI uri;
 
@@ -52,10 +53,6 @@ public class ITSetup  {
 
         this.springResource = ConcurrentProcessSingleton.getInstance().getSpringResource();
 
-        //start tomcat
-
-
-
         emf =                springResource.getBean( EntityManagerFactory.class );
         smf =                springResource.getBean( ServiceManagerFactory.class );
         tokenService =       springResource.getBean( TokenService.class );
@@ -63,16 +60,15 @@ public class ITSetup  {
         applicationCreator = springResource.getBean( ApplicationCreator.class );
         managementService =  springResource.getBean( ManagementService.class );
 
+        tomcatResource = TomcatResource.instance;
+        tomcatResource.setWebAppsPath( "src/main/webapp" );
 
         // Initialize Jersey Client
         //TODO, make this port a resource that's filtered by maven build for the port number
         uri = UriBuilder.fromUri("http://localhost/").port( 8080 ).build();
-
-
     }
 
 
-
     public int getTomcatPort() {
         return 8080;
     }
@@ -111,9 +107,4 @@ public class ITSetup  {
     public SignInProviderFactory getProviderFactory() {
         return providerFactory;
     }
-
-
-    public URI getBaseURI() {
-        return uri;
-    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e05800e4/stack/rest/src/test/java/org/apache/usergrid/rest/TomcatResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/TomcatResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/TomcatResource.java
new file mode 100644
index 0000000..5f00f7b
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/TomcatResource.java
@@ -0,0 +1,182 @@
+/*
+ * 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.rest;
+
+import com.google.common.io.Files;
+import com.sun.jersey.api.client.Client;
+import com.sun.jersey.api.client.WebResource;
+import org.apache.catalina.LifecycleException;
+import org.apache.catalina.startup.Tomcat;
+import org.apache.commons.lang.math.RandomUtils;
+import org.apache.usergrid.cassandra.AvailablePortFinder;
+import org.junit.rules.ExternalResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import javax.servlet.ServletException;
+import java.io.File;
+import java.util.concurrent.atomic.AtomicInteger;
+
+
+/**
+ * Start and stop embedded Tomcat.
+ */
+public class TomcatResource extends ExternalResource {
+    private static final Logger log = LoggerFactory.getLogger(TomcatResource.class);
+
+    public static final TomcatResource instance = new TomcatResource();
+
+    private static final Object mutex = new Object();
+    private String webAppsPath = "src/main/webapp";
+    private int port;
+    private boolean started = false;
+
+    private static AtomicInteger clientCount = new AtomicInteger(0);
+
+    Tomcat tomcat = null;
+    Process process = null;
+
+
+    public TomcatResource() {
+        try {
+            String[] locations = { "usergrid-properties-context.xml" };
+            ConfigurableApplicationContext appContext =
+                new ClassPathXmlApplicationContext( locations );
+
+        } catch (Exception ex) {
+            throw new RuntimeException("Error getting properties", ex);
+        }
+    }
+
+
+    @Override
+    protected void after() {
+        log.info("Entering after");
+
+        synchronized (mutex) {
+
+            if ( clientCount.decrementAndGet() < 1 ) {
+
+                log.info("----------------------------------------------------------------------");
+                log.info("Destroying Tomcat running on port " + port);
+                log.info("----------------------------------------------------------------------");
+
+                if ( process != null ) {
+                    process.destroy();
+
+                } else if ( tomcat != null ) {
+                    try {
+                        tomcat.stop();
+                        tomcat.destroy();
+                    } catch (LifecycleException ex) {
+                        log.error("Error stopping Tomcat", ex);
+                    }
+                }
+                started = false;
+
+            } else {
+                log.info("NOT stopping Tomcat because it is still in use by {}", clientCount.get());
+            }
+        }
+
+        log.info("Leaving after");
+    }
+
+
+    @Override
+    protected void before() throws Throwable {
+        log.info("Entering before");
+
+        synchronized (mutex) {
+
+            clientCount.incrementAndGet();
+
+            if (started) {
+                log.info("NOT starting Tomcat because it is already started");
+                log.info("Leaving before: {} users of Tomcat", clientCount.get());
+                return;
+            }
+
+            startTomcatEmbedded();
+
+            log.info("Leaving before: Started Tomcat, now {} users", clientCount.get());
+        }
+
+    }
+
+
+    private void waitForTomcat() throws RuntimeException {
+        String url = "http://localhost:" + port + "/status";
+        int count = 0;
+        while (count++ < 30) {
+            try {
+                Thread.sleep(1000);
+                Client c = Client.create();
+                WebResource wr = c.resource( url );
+                wr.get(String.class);
+                log.info("Tomcat is started.");
+                started = true;
+                break;
+
+            } catch (Exception e) {
+                log.info("Waiting for Tomcat on url {}", url);
+            }
+        }
+        if ( !started ) {
+            throw new RuntimeException("Tomcat process never started.");
+        }
+    }
+
+
+    private void startTomcatEmbedded() throws ServletException, LifecycleException {
+
+        File dataDir = Files.createTempDir();
+        dataDir.deleteOnExit();
+
+        port = AvailablePortFinder.getNextAvailable( 9998 + RandomUtils.nextInt(10)  );
+
+        tomcat = new Tomcat();
+        tomcat.setBaseDir( dataDir.getAbsolutePath() );
+        tomcat.setPort( port );
+        tomcat.getConnector().setAttribute("maxThreads", "2000");
+        tomcat.addWebapp( "/", new File( getWebAppsPath() ).getAbsolutePath() );
+
+        log.info("-----------------------------------------------------------------");
+        log.info("Starting Tomcat embedded port {} dir {}", port, dataDir.getAbsolutePath());
+        log.info("-----------------------------------------------------------------");
+        tomcat.start();
+
+        waitForTomcat();
+
+        mutex.notifyAll();
+    }
+
+    public int getPort() {
+        return port;
+    }
+
+    public String getWebAppsPath() {
+        return webAppsPath;
+    }
+
+    public void setWebAppsPath(String webAppsPath) {
+        this.webAppsPath = webAppsPath;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e05800e4/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
index cdba34c..43d0ba4 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
@@ -17,27 +17,6 @@
 package org.apache.usergrid.rest.test.resource2point0;
 
 
-import java.net.URI;
-import java.net.URLClassLoader;
-import java.util.Arrays;
-
-import org.jboss.arquillian.container.test.api.Deployment;
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.jboss.shrinkwrap.resolver.api.maven.archive.importer.MavenImporter;
-import org.junit.Rule;
-import org.junit.runner.RunWith;
-
-import org.apache.usergrid.rest.ITSetup;
-import org.apache.usergrid.rest.test.resource2point0.endpoints.ApplicationsResource;
-import org.apache.usergrid.rest.test.resource2point0.endpoints.OrganizationResource;
-import org.apache.usergrid.rest.test.resource2point0.endpoints.mgmt.ManagementResource;
-import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
-import org.apache.usergrid.rest.test.resource2point0.model.Entity;
-import org.apache.usergrid.rest.test.resource2point0.model.Token;
-import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
-
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.sun.jersey.api.client.UniformInterfaceException;
@@ -48,26 +27,40 @@ import com.sun.jersey.test.framework.AppDescriptor;
 import com.sun.jersey.test.framework.JerseyTest;
 import com.sun.jersey.test.framework.WebAppDescriptor;
 import com.sun.jersey.test.framework.spi.container.TestContainerFactory;
+import org.apache.usergrid.rest.ITSetup;
+import org.apache.usergrid.rest.TomcatResource;
+import org.apache.usergrid.rest.test.resource2point0.endpoints.ApplicationsResource;
+import org.apache.usergrid.rest.test.resource2point0.endpoints.OrganizationResource;
+import org.apache.usergrid.rest.test.resource2point0.endpoints.mgmt.ManagementResource;
+import org.apache.usergrid.rest.test.resource2point0.model.Token;
+import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
+import org.junit.Rule;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URLClassLoader;
+import java.util.Arrays;
 
 import static org.junit.Assert.assertEquals;
 
 
 
 /**
- * How would we get the client from here
+ * Base class for REST tests.
  */
-@RunWith( Arquillian.class )
+//@RunWith( Arquillian.class )
 public class AbstractRestIT extends JerseyTest {
 
     private static ClientConfig clientConfig = new DefaultClientConfig();
 
-
+    @Rule
+    public TomcatResource tomcatResource = new TomcatResource();
 
     public static ITSetup setup = new ITSetup(  );
 //
 //    TODO: Allow the client to be setup seperately
     @Rule
-    public ClientSetup clientSetup = new ClientSetup(setup.getBaseURI().toString());
+    public ClientSetup clientSetup = new ClientSetup( this.getBaseURI().toString() );
 
     protected static final AppDescriptor descriptor;
 
@@ -86,19 +79,19 @@ public class AbstractRestIT extends JerseyTest {
     }
 
 
-    //We set testable = false so we deploy the archive to the server and test it locally
-    @Deployment( testable = false )
-    public static WebArchive createTestArchive() {
-
-        //we use the MavenImporter from shrinkwrap to just produce whatever maven would build then test with it
-
-        //set maven to be in offline mode
-
-        System.setProperty( "org.apache.maven.offline", "true" );
-
-        return ShrinkWrap.create( MavenImporter.class ).loadPomFromFile( "pom.xml", "arquillian-tomcat" )
-                         .importBuildOutput().as( WebArchive.class );
-    }
+//    //We set testable = false so we deploy the archive to the server and test it locally
+//    @Deployment( testable = false )
+//    public static WebArchive createTestArchive() {
+//
+//        //we use the MavenImporter from shrinkwrap to just produce whatever maven would build then test with it
+//
+//        //set maven to be in offline mode
+//
+//        System.setProperty( "org.apache.maven.offline", "true" );
+//
+//        return ShrinkWrap.create( MavenImporter.class ).loadPomFromFile( "pom.xml", "arquillian-tomcat" )
+//                         .importBuildOutput().as( WebArchive.class );
+//    }
 
     public static void dumpClasspath( ClassLoader loader ) {
         System.out.println( "Classloader " + loader + ":" );
@@ -118,7 +111,11 @@ public class AbstractRestIT extends JerseyTest {
 
     @Override
     protected URI getBaseURI() {
-        return setup.getBaseURI();
+        try {
+            return new URI("http://localhost:" + tomcatResource.getPort());
+        } catch (URISyntaxException e) {
+            throw new RuntimeException("Error determining baseURI", e);
+        }
     }
 
     @Override


[07/11] incubator-usergrid git commit: Fixes startup order bug.

Posted by sf...@apache.org.
Fixes startup order bug.

Still broken.  Need to fix mock mail 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/ba7a11ae
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/ba7a11ae
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/ba7a11ae

Branch: refs/heads/USERGRID-273-indexbuffer
Commit: ba7a11aee0c7cc2e66e90acfd6c5dc45f122ed09
Parents: e05800e
Author: Todd Nine <tn...@apigee.com>
Authored: Tue Feb 24 19:21:33 2015 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Tue Feb 24 19:21:33 2015 -0700

----------------------------------------------------------------------
 .../apache/usergrid/rest/AbstractRestIT.java    |  14 +-
 .../java/org/apache/usergrid/rest/ITSetup.java  |  48 +----
 .../apache/usergrid/rest/TomcatResource.java    | 182 ------------------
 .../org/apache/usergrid/rest/TomcatRuntime.java | 192 +++++++++++++++++++
 .../rest/management/RegistrationIT.java         |   9 +-
 .../test/resource2point0/AbstractRestIT.java    |  12 +-
 6 files changed, 221 insertions(+), 236 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ba7a11ae/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
index 15b2882..082e436 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
@@ -28,6 +28,9 @@ import com.sun.jersey.test.framework.JerseyTest;
 import com.sun.jersey.test.framework.WebAppDescriptor;
 import com.sun.jersey.test.framework.spi.container.TestContainerFactory;
 import org.apache.usergrid.java.client.Client;
+import org.apache.usergrid.management.ManagementService;
+import org.apache.usergrid.setup.ConcurrentProcessSingleton;
+
 import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.Rule;
@@ -64,6 +67,9 @@ public abstract class AbstractRestIT extends JerseyTest {
     private static final Logger LOG = LoggerFactory.getLogger( AbstractRestIT.class );
     private static boolean usersSetup = false;
 
+    protected static TomcatRuntime tomcatRuntime = TomcatRuntime.getInstance();
+
+    protected static final ITSetup setup = ITSetup.getInstance();
 
     private static ClientConfig clientConfig = new DefaultClientConfig();
 
@@ -75,10 +81,6 @@ public abstract class AbstractRestIT extends JerseyTest {
 
     protected static final AppDescriptor descriptor;
 
-    public static ITSetup setup = new ITSetup();
-
-    @Rule
-    public TomcatResource tomcatResource = new TomcatResource();
 
     //private static final URI baseURI = setup.getBaseURI();
 
@@ -186,7 +188,7 @@ public abstract class AbstractRestIT extends JerseyTest {
         setUserPassword( "ed@anuff.com", "sesame" );
 
         client = new Client( "test-organization", "test-app" ).withApiUrl(
-                UriBuilder.fromUri( "http://localhost/" ).port( setup.getTomcatPort() ).build().toString() );
+                UriBuilder.fromUri( "http://localhost/" ).port(tomcatRuntime.getPort() ).build().toString() );
 
         org.apache.usergrid.java.client.response.ApiResponse response =
                 client.authorizeAppUser( "ed@anuff.com", "sesame" );
@@ -206,7 +208,7 @@ public abstract class AbstractRestIT extends JerseyTest {
     @Override
     protected URI getBaseURI() {
         try {
-            return new URI("http://localhost:" + tomcatResource.getPort());
+            return new URI("http://localhost:" + tomcatRuntime.getPort());
         } catch (URISyntaxException e) {
             throw new RuntimeException("Error determining baseURI", e);
         }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ba7a11ae/stack/rest/src/test/java/org/apache/usergrid/rest/ITSetup.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/ITSetup.java b/stack/rest/src/test/java/org/apache/usergrid/rest/ITSetup.java
index 7888061..510c992 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/ITSetup.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/ITSetup.java
@@ -35,45 +35,37 @@ import org.apache.usergrid.setup.ConcurrentProcessSingleton;
 /** A {@link org.junit.rules.TestRule} that sets up services. */
 public class ITSetup  {
 
-    private ServiceManagerFactory smf;
+    private static ITSetup instance;
+
     private EntityManagerFactory emf;
-    private ApplicationCreator applicationCreator;
-    private TokenService tokenService;
-    private SignInProviderFactory providerFactory;
     private Properties properties;
     private ManagementService managementService;
-    private TomcatResource tomcatResource;
 
-    private URI uri;
 
     private SpringResource springResource;
 
 
-    public ITSetup( ) {
+    private ITSetup( ) {
 
         this.springResource = ConcurrentProcessSingleton.getInstance().getSpringResource();
 
         emf =                springResource.getBean( EntityManagerFactory.class );
-        smf =                springResource.getBean( ServiceManagerFactory.class );
-        tokenService =       springResource.getBean( TokenService.class );
-        providerFactory =    springResource.getBean( SignInProviderFactory.class );
-        applicationCreator = springResource.getBean( ApplicationCreator.class );
         managementService =  springResource.getBean( ManagementService.class );
+        properties = springResource.getBean( "properties", Properties.class );
 
-        tomcatResource = TomcatResource.instance;
-        tomcatResource.setWebAppsPath( "src/main/webapp" );
 
-        // Initialize Jersey Client
-        //TODO, make this port a resource that's filtered by maven build for the port number
-        uri = UriBuilder.fromUri("http://localhost/").port( 8080 ).build();
     }
 
+    public static synchronized ITSetup getInstance(){
+        if(instance == null){
+            instance = new ITSetup();
+        }
 
-    public int getTomcatPort() {
-        return 8080;
+        return instance;
     }
 
 
+
     public ManagementService getMgmtSvc() {
         return managementService;
     }
@@ -83,28 +75,8 @@ public class ITSetup  {
         return emf;
     }
 
-
-    public ServiceManagerFactory getSmf() {
-        return smf;
-    }
-
-
-    public ApplicationCreator getAppCreator() {
-        return applicationCreator;
-    }
-
-
-    public TokenService getTokenSvc() {
-        return tokenService;
-    }
-
-
     public Properties getProps() {
         return properties;
     }
 
-
-    public SignInProviderFactory getProviderFactory() {
-        return providerFactory;
-    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ba7a11ae/stack/rest/src/test/java/org/apache/usergrid/rest/TomcatResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/TomcatResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/TomcatResource.java
deleted file mode 100644
index 5f00f7b..0000000
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/TomcatResource.java
+++ /dev/null
@@ -1,182 +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.rest;
-
-import com.google.common.io.Files;
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.WebResource;
-import org.apache.catalina.LifecycleException;
-import org.apache.catalina.startup.Tomcat;
-import org.apache.commons.lang.math.RandomUtils;
-import org.apache.usergrid.cassandra.AvailablePortFinder;
-import org.junit.rules.ExternalResource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-import javax.servlet.ServletException;
-import java.io.File;
-import java.util.concurrent.atomic.AtomicInteger;
-
-
-/**
- * Start and stop embedded Tomcat.
- */
-public class TomcatResource extends ExternalResource {
-    private static final Logger log = LoggerFactory.getLogger(TomcatResource.class);
-
-    public static final TomcatResource instance = new TomcatResource();
-
-    private static final Object mutex = new Object();
-    private String webAppsPath = "src/main/webapp";
-    private int port;
-    private boolean started = false;
-
-    private static AtomicInteger clientCount = new AtomicInteger(0);
-
-    Tomcat tomcat = null;
-    Process process = null;
-
-
-    public TomcatResource() {
-        try {
-            String[] locations = { "usergrid-properties-context.xml" };
-            ConfigurableApplicationContext appContext =
-                new ClassPathXmlApplicationContext( locations );
-
-        } catch (Exception ex) {
-            throw new RuntimeException("Error getting properties", ex);
-        }
-    }
-
-
-    @Override
-    protected void after() {
-        log.info("Entering after");
-
-        synchronized (mutex) {
-
-            if ( clientCount.decrementAndGet() < 1 ) {
-
-                log.info("----------------------------------------------------------------------");
-                log.info("Destroying Tomcat running on port " + port);
-                log.info("----------------------------------------------------------------------");
-
-                if ( process != null ) {
-                    process.destroy();
-
-                } else if ( tomcat != null ) {
-                    try {
-                        tomcat.stop();
-                        tomcat.destroy();
-                    } catch (LifecycleException ex) {
-                        log.error("Error stopping Tomcat", ex);
-                    }
-                }
-                started = false;
-
-            } else {
-                log.info("NOT stopping Tomcat because it is still in use by {}", clientCount.get());
-            }
-        }
-
-        log.info("Leaving after");
-    }
-
-
-    @Override
-    protected void before() throws Throwable {
-        log.info("Entering before");
-
-        synchronized (mutex) {
-
-            clientCount.incrementAndGet();
-
-            if (started) {
-                log.info("NOT starting Tomcat because it is already started");
-                log.info("Leaving before: {} users of Tomcat", clientCount.get());
-                return;
-            }
-
-            startTomcatEmbedded();
-
-            log.info("Leaving before: Started Tomcat, now {} users", clientCount.get());
-        }
-
-    }
-
-
-    private void waitForTomcat() throws RuntimeException {
-        String url = "http://localhost:" + port + "/status";
-        int count = 0;
-        while (count++ < 30) {
-            try {
-                Thread.sleep(1000);
-                Client c = Client.create();
-                WebResource wr = c.resource( url );
-                wr.get(String.class);
-                log.info("Tomcat is started.");
-                started = true;
-                break;
-
-            } catch (Exception e) {
-                log.info("Waiting for Tomcat on url {}", url);
-            }
-        }
-        if ( !started ) {
-            throw new RuntimeException("Tomcat process never started.");
-        }
-    }
-
-
-    private void startTomcatEmbedded() throws ServletException, LifecycleException {
-
-        File dataDir = Files.createTempDir();
-        dataDir.deleteOnExit();
-
-        port = AvailablePortFinder.getNextAvailable( 9998 + RandomUtils.nextInt(10)  );
-
-        tomcat = new Tomcat();
-        tomcat.setBaseDir( dataDir.getAbsolutePath() );
-        tomcat.setPort( port );
-        tomcat.getConnector().setAttribute("maxThreads", "2000");
-        tomcat.addWebapp( "/", new File( getWebAppsPath() ).getAbsolutePath() );
-
-        log.info("-----------------------------------------------------------------");
-        log.info("Starting Tomcat embedded port {} dir {}", port, dataDir.getAbsolutePath());
-        log.info("-----------------------------------------------------------------");
-        tomcat.start();
-
-        waitForTomcat();
-
-        mutex.notifyAll();
-    }
-
-    public int getPort() {
-        return port;
-    }
-
-    public String getWebAppsPath() {
-        return webAppsPath;
-    }
-
-    public void setWebAppsPath(String webAppsPath) {
-        this.webAppsPath = webAppsPath;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ba7a11ae/stack/rest/src/test/java/org/apache/usergrid/rest/TomcatRuntime.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/TomcatRuntime.java b/stack/rest/src/test/java/org/apache/usergrid/rest/TomcatRuntime.java
new file mode 100644
index 0000000..ab22450
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/TomcatRuntime.java
@@ -0,0 +1,192 @@
+/*
+ * 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.rest;
+
+
+import java.io.File;
+
+import org.junit.rules.ExternalResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.catalina.LifecycleException;
+import org.apache.catalina.startup.Tomcat;
+import org.apache.commons.lang.math.RandomUtils;
+
+import org.apache.usergrid.cassandra.AvailablePortFinder;
+import org.apache.usergrid.setup.ConcurrentProcessSingleton;
+
+import com.google.common.io.Files;
+import com.sun.jersey.api.client.Client;
+import com.sun.jersey.api.client.WebResource;
+
+
+/**
+ * Start and stop embedded Tomcat.
+ */
+public class TomcatRuntime extends ExternalResource {
+    private static final Logger log = LoggerFactory.getLogger( TomcatRuntime.class );
+
+
+    private static final String WEBAPPS_PATH = "src/main/webapp";
+
+    private static TomcatRuntime instance;
+
+    public final TomcatInstance tomcat;
+
+
+    private TomcatRuntime() {
+
+        //before we run tomcat, we need to cleanup our data
+        ConcurrentProcessSingleton.getInstance();
+
+        tomcat = new TomcatInstance( WEBAPPS_PATH );
+        tomcat.startTomcat();
+
+        //stop on JVM shutdown
+        Runtime.getRuntime().addShutdownHook( new Thread() {
+            @Override
+            public void run() {
+                tomcat.stopTomcat();
+            }
+        } );
+    }
+
+
+    /**
+     * Get the instance of the tomcat runtime and starts the tomcat singleton.  Starts tomcat once per JVM
+     * @return
+     */
+    public static synchronized TomcatRuntime getInstance() {
+        if ( instance == null ) {
+
+
+            instance = new TomcatRuntime();
+        }
+
+        return instance;
+    }
+
+
+    /**
+     * Get the port tomcat is running on
+     */
+    public int getPort() {
+        return tomcat.getPort();
+    }
+
+
+    /**
+     * Inner class of tomcat runtime
+     */
+    private static class TomcatInstance {
+
+        public static final int THREADS_PERPROC = 25;
+
+        private final String webAppsPath;
+
+        private Tomcat tomcat = null;
+        private int port;
+
+        private boolean started = false;
+
+
+        private TomcatInstance( final String webAppsPath ) {this.webAppsPath = webAppsPath;}
+
+
+        /**
+         * Start the tomcat instance
+         */
+        public void startTomcat() {
+            try {
+
+                //we don't want to use all our threads, we'll kill the box
+                final int availableProcessors = Runtime.getRuntime().availableProcessors();
+                final int usedProcs = Math.min( 2, availableProcessors );
+                final int threads = usedProcs * THREADS_PERPROC;
+
+
+                File dataDir = Files.createTempDir();
+                dataDir.deleteOnExit();
+
+                port = AvailablePortFinder.getNextAvailable( 9998 + RandomUtils.nextInt( 10 ) );
+
+                tomcat = new Tomcat();
+                tomcat.setBaseDir( dataDir.getAbsolutePath() );
+                tomcat.setPort( port );
+
+
+                tomcat.getConnector().setAttribute( "maxThreads", "" + threads );
+
+                tomcat.addWebapp( "/", new File( webAppsPath ).getAbsolutePath() );
+
+
+                log.info( "-----------------------------------------------------------------" );
+                log.info( "Starting Tomcat embedded port {} dir {}", port, dataDir.getAbsolutePath() );
+                log.info( "-----------------------------------------------------------------" );
+                tomcat.start();
+
+                waitForTomcat();
+
+            }
+            catch ( Exception e ) {
+                throw new RuntimeException( "Couldn't start tomcat", e );
+            }
+        }
+
+
+        /**
+         * Stop the embedded tomcat process
+         */
+        public void stopTomcat() {
+            try {
+                tomcat.stop();
+            }
+            catch ( LifecycleException e ) {
+                throw new RuntimeException( "Unable to stop tomcat", e );
+            }
+        }
+
+
+        public int getPort() {
+            return port;
+        }
+
+
+        private void waitForTomcat() throws RuntimeException {
+            String url = "http://localhost:" + port + "/status";
+            int count = 0;
+            while ( count++ < 30 ) {
+                try {
+                    Thread.sleep( 1000 );
+                    Client c = Client.create();
+                    WebResource wr = c.resource( url );
+                    wr.get( String.class );
+                    log.info( "Tomcat is started." );
+                    started = true;
+                    break;
+                }
+                catch ( Exception e ) {
+                    log.info( "Waiting for Tomcat on url {}", url );
+                }
+            }
+            if ( !started ) {
+                throw new RuntimeException( "Tomcat process never started." );
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ba7a11ae/stack/rest/src/test/java/org/apache/usergrid/rest/management/RegistrationIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/RegistrationIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/RegistrationIT.java
index aca33ba..f949da3 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/RegistrationIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/RegistrationIT.java
@@ -43,6 +43,7 @@ import org.slf4j.LoggerFactory;
 import org.apache.usergrid.management.UserInfo;
 import org.apache.usergrid.persistence.model.util.UUIDGenerator;
 import org.apache.usergrid.rest.AbstractRestIT;
+import org.apache.usergrid.rest.ITSetup;
 import org.apache.usergrid.rest.TestContextSetup;
 import org.apache.usergrid.rest.test.security.TestAppUser;
 import org.apache.usergrid.rest.test.security.TestUser;
@@ -71,6 +72,8 @@ public class RegistrationIT extends AbstractRestIT {
 
     private static final Logger logger = LoggerFactory.getLogger( RegistrationIT.class );
 
+    private static final ITSetup setup = ITSetup.getInstance();
+
     @Rule
     public TestContextSetup context = new TestContextSetup( this );
 
@@ -100,7 +103,7 @@ public class RegistrationIT extends AbstractRestIT {
             context.createAppForOrg();
 
             final UUID owner_uuid = context.getActiveUser().getUuid();
-            
+
 //            refreshIndex("test-organization", "test-app");
 //
 //            UUID owner_uuid =
@@ -309,7 +312,7 @@ public class RegistrationIT extends AbstractRestIT {
             String adminUserName = "AdminUserFromOtherOrg";
             String adminUserEmail = "AdminUserFromOtherOrg@otherorg.com";
 
-            UserInfo adminUser = setup.getMgmtSvc().createAdminUser( 
+            UserInfo adminUser = setup.getMgmtSvc().createAdminUser(
                     adminUserEmail, adminUserEmail, adminUserEmail, "password1", true, false );
 
             refreshIndex("test-organization", "test-app");
@@ -323,7 +326,7 @@ public class RegistrationIT extends AbstractRestIT {
             // this should NOT send resetpwd link in email to newly added org admin user(that
             // already exists in usergrid) only "User Invited To Organization" email
             String adminToken = adminToken();
-            JsonNode node = postAddAdminToOrg( "test-organization", 
+            JsonNode node = postAddAdminToOrg( "test-organization",
                     adminUserEmail, "password1", adminToken );
             String uuid = node.get( "data" ).get( "user" ).get( "uuid" ).textValue();
             UUID userId = UUID.fromString( uuid );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ba7a11ae/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
index 43d0ba4..90d3d55 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
@@ -28,7 +28,7 @@ import com.sun.jersey.test.framework.JerseyTest;
 import com.sun.jersey.test.framework.WebAppDescriptor;
 import com.sun.jersey.test.framework.spi.container.TestContainerFactory;
 import org.apache.usergrid.rest.ITSetup;
-import org.apache.usergrid.rest.TomcatResource;
+import org.apache.usergrid.rest.TomcatRuntime;
 import org.apache.usergrid.rest.test.resource2point0.endpoints.ApplicationsResource;
 import org.apache.usergrid.rest.test.resource2point0.endpoints.OrganizationResource;
 import org.apache.usergrid.rest.test.resource2point0.endpoints.mgmt.ManagementResource;
@@ -53,12 +53,10 @@ public class AbstractRestIT extends JerseyTest {
 
     private static ClientConfig clientConfig = new DefaultClientConfig();
 
-    @Rule
-    public TomcatResource tomcatResource = new TomcatResource();
+    public static TomcatRuntime tomcatRuntime = TomcatRuntime.getInstance();
+
+
 
-    public static ITSetup setup = new ITSetup(  );
-//
-//    TODO: Allow the client to be setup seperately
     @Rule
     public ClientSetup clientSetup = new ClientSetup( this.getBaseURI().toString() );
 
@@ -112,7 +110,7 @@ public class AbstractRestIT extends JerseyTest {
     @Override
     protected URI getBaseURI() {
         try {
-            return new URI("http://localhost:" + tomcatResource.getPort());
+            return new URI("http://localhost:" + tomcatRuntime.getPort());
         } catch (URISyntaxException e) {
             throw new RuntimeException("Error determining baseURI", e);
         }


[04/11] incubator-usergrid git commit: Merge branch 'USERGRID-273' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into USERGRID-273

Posted by sf...@apache.org.
Merge branch 'USERGRID-273' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into USERGRID-273

Conflicts:
	stack/rest/pom.xml


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

Branch: refs/heads/USERGRID-273-indexbuffer
Commit: 99d694b87ed85b515ac77f929eee034e92ac4560
Parents: ec8e666 b82999e
Author: Dave Johnson <dm...@apigee.com>
Authored: Tue Feb 24 15:17:18 2015 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Tue Feb 24 15:17:18 2015 -0500

----------------------------------------------------------------------

----------------------------------------------------------------------



[11/11] incubator-usergrid git commit: Merge branch 'USERGRID-273' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into USERGRID-273-indexbuffer

Posted by sf...@apache.org.
Merge branch 'USERGRID-273' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into USERGRID-273-indexbuffer


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

Branch: refs/heads/USERGRID-273-indexbuffer
Commit: 2145f21cc54f408a9ca94b1b8ad7ac4b7c6b1ed2
Parents: 6276726 9b846c3
Author: Shawn Feldman <sf...@apache.org>
Authored: Wed Feb 25 10:08:24 2015 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Wed Feb 25 10:08:24 2015 -0700

----------------------------------------------------------------------
 .../corepersistence/CpEntityManagerFactory.java |   7 +-
 .../persistence/EntityManagerFactory.java       |   5 -
 .../PerformanceEntityRebuildIndexTest.java      |  13 +-
 .../cassandra/EntityManagerFactoryImplIT.java   |   5 -
 stack/rest/catalina_base/bin/setenv.sh          |   8 +
 stack/rest/pom.xml                              | 153 +++++----------
 .../org/apache/usergrid/rest/IndexResource.java |  27 +--
 .../usergrid/rest/JobServiceBoostrap.java       |   4 +-
 .../apache/usergrid/rest/ShutdownListener.java  |  73 +++++++
 .../applications/ApplicationsResource.java      |  19 +-
 stack/rest/src/main/webapp/WEB-INF/web.xml      |  13 +-
 .../apache/usergrid/rest/AbstractRestIT.java    |  77 ++++----
 .../java/org/apache/usergrid/rest/BasicIT.java  |  69 ++++---
 .../java/org/apache/usergrid/rest/ITSetup.java  |  57 +-----
 .../org/apache/usergrid/rest/TomcatRuntime.java | 192 +++++++++++++++++++
 .../rest/management/RegistrationIT.java         |   9 +-
 .../test/resource2point0/AbstractRestIT.java    |  77 ++++----
 stack/rest/src/test/resources/arquillian.xml    |  14 +-
 .../resources/usergrid-deployment.properties    | 111 -----------
 19 files changed, 472 insertions(+), 461 deletions(-)
----------------------------------------------------------------------



[05/11] incubator-usergrid git commit: Back off of Arquillian for now.

Posted by sf...@apache.org.
Back off of Arquillian for now.


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

Branch: refs/heads/USERGRID-273-indexbuffer
Commit: 47953555dc5e7f6186e3a0c4bd5d217bdefe66b8
Parents: 99d694b
Author: Dave Johnson <dm...@apigee.com>
Authored: Tue Feb 24 16:34:06 2015 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Tue Feb 24 16:34:06 2015 -0500

----------------------------------------------------------------------
 stack/rest/pom.xml                              | 110 ++++++-------------
 .../apache/usergrid/rest/AbstractRestIT.java    |  32 +++---
 2 files changed, 51 insertions(+), 91 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/47953555/stack/rest/pom.xml
----------------------------------------------------------------------
diff --git a/stack/rest/pom.xml b/stack/rest/pom.xml
index c1c8ea2..70072d9 100644
--- a/stack/rest/pom.xml
+++ b/stack/rest/pom.xml
@@ -41,35 +41,26 @@
     <!-- profile that arquillian uses when it builds/starts tomcat -->
     <profiles>
 
-        <profile>
-            <id>arquillian-tomcat</id>
-
-            <activation>
-                <activeByDefault>true</activeByDefault>
-            </activation>
-
-            <dependencies>
-
-                <dependency>
-                    <groupId>org.jboss.arquillian.container</groupId>
-                    <artifactId>arquillian-tomcat-remote-7</artifactId>
-                    <version>1.0.0.CR7</version>
-                    <scope>test</scope>
-                </dependency>
-
-                <!-- only deploy once during tests -->
-                <dependency>
-                    <groupId>org.eu.ingwar.tools</groupId>
-                    <artifactId>arquillian-suite-extension</artifactId>
-                    <version>1.1.2</version>
-                    <scope>test</scope>
-                </dependency>
-
-            </dependencies>
-
-
-        </profile>
-
+        <!--<profile>-->
+            <!--<id>arquillian-tomcat</id>-->
+            <!--<activation>-->
+                <!--<activeByDefault>true</activeByDefault>-->
+            <!--</activation>-->
+            <!--<dependencies>-->
+                <!--<dependency>-->
+                    <!--<groupId>org.jboss.arquillian.container</groupId>-->
+                    <!--<artifactId>arquillian-tomcat-remote-7</artifactId>-->
+                    <!--<version>1.0.0.CR7</version>-->
+                    <!--<scope>test</scope>-->
+                <!--</dependency>-->
+                <!--<dependency>-->
+                    <!--<groupId>org.eu.ingwar.tools</groupId>-->
+                    <!--<artifactId>arquillian-suite-extension</artifactId>-->
+                    <!--<version>1.1.1</version>-->
+                    <!--<scope>test</scope>-->
+                <!--</dependency>-->
+            <!--</dependencies>-->
+        <!--</profile>-->
 
     </profiles>
 
@@ -377,67 +368,36 @@
 
         <!-- Arquillian deps -->
 
-        <dependency>
-            <groupId>org.codehaus.jackson</groupId>
-            <artifactId>jackson-xc</artifactId>
-            <version>${jackson-version}</version>
-            <scope>test</scope>
-        </dependency>
-
         <!--<dependency>-->
-            <!--<groupId>org.jboss.arquillian.container</groupId>-->
-            <!--<artifactId>arquillian-tomcat-embedded-7</artifactId>-->
-            <!--<version>1.1.7.Final</version>-->
+            <!--<groupId>org.codehaus.jackson</groupId>-->
+            <!--<artifactId>jackson-xc</artifactId>-->
+            <!--<version>${jackson-version}</version>-->
             <!--<scope>test</scope>-->
         <!--</dependency>-->
 
-        <dependency>
-            <groupId>org.jboss.arquillian</groupId>
-            <artifactId>arquillian-bom</artifactId>
-            <version>1.1.7.Final</version>
-            <scope>test</scope>
-            <type>pom</type>
-        </dependency>
-
-        <dependency>
-            <groupId>org.jboss.arquillian.junit</groupId>
-            <artifactId>arquillian-junit-container</artifactId>
-            <version>1.1.7.Final</version>
-            <scope>test</scope>
-        </dependency>
-
-        <!--Some Arquillian dependency runs and old version of Guice.-->
-        <!--We're overridding it here so that we include the right value into the test scope-->
         <!--<dependency>-->
-          <!--<groupId>com.google.inject</groupId>-->
-          <!--<artifactId>guice</artifactId>-->
-          <!--<version>${guice.version}</version>-->
+            <!--<groupId>org.jboss.arquillian</groupId>-->
+            <!--<artifactId>arquillian-bom</artifactId>-->
+            <!--<version>1.1.7.Final</version>-->
             <!--<scope>test</scope>-->
+            <!--<type>pom</type>-->
         <!--</dependency>-->
 
         <!--<dependency>-->
-          <!--<groupId>com.google.inject.extensions</groupId>-->
-          <!--<artifactId>guice-multibindings</artifactId>-->
-          <!--<version>${guice.version}</version>-->
+            <!--<groupId>org.jboss.arquillian.junit</groupId>-->
+            <!--<artifactId>arquillian-junit-container</artifactId>-->
+            <!--<version>1.1.7.Final</version>-->
             <!--<scope>test</scope>-->
         <!--</dependency>-->
 
         <!--<dependency>-->
-          <!--<groupId>com.google.inject.extensions</groupId>-->
-          <!--<artifactId>guice-assistedinject</artifactId>-->
-          <!--<version>${guice.version}</version>-->
-            <!--<scope>test</scope>-->
+              <!--<groupId>org.jboss.shrinkwrap.resolver</groupId>-->
+              <!--<artifactId>shrinkwrap-resolver-depchain</artifactId>-->
+              <!--<version>2.1.1</version>-->
+              <!--<scope>test</scope>-->
+              <!--<type>pom</type>-->
         <!--</dependency>-->
 
-        <!-- documentation here https://github.com/shrinkwrap/resolver -->
-        <dependency>
-              <groupId>org.jboss.shrinkwrap.resolver</groupId>
-              <artifactId>shrinkwrap-resolver-depchain</artifactId>
-              <version>2.1.1</version>
-              <scope>test</scope>
-              <type>pom</type>
-        </dependency>
-
         <!--  use the external test client.  Just depend on the maven jetty plugin to launch jetty -->
         <dependency>
             <groupId>com.sun.jersey.jersey-test-framework</groupId>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/47953555/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
index fab1e55..eb1f628 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/AbstractRestIT.java
@@ -65,8 +65,8 @@ import org.slf4j.LoggerFactory;
  * following naming convention: test_[HTTP verb]_[action mapping]_[ok|fail][_[specific
  * failure condition if multiple]
  */
-@ArquillianSuiteDeployment
-@RunWith(Arquillian.class)
+//@ArquillianSuiteDeployment
+//@RunWith(Arquillian.class)
 public abstract class AbstractRestIT extends JerseyTest {
     private static final Logger LOG = LoggerFactory.getLogger( AbstractRestIT.class );
     private static boolean usersSetup = false;
@@ -104,20 +104,20 @@ public abstract class AbstractRestIT extends JerseyTest {
     }
 
 
-    // We set testable = false so we deploy the archive to the server and test it locally
-    @Deployment( testable = false )
-    public static WebArchive createTestArchive() {
-
-        // we use the MavenImporter from shrinkwrap to just produce whatever maven would build then test with it
-
-        // set maven to be in offline mode
-
-        System.setProperty( "org.apache.maven.offline", "true" );
-        return ShrinkWrap.create(MavenImporter.class)
-            .loadPomFromFile( "pom.xml", "arquillian-tomcat" )
-            .importBuildOutput()
-            .as( WebArchive.class );
-    }
+//    // We set testable = false so we deploy the archive to the server and test it locally
+//    @org.jboss.arquillian.container.test.api.Deployment( testable = false )
+//    public static WebArchive createTestArchive() {
+//
+//        // we use the MavenImporter from shrinkwrap to just produce whatever maven would build then test with it
+//
+//        // set maven to be in offline mode
+//
+//        System.setProperty( "org.apache.maven.offline", "true" );
+//        return ShrinkWrap.create(MavenImporter.class)
+//            .loadPomFromFile( "pom.xml", "arquillian-tomcat" )
+//            .importBuildOutput()
+//            .as( WebArchive.class );
+//    }
 
 
     @AfterClass


[09/11] incubator-usergrid git commit: Removes wait from progress observer, since this is no longer used.

Posted by sf...@apache.org.
Removes wait from progress observer, since this is no longer used.


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

Branch: refs/heads/USERGRID-273-indexbuffer
Commit: d0e3782d75b2127934ab2e3f5f7145c48530e406
Parents: ba7a11a
Author: Todd Nine <tn...@apigee.com>
Authored: Wed Feb 25 09:11:42 2015 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Wed Feb 25 09:11:42 2015 -0700

----------------------------------------------------------------------
 .../corepersistence/CpEntityManagerFactory.java |  7 ++---
 .../persistence/EntityManagerFactory.java       |  5 ----
 .../PerformanceEntityRebuildIndexTest.java      | 13 +++-------
 .../cassandra/EntityManagerFactoryImplIT.java   |  5 ----
 .../org/apache/usergrid/rest/IndexResource.java | 27 +++-----------------
 5 files changed, 9 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d0e3782d/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 ebb3136..3c63bd6 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
@@ -358,12 +358,9 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
         this.rebuildApplicationIndexes(applicationId, new ProgressObserver() {
             @Override
             public void onProgress(EntityRef entity) {
-                logger.debug("Restored entity {}:{}", entity.getType(), entity.getUuid());
-            }
-            @Override
-            public long getWriteDelayTime() {
-                return 0;
+                logger.info("Restored entity {}:{}", entity.getType(), entity.getUuid());
             }
+
         });
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d0e3782d/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
index 2881111..b668e24 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/EntityManagerFactory.java
@@ -176,10 +176,5 @@ public interface EntityManagerFactory {
 
         public void onProgress( EntityRef entity);
 
-        /**
-         * Get the write delay time from the progress observer.  Used to throttle writes
-         * @return
-         */
-        public long getWriteDelayTime();
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d0e3782d/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java b/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
index 4bbce9c..def9ed5 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/PerformanceEntityRebuildIndexTest.java
@@ -202,7 +202,7 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
 
                 meter.mark();
                 logger.debug("Indexing {}:{}", entity.getType(), entity.getUuid());
-                if ( !logger.isDebugEnabled() && counter % 100 == 0 ) {
+                if ( counter % 100 == 0 ) {
                     logger.info("Reindexed {} entities", counter );
                 }
                 counter++;
@@ -210,10 +210,6 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
 
 
 
-            @Override
-            public long getWriteDelayTime() {
-                return 0;
-            }
         };
 
         try {
@@ -347,16 +343,13 @@ public class PerformanceEntityRebuildIndexTest extends AbstractCoreIT {
 
                 meter.mark();
                 logger.debug("Indexing {}:{}", entity.getType(), entity.getUuid());
-                if ( !logger.isDebugEnabled() && counter % 100 == 0 ) {
+                if ( counter % 100 == 0 ) {
                     logger.info("Reindexed {} entities", counter );
                 }
                 counter++;
             }
 
-            @Override
-            public long getWriteDelayTime() {
-                return 0;
-            }
+
         };
 
         try {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d0e3782d/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
index 850ac6b..d224440 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImplIT.java
@@ -160,11 +160,6 @@ public class EntityManagerFactoryImplIT extends AbstractCoreIT {
             public void onProgress(EntityRef entity) {
                 logger.debug("Reindexing {}:{}", entity.getType(), entity.getUuid() );
             }
-
-            @Override
-            public long getWriteDelayTime() {
-                return 0;
-            }
         });
 
         // test to see that app now works and is happy

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/d0e3782d/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 85f27ed..f5338c5 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
@@ -72,11 +72,6 @@ public class IndexResource extends AbstractContextResource {
                 logger.info( "Indexing entity {}:{} ", entity.getType(), entity.getUuid() );
             }
 
-
-            @Override
-            public long getWriteDelayTime() {
-                return 0;
-            }
         };
 
 
@@ -127,10 +122,6 @@ public class IndexResource extends AbstractContextResource {
             }
 
 
-            @Override
-            public long getWriteDelayTime() {
-                return delay;
-            }
         };
 
 
@@ -165,8 +156,7 @@ public class IndexResource extends AbstractContextResource {
         @PathParam( "applicationId" ) final String applicationIdStr,
         @PathParam( "collectionName" ) final String collectionName,
         @QueryParam( "reverse" ) @DefaultValue( "false" ) final Boolean reverse,
-        @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback,
-        @QueryParam( "delay" ) @DefaultValue( "10" ) final long delay ) throws Exception {
+        @QueryParam( "callback" ) @DefaultValue( "callback" ) String callback) throws Exception {
 
         final UUID appId = UUIDUtils.tryExtractUUID( applicationIdStr );
         ApiResponse response = createApiResponse();
@@ -177,7 +167,7 @@ public class IndexResource extends AbstractContextResource {
             public void run() {
 
                 try {
-                    rebuildCollection( appId, collectionName, reverse, delay );
+                    rebuildCollection( appId, collectionName, reverse );
                 } catch (Exception e) {
 
                     // TODO: handle this in rebuildCollection() instead
@@ -216,11 +206,6 @@ public class IndexResource extends AbstractContextResource {
                 logger.info( "Indexing entity {}:{}", entity.getType(), entity.getUuid() );
             }
 
-
-            @Override
-            public long getWriteDelayTime() {
-                return delay;
-            }
         };
 
         final Thread rebuild = new Thread() {
@@ -276,8 +261,7 @@ public class IndexResource extends AbstractContextResource {
     private void rebuildCollection(
         final UUID applicationId,
         final String collectionName,
-        final boolean reverse,
-        final long delay ) throws Exception {
+        final boolean reverse) throws Exception {
 
         EntityManagerFactory.ProgressObserver po = new EntityManagerFactory.ProgressObserver() {
 
@@ -285,10 +269,7 @@ public class IndexResource extends AbstractContextResource {
             public void onProgress( final EntityRef entity ) {
                 logger.info( "Indexing entity {}:{}", entity.getType(), entity.getUuid() );
             }
-            @Override
-            public long getWriteDelayTime() {
-                return delay;
-            }
+
         };
 
         logger.info( "Reindexing for app id: {} and collection {}", applicationId, collectionName );