mirror of https://github.com/apache/cloudstack.git
global replacement to avoid using getClass().getName() for unique names
This commit is contained in:
parent
c7e120a72e
commit
7103e1c9a7
|
|
@ -91,7 +91,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
|
|||
}
|
||||
|
||||
private void runDirectAgentScanTimerTask() {
|
||||
GlobalLock scanLock = GlobalLock.getInternLock(this.getClass().getName());
|
||||
GlobalLock scanLock = GlobalLock.getInternLock("clustermgr.scan");
|
||||
try {
|
||||
if(scanLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_COOPERATION)) {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -74,7 +74,6 @@ import com.cloud.exception.StorageUnavailableException;
|
|||
import com.cloud.host.Host.Type;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.info.ConsoleProxyConnectionInfo;
|
||||
import com.cloud.info.ConsoleProxyInfo;
|
||||
|
|
@ -1024,17 +1023,6 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||
|
||||
@Override
|
||||
public boolean stopProxy(long proxyVmId) {
|
||||
|
||||
// AsyncJobExecutor asyncExecutor = BaseAsyncJobExecutor.getCurrentExecutor();
|
||||
// if (asyncExecutor != null) {
|
||||
// AsyncJobVO job = asyncExecutor.getJob();
|
||||
//
|
||||
// if (s_logger.isInfoEnabled()) {
|
||||
// s_logger.info("Stop console proxy " + proxyVmId + ", update async job-" + job.getId());
|
||||
// }
|
||||
// _asyncMgr.updateAsyncJobAttachment(job.getId(), "console_proxy", proxyVmId);
|
||||
// }
|
||||
|
||||
ConsoleProxyVO proxy = _consoleProxyDao.findById(proxyVmId);
|
||||
if (proxy == null) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
|
|
@ -1042,11 +1030,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||
}
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
* saveStartedEvent(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM,
|
||||
* EventTypes.EVENT_PROXY_STOP, "Stopping console proxy with Id: " +
|
||||
* proxyVmId, startEventId);
|
||||
*/
|
||||
|
||||
try {
|
||||
return _itMgr.stop(proxy, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount());
|
||||
} catch (ResourceUnavailableException e) {
|
||||
|
|
@ -1057,16 +1041,6 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||
|
||||
@Override
|
||||
public boolean rebootProxy(long proxyVmId) {
|
||||
// AsyncJobExecutor asyncExecutor = BaseAsyncJobExecutor.getCurrentExecutor();
|
||||
// if (asyncExecutor != null) {
|
||||
// AsyncJobVO job = asyncExecutor.getJob();
|
||||
//
|
||||
// if (s_logger.isInfoEnabled()) {
|
||||
// s_logger.info("Reboot console proxy " + proxyVmId + ", update async job-" + job.getId());
|
||||
// }
|
||||
// _asyncMgr.updateAsyncJobAttachment(job.getId(), "console_proxy", proxyVmId);
|
||||
// }
|
||||
|
||||
final ConsoleProxyVO proxy = _consoleProxyDao.findById(proxyVmId);
|
||||
|
||||
if (proxy == null || proxy.getState() == State.Destroyed) {
|
||||
|
|
@ -1423,6 +1397,11 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||
public void finalizeStop(VirtualMachineProfile<ConsoleProxyVO> profile, StopAnswer answer) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getScanHandlerName() {
|
||||
return "consoleproxy";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScanStart() {
|
||||
// to reduce possible number of DB queries for capacity scan, we run following aggregated queries in preparation stage
|
||||
|
|
|
|||
|
|
@ -1822,7 +1822,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
|||
|
||||
@Override
|
||||
public void cleanupStorage(boolean recurring) {
|
||||
GlobalLock scanLock = GlobalLock.getInternLock(this.getClass().getName());
|
||||
GlobalLock scanLock = GlobalLock.getInternLock("storagemgr.cleanup");
|
||||
|
||||
try {
|
||||
if (scanLock.lock(3)) {
|
||||
|
|
|
|||
|
|
@ -702,17 +702,6 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
|||
|
||||
@Override
|
||||
public boolean stopSecStorageVm(long secStorageVmId) {
|
||||
|
||||
// AsyncJobExecutor asyncExecutor = BaseAsyncJobExecutor.getCurrentExecutor();
|
||||
// if (asyncExecutor != null) {
|
||||
// AsyncJobVO job = asyncExecutor.getJob();
|
||||
//
|
||||
// if (s_logger.isInfoEnabled()) {
|
||||
// s_logger.info("Stop secondary storage vm " + secStorageVmId + ", update async job-" + job.getId());
|
||||
// }
|
||||
// _asyncMgr.updateAsyncJobAttachment(job.getId(), "secStorageVm", secStorageVmId);
|
||||
// }
|
||||
|
||||
SecondaryStorageVmVO secStorageVm = _secStorageVmDao.findById(secStorageVmId);
|
||||
if (secStorageVm == null) {
|
||||
String msg = "Stopping secondary storage vm failed: secondary storage vm " + secStorageVmId + " no longer exists";
|
||||
|
|
@ -757,16 +746,6 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
|||
|
||||
@Override
|
||||
public boolean rebootSecStorageVm(long secStorageVmId) {
|
||||
// AsyncJobExecutor asyncExecutor = BaseAsyncJobExecutor.getCurrentExecutor();
|
||||
// if (asyncExecutor != null) {
|
||||
// AsyncJobVO job = asyncExecutor.getJob();
|
||||
//
|
||||
// if (s_logger.isInfoEnabled()) {
|
||||
// s_logger.info("Reboot secondary storage vm " + secStorageVmId + ", update async job-" + job.getId());
|
||||
// }
|
||||
// _asyncMgr.updateAsyncJobAttachment(job.getId(), "secstorage_vm", secStorageVmId);
|
||||
// }
|
||||
|
||||
final SecondaryStorageVmVO secStorageVm = _secStorageVmDao.findById(secStorageVmId);
|
||||
|
||||
if (secStorageVm == null || secStorageVm.getState() == State.Destroyed) {
|
||||
|
|
@ -1003,6 +982,11 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
|||
public void finalizeExpunge(SecondaryStorageVmVO vm) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getScanHandlerName() {
|
||||
return "secstorage";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canScan() {
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ public class SnapshotSchedulerImpl implements SnapshotScheduler {
|
|||
// We don't maintain the time. The timer task does.
|
||||
_currentTimestamp = currentTimestamp;
|
||||
|
||||
GlobalLock scanLock = GlobalLock.getInternLock(this.getClass().getName());
|
||||
GlobalLock scanLock = GlobalLock.getInternLock("snapshot.poll");
|
||||
try {
|
||||
if(scanLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_COOPERATION)) {
|
||||
try {
|
||||
|
|
@ -121,7 +121,7 @@ public class SnapshotSchedulerImpl implements SnapshotScheduler {
|
|||
scanLock.releaseRef();
|
||||
}
|
||||
|
||||
scanLock = GlobalLock.getInternLock(this.getClass().getName());
|
||||
scanLock = GlobalLock.getInternLock("snapshot.poll");
|
||||
try {
|
||||
if(scanLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_COOPERATION)) {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -424,7 +424,7 @@ public class UploadMonitorImpl implements UploadMonitor {
|
|||
try {
|
||||
s_logger.info("Extract Monitor Garbage Collection Thread is running.");
|
||||
|
||||
GlobalLock scanLock = GlobalLock.getInternLock(this.getClass().getName());
|
||||
GlobalLock scanLock = GlobalLock.getInternLock("uploadmonitor.storageGC");
|
||||
try {
|
||||
if (scanLock.lock(3)) {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import com.cloud.utils.Pair;
|
|||
import com.cloud.vm.SystemVmLoadScanner.AfterScanAction;
|
||||
|
||||
public interface SystemVmLoadScanHandler<T> {
|
||||
String getScanHandlerName();
|
||||
boolean canScan();
|
||||
|
||||
void onScanStart();
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public class SystemVmLoadScanner<T> {
|
|||
public SystemVmLoadScanner(SystemVmLoadScanHandler<T> scanHandler) {
|
||||
_scanHandler = scanHandler;
|
||||
_capacityScanScheduler = Executors.newScheduledThreadPool(1, new NamedThreadFactory(scanHandler.getClass().getSimpleName()));
|
||||
_capacityScanLock = GlobalLock.getInternLock(scanHandler.getClass().getSimpleName() + ".scan.lock");
|
||||
_capacityScanLock = GlobalLock.getInternLock(scanHandler.getScanHandlerName() + ".scan.lock");
|
||||
}
|
||||
|
||||
public void initScan(long startupDelayMs, long scanIntervalMs) {
|
||||
|
|
|
|||
|
|
@ -1125,7 +1125,7 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
|
|||
|
||||
|
||||
protected void cancelWorkItems(long nodeId) {
|
||||
GlobalLock scanLock = GlobalLock.getInternLock(this.getClass().getName());
|
||||
GlobalLock scanLock = GlobalLock.getInternLock("vmmgr.cancel.workitem");
|
||||
|
||||
try {
|
||||
if (scanLock.lock(3)) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue