use of com.cloud.utils.db.UpdateBuilder in project cloudstack by apache.
the class EngineClusterDaoImpl method updateState.
@Override
public boolean updateState(State currentState, Event event, State nextState, DataCenterResourceEntity clusterEntity, Object data) {
EngineClusterVO vo = findById(clusterEntity.getId());
Date oldUpdatedTime = vo.getLastUpdated();
SearchCriteria<EngineClusterVO> sc = StateChangeSearch.create();
sc.setParameters("id", vo.getId());
sc.setParameters("state", currentState);
UpdateBuilder builder = getUpdateBuilder(vo);
builder.set(vo, "state", nextState);
builder.set(vo, "lastUpdated", new Date());
int rows = update(vo, sc);
if (rows == 0 && s_logger.isDebugEnabled()) {
EngineClusterVO dbCluster = findByIdIncludingRemoved(vo.getId());
if (dbCluster != null) {
StringBuilder str = new StringBuilder("Unable to update ").append(vo.toString());
str.append(": DB Data={id=").append(dbCluster.getId()).append("; state=").append(dbCluster.getState()).append(";updatedTime=").append(dbCluster.getLastUpdated());
str.append(": New Data={id=").append(vo.getId()).append("; state=").append(nextState).append("; event=").append(event).append("; updatedTime=").append(vo.getLastUpdated());
str.append(": stale Data={id=").append(vo.getId()).append("; state=").append(currentState).append("; event=").append(event).append("; updatedTime=").append(oldUpdatedTime);
} else {
s_logger.debug("Unable to update dataCenter: id=" + vo.getId() + ", as there is no such dataCenter exists in the database anymore");
}
}
return rows > 0;
}
use of com.cloud.utils.db.UpdateBuilder in project cloudstack by apache.
the class ConsoleProxyDaoImpl method remove.
@Override
public boolean remove(Long id) {
TransactionLegacy txn = TransactionLegacy.currentTxn();
txn.start();
ConsoleProxyVO proxy = createForUpdate();
proxy.setPublicIpAddress(null);
proxy.setPrivateIpAddress(null);
UpdateBuilder ub = getUpdateBuilder(proxy);
ub.set(proxy, "state", State.Destroyed);
ub.set(proxy, "privateIpAddress", null);
update(id, ub, proxy);
boolean result = super.remove(id);
txn.commit();
return result;
}
use of com.cloud.utils.db.UpdateBuilder in project cloudstack by apache.
the class SnapshotDataStoreDaoImpl method updateVolumeIds.
@Override
public void updateVolumeIds(long oldVolId, long newVolId) {
SearchCriteria<SnapshotDataStoreVO> sc = volumeIdSearch.create();
sc.setParameters("volume_id", oldVolId);
SnapshotDataStoreVO snapshot = createForUpdate();
snapshot.setVolumeId(newVolId);
UpdateBuilder ub = getUpdateBuilder(snapshot);
update(ub, sc, null);
}
use of com.cloud.utils.db.UpdateBuilder in project cloudstack by apache.
the class SnapshotDataStoreDaoImpl method updateState.
@Override
public boolean updateState(State currentState, Event event, State nextState, DataObjectInStore vo, Object data) {
SnapshotDataStoreVO dataObj = (SnapshotDataStoreVO) vo;
Long oldUpdated = dataObj.getUpdatedCount();
Date oldUpdatedTime = dataObj.getUpdated();
SearchCriteria<SnapshotDataStoreVO> sc = updateStateSearch.create();
sc.setParameters("id", dataObj.getId());
sc.setParameters("state", currentState);
sc.setParameters("updatedCount", dataObj.getUpdatedCount());
dataObj.incrUpdatedCount();
UpdateBuilder builder = getUpdateBuilder(dataObj);
builder.set(dataObj, "state", nextState);
builder.set(dataObj, "updated", new Date());
int rows = update(dataObj, sc);
if (rows == 0 && s_logger.isDebugEnabled()) {
SnapshotDataStoreVO dbVol = findByIdIncludingRemoved(dataObj.getId());
if (dbVol != null) {
StringBuilder str = new StringBuilder("Unable to update ").append(dataObj.toString());
str.append(": DB Data={id=").append(dbVol.getId()).append("; state=").append(dbVol.getState()).append("; updatecount=").append(dbVol.getUpdatedCount()).append(";updatedTime=").append(dbVol.getUpdated());
str.append(": New Data={id=").append(dataObj.getId()).append("; state=").append(nextState).append("; event=").append(event).append("; updatecount=").append(dataObj.getUpdatedCount()).append("; updatedTime=").append(dataObj.getUpdated());
str.append(": stale Data={id=").append(dataObj.getId()).append("; state=").append(currentState).append("; event=").append(event).append("; updatecount=").append(oldUpdated).append("; updatedTime=").append(oldUpdatedTime);
} else {
s_logger.debug("Unable to update objectIndatastore: id=" + dataObj.getId() + ", as there is no such object exists in the database anymore");
}
}
return rows > 0;
}
use of com.cloud.utils.db.UpdateBuilder in project cloudstack by apache.
the class TemplateDataStoreDaoImpl method updateState.
@Override
public boolean updateState(State currentState, Event event, State nextState, DataObjectInStore vo, Object data) {
TemplateDataStoreVO dataObj = (TemplateDataStoreVO) vo;
Long oldUpdated = dataObj.getUpdatedCount();
Date oldUpdatedTime = dataObj.getUpdated();
SearchCriteria<TemplateDataStoreVO> sc = updateStateSearch.create();
sc.setParameters("id", dataObj.getId());
sc.setParameters("state", currentState);
sc.setParameters("updatedCount", dataObj.getUpdatedCount());
dataObj.incrUpdatedCount();
UpdateBuilder builder = getUpdateBuilder(dataObj);
builder.set(dataObj, "state", nextState);
builder.set(dataObj, "updated", new Date());
if (nextState == State.Destroyed) {
builder.set(dataObj, "destroyed", true);
}
int rows = update(dataObj, sc);
if (rows == 0 && s_logger.isDebugEnabled()) {
TemplateDataStoreVO dbVol = findByIdIncludingRemoved(dataObj.getId());
if (dbVol != null) {
StringBuilder str = new StringBuilder("Unable to update ").append(dataObj.toString());
str.append(": DB Data={id=").append(dbVol.getId()).append("; state=").append(dbVol.getState()).append("; updatecount=").append(dbVol.getUpdatedCount()).append(";updatedTime=").append(dbVol.getUpdated());
str.append(": New Data={id=").append(dataObj.getId()).append("; state=").append(nextState).append("; event=").append(event).append("; updatecount=").append(dataObj.getUpdatedCount()).append("; updatedTime=").append(dataObj.getUpdated());
str.append(": stale Data={id=").append(dataObj.getId()).append("; state=").append(currentState).append("; event=").append(event).append("; updatecount=").append(oldUpdated).append("; updatedTime=").append(oldUpdatedTime);
} else {
s_logger.debug("Unable to update objectIndatastore: id=" + dataObj.getId() + ", as there is no such object exists in the database anymore");
}
}
return rows > 0;
}
Aggregations