Yair Zaslavsky has uploaded a new change for review. Change subject: [WIP] core: changes to scheduler module ......................................................................
[WIP] core: changes to scheduler module 1. Moved all the scheduler code to utils 2. Changed The shceudler to be a non EJB singletone (in the future this will be CDI bean) Change-Id: Iaf02ee983d0d27ea580c0d0d3ae05e466d8c7051 Signed-off-by: Yair Zaslavsky <[email protected]> --- M backend/manager/modules/bll/pom.xml M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AsyncTaskManager.java M backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/BackwardCompatibilityTaskCreationTest.java M backend/manager/modules/pom.xml D backend/manager/modules/scheduler/exclude-filters.xml D backend/manager/modules/scheduler/pom.xml M backend/manager/modules/utils/pom.xml M backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ejb/BeanType.java M backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ejb/EngineEJBUtilsStrategy.java R backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/timer/FixedDelayJobListener.java R backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/timer/JobWrapper.java R backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/timer/OnTimerMethodAnnotation.java R backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/timer/SchedulerUtil.java R backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/timer/SchedulerUtilQuartzImpl.java M backend/manager/modules/utils/src/main/modules/org/ovirt/engine/core/utils/main/module.xml R backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/timer/SchedulerUtilQuartsImplTest.java M backend/manager/modules/vdsbroker/pom.xml M ovirt-engine.spec.in 18 files changed, 22 insertions(+), 168 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/23/25323/1 diff --git a/backend/manager/modules/bll/pom.xml b/backend/manager/modules/bll/pom.xml index 1f00ecd..2a832e8 100644 --- a/backend/manager/modules/bll/pom.xml +++ b/backend/manager/modules/bll/pom.xml @@ -73,14 +73,6 @@ </dependency> <dependency> - <groupId>${engine.groupId}</groupId> - <artifactId>scheduler</artifactId> - <version>${engine.version}</version> - <scope>provided</scope> - <type>ejb</type> - </dependency> - - <dependency> <groupId>com.woorea</groupId> <artifactId>keystone-client</artifactId> <version>${openstack-client.version}</version> diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AsyncTaskManager.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AsyncTaskManager.java index 5bdde5f..b9a2659 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AsyncTaskManager.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AsyncTaskManager.java @@ -60,7 +60,7 @@ private boolean logChangedMap = true; /** The period of time (in minutes) to hold the asynchronous tasks' statuses in the asynchronous tasks cache **/ - private final int _cacheTimeInMinutes; + private int _cacheTimeInMinutes; /**Map of tasks in DB per storage pool that exist after restart **/ private ConcurrentMap<Guid, List<AsyncTasks>> tasksInDbAfterRestart = null; @@ -79,6 +79,9 @@ } private AsyncTaskManager() { + } + + public void initAsyncTaskManager() { _tasks = new ConcurrentHashMap<Guid, SPMAsyncTask>(); SchedulerUtil scheduler = SchedulerUtilQuartzImpl.getInstance(); @@ -90,9 +93,8 @@ new Object[]{}, Config.<Integer>getValue(ConfigValues.AsyncTaskStatusCacheRefreshRateInSeconds), Config.<Integer>getValue(ConfigValues.AsyncTaskStatusCacheRefreshRateInSeconds), TimeUnit.SECONDS); _cacheTimeInMinutes = Config.<Integer>getValue(ConfigValues.AsyncTaskStatusCachingTimeInMinutes); - } - public void initAsyncTaskManager() { + tasksInDbAfterRestart = new ConcurrentHashMap(); Map<Guid, List<AsyncTasks>> rootCommandIdToTasksMap = groupTasksByRootCommandId(DbFacade.getInstance().getAsyncTaskDao().getAll()); int numberOfCommandsWithEmptyVdsmId = 0; diff --git a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/BackwardCompatibilityTaskCreationTest.java b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/BackwardCompatibilityTaskCreationTest.java index df652ac..215349e 100644 --- a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/BackwardCompatibilityTaskCreationTest.java +++ b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/BackwardCompatibilityTaskCreationTest.java @@ -5,7 +5,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; -import static org.ovirt.engine.core.utils.MockConfigRule.mockConfig; import java.sql.Connection; import java.util.Collections; @@ -38,18 +37,14 @@ import org.ovirt.engine.core.common.businessentities.AsyncTaskResultEnum; import org.ovirt.engine.core.common.businessentities.AsyncTaskStatusEnum; import org.ovirt.engine.core.common.businessentities.VM; -import org.ovirt.engine.core.common.config.ConfigValues; import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.dal.dbbroker.DbFacade; import org.ovirt.engine.core.dal.dbbroker.DbFacadeLocator; import org.ovirt.engine.core.dao.AsyncTaskDAO; -import org.ovirt.engine.core.utils.MockConfigRule; import org.ovirt.engine.core.utils.MockEJBStrategyRule; import org.ovirt.engine.core.utils.RandomUtils; import org.ovirt.engine.core.utils.RandomUtilsSeedingRule; -import org.ovirt.engine.core.utils.ejb.BeanType; import org.ovirt.engine.core.utils.ejb.ContainerManagedResourceType; -import org.ovirt.engine.core.utils.timer.SchedulerUtil; /** * A test for task creation in the various commands. @@ -62,14 +57,7 @@ public static final RandomUtilsSeedingRule rusr = new RandomUtilsSeedingRule(); @ClassRule - public static final MockConfigRule mcr = new MockConfigRule( - mockConfig(ConfigValues.AsyncTaskPollingRate, 10), - mockConfig(ConfigValues.AsyncTaskStatusCacheRefreshRateInSeconds, 10), - mockConfig(ConfigValues.AsyncTaskStatusCachingTimeInMinutes, 10) - ); - - @ClassRule - public static MockEJBStrategyRule ejbRule = new MockEJBStrategyRule(BeanType.SCHEDULER, mock(SchedulerUtil.class)); + public static MockEJBStrategyRule ejbRule = new MockEJBStrategyRule(); @BeforeClass public static void beforeClass() { diff --git a/backend/manager/modules/pom.xml b/backend/manager/modules/pom.xml index 7c66b9f..3d6471e 100644 --- a/backend/manager/modules/pom.xml +++ b/backend/manager/modules/pom.xml @@ -20,7 +20,6 @@ <module>common</module> <module>dal</module> <module>vdsbroker</module> - <module>scheduler</module> <module>searchbackend</module> <module>bll</module> <module>restapi</module> diff --git a/backend/manager/modules/scheduler/exclude-filters.xml b/backend/manager/modules/scheduler/exclude-filters.xml deleted file mode 100644 index 43bc332..0000000 --- a/backend/manager/modules/scheduler/exclude-filters.xml +++ /dev/null @@ -1,2 +0,0 @@ -<FindBugsFilter> -</FindBugsFilter> diff --git a/backend/manager/modules/scheduler/pom.xml b/backend/manager/modules/scheduler/pom.xml deleted file mode 100644 index 85a840d..0000000 --- a/backend/manager/modules/scheduler/pom.xml +++ /dev/null @@ -1,105 +0,0 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.ovirt.engine.core</groupId> - <artifactId>manager-modules</artifactId> - <version>3.5.0-SNAPSHOT</version> - </parent> - - <artifactId>scheduler</artifactId> - <packaging>ejb</packaging> - - <name>engine scheduler bean</name> - - <dependencies> - <dependency> - <groupId>${engine.groupId}</groupId> - <artifactId>utils</artifactId> - <version>${engine.version}</version> - </dependency> - - <!-- external dependencies --> - <dependency> - <groupId>org.jboss.spec.javax.ejb</groupId> - <artifactId>jboss-ejb-api_3.1_spec</artifactId> - </dependency> - - <dependency> - <groupId>org.quartz-scheduler</groupId> - <artifactId>quartz</artifactId> - </dependency> - </dependencies> - - <build> - <plugins> - <plugin> - <artifactId>maven-surefire-plugin</artifactId> - <configuration> - <additionalClasspathElements> - <additionalClasspathElement>${basedir}/src/test/java</additionalClasspathElement> - </additionalClasspathElements> - </configuration> - </plugin> - <plugin> - <artifactId>maven-ejb-plugin</artifactId> - <configuration> - <ejbVersion>3.1</ejbVersion> - <generateClient>true</generateClient> - <archive> - <manifest> - <addClasspath>false</addClasspath> - </manifest> - <manifestEntries> - <Dependencies>org.slf4j</Dependencies> - </manifestEntries> - </archive> - </configuration> - </plugin> - </plugins> - </build> - - <profiles> - <profile> - <id>findbugs</id> - <activation> - <activeByDefault>true</activeByDefault> - </activation> - <build> - <plugins> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>findbugs-maven-plugin</artifactId> - <version>${findbugs.version}</version> - <configuration> - <xmlOutput>true</xmlOutput> - <!-- Optional directory to put findbugs xdoc xml report --> - <excludeFilterFile> ${basedir}/exclude-filters.xml</excludeFilterFile> - <xmlOutputDirectory>target/site</xmlOutputDirectory> - </configuration> - </plugin> - </plugins> - </build> - </profile> - - <profile> - <id>findbugs-general</id> - <build> - <plugins> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>findbugs-maven-plugin</artifactId> - <version>${findbugs.version}</version> - <configuration> - <xmlOutput>true</xmlOutput> - <!-- Optional directory to put findbugs xdoc xml report --> - <excludeFilterFile> ${basedir}/exclude-filters.xml, ${basedir}/../../../../exclude-filters-general.xml</excludeFilterFile> - <xmlOutputDirectory>target/site</xmlOutputDirectory> - </configuration> - </plugin> - </plugins> - </build> - </profile> - </profiles> - -</project> diff --git a/backend/manager/modules/utils/pom.xml b/backend/manager/modules/utils/pom.xml index daf3b1c..59d9c79 100644 --- a/backend/manager/modules/utils/pom.xml +++ b/backend/manager/modules/utils/pom.xml @@ -153,6 +153,12 @@ <artifactId>glance-client</artifactId> <version>${openstack-client.version}</version> </dependency> + + <dependency> + <groupId>org.quartz-scheduler</groupId> + <artifactId>quartz</artifactId> + </dependency> + </dependencies> diff --git a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ejb/BeanType.java b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ejb/BeanType.java index 1186080..8542db9 100644 --- a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ejb/BeanType.java +++ b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ejb/BeanType.java @@ -7,7 +7,6 @@ */ public enum BeanType { BACKEND, // Backend bean - SCHEDULER, // SchedulerUtil USERS_DOMAINS_CACHE, VDS_EVENT_LISTENER, LOCK_MANAGER, diff --git a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ejb/EngineEJBUtilsStrategy.java b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ejb/EngineEJBUtilsStrategy.java index 4c37350..1db7598 100644 --- a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ejb/EngineEJBUtilsStrategy.java +++ b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ejb/EngineEJBUtilsStrategy.java @@ -14,7 +14,6 @@ @Override protected void addJNDIBeans() { addBeanJNDIName(BeanType.BACKEND, ENGINE_CONTEXT_PREFIX.concat("bll/Backend")); - addBeanJNDIName(BeanType.SCHEDULER, ENGINE_CONTEXT_PREFIX.concat("scheduler/Scheduler")); addBeanJNDIName(BeanType.USERS_DOMAINS_CACHE, ENGINE_CONTEXT_PREFIX.concat("bll/UsersDomainsCacheManagerService")); addBeanJNDIName(BeanType.VDS_EVENT_LISTENER, ENGINE_CONTEXT_PREFIX.concat("bll/VdsEventListener")); diff --git a/backend/manager/modules/scheduler/src/main/java/org/ovirt/engine/core/utils/timer/FixedDelayJobListener.java b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/timer/FixedDelayJobListener.java similarity index 100% rename from backend/manager/modules/scheduler/src/main/java/org/ovirt/engine/core/utils/timer/FixedDelayJobListener.java rename to backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/timer/FixedDelayJobListener.java diff --git a/backend/manager/modules/scheduler/src/main/java/org/ovirt/engine/core/utils/timer/JobWrapper.java b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/timer/JobWrapper.java similarity index 100% rename from backend/manager/modules/scheduler/src/main/java/org/ovirt/engine/core/utils/timer/JobWrapper.java rename to backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/timer/JobWrapper.java diff --git a/backend/manager/modules/scheduler/src/main/java/org/ovirt/engine/core/utils/timer/OnTimerMethodAnnotation.java b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/timer/OnTimerMethodAnnotation.java similarity index 100% rename from backend/manager/modules/scheduler/src/main/java/org/ovirt/engine/core/utils/timer/OnTimerMethodAnnotation.java rename to backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/timer/OnTimerMethodAnnotation.java diff --git a/backend/manager/modules/scheduler/src/main/java/org/ovirt/engine/core/utils/timer/SchedulerUtil.java b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/timer/SchedulerUtil.java similarity index 100% rename from backend/manager/modules/scheduler/src/main/java/org/ovirt/engine/core/utils/timer/SchedulerUtil.java rename to backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/timer/SchedulerUtil.java diff --git a/backend/manager/modules/scheduler/src/main/java/org/ovirt/engine/core/utils/timer/SchedulerUtilQuartzImpl.java b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/timer/SchedulerUtilQuartzImpl.java similarity index 92% rename from backend/manager/modules/scheduler/src/main/java/org/ovirt/engine/core/utils/timer/SchedulerUtilQuartzImpl.java rename to backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/timer/SchedulerUtilQuartzImpl.java index c77bae8..155e84a 100644 --- a/backend/manager/modules/scheduler/src/main/java/org/ovirt/engine/core/utils/timer/SchedulerUtilQuartzImpl.java +++ b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/timer/SchedulerUtilQuartzImpl.java @@ -14,21 +14,11 @@ import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; -import javax.ejb.ConcurrencyManagement; -import javax.ejb.ConcurrencyManagementType; -import javax.ejb.DependsOn; -import javax.ejb.Singleton; -import javax.ejb.Startup; -import javax.ejb.TransactionAttribute; -import javax.ejb.TransactionAttributeType; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.ovirt.engine.core.common.config.Config; import org.ovirt.engine.core.common.config.ConfigValues; -import org.ovirt.engine.core.utils.ejb.BeanProxyType; -import org.ovirt.engine.core.utils.ejb.BeanType; -import org.ovirt.engine.core.utils.ejb.EjbUtils; import org.quartz.JobDataMap; import org.quartz.JobDetail; import org.quartz.Scheduler; @@ -38,17 +28,6 @@ import org.quartz.TriggerKey; import org.quartz.impl.StdSchedulerFactory; -// Here we use a Singleton bean, names Scheduler. -// The @Startup annotation is to make sure the bean is initialized on startup. -// @ConcurrencyManagement - we use bean managed concurrency: -// Singletons that use bean-managed concurrency allow full concurrent access to all the -// business and timeout methods in the singleton. -// The developer of the singleton is responsible for ensuring that the state of the singleton is synchronized across all clients. -@Singleton(name = "Scheduler") -@DependsOn("LockManager") -@Startup -@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) -@ConcurrencyManagement(ConcurrencyManagementType.BEAN) public class SchedulerUtilQuartzImpl implements SchedulerUtil { // consts @@ -66,6 +45,7 @@ private Scheduler sched; private final AtomicLong sequenceNumber = new AtomicLong(Long.MIN_VALUE); + private static volatile SchedulerUtil instance = null; /** * This method is called upon the bean creation as part @@ -107,7 +87,14 @@ * @return a SchedulerUtil instance */ public static SchedulerUtil getInstance() { - return EjbUtils.findBean(BeanType.SCHEDULER, BeanProxyType.LOCAL); + if (instance == null) { + synchronized (SchedulerUtil.class) { + if (instance == null) { + instance = new SchedulerUtilQuartzImpl(); + } + } + } + return instance; } /** diff --git a/backend/manager/modules/utils/src/main/modules/org/ovirt/engine/core/utils/main/module.xml b/backend/manager/modules/utils/src/main/modules/org/ovirt/engine/core/utils/main/module.xml index b78493f..d50146c 100644 --- a/backend/manager/modules/utils/src/main/modules/org/ovirt/engine/core/utils/main/module.xml +++ b/backend/manager/modules/utils/src/main/modules/org/ovirt/engine/core/utils/main/module.xml @@ -27,6 +27,7 @@ <module name="org.ovirt.engine.core.dal"/> <module name="org.infinispan"/> <module name="org.springframework"/> + <module name="org.quartz"/> </dependencies> </module> diff --git a/backend/manager/modules/scheduler/src/test/java/org/ovirt/engine/core/utils/timer/SchedulerUtilQuartsImplTest.java b/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/timer/SchedulerUtilQuartsImplTest.java similarity index 100% rename from backend/manager/modules/scheduler/src/test/java/org/ovirt/engine/core/utils/timer/SchedulerUtilQuartsImplTest.java rename to backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/timer/SchedulerUtilQuartsImplTest.java diff --git a/backend/manager/modules/vdsbroker/pom.xml b/backend/manager/modules/vdsbroker/pom.xml index 29bf103..b86721b 100644 --- a/backend/manager/modules/vdsbroker/pom.xml +++ b/backend/manager/modules/vdsbroker/pom.xml @@ -36,15 +36,6 @@ <artifactId>dal</artifactId> <version>${engine.version}</version> </dependency> - - <dependency> - <groupId>${engine.groupId}</groupId> - <artifactId>scheduler</artifactId> - <version>${engine.version}</version> - <scope>provided</scope> - <type>ejb</type> - </dependency> - <dependency> <groupId>${engine.groupId}</groupId> <artifactId>utils</artifactId> diff --git a/ovirt-engine.spec.in b/ovirt-engine.spec.in index c0dc2f4..77c1eae 100644 --- a/ovirt-engine.spec.in +++ b/ovirt-engine.spec.in @@ -824,13 +824,11 @@ %{engine_ear}/docs.war/ %{engine_ear}/lib %{engine_ear}/root.war/ -%{engine_ear}/scheduler.jar %{engine_ear}/services.war/ %{engine_ear}/welcome.war/ %{engine_etc}/osinfo.conf.d/ %{engine_java}/bll.jar %{engine_java}/dal.jar -%{engine_java}/scheduler.jar %{engine_java}/searchbackend.jar %{engine_java}/vdsbroker.jar %{engine_jboss_modules}/ @@ -850,7 +848,6 @@ %{_mavenpomdir}/JPP.%{name}-tools.pom %{_mavenpomdir}/JPP.%{name}-bll.pom %{_mavenpomdir}/JPP.%{name}-dal.pom -%{_mavenpomdir}/JPP.%{name}-scheduler.pom %{_mavenpomdir}/JPP.%{name}-searchbackend.pom %{_mavenpomdir}/JPP.%{name}-vdsbroker.pom %endif -- To view, visit http://gerrit.ovirt.org/25323 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iaf02ee983d0d27ea580c0d0d3ae05e466d8c7051 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Yair Zaslavsky <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
