From dd91974920c8a8c6b10010aaa95e5ac6987d4c35 Mon Sep 17 00:00:00 2001 From: Alena Prokharchyk Date: Thu, 11 Jul 2013 17:17:51 -0700 Subject: [PATCH] CLOUDSTACK-2843: added CopyCommand to the list of the commands controlled by execute.in.sequence.hypervisor.commands global config. This command was introduced by the Storage refactoring, and used for volume creation on the primary storage --- .../com/cloud/server/ManagementService.java | 2 ++ .../storage/command/CopyCommand.java | 7 +++++-- .../motion/AncientDataMotionStrategy.java | 19 +++++++++++-------- .../src/com/cloud/configuration/Config.java | 2 +- .../com/cloud/server/ManagementServer.java | 2 -- setup/db/db/schema-410to420.sql | 2 +- 6 files changed, 20 insertions(+), 14 deletions(-) diff --git a/api/src/com/cloud/server/ManagementService.java b/api/src/com/cloud/server/ManagementService.java index 8d00ef202fd..e943a8c008d 100755 --- a/api/src/com/cloud/server/ManagementService.java +++ b/api/src/com/cloud/server/ManagementService.java @@ -371,4 +371,6 @@ public interface ManagementService { List listDeploymentPlanners(); VirtualMachine upgradeSystemVM(ScaleSystemVMCmd cmd) throws ResourceUnavailableException, ManagementServerException, VirtualMachineMigrationException, ConcurrentOperationException; + + boolean getExecuteInSequence(); } diff --git a/engine/api/src/org/apache/cloudstack/storage/command/CopyCommand.java b/engine/api/src/org/apache/cloudstack/storage/command/CopyCommand.java index 852d8013c93..f14f37ebd49 100644 --- a/engine/api/src/org/apache/cloudstack/storage/command/CopyCommand.java +++ b/engine/api/src/org/apache/cloudstack/storage/command/CopyCommand.java @@ -23,12 +23,15 @@ public final class CopyCommand extends Command implements StorageSubSystemComman private DataTO srcTO; private DataTO destTO; private DataTO cacheTO; + boolean executeInSequence = false; - public CopyCommand(DataTO srcData, DataTO destData, int timeout) { + + public CopyCommand(DataTO srcData, DataTO destData, int timeout, boolean executeInSequence) { super(); this.srcTO = srcData; this.destTO = destData; this.setWait(timeout); + this.executeInSequence = executeInSequence; } public DataTO getDestTO() { @@ -41,7 +44,7 @@ public final class CopyCommand extends Command implements StorageSubSystemComman @Override public boolean executeInSequence() { - return true; + return executeInSequence; } public DataTO getCacheTO() { diff --git a/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java b/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java index 04d04363a37..00c693f0b57 100644 --- a/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java +++ b/engine/storage/datamotion/src/org/apache/cloudstack/storage/motion/AncientDataMotionStrategy.java @@ -59,6 +59,7 @@ import com.cloud.configuration.dao.ConfigurationDao; import com.cloud.host.Host; import com.cloud.host.dao.HostDao; import com.cloud.hypervisor.Hypervisor.HypervisorType; +import com.cloud.server.ManagementService; import com.cloud.storage.DataStoreRole; import com.cloud.storage.StorageManager; import com.cloud.storage.StoragePool; @@ -113,6 +114,8 @@ public class AncientDataMotionStrategy implements DataMotionStrategy { VolumeManager volumeMgr; @Inject StorageCacheManager cacheMgr; + @Inject + ManagementService _mgmtServer; @Override public boolean canHandle(DataObject srcData, DataObject destData) { @@ -184,7 +187,7 @@ public class AncientDataMotionStrategy implements DataMotionStrategy { srcForCopy = cacheData = cacheMgr.createCacheObject(srcData, destScope); } - CopyCommand cmd = new CopyCommand(srcForCopy.getTO(), destData.getTO(), _primaryStorageDownloadWait); + CopyCommand cmd = new CopyCommand(srcForCopy.getTO(), destData.getTO(), _primaryStorageDownloadWait, _mgmtServer.getExecuteInSequence()); EndPoint ep = selector.select(srcForCopy, destData); answer = ep.sendMessage(cmd); @@ -242,7 +245,7 @@ public class AncientDataMotionStrategy implements DataMotionStrategy { int _createVolumeFromSnapshotWait = NumbersUtil.parseInt(value, Integer.parseInt(Config.CreateVolumeFromSnapshotWait.getDefaultValue())); - CopyCommand cmd = new CopyCommand(srcData.getTO(), volObj.getTO(), _createVolumeFromSnapshotWait); + CopyCommand cmd = new CopyCommand(srcData.getTO(), volObj.getTO(), _createVolumeFromSnapshotWait, _mgmtServer.getExecuteInSequence()); EndPoint ep = selector.select(snapObj, volObj); Answer answer = ep.sendMessage(cmd); @@ -258,7 +261,7 @@ public class AncientDataMotionStrategy implements DataMotionStrategy { } protected Answer cloneVolume(DataObject template, DataObject volume) { - CopyCommand cmd = new CopyCommand(template.getTO(), volume.getTO(), 0); + CopyCommand cmd = new CopyCommand(template.getTO(), volume.getTO(), 0, _mgmtServer.getExecuteInSequence()); try { EndPoint ep = selector.select(volume.getDataStore()); Answer answer = ep.sendMessage(cmd); @@ -301,7 +304,7 @@ public class AncientDataMotionStrategy implements DataMotionStrategy { objOnImageStore.processEvent(Event.CopyingRequested); - CopyCommand cmd = new CopyCommand(objOnImageStore.getTO(), destData.getTO(), _copyvolumewait); + CopyCommand cmd = new CopyCommand(objOnImageStore.getTO(), destData.getTO(), _copyvolumewait, _mgmtServer.getExecuteInSequence()); EndPoint ep = selector.select(objOnImageStore, destData); answer = ep.sendMessage(cmd); @@ -319,7 +322,7 @@ public class AncientDataMotionStrategy implements DataMotionStrategy { return answer; } else { DataObject cacheData = cacheMgr.createCacheObject(srcData, destScope); - CopyCommand cmd = new CopyCommand(cacheData.getTO(), destData.getTO(), _copyvolumewait); + CopyCommand cmd = new CopyCommand(cacheData.getTO(), destData.getTO(), _copyvolumewait, _mgmtServer.getExecuteInSequence()); EndPoint ep = selector.select(cacheData, destData); Answer answer = ep.sendMessage(cmd); return answer; @@ -376,7 +379,7 @@ public class AncientDataMotionStrategy implements DataMotionStrategy { srcData = cacheSnapshotChain(snapshot); } - CopyCommand cmd = new CopyCommand(srcData.getTO(), destData.getTO(), _createprivatetemplatefromsnapshotwait); + CopyCommand cmd = new CopyCommand(srcData.getTO(), destData.getTO(), _createprivatetemplatefromsnapshotwait, _mgmtServer.getExecuteInSequence()); EndPoint ep = selector.select(srcData, destData); Answer answer = ep.sendMessage(cmd); return answer; @@ -393,12 +396,12 @@ public class AncientDataMotionStrategy implements DataMotionStrategy { if (needCacheStorage(srcData, destData)) { cacheData = cacheMgr.getCacheObject(srcData, destData.getDataStore().getScope()); - CopyCommand cmd = new CopyCommand(srcData.getTO(), destData.getTO(), _backupsnapshotwait); + CopyCommand cmd = new CopyCommand(srcData.getTO(), destData.getTO(), _backupsnapshotwait, _mgmtServer.getExecuteInSequence()); cmd.setCacheTO(cacheData.getTO()); EndPoint ep = selector.select(srcData, destData); answer = ep.sendMessage(cmd); } else { - CopyCommand cmd = new CopyCommand(srcData.getTO(), destData.getTO(), _backupsnapshotwait); + CopyCommand cmd = new CopyCommand(srcData.getTO(), destData.getTO(), _backupsnapshotwait, _mgmtServer.getExecuteInSequence()); EndPoint ep = selector.select(srcData, destData); answer = ep.sendMessage(cmd); } diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java index d3ed7182f80..e77f6ce0403 100755 --- a/server/src/com/cloud/configuration/Config.java +++ b/server/src/com/cloud/configuration/Config.java @@ -432,7 +432,7 @@ public enum Config { "routes", ConfigurationParameterScope.zone.toString()), InternalLbVmServiceOfferingId("Advanced", ManagementServer.class, String.class, "internallbvm.service.offering", null, "Uuid of the service offering used by internal lb vm; if NULL - default system internal lb offering will be used", null), - ExecuteInSequence("Advanced", ManagementServer.class, Boolean.class, "execute.in.sequence.hypervisor.commands", "false", "If set to true, StartCommand, StopCommand, CopyVolumeCommand, CreateCommand will be synchronized on the agent side." + + ExecuteInSequence("Advanced", ManagementServer.class, Boolean.class, "execute.in.sequence.hypervisor.commands", "false", "If set to true, StartCommand, StopCommand, CopyCommand will be synchronized on the agent side." + " If set to false, these commands become asynchronous. Default value is false.", null), ExecuteInSequenceNetworkElementCommands("Advanced", NetworkManager.class, Boolean.class, "execute.in.sequence.network.element.commands", "false", "If set to true, DhcpEntryCommand, SavePasswordCommand, UserDataCommand, VmDataCommand will be synchronized on the agent side." + " If set to false, these commands become asynchronous. Default value is false.", null); diff --git a/server/src/com/cloud/server/ManagementServer.java b/server/src/com/cloud/server/ManagementServer.java index aec1be705dc..f60ce488e10 100755 --- a/server/src/com/cloud/server/ManagementServer.java +++ b/server/src/com/cloud/server/ManagementServer.java @@ -72,6 +72,4 @@ public interface ManagementServer extends ManagementService, PluggableService { String getEncryptionIV(); void resetEncryptionKeyIV(); - boolean getExecuteInSequence(); - } diff --git a/setup/db/db/schema-410to420.sql b/setup/db/db/schema-410to420.sql index 1e9c2012cca..b48ae6a5d85 100644 --- a/setup/db/db/schema-410to420.sql +++ b/setup/db/db/schema-410to420.sql @@ -2153,7 +2153,7 @@ UPDATE `cloud`.`networks` set name='Shared SG enabled network', display_text='Sh INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'use.system.public.ips', 'true', 'If true, when account has dedicated public ip range(s), once the ips dedicated to the account have been consumed ips will be acquired from the system pool'); INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'use.system.guest.vlans', 'true', 'If true, when account has dedicated guest vlan range(s), once the vlans dedicated to the account have been consumed vlans will be allocated from the system pool'); -INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'execute.in.sequence.hypervisor.commands', 'false', 'If set to true, StartCommand, StopCommand, CopyVolumeCommand, CreateCommand will be synchronized on the agent side. If set to false, these commands become asynchronous. Default value is false.'); +INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'execute.in.sequence.hypervisor.commands', 'false', 'If set to true, StartCommand, StopCommand, CopyCommand will be synchronized on the agent side. If set to false, these commands become asynchronous. Default value is false.'); INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'execute.in.sequence.network.element.commands', 'false', 'If set to true, DhcpEntryCommand, SavePasswordCommand, UserDataCommand, VmDataCommand will be synchronized on the agent side. If set to false, these commands become asynchronous. Default value is false.'); INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'management-server', 'direct.agent.scan.interval', 90, 'Time interval (in seconds) to run the direct agent scan task.');