Fixed up conflicts

This commit is contained in:
Alex Huang 2011-05-12 17:08:49 -07:00
parent 0e602a0308
commit f9278aae05
4 changed files with 70 additions and 75 deletions

View File

@ -354,7 +354,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS
_nodeId = MacAddress.getMacAddress().toLong();
}
_hostDao.markHostsAsDisconnected(_nodeId, Status.Up, Status.Connecting, Status.Updating, Status.Disconnected, Status.Down);
_hostDao.markHostsAsDisconnected(_nodeId);
_monitor = new AgentMonitor(_nodeId, _hostDao, _volDao, _vmDao, _dcDao, _podDao, this, _alertMgr, _pingTimeout);
registerForHostEvents(_monitor, true, true, false);

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");
@ -77,19 +77,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()) {
@ -597,7 +597,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);

View File

@ -188,7 +188,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
SequenceSearch = createSearchBuilder();
SequenceSearch.and("id", SequenceSearch.entity().getId(), SearchCriteria.Op.EQ);
// SequenceSearch.addRetrieve("sequence", SequenceSearch.entity().getSequence());
// SequenceSearch.addRetrieve("sequence", SequenceSearch.entity().getSequence());
SequenceSearch.done();
DirectlyConnectedSearch = createSearchBuilder();
@ -204,7 +204,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
UnmanagedDirectConnectSearch.and("lastPinged", UnmanagedDirectConnectSearch.entity().getLastPinged(), SearchCriteria.Op.LTEQ);
UnmanagedDirectConnectSearch.cp();
UnmanagedDirectConnectSearch.cp();
*/
*/
UnmanagedDirectConnectSearch.done();
DirectConnectSearch = createSearchBuilder();
@ -258,25 +258,25 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
@Override
public HostVO findSecondaryStorageHost(long dcId) {
SearchCriteria<HostVO> sc = TypeDcSearch.create();
sc.setParameters("type", Host.Type.SecondaryStorage);
sc.setParameters("dc", dcId);
List<HostVO> storageHosts = listBy(sc);
SearchCriteria<HostVO> sc = TypeDcSearch.create();
sc.setParameters("type", Host.Type.SecondaryStorage);
sc.setParameters("dc", dcId);
List<HostVO> storageHosts = listBy(sc);
if (storageHosts == null || storageHosts.size() != 1) {
return null;
} else {
return storageHosts.get(0);
}
if (storageHosts == null || storageHosts.size() != 1) {
return null;
} else {
return storageHosts.get(0);
}
}
@Override
public List<HostVO> listSecondaryStorageHosts() {
SearchCriteria<HostVO> sc = TypeSearch.create();
sc.setParameters("type", Host.Type.SecondaryStorage);
List<HostVO> secondaryStorageHosts = listIncludingRemovedBy(sc);
SearchCriteria<HostVO> sc = TypeSearch.create();
sc.setParameters("type", Host.Type.SecondaryStorage);
List<HostVO> secondaryStorageHosts = listIncludingRemovedBy(sc);
return secondaryStorageHosts;
return secondaryStorageHosts;
}
@Override
@ -287,16 +287,15 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
@Override
public List<HostVO> findDirectAgentToLoad(long msid, long lastPingSecondsAfter, Long limit) {
SearchCriteria<HostVO> sc = UnmanagedDirectConnectSearch.create();
sc.setParameters("lastPinged", lastPingSecondsAfter);
SearchCriteria<HostVO> sc = UnmanagedDirectConnectSearch.create();
sc.setParameters("lastPinged", lastPingSecondsAfter);
return search(sc, new Filter(HostVO.class, "clusterId", true, 0L, limit));
}
@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);
@ -426,8 +425,8 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
@Override
public void loadHostTags(HostVO host){
List<String> hostTags = _hostTagsDao.gethostTags(host.getId());
host.setHostTags(hostTags);
List<String> hostTags = _hostTagsDao.gethostTags(host.getId());
host.setHostTags(hostTags);
}
@Override
@ -475,8 +474,8 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
sc.setParameters("status", oldStatus);
sc.setParameters("id", host.getId());
if (newStatus.checkManagementServer()) {
sc.setParameters("ping", oldPingTime);
sc.setParameters("msid", msId);
sc.setParameters("ping", oldPingTime);
sc.setParameters("msid", msId);
}
UpdateBuilder ub = getUpdateBuilder(host);
@ -487,9 +486,9 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
} else {
ub.set(host, _msIdAttr, msId);
}
if( event.equals(Event.Ping) || event.equals(Event.AgentConnected)) {
ub.set(host, _pingTimeAttr, System.currentTimeMillis() >> 10);
}
if( event.equals(Event.Ping) || event.equals(Event.AgentConnected)) {
ub.set(host, _pingTimeAttr, System.currentTimeMillis() >> 10);
}
}
if ( event.equals(Event.ManagementServerDown)) {
ub.set(host, _pingTimeAttr, (( System.currentTimeMillis() >> 10) - ( 10 * 60 )));
@ -498,14 +497,14 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
assert result <= 1 : "How can this update " + result + " rows? ";
if (s_logger.isDebugEnabled() && result == 0) {
HostVO vo = findById(host.getId());
assert vo != null : "How how how? : " + host.getId();
HostVO vo = findById(host.getId());
assert vo != null : "How how how? : " + host.getId();
StringBuilder str = new StringBuilder("Unable to update host for event:").append(event.toString());
str.append(". New=[status=").append(newStatus.toString()).append(":msid=").append(newStatus.lostConnection() ? "null" : msId).append(":lastpinged=").append(host.getLastPinged()).append("]");
str.append("; Old=[status=").append(oldStatus.toString()).append(":msid=").append(msId).append(":lastpinged=").append(oldPingTime).append("]");
str.append("; DB=[status=").append(vo.getStatus().toString()).append(":msid=").append(vo.getManagementServerId()).append(":lastpinged=").append(vo.getLastPinged()).append("]");
s_logger.debug(str.toString());
StringBuilder str = new StringBuilder("Unable to update host for event:").append(event.toString());
str.append(". New=[status=").append(newStatus.toString()).append(":msid=").append(newStatus.lostConnection() ? "null" : msId).append(":lastpinged=").append(host.getLastPinged()).append("]");
str.append("; Old=[status=").append(oldStatus.toString()).append(":msid=").append(msId).append(":lastpinged=").append(oldPingTime).append("]");
str.append("; DB=[status=").append(vo.getStatus().toString()).append(":msid=").append(vo.getManagementServerId()).append(":lastpinged=").append(vo.getLastPinged()).append("]");
s_logger.debug(str.toString());
}
return result > 0;
}
@ -550,7 +549,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
@Override
public List<HostVO> findHostsLike(String hostName) {
SearchCriteria<HostVO> sc = NameLikeSearch.create();
SearchCriteria<HostVO> sc = NameLikeSearch.create();
sc.setParameters("name", "%" + hostName + "%");
return listBy(sc);
}
@ -591,8 +590,8 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
@Override
public List<HostVO> listByStatus(Status... status) {
SearchCriteria<HostVO> sc = StatusSearch.create();
sc.setParameters("status", (Object[])status);
SearchCriteria<HostVO> sc = StatusSearch.create();
sc.setParameters("status", (Object[])status);
return listBy(sc);
}
@ -675,17 +674,17 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
@Override @DB
public List<RunningHostCountInfo> getRunningHostCounts(Date cutTime) {
String sql = "select * from (" +
"select h.data_center_id, h.type, count(*) as count from host as h INNER JOIN mshost as m ON h.mgmt_server_id=m.msid " +
"where h.status='Up' and h.type='SecondaryStorage' and m.last_update > ? " +
"group by h.data_center_id, h.type " +
"UNION ALL " +
"select h.data_center_id, h.type, count(*) as count from host as h INNER JOIN mshost as m ON h.mgmt_server_id=m.msid " +
"where h.status='Up' and h.type='Routing' and m.last_update > ? " +
"group by h.data_center_id, h.type) as t " +
"ORDER by t.data_center_id, t.type";
String sql = "select * from (" +
"select h.data_center_id, h.type, count(*) as count from host as h INNER JOIN mshost as m ON h.mgmt_server_id=m.msid " +
"where h.status='Up' and h.type='SecondaryStorage' and m.last_update > ? " +
"group by h.data_center_id, h.type " +
"UNION ALL " +
"select h.data_center_id, h.type, count(*) as count from host as h INNER JOIN mshost as m ON h.mgmt_server_id=m.msid " +
"where h.status='Up' and h.type='Routing' and m.last_update > ? " +
"group by h.data_center_id, h.type) as t " +
"ORDER by t.data_center_id, t.type";
ArrayList<RunningHostCountInfo> l = new ArrayList<RunningHostCountInfo>();
ArrayList<RunningHostCountInfo> l = new ArrayList<RunningHostCountInfo>();
Transaction txn = Transaction.currentTxn();;
PreparedStatement pstmt = null;
@ -697,12 +696,12 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
ResultSet rs = pstmt.executeQuery();
while(rs.next()) {
RunningHostCountInfo info = new RunningHostCountInfo();
info.setDcId(rs.getLong(1));
info.setHostType(rs.getString(2));
info.setCount(rs.getInt(3));
RunningHostCountInfo info = new RunningHostCountInfo();
info.setDcId(rs.getLong(1));
info.setHostType(rs.getString(2));
info.setCount(rs.getInt(3));
l.add(info);
l.add(info);
}
} catch (SQLException e) {
} catch (Throwable e) {
@ -758,8 +757,5 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
sc.setParameters("statuses", (Object[])statuses);
return customSearch(sc, null);
}
}
}
}