diff --git a/server/src/com/cloud/api/ApiDispatcher.java b/server/src/com/cloud/api/ApiDispatcher.java index 9061dda2275..dfe4a1fc789 100755 --- a/server/src/com/cloud/api/ApiDispatcher.java +++ b/server/src/com/cloud/api/ApiDispatcher.java @@ -63,7 +63,7 @@ public class ApiDispatcher { ComponentLocator _locator; AsyncJobManager _asyncMgr; IdentityDao _identityDao; - long _createSnapshotQueueSizeLimit; + Long _createSnapshotQueueSizeLimit; // singleton class private static ApiDispatcher s_instance = new ApiDispatcher(); @@ -78,7 +78,16 @@ public class ApiDispatcher { _identityDao = _locator.getDao(IdentityDao.class); ConfigurationDao configDao = _locator.getDao(ConfigurationDao.class); Map configs = configDao.getConfiguration(); - _createSnapshotQueueSizeLimit = NumbersUtil.parseInt(configs.get(Config.ConcurrentSnapshotsThresholdPerHost.key()), 10); + String strSnapshotLimit = configs.get(Config.ConcurrentSnapshotsThresholdPerHost.key()); + if (strSnapshotLimit != null) { + Long snapshotLimit = NumbersUtil.parseLong(strSnapshotLimit, 1L); + if (snapshotLimit <= 0) { + s_logger.debug("Global config parameter " + Config.ConcurrentSnapshotsThresholdPerHost.toString() + + " is less or equal 0; defaulting to unlimited"); + } else { + _createSnapshotQueueSizeLimit = snapshotLimit; + } + } } public void dispatchCreateCmd(BaseAsyncCreateCmd cmd, Map params) { @@ -138,14 +147,20 @@ public class ApiDispatcher { ctx.setStartEventId(Long.valueOf(startEventId)); // Synchronise job on the object if needed - if (asyncCmd.getJob() != null && asyncCmd.getSyncObjId() != null && asyncCmd.getSyncObjType() != null) { - long queueSizeLimit = 1; + Long queueSizeLimit = null; if (asyncCmd.getSyncObjType() != null && asyncCmd.getSyncObjType().equalsIgnoreCase(BaseAsyncCmd.snapshotHostSyncObject)) { queueSizeLimit = _createSnapshotQueueSizeLimit; + } else { + queueSizeLimit = 1L; + } + + if (queueSizeLimit != null) { + _asyncMgr.syncAsyncJobExecution(asyncCmd.getJob(), asyncCmd.getSyncObjType(), + asyncCmd.getSyncObjId().longValue(), queueSizeLimit); + } else { + s_logger.trace("The queue size is unlimited, skipping the synchronizing"); } - _asyncMgr.syncAsyncJobExecution(asyncCmd.getJob(), asyncCmd.getSyncObjType(), - asyncCmd.getSyncObjId().longValue(), queueSizeLimit); } } diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java index c214bd02478..66ac2762de1 100755 --- a/server/src/com/cloud/configuration/Config.java +++ b/server/src/com/cloud/configuration/Config.java @@ -350,8 +350,8 @@ public enum Config { VpcCleanupInterval("Advanced", ManagementServer.class, Integer.class, "vpc.cleanup.interval", "3600", "The interval (in seconds) between cleanup for Inactive VPCs", null), VpcMaxNetworks("Advanced", ManagementServer.class, Integer.class, "vpc.max.networks", "3", "Maximum number of networks per vpc", null), - ConcurrentSnapshotsThresholdPerHost("Advanced", ManagementServer.class, String.class, "concurrent.snapshots.threshold.perhost", - "10", "Limits number of snapshots that can be handled by the host concurrently", null); + ConcurrentSnapshotsThresholdPerHost("Advanced", ManagementServer.class, Long.class, "concurrent.snapshots.threshold.perhost", + null, "Limits number of snapshots that can be handled by the host concurrently; default is NULL - unlimited", null); private final String _category;