Removed the check for statuses in marking hosts as disconnected

This commit is contained in:
Alex Huang 2011-05-12 16:48:02 -07:00
parent 8ac4605a0f
commit 028f12f1b9
4 changed files with 43 additions and 45 deletions

View File

@ -329,7 +329,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS
_nodeId = ManagementServerNode.getManagementServerId();
_hostDao.markHostsAsDisconnected(_nodeId, Status.Up, Status.Connecting, Status.Updating, Status.Disconnected, Status.Down);
_hostDao.markHostsAsDisconnected(_nodeId);
_monitor = new AgentMonitor(_nodeId, _hostDao, _vmDao, _dcDao, _podDao, this, _alertMgr, _pingTimeout);
registerForHostEvents(_monitor, true, true, false);
@ -1206,7 +1206,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS
_accountMgr.checkAccessAndSpecifyAuthority(UserContext.current().getCaller(), host.getDataCenterId());
return deleteHost(hostId, isForced, caller);
}
@Override
public boolean updateHostPassword(UpdateHostPasswordCmd cmd){
List<HostVO> hosts = _hostDao.listByCluster(cmd.getClusterId());
@ -1289,7 +1289,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS
}
return true;
}
@DB
protected boolean deleteSecondaryStorageHost(HostVO secStorageHost) {
@ -2480,9 +2480,9 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS
if (!handled) {
server = createHost(startup, null, null, false, null, null);
} else {
server = _hostDao.findByGuid(startup[0].getGuid());
server = _hostDao.findByGuid(startup[0].getGuid());
}
if (server == null) {
return null;
}
@ -2500,7 +2500,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS
return _agents.get(hostId);
}
}
protected AgentAttache createAttache(long id, HostVO server, Link link) {
s_logger.debug("create ConnectedAgentAttache for " + id);
final AgentAttache attache = new ConnectedAgentAttache(this, id, link, server.getStatus() == Status.Maintenance || server.getStatus() == Status.ErrorInMaintenance

View File

@ -56,14 +56,14 @@ import com.cloud.utils.nio.Task;
@Local(value = { AgentManager.class, ResourceService.class })
public class ClusteredAgentManagerImpl extends AgentManagerImpl implements ClusterManagerListener {
final static Logger s_logger = Logger.getLogger(ClusteredAgentManagerImpl.class);
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 long _loadSize = 100;
@Inject protected ClusterManager _clusterMgr = null;
protected HashMap<String, SocketChannel> _peers;
private final Timer _timer = new Timer("ClusteredAgentManager Timer");
@ -78,19 +78,19 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
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, xmlParams);
}
@Override
public boolean start() {
if (!super.start()) {
@ -603,7 +603,7 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
public void onManagementNodeLeft(List<ManagementServerHostVO> nodeList, long selfNodeId) {
for (ManagementServerHostVO vo : nodeList) {
s_logger.info("Marking hosts as disconnected on Management server" + vo.getMsid());
_hostDao.markHostsAsDisconnected(vo.getMsid(), Status.Up, Status.Connecting, Status.Updating, Status.Disconnected, Status.Down);
_hostDao.markHostsAsDisconnected(vo.getMsid());
}
}

View File

@ -49,16 +49,15 @@ public interface HostDao extends GenericDao<HostVO, Long> {
* Lists all secondary storage hosts, across all zones
* @return list of Hosts
*/
List<HostVO> listSecondaryStorageHosts();
/**
* Mark all hosts in Up or Orphaned state as disconnected. This method
* is used at AgentManager startup to reset all of the connections.
*
* @param msId management server id.
* @param statuses states of the host.
*/
void markHostsAsDisconnected(long msId, Status... states);
List<HostVO> listSecondaryStorageHosts();
/**
* Mark all hosts associated with a certain management server
* as disconnected.
*
* @param msId management server id.
*/
void markHostsAsDisconnected(long msId);
List<HostVO> findLostHosts(long timeout);
@ -96,9 +95,9 @@ public interface HostDao extends GenericDao<HostVO, Long> {
* @return HostVO or null if not found.
*/
public HostVO findByGuid(String macAddress);
public HostVO findByName(String name);
/**
* find all hosts of a certain type in a data center
@ -139,7 +138,7 @@ public interface HostDao extends GenericDao<HostVO, Long> {
long getNextSequence(long hostId);
void loadDetails(HostVO host);
void saveDetails(HostVO host);
HostVO findConsoleProxyHost(String name, Type type);
@ -162,10 +161,10 @@ public interface HostDao extends GenericDao<HostVO, Long> {
void loadHostTags(HostVO host);
List<HostVO> listByHostTag(Host.Type type, Long clusterId, Long podId, long dcId, String hostTag);
long countRoutingHostsByDataCenter(long dcId);
List<HostVO> listSecondaryStorageHosts(long dataCenterId);
List<HostVO> listSecondaryStorageHosts(long dataCenterId);
boolean directConnect(HostVO host, long msId, boolean secondConnect);

View File

@ -91,7 +91,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
protected final GenericSearchBuilder<HostVO, Long> HostsInStatusSearch;
protected final GenericSearchBuilder<HostVO, Long> CountRoutingByDc;
protected final Attribute _statusAttr;
protected final Attribute _msIdAttr;
protected final Attribute _pingTimeAttr;
@ -188,11 +188,11 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
NameLikeSearch = createSearchBuilder();
NameLikeSearch.and("name", NameLikeSearch.entity().getName(), SearchCriteria.Op.LIKE);
NameLikeSearch.done();
NameSearch = createSearchBuilder();
NameSearch.and("name", NameSearch.entity().getName(), SearchCriteria.Op.EQ);
NameSearch.done();
SequenceSearch = createSearchBuilder();
SequenceSearch.and("id", SequenceSearch.entity().getId(), SearchCriteria.Op.EQ);
// SequenceSearch.addRetrieve("sequence", SequenceSearch.entity().getSequence());
@ -244,14 +244,14 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
HostsInStatusSearch.and("type", HostsInStatusSearch.entity().getType(), Op.EQ);
HostsInStatusSearch.and("statuses", HostsInStatusSearch.entity().getStatus(), Op.IN);
HostsInStatusSearch.done();
CountRoutingByDc = createSearchBuilder(Long.class);
CountRoutingByDc.select(null, Func.COUNT, null);
CountRoutingByDc.and("dc", CountRoutingByDc.entity().getDataCenterId(), SearchCriteria.Op.EQ);
CountRoutingByDc.and("type", CountRoutingByDc.entity().getType(), SearchCriteria.Op.EQ);
CountRoutingByDc.and("status", CountRoutingByDc.entity().getStatus(), SearchCriteria.Op.EQ);
CountRoutingByDc.done();
CountRoutingByDc.done();
_statusAttr = _allAttributes.get("status");
_msIdAttr = _allAttributes.get("managementServerId");
_pingTimeAttr = _allAttributes.get("lastPinged");
@ -276,7 +276,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
sc.setParameters("type", Host.Type.SecondaryStorage);
sc.setParameters("dc", dcId);
List<HostVO> storageHosts = listBy(sc);
if (storageHosts == null || storageHosts.size() < 1) {
return null;
} else {
@ -307,10 +307,9 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
}
@Override
public void markHostsAsDisconnected(long msId, Status... states) {
public void markHostsAsDisconnected(long msId) {
SearchCriteria<HostVO> sc = MsStatusSearch.create();
sc.setParameters("ms", msId);
sc.setParameters("statuses", (Object[])states);
HostVO host = createForUpdate();
host.setManagementServerId(null);
@ -553,8 +552,8 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
SearchCriteria<HostVO> sc = GuidSearch.create("guid", guid);
return findOneBy(sc);
}
@Override
@Override
public HostVO findByName(String name) {
SearchCriteria<HostVO> sc = NameSearch.create("name", name);
return findOneBy(sc);
@ -780,7 +779,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
return customSearch(sc, null);
}
@Override
public long countRoutingHostsByDataCenter(long dcId){
SearchCriteria<Long> sc = CountRoutingByDc.create();
@ -788,7 +787,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
sc.setParameters("type", Host.Type.Routing);
sc.setParameters("status", Status.Up.toString());
return customSearch(sc, null).get(0);
}
}
@Override
public List<HostVO> listSecondaryStorageHosts(long dataCenterId) {
@ -796,16 +795,16 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
sc.setParameters("type", Host.Type.SecondaryStorage);
sc.setParameters("dc", dataCenterId);
List<HostVO> secondaryStorageHosts = listIncludingRemovedBy(sc);
return secondaryStorageHosts;
}
@Override
public HostVO findTrafficMonitorHost() {
SearchCriteria<HostVO> sc = TypeSearch.create();
sc.setParameters("type", Host.Type.TrafficMonitor);
List<HostVO> trafficHosts = listBy(sc);
if (trafficHosts == null || trafficHosts.size() < 1) {
return null;
} else {