mirror of https://github.com/apache/cloudstack.git
make agent load size configurable
This commit is contained in:
parent
1e797c6ecb
commit
02bd10ae09
|
|
@ -33,6 +33,8 @@ import com.cloud.cluster.ClusterManager;
|
|||
import com.cloud.cluster.ClusterManagerListener;
|
||||
import com.cloud.cluster.ManagementServerHostVO;
|
||||
import com.cloud.cluster.dao.ManagementServerHostDao;
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Status;
|
||||
|
|
@ -40,6 +42,8 @@ import com.cloud.host.Status.Event;
|
|||
import com.cloud.resource.ResourceService;
|
||||
import com.cloud.resource.ServerResource;
|
||||
import com.cloud.storage.resource.DummySecondaryStorageResource;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.GlobalLock;
|
||||
|
|
@ -56,7 +60,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
|
|||
public final static long STARTUP_DELAY = 5000;
|
||||
public final static long SCAN_INTERVAL = 90000; // 90 seconds, it takes 60 sec for xenserver to fail login
|
||||
public final static int ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_COOPERATION = 5; // 5 seconds
|
||||
public final static long LOAD_SIZE = 100;
|
||||
public long _loadSize = 100;
|
||||
|
||||
@Inject protected ClusterManager _clusterMgr = null;
|
||||
|
||||
|
|
@ -70,15 +74,20 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
public boolean configure(String name, Map<String, Object> xmlParams) throws ConfigurationException {
|
||||
_peers = new HashMap<String, SocketChannel>(7);
|
||||
_nodeId = _clusterMgr.getManagementNodeId();
|
||||
|
||||
ConfigurationDao configDao = ComponentLocator.getCurrentLocator().getDao(ConfigurationDao.class);
|
||||
Map<String, String> params = configDao.getConfiguration(xmlParams);
|
||||
String value = params.get(Config.DirectAgentLoadSize.key());
|
||||
_loadSize = NumbersUtil.parseInt(value, 16);
|
||||
|
||||
ClusteredAgentAttache.initialize(this);
|
||||
|
||||
_clusterMgr.registerListener(this);
|
||||
|
||||
return super.configure(name, params);
|
||||
return super.configure(name, xmlParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -112,11 +121,11 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
|
|||
|
||||
// for agents that are self-managed, threshold to be considered as disconnected is 3 ping intervals
|
||||
long cutSeconds = (System.currentTimeMillis() >> 10) - (_pingInterval*3);
|
||||
List<HostVO> hosts = _hostDao.findDirectAgentToLoad(_clusterMgr.getManagementNodeId(), cutSeconds, LOAD_SIZE);
|
||||
if ( hosts != null && hosts.size() == LOAD_SIZE ) {
|
||||
Long clusterId = hosts.get((int)(LOAD_SIZE-1)).getClusterId();
|
||||
List<HostVO> hosts = _hostDao.findDirectAgentToLoad(_clusterMgr.getManagementNodeId(), cutSeconds, _loadSize);
|
||||
if ( hosts != null && hosts.size() == _loadSize ) {
|
||||
Long clusterId = hosts.get((int)(_loadSize-1)).getClusterId();
|
||||
if ( clusterId != null) {
|
||||
for ( int i = (int)(LOAD_SIZE-1); i > 0; i-- ) {
|
||||
for ( int i = (int)(_loadSize-1); i > 0; i-- ) {
|
||||
if ( hosts.get(i).getClusterId() == clusterId ) {
|
||||
hosts.remove(i);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -227,7 +227,8 @@ public enum Config {
|
|||
DefaultMaxAccountPublicIPs("Account Defaults", ManagementServer.class, Long.class, "max.account.public.ips", "20", "The default maximum number of public IPs that can be consumed by an account", null),
|
||||
DefaultMaxAccountTemplates("Account Defaults", ManagementServer.class, Long.class, "max.account.templates", "20", "The default maximum number of templates that can be deployed for an account", null),
|
||||
DefaultMaxAccountSnapshots("Account Defaults", ManagementServer.class, Long.class, "max.account.snapshots", "20", "The default maximum number of snapshots that can be created for an account", null),
|
||||
DefaultMaxAccountVolumes("Account Defaults", ManagementServer.class, Long.class, "max.account.volumes", "20", "The default maximum number of volumes that can be created for an account", null);
|
||||
DefaultMaxAccountVolumes("Account Defaults", ManagementServer.class, Long.class, "max.account.volumes", "20", "The default maximum number of volumes that can be created for an account", null),
|
||||
DirectAgentLoadSize("Advanced", ManagementServer.class, Integer.class, "direct.agent.load.size", "16", "The number of direct agents to load each time", null);
|
||||
|
||||
private final String _category;
|
||||
private final Class<?> _componentClass;
|
||||
|
|
|
|||
Loading…
Reference in New Issue