Sahina Bose has uploaded a new change for review. Change subject: engine: Fixed error where gluster task scheduler thread dies ......................................................................
engine: Fixed error where gluster task scheduler thread dies In case there's any exception in the BLL method the scheduler thread that monitors the gluster tasks dies and further monitoring does not happen Wrapped the call to BLL methods in a separate thread to avoid this. Change-Id: Ia94a2cccece1c0a45c46bbd7cc3e1e58c9aa379f Signed-off-by: Sahina Bose <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterTasksSyncJob.java M backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GlusterTasksSyncJobTest.java 2 files changed, 28 insertions(+), 18 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/89/20089/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterTasksSyncJob.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterTasksSyncJob.java index 94ae211..e128a71 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterTasksSyncJob.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterTasksSyncJob.java @@ -35,6 +35,7 @@ import org.ovirt.engine.core.dao.gluster.GlusterDBUtils; import org.ovirt.engine.core.utils.log.Log; import org.ovirt.engine.core.utils.log.LogFactory; +import org.ovirt.engine.core.utils.threadpool.ThreadPoolUtil; import org.ovirt.engine.core.utils.timer.OnTimerMethodAnnotation; import org.ovirt.engine.core.utils.transaction.TransactionMethod; import org.ovirt.engine.core.utils.transaction.TransactionSupport; @@ -101,20 +102,7 @@ List<Step> steps = getStepDao().getStepsByExternalId(taskId); if (steps == null || steps.isEmpty()) { - // the task may have been started from the CLI - // need to add job to monitor - TransactionSupport.executeInNewTransaction(new TransactionMethod<Void>() { - - @Override - public Void runInTransaction() { - try { - createJobToMonitor(cluster,task); - } catch (VdcBLLException e) { - log.error("Error creating job for task from CLI", e); - } - return null; - } - }); + createJobForTaskFromCLI(cluster, task); } //update status in step table for (Step step: steps) { @@ -138,6 +126,28 @@ return runningTasks; } + private void createJobForTaskFromCLI(final VDSGroup cluster, final GlusterAsyncTask task) { + ThreadPoolUtil.execute(new Runnable() { + @Override + public void run() { + // the task may have been started from the CLI + // need to add job to monitor + TransactionSupport.executeInNewTransaction(new TransactionMethod<Void>() { + + @Override + public Void runInTransaction() { + try { + createJobToMonitor(cluster,task); + } catch (VdcBLLException e) { + log.error("Error creating job for task from CLI", e); + } + return null; + } + }); + } + }); + } + private void createJobToMonitor(VDSGroup cluster, GlusterAsyncTask task) { if (task.getStatus() != JobExecutionStatus.STARTED) { diff --git a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GlusterTasksSyncJobTest.java b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GlusterTasksSyncJobTest.java index 819c517..791b8c3 100644 --- a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GlusterTasksSyncJobTest.java +++ b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GlusterTasksSyncJobTest.java @@ -87,7 +87,9 @@ @ClassRule public static MockConfigRule mcr = new MockConfigRule( mockConfig(ConfigValues.GlusterAysncTasksSupport, Version.v3_2.toString(), false), - mockConfig(ConfigValues.GlusterAysncTasksSupport, Version.v3_3.toString(), true)); + mockConfig(ConfigValues.GlusterAysncTasksSupport, Version.v3_3.toString(), true), + mockConfig(ConfigValues.DefaultMinThreadPoolSize, 10), + mockConfig(ConfigValues.DefaultMaxThreadPoolSize, 20)); @Before public void init() { @@ -138,8 +140,7 @@ tasksSyncJob.updateGlusterAsyncTasks(); Mockito.verify(jobRepository, times(0)).updateStep(any(Step.class)); Mockito.verify(tasksSyncJob, times(0)).endStepJob(any(Step.class)); - Mockito.verify(backend, times(6)).runInternalAction(any(VdcActionType.class), any(VdcActionParametersBase.class)); - } + } @Test public void testCreateTasksStartedFromCLIWithErrors() { @@ -151,7 +152,6 @@ tasksSyncJob.updateGlusterAsyncTasks(); Mockito.verify(jobRepository, times(0)).updateStep(any(Step.class)); Mockito.verify(tasksSyncJob, times(0)).endStepJob(any(Step.class)); - Mockito.verify(backend, times(2)).runInternalAction(any(VdcActionType.class), any(VdcActionParametersBase.class)); } -- To view, visit http://gerrit.ovirt.org/20089 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia94a2cccece1c0a45c46bbd7cc3e1e58c9aa379f Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Sahina Bose <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
