Michael Kublin has uploaded a new change for review.

Change subject: engine: Replacing use of Quartz scheduler by ThreadPool during 
SPM election
......................................................................

engine: Replacing use of Quartz scheduler by ThreadPool during SPM election

The following patch will use a thread pool util instead of quartz scheduler for
running imediate job.

Change-Id: Ice54e028545ea6772528c9ab30abc7ff5c5276c7
Signed-off-by: Michael Kublin <[email protected]>
---
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/irsbroker/IrsBrokerCommand.java
1 file changed, 26 insertions(+), 20 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/47/11647/1

diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/irsbroker/IrsBrokerCommand.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/irsbroker/IrsBrokerCommand.java
index 3e44df5..e745c11 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/irsbroker/IrsBrokerCommand.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/irsbroker/IrsBrokerCommand.java
@@ -67,6 +67,7 @@
 import org.ovirt.engine.core.utils.log.Logged;
 import org.ovirt.engine.core.utils.log.Logged.LogLevel;
 import org.ovirt.engine.core.utils.log.LoggedUtils;
+import org.ovirt.engine.core.utils.threadpool.ThreadPoolUtil;
 import org.ovirt.engine.core.utils.timer.OnTimerMethodAnnotation;
 import org.ovirt.engine.core.utils.timer.SchedulerUtilQuartzImpl;
 import org.ovirt.engine.core.utils.transaction.TransactionMethod;
@@ -503,15 +504,17 @@
 
         public IIrsServer getIrsProxy() {
             if (getmIrsProxy() == null) {
-                storage_pool storagePool = 
DbFacade.getInstance().getStoragePoolDao().get(_storagePoolId);
+                final storage_pool storagePool = 
DbFacade.getInstance().getStoragePoolDao().get(_storagePoolId);
                 // don't try to start spm on uninitialized pool
                 if (storagePool.getstatus() != 
StoragePoolStatus.Uninitialized) {
-                    String host = 
TransactionSupport.executeInScope(TransactionScopeOption.Suppress, new 
TransactionMethod<String>() {
-                        @Override
-                        public String runInTransaction() {
-                            return gethostFromVds();
-                        }
-                    });
+                    String host =
+                            
TransactionSupport.executeInScope(TransactionScopeOption.Suppress,
+                                    new TransactionMethod<String>() {
+                                        @Override
+                                        public String runInTransaction() {
+                                            return gethostFromVds();
+                                        }
+                                    });
 
                     if (host != null) {
                         int clientTimeOut = Config.<Integer> 
GetValue(ConfigValues.vdsTimeout) * 1000;
@@ -522,26 +525,29 @@
                                         IrsServerConnector.class,
                                         Config.<Boolean> 
GetValue(ConfigValues.UseSecureConnectionWithServers));
                         privatemIrsProxy = new 
IrsServerWrapper(returnValue.getFirst(), returnValue.getSecond());
-                        Class[] inputTypes = new Class[] { storage_pool.class, 
boolean.class };
-                        Object[] inputParams = new Object[] { storagePool, 
_isSpmStartCalled };
-                        // TODO use thread pool
-                        
SchedulerUtilQuartzImpl.getInstance().scheduleAOneTimeJob(this, 
"StorageEventOnTimer",
-                                inputTypes, inputParams, 0, 
TimeUnit.MILLISECONDS);
+                        runStoragePoolUpEvent(storagePool);
                     }
                 }
             }
             return getmIrsProxy();
         }
 
-        @OnTimerMethodAnnotation("StorageEventOnTimer")
-        public void StorageEventOnTimer(storage_pool storagePool, boolean 
_isSpmStartCalled) {
-            try {
-                if 
(DbFacade.getInstance().IsStoragePoolMasterUp(_storagePoolId)) {
-                    
ResourceManager.getInstance().getEventListener().storagePoolUpEvent(storagePool,
 _isSpmStartCalled);
+        private void runStoragePoolUpEvent(final storage_pool storagePool) {
+            ThreadPoolUtil.execute(new Runnable() {
+                @Override
+                public void run() {
+                    try {
+                        if 
(DbFacade.getInstance().IsStoragePoolMasterUp(_storagePoolId)) {
+                            ResourceManager.getInstance()
+                                    .getEventListener()
+                                    .storagePoolUpEvent(storagePool, 
_isSpmStartCalled);
+                        }
+                    } catch (RuntimeException exp) {
+                        log.error("Error in StoragePoolUpEvent - ", exp);
+                    }
+
                 }
-            } catch (RuntimeException exp) {
-                log.error("Error in StoragePoolUpEvent - ", exp);
-            }
+            });
         }
 
         /**


--
To view, visit http://gerrit.ovirt.org/11647
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ice54e028545ea6772528c9ab30abc7ff5c5276c7
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Michael Kublin <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to