You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2015/02/10 19:45:40 UTC
[1/2] incubator-usergrid git commit: Add job service bootstrap.
Repository: incubator-usergrid
Updated Branches:
refs/heads/two-dot-o-import f3a5b7499 -> c3839c83b
Add job service bootstrap.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/81ebc7b8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/81ebc7b8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/81ebc7b8
Branch: refs/heads/two-dot-o-import
Commit: 81ebc7b811985dd66b673242a7112174791761ab
Parents: 6df5d00
Author: Dave Johnson <dm...@apigee.com>
Authored: Tue Feb 10 13:24:50 2015 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Tue Feb 10 13:24:50 2015 -0500
----------------------------------------------------------------------
.../usergrid/rest/JobServiceBoostrap.java | 75 ++++++++++++++++++++
.../main/resources/usergrid-rest-context.xml | 6 +-
.../management/importer/ImportServiceImpl.java | 9 +--
3 files changed, 80 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/81ebc7b8/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
new file mode 100644
index 0000000..7053c6c
--- /dev/null
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/JobServiceBoostrap.java
@@ -0,0 +1,75 @@
+/*
+ * 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.persistence.EntityManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationListener;
+import org.springframework.context.event.ContextRefreshedEvent;
+
+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";
+
+ @Autowired
+ private JobSchedulerService schedulerService;
+
+ @Autowired
+ private Properties properties;
+
+ @Autowired
+ EntityManager em;
+
+ public JobServiceBoostrap() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.springframework.context.ApplicationListener#onApplicationEvent(org
+ * .springframework.context.ApplicationEvent)
+ */
+ @Override
+ public void onApplicationEvent( ContextRefreshedEvent event ) {
+ String start = properties.getProperty( START_SCHEDULER_PROP, "true" );
+ if ( Boolean.parseBoolean( start ) ) {
+ logger.info( "Starting Scheduler Service..." );
+ // start the scheduler service
+ schedulerService.startAsync();
+ schedulerService.awaitRunning();
+
+ } else {
+ logger.info( "Scheduler Service disabled" );
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/81ebc7b8/stack/rest/src/main/resources/usergrid-rest-context.xml
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/resources/usergrid-rest-context.xml b/stack/rest/src/main/resources/usergrid-rest-context.xml
index 8722823..5c63e72 100644
--- a/stack/rest/src/main/resources/usergrid-rest-context.xml
+++ b/stack/rest/src/main/resources/usergrid-rest-context.xml
@@ -24,7 +24,7 @@
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<import resource="classpath:/usergrid-services-context.xml" />
-
+
<context:component-scan base-package="org.apache.usergrid.rest" />
@@ -56,7 +56,9 @@
<property name="realm" ref="realm" />
</bean>
- <bean id="cacheManager" class="org.apache.shiro.cache.MemoryConstrainedCacheManager" />
+ <bean id="cacheManager" class="org.apache.shiro.cache.MemoryConstrainedCacheManager" />
+
+ <bean id="jobServiceBootstrap" class="org.apache.usergrid.rest.JobServiceBoostrap" />
<!-- override the task executor -->
<bean id="taskExecutor"
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/81ebc7b8/stack/services/src/main/java/org/apache/usergrid/management/importer/ImportServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/importer/ImportServiceImpl.java b/stack/services/src/main/java/org/apache/usergrid/management/importer/ImportServiceImpl.java
index 1f93ded..448edb7 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/importer/ImportServiceImpl.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/importer/ImportServiceImpl.java
@@ -21,7 +21,6 @@ import com.amazonaws.SDKGlobalConfiguration;
import org.apache.commons.lang.RandomStringUtils;
import org.apache.usergrid.batch.JobExecution;
import org.apache.usergrid.batch.service.SchedulerService;
-import org.apache.usergrid.corepersistence.CpSetup;
import org.apache.usergrid.corepersistence.util.CpNamingUtils;
import org.apache.usergrid.management.ManagementService;
import org.apache.usergrid.persistence.*;
@@ -30,12 +29,6 @@ import org.apache.usergrid.persistence.entities.Import;
import org.apache.usergrid.persistence.entities.JobData;
import org.apache.usergrid.persistence.index.query.Query;
import org.apache.usergrid.persistence.index.query.Query.Level;
-import org.apache.usergrid.persistence.queue.QueueManager;
-import org.apache.usergrid.persistence.queue.QueueManagerFactory;
-import org.apache.usergrid.persistence.queue.QueueScope;
-import org.apache.usergrid.persistence.queue.QueueScopeFactory;
-import org.apache.usergrid.services.ServiceManagerFactory;
-import org.apache.usergrid.services.queues.ImportQueueListener;
import org.apache.usergrid.services.queues.ImportQueueMessage;
import org.apache.usergrid.utils.InflectionUtils;
import org.codehaus.jackson.JsonFactory;
@@ -81,7 +74,7 @@ public class ImportServiceImpl implements ImportService {
public void init(){
}
-
+
/**
* This schedules the main import Job.
*
[2/2] incubator-usergrid git commit: Merge branch 'two-dot-o-import'
of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into
two-dot-o-import
Posted by sn...@apache.org.
Merge branch 'two-dot-o-import' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into two-dot-o-import
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/c3839c83
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/c3839c83
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/c3839c83
Branch: refs/heads/two-dot-o-import
Commit: c3839c83b0f146714f1f641afd55b97d1a7535a0
Parents: 81ebc7b f3a5b74
Author: Dave Johnson <dm...@apigee.com>
Authored: Tue Feb 10 13:45:22 2015 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Tue Feb 10 13:45:22 2015 -0500
----------------------------------------------------------------------
.../persistence/EntityConnectionsIT.java | 121 +++++++++++++++++--
1 file changed, 111 insertions(+), 10 deletions(-)
----------------------------------------------------------------------