mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-669: put system vm work under new vmsync model
This commit is contained in:
parent
3f526fb052
commit
d931718ab2
|
|
@ -20,11 +20,16 @@
|
|||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:aop="http://www.springframework.org/schema/aop"
|
||||
xmlns:util="http://www.springframework.org/schema/util"
|
||||
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
|
||||
http://www.springframework.org/schema/aop
|
||||
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context-3.0.xsd"
|
||||
http://www.springframework.org/schema/context/spring-context-3.0.xsd
|
||||
http://www.springframework.org/schema/util
|
||||
http://www.springframework.org/schema/util/spring-util-3.0.xsd"
|
||||
>
|
||||
|
||||
<bean id="clusterBasedAgentLoadBalancerPlanner"
|
||||
|
|
@ -68,5 +73,10 @@
|
|||
<bean id="virtualMachineEntityImpl" class="org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntityImpl" />
|
||||
|
||||
<bean id="virtualMachinePowerStateSyncImpl" class="com.cloud.vm.VirtualMachinePowerStateSyncImpl" />
|
||||
<bean id= "vmWorkJobDispatcher" class="com.cloud.vm.VmWorkJobDispatcher">
|
||||
<property name="name">
|
||||
<util:constant static-field="com.cloud.vm.VmWorkJobDispatcher.VM_WORK_JOB_DISPATCHER"/>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
|
|
|
|||
|
|
@ -4122,6 +4122,10 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
return null;
|
||||
}
|
||||
|
||||
//
|
||||
// TODO build a common pattern to reduce code duplication in following methods
|
||||
// no time for this at current iteration
|
||||
//
|
||||
public Outcome<VirtualMachine> startVmThroughJobQueue(final String vmUuid,
|
||||
final Map<VirtualMachineProfile.Param, Object> params,
|
||||
final DeploymentPlan planToDeploy) {
|
||||
|
|
@ -4166,7 +4170,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
|
||||
// Transaction syntax sugar has a cost here
|
||||
context.putContextParameter("workJob", workJob);
|
||||
context.putContextParameter("jobId", new Long(vm.getId()));
|
||||
context.putContextParameter("jobId", new Long(workJob.getId()));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -4216,7 +4220,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
}
|
||||
|
||||
context.putContextParameter("workJob", workJob);
|
||||
context.putContextParameter("jobId", new Long(vm.getId()));
|
||||
context.putContextParameter("jobId", new Long(workJob.getId()));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -4268,7 +4272,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
}
|
||||
|
||||
context.putContextParameter("workJob", workJob);
|
||||
context.putContextParameter("jobId", new Long(vm.getId()));
|
||||
context.putContextParameter("jobId", new Long(workJob.getId()));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -4318,7 +4322,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
_jobMgr.submitAsyncJob(workJob, VmWorkJobDispatcher.VM_WORK_QUEUE, vm.getId());
|
||||
}
|
||||
context.putContextParameter("workJob", workJob);
|
||||
context.putContextParameter("jobId", new Long(vm.getId()));
|
||||
context.putContextParameter("jobId", new Long(workJob.getId()));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -4372,7 +4376,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
_jobMgr.submitAsyncJob(workJob, VmWorkJobDispatcher.VM_WORK_QUEUE, vm.getId());
|
||||
}
|
||||
context.putContextParameter("workJob", workJob);
|
||||
context.putContextParameter("jobId", new Long(vm.getId()));
|
||||
context.putContextParameter("jobId", new Long(workJob.getId()));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -4383,10 +4387,6 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
VirtualMachine.PowerState.PowerOn, vm.getId(), destHostId);
|
||||
}
|
||||
|
||||
//
|
||||
// TODO build a common pattern to reduce code duplication in following methods
|
||||
// no time for this at current iteration
|
||||
//
|
||||
public Outcome<VirtualMachine> migrateVmForScaleThroughJobQueue(
|
||||
final String vmUuid, final long srcHostId, final DeployDestination dest, final Long newSvcOfferingId) {
|
||||
|
||||
|
|
@ -4429,7 +4429,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
_jobMgr.submitAsyncJob(workJob, VmWorkJobDispatcher.VM_WORK_QUEUE, vm.getId());
|
||||
}
|
||||
context.putContextParameter("workJob", workJob);
|
||||
context.putContextParameter("jobId", new Long(vm.getId()));
|
||||
context.putContextParameter("jobId", new Long(workJob.getId()));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -4481,7 +4481,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
_jobMgr.submitAsyncJob(workJob, VmWorkJobDispatcher.VM_WORK_QUEUE, vm.getId());
|
||||
}
|
||||
context.putContextParameter("workJob", workJob);
|
||||
context.putContextParameter("jobId", new Long(vm.getId()));
|
||||
context.putContextParameter("jobId", new Long(workJob.getId()));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -4531,7 +4531,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
_jobMgr.submitAsyncJob(workJob, VmWorkJobDispatcher.VM_WORK_QUEUE, vm.getId());
|
||||
}
|
||||
context.putContextParameter("workJob", workJob);
|
||||
context.putContextParameter("jobId", new Long(vm.getId()));
|
||||
context.putContextParameter("jobId", new Long(workJob.getId()));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -4581,7 +4581,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
_jobMgr.submitAsyncJob(workJob, VmWorkJobDispatcher.VM_WORK_QUEUE, vm.getId());
|
||||
}
|
||||
context.putContextParameter("workJob", workJob);
|
||||
context.putContextParameter("jobId", new Long(vm.getId()));
|
||||
context.putContextParameter("jobId", new Long(workJob.getId()));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -4631,7 +4631,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
_jobMgr.submitAsyncJob(workJob, VmWorkJobDispatcher.VM_WORK_QUEUE, vm.getId());
|
||||
}
|
||||
context.putContextParameter("workJob", workJob);
|
||||
context.putContextParameter("jobId", new Long(vm.getId()));
|
||||
context.putContextParameter("jobId", new Long(workJob.getId()));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -4683,7 +4683,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
_jobMgr.submitAsyncJob(workJob, VmWorkJobDispatcher.VM_WORK_QUEUE, vm.getId());
|
||||
}
|
||||
context.putContextParameter("workJob", workJob);
|
||||
context.putContextParameter("jobId", new Long(vm.getId()));
|
||||
context.putContextParameter("jobId", new Long(workJob.getId()));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -158,7 +158,9 @@
|
|||
|
||||
<bean id="snapshotManagerImpl" class="com.cloud.storage.snapshot.SnapshotManagerImpl" />
|
||||
|
||||
<bean id="snapshotSchedulerImpl" class="com.cloud.storage.snapshot.SnapshotSchedulerImpl" />
|
||||
<bean id="snapshotSchedulerImpl" class="com.cloud.storage.snapshot.SnapshotSchedulerImpl" >
|
||||
<property name="asyncJobDispatcher" ref="ApiAsyncJobDispatcher" />
|
||||
</bean>
|
||||
<bean id="storageNetworkManagerImpl" class="com.cloud.network.StorageNetworkManagerImpl" />
|
||||
<bean id="taggedResourceManagerImpl" class="com.cloud.tags.TaggedResourceManagerImpl" />
|
||||
<bean id="resourceMetaDataManagerImpl" class="com.cloud.metadata.ResourceMetaDataManagerImpl" />
|
||||
|
|
|
|||
|
|
@ -72,8 +72,8 @@ public class SnapshotSchedulerImpl extends ManagerBase implements SnapshotSchedu
|
|||
|
||||
@Inject
|
||||
protected AsyncJobDao _asyncJobDao;
|
||||
@Inject
|
||||
protected AsyncJobDispatcher _asyncDispatcher;
|
||||
|
||||
@Inject protected SnapshotDao _snapshotDao;
|
||||
@Inject protected SnapshotScheduleDao _snapshotScheduleDao;
|
||||
@Inject protected SnapshotPolicyDao _snapshotPolicyDao;
|
||||
|
|
@ -86,7 +86,15 @@ public class SnapshotSchedulerImpl extends ManagerBase implements SnapshotSchedu
|
|||
private Timer _testClockTimer;
|
||||
private Date _currentTimestamp;
|
||||
private TestClock _testTimerTask;
|
||||
|
||||
|
||||
public AsyncJobDispatcher getAsyncJobDispatcher() {
|
||||
return _asyncDispatcher;
|
||||
}
|
||||
|
||||
public void setAsyncJobDispatcher(AsyncJobDispatcher dispatcher) {
|
||||
_asyncDispatcher = dispatcher;
|
||||
}
|
||||
|
||||
private Date getNextScheduledTime(long policyId, Date currentTimestamp) {
|
||||
SnapshotPolicyVO policy = _snapshotPolicyDao.findById(policyId);
|
||||
Date nextTimestamp = null;
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ import java.util.concurrent.ScheduledExecutorService;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
import org.apache.cloudstack.framework.jobs.AsyncJobExecutionContext;
|
||||
import org.apache.cloudstack.managed.context.ManagedContextRunnable;
|
||||
|
||||
import com.cloud.utils.Pair;
|
||||
|
|
@ -40,7 +42,7 @@ public class SystemVmLoadScanner<T> {
|
|||
private final SystemVmLoadScanHandler<T> _scanHandler;
|
||||
private final ScheduledExecutorService _capacityScanScheduler;
|
||||
private final GlobalLock _capacityScanLock;
|
||||
|
||||
|
||||
public SystemVmLoadScanner(SystemVmLoadScanHandler<T> scanHandler) {
|
||||
_scanHandler = scanHandler;
|
||||
_capacityScanScheduler = Executors.newScheduledThreadPool(1, new NamedThreadFactory(scanHandler.getScanHandlerName()));
|
||||
|
|
@ -67,8 +69,16 @@ public class SystemVmLoadScanner<T> {
|
|||
|
||||
@Override
|
||||
protected void runInContext() {
|
||||
try {
|
||||
try {
|
||||
CallContext callContext = CallContext.current();
|
||||
assert(callContext != null);
|
||||
|
||||
AsyncJobExecutionContext.registerPseudoExecutionContext(
|
||||
callContext.getCallingAccountId(), callContext.getCallingUserId());
|
||||
|
||||
reallyRun();
|
||||
|
||||
AsyncJobExecutionContext.unregister();
|
||||
} catch (Throwable e) {
|
||||
s_logger.warn("Unexpected exception " + e.getMessage(), e);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue