@Override public synchronized void storeUpperLimit(final long limit) throws MultipleRunningTimestampServiceError { kvs.runInTransaction((Function<DSLContext, Void>) ctx -> { int rowsUpdated = ctx.update(TABLE) .set(LATEST_TIMESTAMP, limit) .where(DUMMY_COLUMN.eq(0).and(LATEST_TIMESTAMP.eq(latestTimestamp))) .execute(); if (rowsUpdated != 1) { long actualLatestTimestamp = getLatestTimestamp(ctx); throw new MultipleRunningTimestampServiceError("Timestamp limit changed underneath " + "us (limit in memory: " + latestTimestamp + ", limit in db: " + actualLatestTimestamp + "). This may indicate that another timestamp service is running against this db!"); } latestTimestamp = limit; return null; }); }
public boolean updateStatus(List<ProcessKey> processKeys, ProcessStatus status, List<ProcessStatus> expected) { return txResult(tx -> { List<UUID> instanceIds = processKeys.stream() .map(PartialProcessKey::getInstanceId) .collect(Collectors.toList()); UpdateConditionStep q = tx.update(PROCESS_QUEUE) .set(PROCESS_QUEUE.CURRENT_STATUS, status.toString()) .set(PROCESS_QUEUE.LAST_UPDATED_AT, currentTimestamp()) .set(PROCESS_QUEUE.LAST_RUN_AT, createRunningAtValue(status)) .where(PROCESS_QUEUE.INSTANCE_ID.in(instanceIds)); if (expected != null) { List<String> l = expected.stream() .map(Enum::toString) .collect(Collectors.toList()); q.and(PROCESS_QUEUE.CURRENT_STATUS.in(l)); } int i = q.execute(); insertHistoryStatus(tx, processKeys, status); return i == processKeys.size(); }); }
private int[] update(DSLContext tx, Connection conn, List<HostItem> hosts) throws SQLException { Field<Integer> currentStatusWeight = decodeStatus(choose(ANSIBLE_HOSTS.STATUS)); Field<Integer> newStatusWeight = decodeStatus(choose(value((String) null))); String update = tx.update(ANSIBLE_HOSTS) .set(ANSIBLE_HOSTS.DURATION, ANSIBLE_HOSTS.DURATION.plus(value((Integer) null))) .set(ANSIBLE_HOSTS.STATUS, when(currentStatusWeight.greaterThan(newStatusWeight), ANSIBLE_HOSTS.STATUS).otherwise(value((String) null))) .set(ANSIBLE_HOSTS.EVENT_SEQ, when(currentStatusWeight.greaterThan(newStatusWeight), ANSIBLE_HOSTS.EVENT_SEQ).otherwise(value((Long) null))) .where(ANSIBLE_HOSTS.INSTANCE_ID.eq(value((UUID) null)) .and(ANSIBLE_HOSTS.INSTANCE_CREATED_AT.eq(value((Timestamp) null)) .and(ANSIBLE_HOSTS.HOST.eq(value((String) null)) .and(ANSIBLE_HOSTS.HOST_GROUP.eq(value((String) null)))))) .getSQL(); try (PreparedStatement ps = conn.prepareStatement(update)) { for (HostItem h : hosts) { ps.setLong(1, h.duration()); ps.setString(2, h.status()); ps.setString(3, h.status()); ps.setString(4, h.status()); ps.setLong(5, h.eventSeq()); ps.setObject(6, h.key().instanceId()); ps.setTimestamp(7, h.key().instanceCreatedAt()); ps.setString(8, h.key().host()); ps.setString(9, h.key().hostGroup()); ps.addBatch(); } return ps.executeBatch(); } }
/** * 更新执行成功时间 * * @param executeId 执行详情编号 */ public void updateSuccessTime(Integer executeId) { dslContext.update(JOB_NODE_EXECUTE_DETAIL) .set(JobNodeExecuteDetail.NED_SUCCESS_TIME, new Timestamp(System.currentTimeMillis())) .where(JobNodeExecuteDetail.NED_ID.eq(executeId)) .execute(); }
@Override public Void withConnection(final Connection conn) throws SQLException { DSL.using(conn, dialect, settings) .update(paymentMethodsTable) .set(DSL.field(IS_DELETED), TRUE) .set(DSL.field(UPDATED_DATE), toTimestamp(utcNow)) .where(DSL.field(KB_PAYMENT_METHOD_ID).equal(kbPaymentMethodId.toString())) .and(DSL.field(KB_TENANT_ID).equal(kbTenantId.toString())) .execute(); return null; } });
/** * 更新最后心跳时间 * * @param nodeAddress 节点地址 */ public void updateLastHeartTime(String nodeAddress) { // 当前时间 Timestamp currentTime = new Timestamp(System.currentTimeMillis()); dslContext.update(JOB_NODE_INFO) .set(JobNodeInfo.JNI_LAST_HEART_TIME, currentTime) .where(JobNodeInfo.JNI_ADDRESS.eq(nodeAddress)) .execute(); }
@Override public Account updateAccount(Account account, String name, String kind, String externalId, String externalType) { Map<TableField<AccountRecord, String>, String> properties = new HashMap<>(); if (StringUtils.isNotEmpty(name)) { properties.put(ACCOUNT.NAME, name); } if (StringUtils.isNotEmpty(kind)) { properties.put(ACCOUNT.KIND, kind); } if (StringUtils.isNotEmpty(externalId)) { properties.put(ACCOUNT.EXTERNAL_ID, externalId); } if (StringUtils.isNotEmpty(externalType)) { properties.put(ACCOUNT.EXTERNAL_ID_TYPE, externalType); } int updateCount = create() .update(ACCOUNT) .set(properties) .where(ACCOUNT.ID .eq(account.getId())) .execute(); if (1 != updateCount) { throw new RuntimeException("UpdateAccount failed."); } return objectManager.reload(account); }
public Integer updateCreateTime(String id, Long time) { return dao.execute(e -> { return e.update(C_ARTICLE) .set(C_ARTICLE.CREATE_TIME, new Timestamp(time)) .where(C_ARTICLE.ID.eq(id)) .execute(); }); }
/** * 更新执行节点的编号 * * @param executeId 执行详情编号 * @param jobNodeAddress 执行任务节点的地址 */ public void updateExecuteNode(Integer executeId, String jobNodeAddress) { dslContext.update(JOB_NODE_EXECUTE_DETAIL) .set(JobNodeExecuteDetail.NED_NODE_ADDRESS, jobNodeAddress) .where(JobNodeExecuteDetail.NED_ID.eq(executeId)) .execute(); }
@Override public void updateNullUpdatedHosts() { if (HOST_REMOVE_DELAY.get() < 0) { return; } create().update(HOST) .set(HOST.REMOVE_AFTER, new Date(System.currentTimeMillis() + HOST_REMOVE_DELAY.get() * 1000)) .where(HOST.REMOVE_AFTER.isNull()) .execute(); }
/** * 更新cron表达式 * * @param triggerKey 任务key * @param cron 表达式 */ public void updateCron(String triggerKey, String cron) { dslContext.update(JOB_NODE_TRIGGER_INFO) .set(JobNodeTriggerInfo.NTI_CRON, cron) .where(JobNodeTriggerInfo.NTI_KEY.eq(triggerKey)) .execute(); }
/** * 执行更新状态 * * @param executeId 执行详情编号 * @param executeStatus 执行详情状态 */ public void updateStatus(Integer executeId, String executeStatus) { dslContext.update(JOB_NODE_EXECUTE_DETAIL) .set(JobNodeExecuteDetail.NED_STATUS, executeStatus) .where(JobNodeExecuteDetail.NED_ID.eq(executeId)) .execute(); }
/** * 更新重试次数 * * @param executeId 执行详情编号 * @param currentRetryCount 当前重试次数 */ public void updateRetryCount(Integer executeId, Integer currentRetryCount) { dslContext.update(JOB_NODE_EXECUTE_DETAIL) .set(JobNodeExecuteDetail.NED_RETRY_COUNT, currentRetryCount) .where(JobNodeExecuteDetail.NED_ID.eq(executeId)) .execute(); } }
public Integer updateStatus(String id, int status) { return dao.execute(e -> { return e.update(C_ARTICLE).set(C_ARTICLE.STATUS, status) .where(C_ARTICLE.ID.eq(id)) .execute(); }); }
protected boolean increment(Client client, String itemName) { int updated = create() .update(CONFIG_ITEM_STATUS) .set(CONFIG_ITEM_STATUS.REQUESTED_VERSION, CONFIG_ITEM_STATUS.REQUESTED_VERSION.plus(1)) .set(CONFIG_ITEM_STATUS.REQUESTED_UPDATED, new Timestamp(System.currentTimeMillis())) .where( CONFIG_ITEM_STATUS.NAME.eq(itemName) .and(targetObjectCondition(client))).execute(); return updated > 0; }
private void updateData(DSLContext tx, UUID id, byte[] data) { int i = tx.update(SECRETS) .set(SECRETS.SECRET_DATA, data) .where(SECRETS.SECRET_ID.eq(id)) .execute(); if (i != 1) { throw new DataAccessException("Invalid number of rows updated: " + i); } }
public void update(DSLContext tx, UUID id, String name, String description) { UpdateSetFirstStep<TeamsRecord> q = tx.update(TEAMS); if (description != null) { q.set(TEAMS.DESCRIPTION, description); } q.set(TEAMS.TEAM_NAME, name) .where(TEAMS.TEAM_ID.eq(id)) .execute(); }
private void updateFireAt(DSLContext tx, UUID triggerId, Instant fireAt) { tx.update(TRIGGER_SCHEDULE) .set(TRIGGER_SCHEDULE.FIRE_AT, Timestamp.from(fireAt)) .where(TRIGGER_SCHEDULE.TRIGGER_ID.eq(triggerId)) .execute(); }