mirror of https://github.com/apache/cloudstack.git
Finally fixed async job
This commit is contained in:
parent
0493ea3ff6
commit
d84bb9720f
|
|
@ -18,18 +18,17 @@ package org.apache.cloudstack.api.response;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import com.amazonaws.services.importexport.model.Job;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
import org.apache.cloudstack.api.EntityReference;
|
||||
import org.apache.cloudstack.api.ResponseObject;
|
||||
import org.apache.cloudstack.jobs.Job;
|
||||
|
||||
import com.cloud.serializer.Param;
|
||||
|
||||
@EntityReference(value=Job.class)
|
||||
@SuppressWarnings("unused")
|
||||
@EntityReference(value = Job.class)
|
||||
public class AsyncJobResponse extends BaseResponse {
|
||||
|
||||
@SerializedName("accountid") @Param(description="the account that executed the async command")
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
DBUSER=cloud
|
||||
DBPW=cloud
|
||||
DBROOTPW=
|
||||
DBROOTPW=cloud
|
||||
MSLOG=vmops.log
|
||||
APISERVERLOG=api.log
|
||||
DBHOST=localhost
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ public class ClusterEntityImpl implements ClusterEntity {
|
|||
|
||||
@Override
|
||||
public State getState() {
|
||||
return clusterVO.getState();
|
||||
return clusterVO.getEngineState();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -19,40 +19,47 @@
|
|||
package org.apache.cloudstack.platform.orchestration;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.NetworkEntity;
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.TemplateEntity;
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntity;
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntityImpl;
|
||||
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
|
||||
import org.apache.cloudstack.engine.service.api.OrchestrationService;
|
||||
import org.apache.cloudstack.engine.vm.VMEntityManager;
|
||||
import org.apache.cloudstack.engine.vm.VirtualMachineOrchestrator;
|
||||
|
||||
import com.cloud.deploy.DeploymentPlan;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.dao.NetworkVO;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.storage.DiskOfferingVO;
|
||||
import com.cloud.storage.dao.DiskOfferingDao;
|
||||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.component.ComponentContext;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachineManager;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
|
||||
|
||||
@Component
|
||||
public class CloudOrchestrator implements OrchestrationService {
|
||||
|
||||
@Inject
|
||||
VirtualMachineOrchestrator _vmOrchestrator;
|
||||
private final static Logger s_logger = Logger.getLogger(CloudOrchestrator.class);
|
||||
|
||||
@Inject
|
||||
private VMEntityManager vmEntityManager;
|
||||
|
|
@ -81,8 +88,39 @@ public class CloudOrchestrator implements OrchestrationService {
|
|||
@Inject
|
||||
protected AccountDao _accountDao = null;
|
||||
|
||||
protected CloudOrchestrator() {
|
||||
public CloudOrchestrator() {
|
||||
}
|
||||
|
||||
public VirtualMachineEntity createFromScratch(String uuid, String iso, String os, String hypervisor, String hostName, int cpu, int speed, long memory, List<String> networks, List<String> computeTags,
|
||||
Map<String, String> details, String owner) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public String reserve(String vm, String planner, Long until) throws InsufficientCapacityException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public String deploy(String reservationId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public void joinNetwork(String network1, String network2) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void createNetwork() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void destroyNetwork() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public VolumeEntity createVolume() {
|
||||
|
|
@ -123,42 +161,118 @@ public class CloudOrchestrator implements OrchestrationService {
|
|||
List<String> rootDiskTags,
|
||||
Map<String, NicProfile> networkNicMap, DeploymentPlan plan) throws InsufficientCapacityException {
|
||||
|
||||
return _vmOrchestrator.create(id,
|
||||
owner,
|
||||
templateId,
|
||||
hostName,
|
||||
displayName,
|
||||
Hypervisor.HypervisorType.valueOf(hypervisor),
|
||||
cpu,
|
||||
speed,
|
||||
memory,
|
||||
diskSize,
|
||||
computeTags,
|
||||
rootDiskTags,
|
||||
networkNicMap,
|
||||
plan);
|
||||
// VirtualMachineEntityImpl vmEntity = new VirtualMachineEntityImpl(id, owner, hostName, displayName, cpu, speed, memory, computeTags, rootDiskTags, networks, vmEntityManager);
|
||||
|
||||
List<Pair<NetworkVO, NicProfile>> networkIpMap = new ArrayList<Pair<NetworkVO, NicProfile>>();
|
||||
for (String uuid : networkNicMap.keySet()) {
|
||||
NetworkVO network = _networkDao.findByUuid(uuid);
|
||||
if(network != null){
|
||||
networkIpMap.add(new Pair<NetworkVO, NicProfile>(network, networkNicMap.get(uuid)));
|
||||
}
|
||||
}
|
||||
|
||||
VirtualMachineEntityImpl vmEntity = ComponentContext.inject(VirtualMachineEntityImpl.class);
|
||||
vmEntity.init(id, owner, hostName, displayName, cpu, speed, memory, computeTags, rootDiskTags, new ArrayList<String>(networkNicMap.keySet()));
|
||||
|
||||
|
||||
HypervisorType hypervisorType = HypervisorType.valueOf(hypervisor);
|
||||
|
||||
//load vm instance and offerings and call virtualMachineManagerImpl
|
||||
VMInstanceVO vm = _vmDao.findByUuid(id);
|
||||
|
||||
// If the template represents an ISO, a disk offering must be passed in, and will be used to create the root disk
|
||||
// Else, a disk offering is optional, and if present will be used to create the data disk
|
||||
|
||||
Pair<DiskOfferingVO, Long> rootDiskOffering = new Pair<DiskOfferingVO, Long>(null, null);
|
||||
List<Pair<DiskOfferingVO, Long>> dataDiskOfferings = new ArrayList<Pair<DiskOfferingVO, Long>>();
|
||||
|
||||
ServiceOfferingVO offering = _serviceOfferingDao.findById(vm.getServiceOfferingId());
|
||||
rootDiskOffering.first(offering);
|
||||
|
||||
if(vm.getDiskOfferingId() != null){
|
||||
DiskOfferingVO diskOffering = _diskOfferingDao.findById(vm.getDiskOfferingId());
|
||||
if (diskOffering == null) {
|
||||
throw new InvalidParameterValueException("Unable to find disk offering " + vm.getDiskOfferingId());
|
||||
}
|
||||
Long size = null;
|
||||
if (diskOffering.getDiskSize() == 0) {
|
||||
size = diskSize;
|
||||
if (size == null) {
|
||||
throw new InvalidParameterValueException(
|
||||
"Disk offering " + diskOffering
|
||||
+ " requires size parameter.");
|
||||
}
|
||||
}
|
||||
dataDiskOfferings.add(new Pair<DiskOfferingVO, Long>(diskOffering, size));
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
_itMgr.allocate(vm.getInstanceName(), _templateDao.findById(new Long(templateId)), offering, rootDiskOffering, dataDiskOfferings, networkIpMap, null, plan,
|
||||
hypervisorType, _accountDao.findById(new Long(owner)));
|
||||
} catch (CloudRuntimeException e) {
|
||||
s_logger.warn("Unable to allocate resources for " + vm, e);
|
||||
return null;
|
||||
}
|
||||
|
||||
return vmEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VirtualMachineEntity createVirtualMachineFromScratch(String id, String owner, String isoId, String hostName, String displayName, String hypervisor, String os, int cpu, int speed, long memory,Long diskSize,
|
||||
List<String> computeTags, List<String> rootDiskTags, Map<String, NicProfile> networkNicMap, DeploymentPlan plan) throws InsufficientCapacityException {
|
||||
|
||||
return _vmOrchestrator.createFromScratch(
|
||||
id,
|
||||
owner,
|
||||
isoId,
|
||||
hostName,
|
||||
displayName,
|
||||
Hypervisor.HypervisorType.valueOf(hypervisor),
|
||||
os,
|
||||
cpu,
|
||||
speed,
|
||||
memory,
|
||||
diskSize,
|
||||
computeTags,
|
||||
rootDiskTags,
|
||||
networkNicMap,
|
||||
plan);
|
||||
// VirtualMachineEntityImpl vmEntity = new VirtualMachineEntityImpl(id, owner, hostName, displayName, cpu, speed, memory, computeTags, rootDiskTags, networks, vmEntityManager);
|
||||
VirtualMachineEntityImpl vmEntity = ComponentContext.inject(VirtualMachineEntityImpl.class);
|
||||
vmEntity.init(id, owner, hostName, displayName, cpu, speed, memory, computeTags, rootDiskTags, new ArrayList<String>(networkNicMap.keySet()));
|
||||
|
||||
//load vm instance and offerings and call virtualMachineManagerImpl
|
||||
VMInstanceVO vm = _vmDao.findByUuid(id);
|
||||
|
||||
|
||||
Pair<DiskOfferingVO, Long> rootDiskOffering = new Pair<DiskOfferingVO, Long>(null, null);
|
||||
ServiceOfferingVO offering = _serviceOfferingDao.findById(vm.getServiceOfferingId());
|
||||
rootDiskOffering.first(offering);
|
||||
|
||||
List<Pair<DiskOfferingVO, Long>> dataDiskOfferings = new ArrayList<Pair<DiskOfferingVO, Long>>();
|
||||
Long diskOfferingId = vm.getDiskOfferingId();
|
||||
if (diskOfferingId == null) {
|
||||
throw new InvalidParameterValueException(
|
||||
"Installing from ISO requires a disk offering to be specified for the root disk.");
|
||||
}
|
||||
DiskOfferingVO diskOffering = _diskOfferingDao.findById(diskOfferingId);
|
||||
if (diskOffering == null) {
|
||||
throw new InvalidParameterValueException("Unable to find disk offering " + diskOfferingId);
|
||||
}
|
||||
Long size = null;
|
||||
if (diskOffering.getDiskSize() == 0) {
|
||||
size = diskSize;
|
||||
if (size == null) {
|
||||
throw new InvalidParameterValueException("Disk offering "
|
||||
+ diskOffering + " requires size parameter.");
|
||||
}
|
||||
}
|
||||
rootDiskOffering.first(diskOffering);
|
||||
rootDiskOffering.second(size);
|
||||
|
||||
List<Pair<NetworkVO, NicProfile>> networkIpMap = new ArrayList<Pair<NetworkVO, NicProfile>>();
|
||||
for (String uuid : networkNicMap.keySet()) {
|
||||
NetworkVO network = _networkDao.findByUuid(uuid);
|
||||
if(network != null){
|
||||
networkIpMap.add(new Pair<NetworkVO, NicProfile>(network, networkNicMap.get(uuid)));
|
||||
}
|
||||
}
|
||||
|
||||
HypervisorType hypervisorType = HypervisorType.valueOf(hypervisor);
|
||||
|
||||
try {
|
||||
_itMgr.allocate(vm.getInstanceName(), _templateDao.findById(new Long(isoId)), offering, rootDiskOffering, dataDiskOfferings, networkIpMap, null, plan, hypervisorType, _accountDao.findById(new Long(owner)));
|
||||
} catch (CloudRuntimeException e) {
|
||||
s_logger.warn("Unable to allocate resources for " + vm, e);
|
||||
return null;
|
||||
}
|
||||
|
||||
return vmEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -169,7 +283,8 @@ public class CloudOrchestrator implements OrchestrationService {
|
|||
|
||||
@Override
|
||||
public VirtualMachineEntity getVirtualMachine(String id) {
|
||||
return _vmOrchestrator.get(id);
|
||||
VirtualMachineEntityImpl vmEntity = new VirtualMachineEntityImpl(id, vmEntityManager);
|
||||
return vmEntity;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -237,7 +237,7 @@ public class EngineClusterVO implements EngineCluster, Identity {
|
|||
return lastUpdated;
|
||||
}
|
||||
|
||||
public State getState() {
|
||||
public State getEngineState() {
|
||||
return engineState;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ public class EngineDataCenterVO implements EngineDataCenter, Identity {
|
|||
@Enumerated(value=EnumType.STRING)
|
||||
@StateMachine(state=State.class, event=Event.class)
|
||||
@Column(name="engine_state", updatable=true, nullable=false, length=32)
|
||||
protected State engineState = null;
|
||||
protected State state = null;
|
||||
|
||||
|
||||
@Override
|
||||
|
|
@ -246,7 +246,7 @@ public class EngineDataCenterVO implements EngineDataCenter, Identity {
|
|||
this.zoneToken = zoneToken;
|
||||
this.domain = domainSuffix;
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.engineState = State.Disabled;
|
||||
this.state = State.Disabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -481,7 +481,7 @@ public class EngineDataCenterVO implements EngineDataCenter, Identity {
|
|||
}
|
||||
|
||||
public State getState() {
|
||||
return engineState;
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ public class EngineHostPodVO implements EnginePod, Identity {
|
|||
@Enumerated(value=EnumType.STRING)
|
||||
@StateMachine(state=State.class, event=Event.class)
|
||||
@Column(name="engine_state", updatable=true, nullable=false, length=32)
|
||||
protected State engineState = null;
|
||||
protected State state = null;
|
||||
|
||||
public EngineHostPodVO(String name, long dcId, String gateway, String cidrAddress, int cidrSize, String description) {
|
||||
this.name = name;
|
||||
|
|
@ -104,7 +104,7 @@ public class EngineHostPodVO implements EnginePod, Identity {
|
|||
this.allocationState = Grouping.AllocationState.Enabled;
|
||||
this.externalDhcp = false;
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
this.engineState = State.Disabled;
|
||||
this.state = State.Disabled;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -240,6 +240,6 @@ public class EngineHostPodVO implements EnginePod, Identity {
|
|||
}
|
||||
|
||||
public State getState() {
|
||||
return engineState;
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,13 +24,13 @@ import java.util.Map;
|
|||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.engine.datacenter.entity.EngineClusterVO;
|
||||
import org.apache.cloudstack.engine.datacenter.entity.EngineHostPodVO;
|
||||
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity;
|
||||
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State;
|
||||
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State.Event;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.org.Grouping;
|
||||
|
|
@ -45,7 +45,6 @@ import com.cloud.utils.db.Transaction;
|
|||
import com.cloud.utils.db.UpdateBuilder;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
@Component(value="EngineClusterDao")
|
||||
@Local(value=EngineClusterDao.class)
|
||||
public class EngineClusterDaoImpl extends GenericDaoBase<EngineClusterVO, Long> implements EngineClusterDao {
|
||||
private static final Logger s_logger = Logger.getLogger(EngineClusterDaoImpl.class);
|
||||
|
|
@ -97,7 +96,7 @@ public class EngineClusterDaoImpl extends GenericDaoBase<EngineClusterVO, Long>
|
|||
|
||||
StateChangeSearch = createSearchBuilder();
|
||||
StateChangeSearch.and("id", StateChangeSearch.entity().getId(), SearchCriteria.Op.EQ);
|
||||
StateChangeSearch.and("state", StateChangeSearch.entity().getState(), SearchCriteria.Op.EQ);
|
||||
StateChangeSearch.and("state", StateChangeSearch.entity().getEngineState(), SearchCriteria.Op.EQ);
|
||||
StateChangeSearch.done();
|
||||
}
|
||||
|
||||
|
|
@ -273,7 +272,7 @@ public class EngineClusterDaoImpl extends GenericDaoBase<EngineClusterVO, Long>
|
|||
EngineClusterVO dbCluster = findByIdIncludingRemoved(vo.getId());
|
||||
if (dbCluster != null) {
|
||||
StringBuilder str = new StringBuilder("Unable to update ").append(vo.toString());
|
||||
str.append(": DB Data={id=").append(dbCluster.getId()).append("; state=").append(dbCluster.getState()).append(";updatedTime=")
|
||||
str.append(": DB Data={id=").append(dbCluster.getId()).append("; state=").append(dbCluster.getEngineState()).append(";updatedTime=")
|
||||
.append(dbCluster.getLastUpdated());
|
||||
str.append(": New Data={id=").append(vo.getId()).append("; state=").append(nextState).append("; event=").append(event).append("; updatedTime=").append(vo.getLastUpdated());
|
||||
str.append(": stale Data={id=").append(vo.getId()).append("; state=").append(currentState).append("; event=").append(event).append("; updatedTime=").append(oldUpdatedTime);
|
||||
|
|
|
|||
|
|
@ -29,11 +29,12 @@ import javax.ejb.Local;
|
|||
import javax.inject.Inject;
|
||||
import javax.persistence.TableGenerator;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import org.apache.cloudstack.engine.datacenter.entity.EngineHostVO;
|
||||
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity;
|
||||
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.Host.Type;
|
||||
|
|
@ -311,7 +312,8 @@ public class EngineHostDaoImpl extends GenericDaoBase<EngineHostVO, Long> implem
|
|||
|
||||
StateChangeSearch = createSearchBuilder();
|
||||
StateChangeSearch.and("id", StateChangeSearch.entity().getId(), SearchCriteria.Op.EQ);
|
||||
StateChangeSearch.and("state", StateChangeSearch.entity().getState(), SearchCriteria.Op.EQ);
|
||||
//FIXME getState() or getStatus()?
|
||||
StateChangeSearch.and("state", StateChangeSearch.entity().getStatus(), SearchCriteria.Op.EQ);
|
||||
StateChangeSearch.done();
|
||||
}
|
||||
|
||||
|
|
@ -336,7 +338,7 @@ public class EngineHostDaoImpl extends GenericDaoBase<EngineHostVO, Long> implem
|
|||
@Override @DB
|
||||
public List<EngineHostVO> findAndUpdateDirectAgentToLoad(long lastPingSecondsAfter, Long limit, long managementServerId) {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
txn.start();
|
||||
SearchCriteria<EngineHostVO> sc = UnmanagedDirectConnectSearch.create();
|
||||
sc.setParameters("lastPinged", lastPingSecondsAfter);
|
||||
//sc.setParameters("resourceStates", ResourceState.ErrorInMaintenance, ResourceState.Maintenance, ResourceState.PrepareForMaintenance, ResourceState.Disabled);
|
||||
|
|
|
|||
|
|
@ -18,97 +18,81 @@ package org.apache.cloudstack.framework.jobs;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.cloudstack.api.Identity;
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
import org.apache.cloudstack.jobs.Job;
|
||||
|
||||
public interface AsyncJob extends Job {
|
||||
|
||||
public interface AsyncJob extends Identity, InternalIdentity {
|
||||
public enum JournalType {
|
||||
SUCCESS, FAILURE
|
||||
};
|
||||
|
||||
public static interface Topics {
|
||||
public static final String JOB_HEARTBEAT = "job.heartbeat";
|
||||
public static final String JOB_STATE = "job.state";
|
||||
}
|
||||
|
||||
public enum JournalType {
|
||||
SUCCESS, FAILURE
|
||||
};
|
||||
|
||||
@Override
|
||||
String getType();
|
||||
|
||||
@Override
|
||||
String getDispatcher();
|
||||
|
||||
@Override
|
||||
int getPendingSignals();
|
||||
public enum Type {
|
||||
None,
|
||||
VirtualMachine,
|
||||
DomainRouter,
|
||||
Volume,
|
||||
ConsoleProxy,
|
||||
Snapshot,
|
||||
Template,
|
||||
Iso,
|
||||
SystemVm,
|
||||
Host,
|
||||
StoragePool,
|
||||
IpAddress,
|
||||
PortableIpAddress,
|
||||
SecurityGroup,
|
||||
PhysicalNetwork,
|
||||
TrafficType,
|
||||
PhysicalNetworkServiceProvider,
|
||||
FirewallRule,
|
||||
Account,
|
||||
User,
|
||||
PrivateGateway,
|
||||
StaticRoute,
|
||||
Counter,
|
||||
Condition,
|
||||
AutoScalePolicy,
|
||||
AutoScaleVmProfile,
|
||||
AutoScaleVmGroup,
|
||||
GlobalLoadBalancerRule,
|
||||
LoadBalancerRule,
|
||||
AffinityGroup,
|
||||
InternalLbVm,
|
||||
DedicatedGuestVlanRange
|
||||
}
|
||||
|
||||
@Override
|
||||
long getUserId();
|
||||
|
||||
@Override
|
||||
long getAccountId();
|
||||
|
||||
@Override
|
||||
String getCmd();
|
||||
|
||||
@Override
|
||||
int getCmdVersion();
|
||||
|
||||
@Override
|
||||
String getCmdInfo();
|
||||
|
||||
@Override
|
||||
int getStatus();
|
||||
|
||||
@Override
|
||||
int getProcessStatus();
|
||||
|
||||
@Override
|
||||
int getResultCode();
|
||||
|
||||
@Override
|
||||
String getResult();
|
||||
|
||||
@Override
|
||||
Long getInitMsid();
|
||||
void setInitMsid(Long msid);
|
||||
|
||||
@Override
|
||||
Long getExecutingMsid();
|
||||
|
||||
@Override
|
||||
Long getCompleteMsid();
|
||||
void setCompleteMsid(Long msid);
|
||||
|
||||
@Override
|
||||
Date getCreated();
|
||||
|
||||
@Override
|
||||
Date getLastUpdated();
|
||||
|
||||
@Override
|
||||
Date getLastPolled();
|
||||
|
||||
Date getRemoved();
|
||||
|
||||
@Override
|
||||
String getInstanceType();
|
||||
|
||||
@Override
|
||||
Long getInstanceId();
|
||||
|
||||
SyncQueueItem getSyncSource();
|
||||
|
|
|
|||
|
|
@ -33,13 +33,15 @@ import javax.persistence.Temporal;
|
|||
import javax.persistence.TemporalType;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import org.apache.cloudstack.jobs.Job;
|
||||
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
@Entity
|
||||
@Table(name="async_job")
|
||||
@Inheritance(strategy=InheritanceType.JOINED)
|
||||
@DiscriminatorColumn(name="job_type", discriminatorType=DiscriminatorType.STRING, length=32)
|
||||
public class AsyncJobVO implements AsyncJob {
|
||||
public class AsyncJobVO implements AsyncJob, Job {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
|
|
@ -112,13 +114,13 @@ public class AsyncJobVO implements AsyncJob {
|
|||
private Date removed;
|
||||
|
||||
@Column(name="uuid")
|
||||
private String uuid;
|
||||
private String uuid;
|
||||
|
||||
@Transient
|
||||
private SyncQueueItem syncSource = null;
|
||||
|
||||
public AsyncJobVO() {
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
public AsyncJobVO(long userId, long accountId, String cmd, String cmdInfo, Long instanceId, String instanceType) {
|
||||
|
|
@ -126,17 +128,11 @@ public class AsyncJobVO implements AsyncJob {
|
|||
this.accountId = accountId;
|
||||
this.cmd = cmd;
|
||||
this.cmdInfo = cmdInfo;
|
||||
this.uuid = UUID.randomUUID().toString();
|
||||
uuid = UUID.randomUUID().toString();
|
||||
this.instanceId = instanceId;
|
||||
this.instanceType = instanceType;
|
||||
}
|
||||
|
||||
public AsyncJobVO(long userId, long accountId, String cmd, String cmdInfo,
|
||||
int callbackType, String callbackAddress, Long instanceId, Type instanceType) {
|
||||
|
||||
this.type ="AsyncJobVO";
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return id;
|
||||
|
|
@ -148,7 +144,7 @@ public class AsyncJobVO implements AsyncJob {
|
|||
|
||||
@Override
|
||||
public String getType() {
|
||||
return this.type;
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
|
|
@ -157,7 +153,7 @@ public class AsyncJobVO implements AsyncJob {
|
|||
|
||||
@Override
|
||||
public String getDispatcher() {
|
||||
return this.dispatcher;
|
||||
return dispatcher;
|
||||
}
|
||||
|
||||
public void setDispatcher(String dispatcher) {
|
||||
|
|
@ -166,11 +162,11 @@ public class AsyncJobVO implements AsyncJob {
|
|||
|
||||
@Override
|
||||
public int getPendingSignals() {
|
||||
return this.pendingSignals;
|
||||
return pendingSignals;
|
||||
}
|
||||
|
||||
public void setPendingSignals(int signals) {
|
||||
this.pendingSignals = signals;
|
||||
pendingSignals = signals;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -266,7 +262,7 @@ public class AsyncJobVO implements AsyncJob {
|
|||
|
||||
@Override
|
||||
public Long getExecutingMsid() {
|
||||
return this.executingMsid;
|
||||
return executingMsid;
|
||||
}
|
||||
|
||||
public void setExecutingMsid(Long executingMsid) {
|
||||
|
|
@ -349,7 +345,7 @@ public class AsyncJobVO implements AsyncJob {
|
|||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
return this.uuid;
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
|
|
|
|||
|
|
@ -95,11 +95,6 @@
|
|||
<artifactId>cloud-framework-events</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-framework-ipc</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<defaultGoal>install</defaultGoal>
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import com.google.gson.reflect.TypeToken;
|
|||
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseAsyncCmd;
|
||||
import org.apache.cloudstack.api.BaseAsyncCreateCmd;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.ExceptionResponse;
|
||||
import org.apache.cloudstack.framework.jobs.AsyncJob;
|
||||
|
|
@ -61,7 +62,7 @@ public class ApiAsyncJobDispatcher extends AdapterBase implements AsyncJobDispat
|
|||
cmdObj = ComponentContext.inject(cmdObj);
|
||||
cmdObj.configure();
|
||||
cmdObj.setJob(job);
|
||||
|
||||
|
||||
Type mapType = new TypeToken<Map<String, String>>() {}.getType();
|
||||
Gson gson = ApiGsonHelper.getBuilder().create();
|
||||
Map<String, String> params = gson.fromJson(job.getCmdInfo(), mapType);
|
||||
|
|
@ -72,6 +73,12 @@ public class ApiAsyncJobDispatcher extends AdapterBase implements AsyncJobDispat
|
|||
Long userId = null;
|
||||
Account accountObject = null;
|
||||
|
||||
if (cmdObj instanceof BaseAsyncCreateCmd) {
|
||||
BaseAsyncCreateCmd create = (BaseAsyncCreateCmd)cmdObj;
|
||||
create.setEntityId(Long.parseLong(params.get("id")));
|
||||
create.setEntityUuid(params.get("uuid"));
|
||||
}
|
||||
|
||||
if (userIdStr != null) {
|
||||
userId = Long.parseLong(userIdStr);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ import javax.annotation.PostConstruct;
|
|||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import org.apache.cloudstack.acl.ControlledEntity;
|
||||
import org.apache.cloudstack.acl.InfrastructureEntity;
|
||||
|
|
@ -69,7 +68,6 @@ import com.cloud.utils.ReflectUtil;
|
|||
import com.cloud.utils.exception.CSExceptionErrorCode;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
@Component
|
||||
public class ApiDispatcher {
|
||||
private static final Logger s_logger = Logger.getLogger(ApiDispatcher.class.getName());
|
||||
|
||||
|
|
|
|||
|
|
@ -588,12 +588,10 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
|
|||
if (job.getInstanceId() == null) {
|
||||
continue;
|
||||
}
|
||||
String instanceUuid = job.getUuid();
|
||||
if (instanceUuid != null) {
|
||||
objectJobMap.put(instanceUuid, job);
|
||||
}
|
||||
String instanceUuid = ApiDBUtils.findJobInstanceUuid(job);
|
||||
objectJobMap.put(instanceUuid, job);
|
||||
}
|
||||
|
||||
|
||||
for (ResponseObject response : responses) {
|
||||
if (response.getObjectId() != null && objectJobMap.containsKey(response.getObjectId())) {
|
||||
AsyncJob job = objectJobMap.get(response.getObjectId());
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
{
|
||||
"zones": [
|
||||
{
|
||||
"name": "DevCloud0",
|
||||
"name": "DevCloud1",
|
||||
"enabled" : "True",
|
||||
"physical_networks": [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -49,16 +49,16 @@ import com.cloud.utils.mgmt.ManagementBean;
|
|||
public class ComponentContext implements ApplicationContextAware {
|
||||
private static final Logger s_logger = Logger.getLogger(ComponentContext.class);
|
||||
|
||||
private static ApplicationContext s_appContext;
|
||||
private static ApplicationContext s_appContext;
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) {
|
||||
s_logger.info("Setup Spring Application context");
|
||||
s_appContext = applicationContext;
|
||||
}
|
||||
s_appContext = applicationContext;
|
||||
}
|
||||
|
||||
public static ApplicationContext getApplicationContext() {
|
||||
return s_appContext;
|
||||
public static ApplicationContext getApplicationContext() {
|
||||
return s_appContext;
|
||||
}
|
||||
|
||||
public static void initComponentsLifeCycle() {
|
||||
|
|
@ -89,7 +89,7 @@ public class ComponentContext implements ApplicationContextAware {
|
|||
try {
|
||||
entry.getValue().check();
|
||||
} catch(Throwable e) {
|
||||
s_logger.error("System integrity check failed. Refuse to startup");
|
||||
s_logger.error("System integrity check failed. Refuse to startup", e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
|
@ -211,7 +211,7 @@ public class ComponentContext implements ApplicationContextAware {
|
|||
} catch (Exception e) {
|
||||
return (T)instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (T)instance;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue