Skip to content

Commit 33d8048

Browse files
author
Kelven Yang
committed
Native HA support improvements
1 parent 1f8c486 commit 33d8048

4 files changed

Lines changed: 23 additions & 4 deletions

File tree

‎server/src/com/cloud/agent/manager/AgentManagerImpl.java‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -702,8 +702,7 @@ public List<? extends Cluster> discoverCluster(AddClusterCmd cmd)
702702
+ discoverer.getName());
703703
}
704704
if (resources != null) {
705-
for (Map.Entry<? extends ServerResource, Map<String, String>> entry : resources
706-
.entrySet()) {
705+
for (Map.Entry<? extends ServerResource, Map<String, String>> entry : resources.entrySet()) {
707706
ServerResource resource = entry.getKey();
708707
AgentAttache attache = simulateStart(resource,
709708
entry.getValue(), true);
@@ -720,8 +719,12 @@ public List<? extends Cluster> discoverCluster(AddClusterCmd cmd)
720719

721720
s_logger.warn("Unable to find the server resources at " + url);
722721
throw new DiscoveryException("Unable to add the external cluster");
722+
} catch(Throwable e) {
723+
s_logger.error("Unexpected exception ", e);
724+
throw new DiscoveryException("Unable to add the external cluster due to unhandled exception");
723725
} finally {
724726
if (!success) {
727+
_clusterDetailsDao.deleteDetails(clusterId);
725728
_clusterDao.remove(clusterId);
726729
}
727730
}

‎server/src/com/cloud/dc/ClusterDetailsDao.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public interface ClusterDetailsDao extends GenericDao<ClusterDetailsVO, Long> {
88
Map<String, String> findDetails(long clusterId);
99

1010
void persist(long clusterId, Map<String, String> details);
11+
void persist(long clusterId, String name, String value);
1112

1213
ClusterDetailsVO findDetail(long clusterId, String name);
1314

‎server/src/com/cloud/dc/ClusterDetailsDaoImpl.java‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,19 @@ public void persist(long clusterId, Map<String, String> details) {
7474
}
7575
txn.commit();
7676
}
77+
78+
@Override
79+
public void persist(long clusterId, String name, String value) {
80+
Transaction txn = Transaction.currentTxn();
81+
txn.start();
82+
SearchCriteria<ClusterDetailsVO> sc = DetailSearch.create();
83+
sc.setParameters("clusterId", clusterId);
84+
sc.setParameters("name", name);
85+
expunge(sc);
86+
87+
ClusterDetailsVO vo = new ClusterDetailsVO(clusterId, name, value);
88+
persist(vo);
89+
txn.commit();
90+
}
91+
7792
}

‎utils/src/com/cloud/utils/nio/Task.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ public String toString() {
8383
public final void run() {
8484
try {
8585
doTask(this);
86-
} catch (Exception e) {
86+
} catch (Throwable e) {
8787
s_logger.warn("Caught the following exception but pushing on", e);
88-
}
88+
}
8989
}
9090
}

0 commit comments

Comments
 (0)