Native HA support improvements

This commit is contained in:
Kelven Yang 2011-02-04 14:30:51 -08:00
parent 1f8c4864d6
commit 33d804846f
4 changed files with 23 additions and 4 deletions

View File

@ -702,8 +702,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory,
+ discoverer.getName());
}
if (resources != null) {
for (Map.Entry<? extends ServerResource, Map<String, String>> entry : resources
.entrySet()) {
for (Map.Entry<? extends ServerResource, Map<String, String>> entry : resources.entrySet()) {
ServerResource resource = entry.getKey();
AgentAttache attache = simulateStart(resource,
entry.getValue(), true);
@ -720,8 +719,12 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory,
s_logger.warn("Unable to find the server resources at " + url);
throw new DiscoveryException("Unable to add the external cluster");
} catch(Throwable e) {
s_logger.error("Unexpected exception ", e);
throw new DiscoveryException("Unable to add the external cluster due to unhandled exception");
} finally {
if (!success) {
_clusterDetailsDao.deleteDetails(clusterId);
_clusterDao.remove(clusterId);
}
}

View File

@ -8,6 +8,7 @@ public interface ClusterDetailsDao extends GenericDao<ClusterDetailsVO, Long> {
Map<String, String> findDetails(long clusterId);
void persist(long clusterId, Map<String, String> details);
void persist(long clusterId, String name, String value);
ClusterDetailsVO findDetail(long clusterId, String name);

View File

@ -74,4 +74,19 @@ public class ClusterDetailsDaoImpl extends GenericDaoBase<ClusterDetailsVO, Long
}
txn.commit();
}
@Override
public void persist(long clusterId, String name, String value) {
Transaction txn = Transaction.currentTxn();
txn.start();
SearchCriteria<ClusterDetailsVO> sc = DetailSearch.create();
sc.setParameters("clusterId", clusterId);
sc.setParameters("name", name);
expunge(sc);
ClusterDetailsVO vo = new ClusterDetailsVO(clusterId, name, value);
persist(vo);
txn.commit();
}
}

View File

@ -83,8 +83,8 @@ public abstract class Task implements Runnable {
public final void run() {
try {
doTask(this);
} catch (Exception e) {
} catch (Throwable e) {
s_logger.warn("Caught the following exception but pushing on", e);
}
}
}
}