Search in sources :

Example 1 with ManagementServerHostPeerVO

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();
    }
}
Also used : TransactionLegacy(com.cloud.utils.db.TransactionLegacy) ManagementServerHostPeerVO(com.cloud.cluster.ManagementServerHostPeerVO) DB(com.cloud.utils.db.DB)

Aggregations

ManagementServerHostPeerVO (com.cloud.cluster.ManagementServerHostPeerVO)1 DB (com.cloud.utils.db.DB)1 TransactionLegacy (com.cloud.utils.db.TransactionLegacy)1