diff --git a/engine/schema/src/com/cloud/vm/dao/NicDaoImpl.java b/engine/schema/src/com/cloud/vm/dao/NicDaoImpl.java index 420643f7363..48697d66650 100644 --- a/engine/schema/src/com/cloud/vm/dao/NicDaoImpl.java +++ b/engine/schema/src/com/cloud/vm/dao/NicDaoImpl.java @@ -53,6 +53,7 @@ public class NicDaoImpl extends GenericDaoBase implements NicDao { AllFieldsSearch.and("broadcastUri", AllFieldsSearch.entity().getBroadcastUri(), Op.EQ); AllFieldsSearch.and("secondaryip", AllFieldsSearch.entity().getSecondaryIp(), Op.EQ); AllFieldsSearch.and("nicid", AllFieldsSearch.entity().getId(), Op.EQ); + AllFieldsSearch.and("strategy", AllFieldsSearch.entity().getReservationStrategy(), Op.EQ); AllFieldsSearch.done(); IpSearch = createSearchBuilder(String.class); diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobMonitor.java b/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobMonitor.java index 25f9583f90e..ea7af83bd31 100644 --- a/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobMonitor.java +++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobMonitor.java @@ -141,6 +141,12 @@ public class AsyncJobMonitor extends ManagerBase { } } + public boolean isJobActive(long jobId) { + synchronized(this) { + return _activeTasks.get(jobId) != null; + } + } + public int getActivePoolThreads() { return _activePoolThreads; } diff --git a/server/src/com/cloud/async/AsyncJobManagerImpl.java b/server/src/com/cloud/async/AsyncJobManagerImpl.java index 359d47b1aba..81350c46360 100644 --- a/server/src/com/cloud/async/AsyncJobManagerImpl.java +++ b/server/src/com/cloud/async/AsyncJobManagerImpl.java @@ -535,13 +535,17 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager, } if((getAndResetPendingSignals(job) & AsyncJobConstants.SIGNAL_MASK_WAKEUP) != 0) { - AsyncJobDispatcher jobDispatcher = getWakeupDispatcher(job); - if(jobDispatcher != null) { - jobDispatcher.runJob(job); - } else { - s_logger.error("Unable to find a wakeup dispatcher from the joined job. job-" + job.getId()); + if(!_jobMonitor.isJobActive(job.getId())) { + AsyncJobDispatcher jobDispatcher = getWakeupDispatcher(job); + if(jobDispatcher != null) { + jobDispatcher.runJob(job); + } else { + s_logger.error("Unable to find a wakeup dispatcher from the joined job. job-" + job.getId()); + } } } else { + assert(_jobMonitor.isJobActive(job.getId())); + AsyncJobDispatcher jobDispatcher = getDispatcher(job.getDispatcher()); if(jobDispatcher != null) { jobDispatcher.runJob(job); diff --git a/server/src/com/cloud/vm/VmWorkStart.java b/server/src/com/cloud/vm/VmWorkStart.java index fbc0a156835..107009ee6a1 100644 --- a/server/src/com/cloud/vm/VmWorkStart.java +++ b/server/src/com/cloud/vm/VmWorkStart.java @@ -51,19 +51,23 @@ public class VmWorkStart extends VmWork { } public DeploymentPlan getPlan() { - // this is ugly, to work with legacy code, we need to re-construct the DeploymentPlan hard-codely - // this has to be refactored together with migrating legacy code into the new way - ReservationContext context = null; - if(reservationId != null) { - Journal journal = new Journal.LogJournal("VmWorkStart", s_logger); - context = new ReservationContextImpl(reservationId, journal, CallContext.current().getCallingUser(), CallContext.current().getCallingAccount()); + if(podId != null || clusterId != null || hostId != null || poolId != null || physicalNetworkId != null) { + // this is ugly, to work with legacy code, we need to re-construct the DeploymentPlan hard-codely + // this has to be refactored together with migrating legacy code into the new way + ReservationContext context = null; + if(reservationId != null) { + Journal journal = new Journal.LogJournal("VmWorkStart", s_logger); + context = new ReservationContextImpl(reservationId, journal, CallContext.current().getCallingUser(), CallContext.current().getCallingAccount()); + } + + DeploymentPlan plan = new DataCenterDeployment( + dcId, podId, clusterId, hostId, poolId, physicalNetworkId, + context); + return plan; } - DeploymentPlan plan = new DataCenterDeployment( - dcId, podId, clusterId, hostId, poolId, physicalNetworkId, - context); - return plan; + return null; } public void setPlan(DeploymentPlan plan) { diff --git a/server/test/com/cloud/vm/VmWorkMockVirtualMachineManagerImpl.java b/server/test/com/cloud/vm/VmWorkMockVirtualMachineManagerImpl.java index 77b9268c892..642dfc17a9a 100644 --- a/server/test/com/cloud/vm/VmWorkMockVirtualMachineManagerImpl.java +++ b/server/test/com/cloud/vm/VmWorkMockVirtualMachineManagerImpl.java @@ -17,7 +17,6 @@ package com.cloud.vm; import java.net.URI; -import java.util.Collection; import java.util.List; import java.util.Map; @@ -165,18 +164,6 @@ public class VmWorkMockVirtualMachineManagerImpl implements VirtualMachineManage } - @Override - public Collection getRegisteredGurus() { - // TODO Auto-generated method stub - return null; - } - - @Override - public VirtualMachineGuru getVmGuru(VirtualMachine vm) { - // TODO Auto-generated method stub - return null; - } - @Override public boolean stateTransitTo(VMInstanceVO vm, Event e, Long hostId) throws NoTransitionException {