public void set(Object entity, String name, Object value) { Attribute attr = makeChange(name, value); set(entity, attr, value); }
@Override public boolean updateState(com.cloud.storage.Volume.State currentState, Event event, com.cloud.storage.Volume.State nextState, Volume vo, Object data) { Long oldUpdated = vo.getUpdatedCount(); Date oldUpdatedTime = vo.getUpdated(); SearchCriteria<VolumeVO> sc = AllFieldsSearch.create(); sc.setParameters("id", vo.getId()); sc.setParameters("state", currentState); sc.setParameters("updatedCount", vo.getUpdatedCount()); vo.incrUpdatedCount(); UpdateBuilder builder = getUpdateBuilder(vo); builder.set(vo, "state", nextState); builder.set(vo, "updated", new Date()); int rows = update((VolumeVO)vo, sc); if (rows == 0 && s_logger.isDebugEnabled()) { VolumeVO dbVol = findByIdIncludingRemoved(vo.getId()); if (dbVol != null) { StringBuilder str = new StringBuilder("Unable to update ").append(vo.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(vo.getId()).append("; state=").append(nextState).append("; event=").append(event).append("; updatecount=").append(vo.getUpdatedCount()) .append("; updatedTime=").append(vo.getUpdated()); str.append(": stale Data={id=").append(vo.getId()).append("; state=").append(currentState).append("; event=").append(event).append("; updatecount=").append(oldUpdated) .append("; updatedTime=").append(oldUpdatedTime); } else { s_logger.debug("Unable to update volume: id=" + vo.getId() + ", as there is no such volume exists in the database anymore"); } } return rows > 0; }
@Override public int remove(SearchCriteria<T> sc) { if (_removeSql == null) { return expunge(sc); } T vo = createForUpdate(); UpdateBuilder ub = getUpdateBuilder(vo); ub.set(vo, _removed.second(), new Date()); return update(ub, sc, null); }
@Override public boolean remove(Long id) { TransactionLegacy txn = TransactionLegacy.currentTxn(); txn.start(); SecondaryStorageVmVO 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; }
@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; }
ub.set(host, _resourceStateAttr, newState); int result = update(ub, sc, null); assert result <= 1 : "How can this update " + result + " rows? ";
ub.set(rolePermission, sortOrderAttribute, sortOrder); final int result = update(ub, sc, null); if (result < 1) {
@Override public boolean remove(final Long id) { final TransactionLegacy txn = TransactionLegacy.currentTxn(); txn.start(); final DomainRouterVO router = createForUpdate(); router.setPublicIpAddress(null); final UpdateBuilder ub = getUpdateBuilder(router); ub.set(router, "state", State.Destroyed); update(id, ub, router); final boolean result = super.remove(id); txn.commit(); return result; }
@Override public void markHostsAsDisconnected(long msId, long lastPing) { SearchCriteria<HostVO> sc = MsStatusSearch.create(); sc.setParameters("ms", msId); HostVO host = createForUpdate(); host.setLastPinged(lastPing); host.setDisconnectedOn(new Date()); UpdateBuilder ub = getUpdateBuilder(host); ub.set(host, "status", Status.Disconnected); update(ub, sc, null); sc = MsStatusSearch.create(); sc.setParameters("ms", msId); host = createForUpdate(); host.setManagementServerId(null); host.setLastPinged(lastPing); host.setDisconnectedOn(new Date()); ub = getUpdateBuilder(host); update(ub, sc, null); }