@Test public void testStartDeleteDAJob_WithoutUnlockObjectMetaTask_ExpectsSuccess() throws Exception { this.deleteDistributedApplianceService.startDeleteDAJob(VALID_DA, null); PowerMockito.verifyStatic(Mockito.times(1)); LockUtil.tryLockDA(VALID_DA, null); }
Job startDeleteDAJob(final DistributedAppliance da, UnlockObjectMetaTask ult) throws Exception { try { if (ult == null) { ult = LockUtil.tryLockDA(da, da.getApplianceManagerConnector()); } Job job; TaskGraph tg = new TaskGraph(); for (VirtualSystem vs : da.getVirtualSystems()) { TaskGraph vsDeleteTaskGraph = new TaskGraph(); vsDeleteTaskGraph.appendTask(this.vsConformanceCheckMetaTask.create(vs)); tg.addTaskGraph(vsDeleteTaskGraph); } tg.appendTask(this.deleteDAFromDbTask.create(da), TaskGuard.ALL_ANCESTORS_SUCCEEDED); tg.appendTask(ult, TaskGuard.ALL_PREDECESSORS_COMPLETED); log.info("Start Submitting Delete DA Job"); job = JobEngine.getEngine().submit("Delete Distributed Appliance '" + da.getName() + "'", tg, LockObjectReference.getObjectReferences(da), new JobCompletionListener() { @Override public void completed(Job job) { if (!job.getStatus().getStatus().isSuccessful()) { try { DeleteDistributedApplianceService.this.dbConnectionManager.getTransactionControl().required(() -> new CompleteJobTransaction<DistributedAppliance>(DistributedAppliance.class, DeleteDistributedApplianceService.this.txBroadcastUtil) .run(DeleteDistributedApplianceService.this.dbConnectionManager.getTransactionalEntityManager(), new CompleteJobTransactionInput(da.getId(), job.getId()))); } catch (Exception e) { log.error("A serious error occurred in the Job Listener", e); throw new RuntimeException("No Transactional resources are available", e); } } } }); log.info("Done submitting with jobId: " + job.getId()); return job; } catch (Exception e) { LockUtil.releaseLocks(ult); throw e; } }
DeleteDistributedApplianceService extends ServiceDispatcher<BaseDeleteRequest, BaseJobResponse> implements DeleteDistributedApplianceServiceApi { Job startDeleteDAJob(final DistributedAppliance da, UnlockObjectMetaTask ult) throws Exception { try { if (ult == null) { ult = LockUtil.tryLockDA(da, da.getApplianceManagerConnector()); } Job job; TaskGraph tg = new TaskGraph(); for (VirtualSystem vs : da.getVirtualSystems()) { TaskGraph vsDeleteTaskGraph = new TaskGraph(); vsDeleteTaskGraph.appendTask(this.vsConformanceCheckMetaTask.create(vs)); tg.addTaskGraph(vsDeleteTaskGraph); } tg.appendTask(this.deleteDAFromDbTask.create(da), TaskGuard.ALL_ANCESTORS_SUCCEEDED); tg.appendTask(ult, TaskGuard.ALL_PREDECESSORS_COMPLETED); log.info("Start Submitting Delete DA Job"); job = JobEngine.getEngine().submit("Delete Distributed Appliance '" + da.getName() + "'", tg, LockObjectReference.getObjectReferences(da), new JobCompletionListener() { @Override public void completed(Job job) { if (!job.getStatus().getStatus().isSuccessful()) { try { DeleteDistributedApplianceService.this.dbConnectionManager.getTransactionControl().required(() -> new CompleteJobTransaction<DistributedAppliance>(DistributedAppliance.class, DeleteDistributedApplianceService.this.txBroadcastUtil) .run(DeleteDistributedApplianceService.this.dbConnectionManager.getTransactionalEntityManager(), new CompleteJobTransactionInput(da.getId(), job.getId()))); } catch (Exception e) { log.error("A serious error occurred in the Job Listener", e); throw new RuntimeException("No Transactional resources are available", e); } } } }); log.info("Done submitting with jobId: " + job.getId()); return job; } catch (Exception e) { LockUtil.releaseLocks(ult); throw e; } } }
DeleteDistributedApplianceService extends ServiceDispatcher<BaseDeleteRequest, BaseJobResponse> implements DeleteDistributedApplianceServiceApi { Job startDeleteDAJob(final DistributedAppliance da, UnlockObjectMetaTask ult) throws Exception { try { if (ult == null) { ult = LockUtil.tryLockDA(da, da.getApplianceManagerConnector()); } Job job; TaskGraph tg = new TaskGraph(); for (VirtualSystem vs : da.getVirtualSystems()) { TaskGraph vsDeleteTaskGraph = new TaskGraph(); vsDeleteTaskGraph.appendTask(this.vsConformanceCheckMetaTask.create(vs)); tg.addTaskGraph(vsDeleteTaskGraph); } tg.appendTask(this.deleteDAFromDbTask.create(da), TaskGuard.ALL_ANCESTORS_SUCCEEDED); tg.appendTask(ult, TaskGuard.ALL_PREDECESSORS_COMPLETED); log.info("Start Submitting Delete DA Job"); job = JobEngine.getEngine().submit("Delete Distributed Appliance '" + da.getName() + "'", tg, LockObjectReference.getObjectReferences(da), new JobCompletionListener() { @Override public void completed(Job job) { if (!job.getStatus().getStatus().isSuccessful()) { try { DeleteDistributedApplianceService.this.dbConnectionManager.getTransactionControl().required(() -> new CompleteJobTransaction<DistributedAppliance>(DistributedAppliance.class, DeleteDistributedApplianceService.this.txBroadcastUtil) .run(DeleteDistributedApplianceService.this.dbConnectionManager.getTransactionalEntityManager(), new CompleteJobTransactionInput(da.getId(), job.getId()))); } catch (Exception e) { log.error("A serious error occurred in the Job Listener", e); throw new RuntimeException("No Transactional resources are available", e); } } } }); log.info("Done submitting with jobId: " + job.getId()); return job; } catch (Exception e) { LockUtil.releaseLocks(ult); throw e; } }  }
DeleteDistributedApplianceService extends ServiceDispatcher<BaseDeleteRequest, BaseJobResponse> implements DeleteDistributedApplianceServiceApi { Job startDeleteDAJob(final DistributedAppliance da, UnlockObjectMetaTask ult) throws Exception { try { if (ult == null) { ult = LockUtil.tryLockDA(da, da.getApplianceManagerConnector()); } Job job; TaskGraph tg = new TaskGraph(); for (VirtualSystem vs : da.getVirtualSystems()) { TaskGraph vsDeleteTaskGraph = new TaskGraph(); vsDeleteTaskGraph.appendTask(this.vsConformanceCheckMetaTask.create(vs)); tg.addTaskGraph(vsDeleteTaskGraph); } tg.appendTask(this.deleteDAFromDbTask.create(da), TaskGuard.ALL_ANCESTORS_SUCCEEDED); tg.appendTask(ult, TaskGuard.ALL_PREDECESSORS_COMPLETED); log.info("Start Submitting Delete DA Job"); job = JobEngine.getEngine().submit("Delete Distributed Appliance '" + da.getName() + "'", tg, LockObjectReference.getObjectReferences(da), new JobCompletionListener() { @Override public void completed(Job job) { if (!job.getStatus().getStatus().isSuccessful()) { try { DeleteDistributedApplianceService.this.dbConnectionManager.getTransactionControl().required(() -> new CompleteJobTransaction<DistributedAppliance>(DistributedAppliance.class, DeleteDistributedApplianceService.this.txBroadcastUtil) .run(DeleteDistributedApplianceService.this.dbConnectionManager.getTransactionalEntityManager(), new CompleteJobTransactionInput(da.getId(), job.getId()))); } catch (Exception e) { log.error("A serious error occurred in the Job Listener", e); throw new RuntimeException("No Transactional resources are available", e); } } } }); log.info("Done submitting with jobId: " + job.getId()); return job; } catch (Exception e) { LockUtil.releaseLocks(ult); throw e; } }  @Override BaseJobResponse exec(BaseDeleteRequest request, EntityManager em); }
DeleteDistributedApplianceService extends ServiceDispatcher<BaseDeleteRequest, BaseJobResponse> implements DeleteDistributedApplianceServiceApi { Job startDeleteDAJob(final DistributedAppliance da, UnlockObjectMetaTask ult) throws Exception { try { if (ult == null) { ult = LockUtil.tryLockDA(da, da.getApplianceManagerConnector()); } Job job; TaskGraph tg = new TaskGraph(); for (VirtualSystem vs : da.getVirtualSystems()) { TaskGraph vsDeleteTaskGraph = new TaskGraph(); vsDeleteTaskGraph.appendTask(this.vsConformanceCheckMetaTask.create(vs)); tg.addTaskGraph(vsDeleteTaskGraph); } tg.appendTask(this.deleteDAFromDbTask.create(da), TaskGuard.ALL_ANCESTORS_SUCCEEDED); tg.appendTask(ult, TaskGuard.ALL_PREDECESSORS_COMPLETED); log.info("Start Submitting Delete DA Job"); job = JobEngine.getEngine().submit("Delete Distributed Appliance '" + da.getName() + "'", tg, LockObjectReference.getObjectReferences(da), new JobCompletionListener() { @Override public void completed(Job job) { if (!job.getStatus().getStatus().isSuccessful()) { try { DeleteDistributedApplianceService.this.dbConnectionManager.getTransactionControl().required(() -> new CompleteJobTransaction<DistributedAppliance>(DistributedAppliance.class, DeleteDistributedApplianceService.this.txBroadcastUtil) .run(DeleteDistributedApplianceService.this.dbConnectionManager.getTransactionalEntityManager(), new CompleteJobTransactionInput(da.getId(), job.getId()))); } catch (Exception e) { log.error("A serious error occurred in the Job Listener", e); throw new RuntimeException("No Transactional resources are available", e); } } } }); log.info("Done submitting with jobId: " + job.getId()); return job; } catch (Exception e) { LockUtil.releaseLocks(ult); throw e; } }  @Override BaseJobResponse exec(BaseDeleteRequest request, EntityManager em);  }