use of com.cloud.cluster.ManagementServerHostPeerVO in project cloudstack by apache.
the class ManagementServerHostPeerDaoImpl method updatePeerInfo.
@Override
@DB
public void updatePeerInfo(long ownerMshost, long peerMshost, long peerRunid, ManagementServerHost.State peerState) {
TransactionLegacy txn = TransactionLegacy.currentTxn();
try {
txn.start();
SearchCriteria<ManagementServerHostPeerVO> sc = FindForUpdateSearch.create();
sc.setParameters("ownerMshost", ownerMshost);
sc.setParameters("peerMshost", peerMshost);
sc.setParameters("peerRunid", peerRunid);
List<ManagementServerHostPeerVO> l = listBy(sc);
if (l.size() == 1) {
ManagementServerHostPeerVO peer = l.get(0);
peer.setPeerState(peerState);
update(peer.getId(), peer);
} else {
ManagementServerHostPeerVO peer = new ManagementServerHostPeerVO(ownerMshost, peerMshost, peerRunid, peerState);
persist(peer);
}
txn.commit();
} catch (Exception e) {
s_logger.warn("Unexpected exception, ", e);
txn.rollback();
}
}
Aggregations