mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
merge changes
This commit is contained in:
parent
19edfdfcdb
commit
d43717eef8
@ -32,7 +32,6 @@ import com.cloud.utils.fsm.StateMachine;
|
||||
*/
|
||||
public interface VirtualMachine extends RunningOn, ControlledEntity {
|
||||
public enum State implements FiniteState<State, Event> {
|
||||
Creating(true, "VM is being created"),
|
||||
Starting(true, "VM is being started. At this state, you should find host id filled which means it's being started on that host."),
|
||||
Running(false, "VM is running. host id has the host that it is running on."),
|
||||
Stopping(true, "VM is being stopped. host id has the host that it is being stopped on."),
|
||||
@ -85,9 +84,9 @@ public interface VirtualMachine extends RunningOn, ControlledEntity {
|
||||
|
||||
protected static final StateMachine<State, VirtualMachine.Event> s_fsm = new StateMachine<State, VirtualMachine.Event>();
|
||||
static {
|
||||
s_fsm.addTransition(null, VirtualMachine.Event.CreateRequested, State.Creating);
|
||||
s_fsm.addTransition(State.Creating, VirtualMachine.Event.OperationSucceeded, State.Stopped);
|
||||
s_fsm.addTransition(State.Creating, VirtualMachine.Event.OperationFailed, State.Error);
|
||||
// s_fsm.addTransition(null, VirtualMachine.Event.CreateRequested, State.Creating);
|
||||
// s_fsm.addTransition(State.Creating, VirtualMachine.Event.OperationSucceeded, State.Stopped);
|
||||
// s_fsm.addTransition(State.Creating, VirtualMachine.Event.OperationFailed, State.Error);
|
||||
s_fsm.addTransition(State.Stopped, VirtualMachine.Event.StartRequested, State.Starting);
|
||||
s_fsm.addTransition(State.Stopped, VirtualMachine.Event.DestroyRequested, State.Destroyed);
|
||||
s_fsm.addTransition(State.Error, VirtualMachine.Event.DestroyRequested, State.Destroyed);
|
||||
@ -102,7 +101,7 @@ public interface VirtualMachine extends RunningOn, ControlledEntity {
|
||||
s_fsm.addTransition(State.Starting, VirtualMachine.Event.AgentReportShutdowned, State.Stopped);
|
||||
s_fsm.addTransition(State.Destroyed, VirtualMachine.Event.RecoveryRequested, State.Stopped);
|
||||
s_fsm.addTransition(State.Destroyed, VirtualMachine.Event.ExpungeOperation, State.Expunging);
|
||||
s_fsm.addTransition(State.Creating, VirtualMachine.Event.MigrationRequested, State.Destroyed);
|
||||
// s_fsm.addTransition(State.Creating, VirtualMachine.Event.MigrationRequested, State.Destroyed);
|
||||
s_fsm.addTransition(State.Running, VirtualMachine.Event.MigrationRequested, State.Migrating);
|
||||
s_fsm.addTransition(State.Running, VirtualMachine.Event.AgentReportRunning, State.Running);
|
||||
s_fsm.addTransition(State.Running, VirtualMachine.Event.AgentReportStopped, State.Stopped);
|
||||
|
||||
@ -156,6 +156,7 @@
|
||||
<lib dir="${jar.dir}">
|
||||
<include name="cloud-*.jar" />
|
||||
<include name="vmware-*.jar" />
|
||||
<exclude name="cloud-servlet-api.jar"/>
|
||||
</lib>
|
||||
<zipfileset dir="${scripts.target.dir}" prefix="WEB-INF/lib/scripts" filemode="555">
|
||||
<include name="**/*" />
|
||||
|
||||
@ -166,7 +166,7 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
|
||||
this.haEnabled = haEnabled;
|
||||
this.mirroredVols = false;
|
||||
this.vncPassword = Long.toHexString(new Random().nextLong());
|
||||
this.state = State.Creating;
|
||||
this.state = State.Stopped;
|
||||
this.accountId = accountId;
|
||||
this.domainId = domainId;
|
||||
this.serviceOfferingId = serviceOfferingId;
|
||||
|
||||
@ -481,7 +481,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
||||
private static boolean isInAssignableState(ConsoleProxyVO proxy) {
|
||||
// console proxies that are in states of being able to serve user VM
|
||||
State state = proxy.getState();
|
||||
if (state == State.Running || state == State.Starting || state == State.Creating || state == State.Migrating) {
|
||||
if (state == State.Running || state == State.Starting || state == State.Migrating) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -599,7 +599,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
||||
}
|
||||
|
||||
public ConsoleProxyVO assignProxyFromStoppedPool(long dataCenterId) {
|
||||
List<ConsoleProxyVO> l = _consoleProxyDao.getProxyListInStates(dataCenterId, State.Creating, State.Starting, State.Stopped, State.Migrating);
|
||||
List<ConsoleProxyVO> l = _consoleProxyDao.getProxyListInStates(dataCenterId, State.Starting, State.Stopped, State.Migrating);
|
||||
if (l != null && l.size() > 0) {
|
||||
return l.get(0);
|
||||
}
|
||||
@ -1047,56 +1047,56 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
||||
}
|
||||
}
|
||||
|
||||
private void checkPendingProxyVMs() {
|
||||
// drive state to change away from transient states
|
||||
List<ConsoleProxyVO> l = _consoleProxyDao.getProxyListInStates(State.Creating);
|
||||
if (l != null && l.size() > 0) {
|
||||
for (ConsoleProxyVO proxy : l) {
|
||||
if (proxy.getLastUpdateTime() == null
|
||||
|| (proxy.getLastUpdateTime() != null && System.currentTimeMillis() - proxy.getLastUpdateTime().getTime() > 60000)) {
|
||||
try {
|
||||
ConsoleProxyVO readyProxy = null;
|
||||
if (_allocProxyLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC)) {
|
||||
try {
|
||||
readyProxy = allocProxyStorage(proxy.getDataCenterId(), proxy.getId());
|
||||
} finally {
|
||||
_allocProxyLock.unlock();
|
||||
}
|
||||
|
||||
if (readyProxy != null) {
|
||||
GlobalLock proxyLock = GlobalLock.getInternLock(getProxyLockName(readyProxy.getId()));
|
||||
try {
|
||||
if (proxyLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC)) {
|
||||
try {
|
||||
readyProxy = start(readyProxy.getId());
|
||||
} finally {
|
||||
proxyLock.unlock();
|
||||
}
|
||||
} else {
|
||||
if (s_logger.isInfoEnabled()) {
|
||||
s_logger.info("Unable to acquire synchronization lock to start console proxy : " + readyProxy.getName());
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
proxyLock.releaseRef();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (s_logger.isInfoEnabled()) {
|
||||
s_logger.info("Unable to acquire synchronization lock to allocate proxy storage, wait for next turn");
|
||||
}
|
||||
}
|
||||
} catch (StorageUnavailableException e) {
|
||||
s_logger.warn("Storage unavailable", e);
|
||||
} catch (InsufficientCapacityException e) {
|
||||
s_logger.warn("insuffiient capacity", e);
|
||||
} catch (ResourceUnavailableException e) {
|
||||
s_logger.debug("Concurrent operation: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// private void checkPendingProxyVMs() {
|
||||
// // drive state to change away from transient states
|
||||
// List<ConsoleProxyVO> l = _consoleProxyDao.getProxyListInStates(State.Creating);
|
||||
// if (l != null && l.size() > 0) {
|
||||
// for (ConsoleProxyVO proxy : l) {
|
||||
// if (proxy.getLastUpdateTime() == null
|
||||
// || (proxy.getLastUpdateTime() != null && System.currentTimeMillis() - proxy.getLastUpdateTime().getTime() > 60000)) {
|
||||
// try {
|
||||
// ConsoleProxyVO readyProxy = null;
|
||||
// if (_allocProxyLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC)) {
|
||||
// try {
|
||||
// readyProxy = allocProxyStorage(proxy.getDataCenterId(), proxy.getId());
|
||||
// } finally {
|
||||
// _allocProxyLock.unlock();
|
||||
// }
|
||||
//
|
||||
// if (readyProxy != null) {
|
||||
// GlobalLock proxyLock = GlobalLock.getInternLock(getProxyLockName(readyProxy.getId()));
|
||||
// try {
|
||||
// if (proxyLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC)) {
|
||||
// try {
|
||||
// readyProxy = start(readyProxy.getId());
|
||||
// } finally {
|
||||
// proxyLock.unlock();
|
||||
// }
|
||||
// } else {
|
||||
// if (s_logger.isInfoEnabled()) {
|
||||
// s_logger.info("Unable to acquire synchronization lock to start console proxy : " + readyProxy.getName());
|
||||
// }
|
||||
// }
|
||||
// } finally {
|
||||
// proxyLock.releaseRef();
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// if (s_logger.isInfoEnabled()) {
|
||||
// s_logger.info("Unable to acquire synchronization lock to allocate proxy storage, wait for next turn");
|
||||
// }
|
||||
// }
|
||||
// } catch (StorageUnavailableException e) {
|
||||
// s_logger.warn("Storage unavailable", e);
|
||||
// } catch (InsufficientCapacityException e) {
|
||||
// s_logger.warn("insuffiient capacity", e);
|
||||
// } catch (ResourceUnavailableException e) {
|
||||
// s_logger.debug("Concurrent operation: " + e.getMessage());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
private Runnable getCapacityScanTask() {
|
||||
return new Runnable() {
|
||||
@ -1144,7 +1144,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
||||
}
|
||||
|
||||
try {
|
||||
checkPendingProxyVMs();
|
||||
// checkPendingProxyVMs();
|
||||
|
||||
// scan default data center first
|
||||
long defaultId = 0;
|
||||
|
||||
@ -12,7 +12,6 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
import javax.persistence.EntityExistsException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
@ -617,7 +616,6 @@ public class OvsNetworkManagerImpl implements OvsNetworkManager {
|
||||
}
|
||||
|
||||
switch (vmState) {
|
||||
case Creating:
|
||||
case Destroyed:
|
||||
case Error:
|
||||
case Migrating:
|
||||
|
||||
@ -248,7 +248,6 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG
|
||||
return;
|
||||
}
|
||||
switch (vmState) {
|
||||
case Creating:
|
||||
case Destroyed:
|
||||
case Error:
|
||||
case Migrating:
|
||||
|
||||
@ -89,7 +89,6 @@ import com.cloud.dc.dao.HostPodDao;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.domain.Domain;
|
||||
import com.cloud.domain.dao.DomainDao;
|
||||
import com.cloud.event.ActionEvent;
|
||||
import com.cloud.event.Event;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.event.EventUtils;
|
||||
@ -438,7 +437,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
|
||||
SearchCriteria<VolumeVO> volumeSC = volumeSB.create();
|
||||
volumeSC.setParameters("poolId", storagePool.getId());
|
||||
volumeSC.setJoinParameters("activeVmSB", "state", new Object[] {State.Creating, State.Starting, State.Running, State.Stopping, State.Migrating});
|
||||
volumeSC.setJoinParameters("activeVmSB", "state", State.Starting, State.Running, State.Stopping, State.Migrating);
|
||||
|
||||
List<VolumeVO> volumes = _volsDao.search(volumeSC, null);
|
||||
if (volumes.size() > 0) {
|
||||
|
||||
@ -337,7 +337,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
||||
s_logger.warn("No storage hosts found in zone " + zoneId + " , skip programming firewall rules");
|
||||
return true;
|
||||
}
|
||||
List<SecondaryStorageVmVO> alreadyRunning = _secStorageVmDao.getSecStorageVmListInStates( State.Running, State.Migrating, State.Creating, State.Starting);
|
||||
List<SecondaryStorageVmVO> alreadyRunning = _secStorageVmDao.getSecStorageVmListInStates( State.Running, State.Migrating, State.Starting);
|
||||
|
||||
String copyPort = Integer.toString(TemplateConstants.DEFAULT_TMPLT_COPY_PORT);
|
||||
SecStorageFirewallCfgCommand cpc = new SecStorageFirewallCfgCommand();
|
||||
@ -525,58 +525,58 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
||||
|
||||
|
||||
|
||||
private void checkPendingSecStorageVMs() {
|
||||
// drive state to change away from transient states
|
||||
List<SecondaryStorageVmVO> l = _secStorageVmDao.getSecStorageVmListInStates(State.Creating);
|
||||
if (l != null && l.size() > 0) {
|
||||
for (SecondaryStorageVmVO secStorageVm : l) {
|
||||
if (secStorageVm.getLastUpdateTime() == null ||
|
||||
(secStorageVm.getLastUpdateTime() != null && System.currentTimeMillis() - secStorageVm.getLastUpdateTime().getTime() > 60000)) {
|
||||
try {
|
||||
SecondaryStorageVmVO readysecStorageVm = null;
|
||||
if (_allocLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC)) {
|
||||
try {
|
||||
readysecStorageVm = allocSecStorageVmStorage(secStorageVm.getDataCenterId(), secStorageVm.getId());
|
||||
} finally {
|
||||
_allocLock.unlock();
|
||||
}
|
||||
|
||||
if (readysecStorageVm != null) {
|
||||
GlobalLock secStorageVmLock = GlobalLock.getInternLock(getSecStorageVmLockName(readysecStorageVm.getId()));
|
||||
try {
|
||||
if (secStorageVmLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC)) {
|
||||
try {
|
||||
readysecStorageVm = start(readysecStorageVm.getId());
|
||||
} finally {
|
||||
secStorageVmLock.unlock();
|
||||
}
|
||||
} else {
|
||||
if (s_logger.isInfoEnabled()) {
|
||||
s_logger.info("Unable to acquire synchronization lock to start secondary storage vm : " + readysecStorageVm.getName());
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
secStorageVmLock.releaseRef();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (s_logger.isInfoEnabled()) {
|
||||
s_logger.info("Unable to acquire synchronization lock to allocate secondary storage vm storage, wait for next turn");
|
||||
}
|
||||
}
|
||||
} catch (StorageUnavailableException e) {
|
||||
s_logger.warn("Storage unavailable", e);
|
||||
} catch (InsufficientCapacityException e) {
|
||||
s_logger.warn("insuffiient capacity", e);
|
||||
} catch (ConcurrentOperationException e) {
|
||||
s_logger.debug("Concurrent operation: " + e.getMessage());
|
||||
} catch (ResourceUnavailableException e) {
|
||||
s_logger.debug("Concurrent operation: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// private void checkPendingSecStorageVMs() {
|
||||
// // drive state to change away from transient states
|
||||
// List<SecondaryStorageVmVO> l = _secStorageVmDao.getSecStorageVmListInStates(State.Creating);
|
||||
// if (l != null && l.size() > 0) {
|
||||
// for (SecondaryStorageVmVO secStorageVm : l) {
|
||||
// if (secStorageVm.getLastUpdateTime() == null ||
|
||||
// (secStorageVm.getLastUpdateTime() != null && System.currentTimeMillis() - secStorageVm.getLastUpdateTime().getTime() > 60000)) {
|
||||
// try {
|
||||
// SecondaryStorageVmVO readysecStorageVm = null;
|
||||
// if (_allocLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC)) {
|
||||
// try {
|
||||
// readysecStorageVm = allocSecStorageVmStorage(secStorageVm.getDataCenterId(), secStorageVm.getId());
|
||||
// } finally {
|
||||
// _allocLock.unlock();
|
||||
// }
|
||||
//
|
||||
// if (readysecStorageVm != null) {
|
||||
// GlobalLock secStorageVmLock = GlobalLock.getInternLock(getSecStorageVmLockName(readysecStorageVm.getId()));
|
||||
// try {
|
||||
// if (secStorageVmLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC)) {
|
||||
// try {
|
||||
// readysecStorageVm = start(readysecStorageVm.getId());
|
||||
// } finally {
|
||||
// secStorageVmLock.unlock();
|
||||
// }
|
||||
// } else {
|
||||
// if (s_logger.isInfoEnabled()) {
|
||||
// s_logger.info("Unable to acquire synchronization lock to start secondary storage vm : " + readysecStorageVm.getName());
|
||||
// }
|
||||
// }
|
||||
// } finally {
|
||||
// secStorageVmLock.releaseRef();
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// if (s_logger.isInfoEnabled()) {
|
||||
// s_logger.info("Unable to acquire synchronization lock to allocate secondary storage vm storage, wait for next turn");
|
||||
// }
|
||||
// }
|
||||
// } catch (StorageUnavailableException e) {
|
||||
// s_logger.warn("Storage unavailable", e);
|
||||
// } catch (InsufficientCapacityException e) {
|
||||
// s_logger.warn("insuffiient capacity", e);
|
||||
// } catch (ConcurrentOperationException e) {
|
||||
// s_logger.debug("Concurrent operation: " + e.getMessage());
|
||||
// } catch (ResourceUnavailableException e) {
|
||||
// s_logger.debug("Concurrent operation: " + e.getMessage());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
private Runnable getCapacityScanTask() {
|
||||
return new Runnable() {
|
||||
@ -616,14 +616,14 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
||||
}
|
||||
|
||||
try {
|
||||
checkPendingSecStorageVMs();
|
||||
//checkPendingSecStorageVMs();
|
||||
|
||||
List<DataCenterVO> datacenters = _dcDao.listAllIncludingRemoved();
|
||||
|
||||
|
||||
for (DataCenterVO dc: datacenters){
|
||||
if(isZoneReady(zoneHostInfoMap, dc.getId())) {
|
||||
List<SecondaryStorageVmVO> alreadyRunning = _secStorageVmDao.getSecStorageVmListInStates(dc.getId(), State.Running, State.Migrating, State.Creating, State.Starting);
|
||||
List<SecondaryStorageVmVO> alreadyRunning = _secStorageVmDao.getSecStorageVmListInStates(dc.getId(), State.Running, State.Migrating, State.Starting);
|
||||
List<SecondaryStorageVmVO> stopped = _secStorageVmDao.getSecStorageVmListInStates(dc.getId(), State.Stopped, State.Stopping);
|
||||
if (alreadyRunning.size() == 0) {
|
||||
if (stopped.size() == 0) {
|
||||
@ -693,7 +693,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
||||
|
||||
public SecondaryStorageVmVO assignSecStorageVmFromStoppedPool(long dataCenterId) {
|
||||
List<SecondaryStorageVmVO> l = _secStorageVmDao.getSecStorageVmListInStates(
|
||||
dataCenterId, State.Creating, State.Starting, State.Stopped,
|
||||
dataCenterId, State.Starting, State.Stopped,
|
||||
State.Migrating);
|
||||
if (l != null && l.size() > 0) {
|
||||
return l.get(0);
|
||||
|
||||
@ -31,7 +31,6 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
import javax.naming.InsufficientResourcesException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
@ -1207,7 +1206,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
return true;
|
||||
}
|
||||
|
||||
if (state == State.Creating || state == State.Destroyed || state == State.Expunging || state == State.Error) {
|
||||
if (state == State.Destroyed || state == State.Expunging || state == State.Error) {
|
||||
s_logger.warn("Stopped called on " + vm.toString() + " but the state is " + state.toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -223,7 +223,6 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager {
|
||||
_storageMgr.allocateRawVolume(VolumeType.DATADISK, "DATA-" + vm.getId(), offering.first(), offering.second(), vm, owner);
|
||||
}
|
||||
|
||||
stateTransitTo(vm, Event.OperationSucceeded, null);
|
||||
txn.commit();
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Allocation completed for VM: " + vm);
|
||||
@ -676,7 +675,7 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (state == State.Creating || state == State.Destroyed || state == State.Expunging || state == State.Error) {
|
||||
if (state == State.Destroyed || state == State.Expunging || state == State.Error) {
|
||||
s_logger.debug("Stopped called on " + vm + " but the state is " + state);
|
||||
return true;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user