use of com.cloud.ha.HaWorkVO in project cloudstack by apache.
the class HighAvailabilityDaoImpl method take.
@Override
public HaWorkVO take(final long serverId) {
final TransactionLegacy txn = TransactionLegacy.currentTxn();
try {
final SearchCriteria<HaWorkVO> sc = TBASearch.create();
sc.setParameters("time", System.currentTimeMillis() >> 10);
sc.setParameters("step", Step.Done, Step.Cancelled);
final Filter filter = new Filter(HaWorkVO.class, null, true, 0l, 1l);
txn.start();
final List<HaWorkVO> vos = lockRows(sc, filter, true);
if (vos.size() == 0) {
txn.commit();
return null;
}
final HaWorkVO work = vos.get(0);
work.setServerId(serverId);
work.setDateTaken(new Date());
update(work.getId(), work);
txn.commit();
return work;
} catch (final Throwable e) {
throw new CloudRuntimeException("Unable to execute take", e);
}
}
use of com.cloud.ha.HaWorkVO in project cloudstack by apache.
the class HighAvailabilityDaoImpl method deleteMigrationWorkItems.
@Override
public void deleteMigrationWorkItems(final long hostId, final WorkType type, final long serverId) {
final SearchCriteria<HaWorkVO> sc = UntakenMigrationSearch.create();
sc.setParameters("host", hostId);
sc.setParameters("type", type.toString());
HaWorkVO work = createForUpdate();
Date date = new Date();
work.setDateTaken(date);
work.setServerId(serverId);
work.setStep(Step.Cancelled);
update(work, sc);
}
use of com.cloud.ha.HaWorkVO in project cloudstack by apache.
the class HighAvailabilityDaoImpl method releaseWorkItems.
@Override
public int releaseWorkItems(long nodeId) {
SearchCriteria<HaWorkVO> sc = ReleaseSearch.create();
sc.setParameters("server", nodeId);
sc.setParameters("step", Step.Done, Step.Cancelled, Step.Error);
HaWorkVO vo = createForUpdate();
vo.setDateTaken(null);
vo.setServerId(null);
return update(vo, sc);
}
Aggregations