Skip to content

Commit

Permalink
WorkflowInstanceDao: Fix formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
jsyrjala committed Nov 26, 2014
1 parent e1bea4a commit c249e48
Showing 1 changed file with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,10 @@ public void processRow(ResultSet rs) throws SQLException {
instance.originalStateVariables.putAll(instance.stateVariables);
}

@SuppressFBWarnings(value="SIC_INNER_SHOULD_BE_STATIC_ANON", justification="common jdbctemplate practice")
@SuppressFBWarnings(value = "SIC_INNER_SHOULD_BE_STATIC_ANON", justification = "common jdbctemplate practice")
@Transactional
public List<Integer> pollNextWorkflowInstanceIds(int batchSize) {
String sql =
"select id, modified from nflow_workflow where executor_id is null and next_activation < current_timestamp and "
String sql = "select id, modified from nflow_workflow where executor_id is null and next_activation < current_timestamp and "
+ executorInfo.getExecutorGroupCondition() + " order by next_activation asc limit " + batchSize;
List<OptimisticLockKey> instances = jdbc.query(sql, new RowMapper<OptimisticLockKey>() {
@Override
Expand All @@ -195,29 +194,29 @@ public OptimisticLockKey mapRow(ResultSet rs, int rowNum) throws SQLException {
batchArgs.add(new Object[] { instance.id, instance.modified });
ids.add(instance.id);
}
int[] updateStatuses = jdbc.batchUpdate(
"update nflow_workflow set executor_id = " + executorInfo.getExecutorId() + " where id = ? and modified = ? and executor_id is null",
batchArgs);
int[] updateStatuses = jdbc.batchUpdate("update nflow_workflow set executor_id = " + executorInfo.getExecutorId()
+ " where id = ? and modified = ? and executor_id is null", batchArgs);
for (int status : updateStatuses) {
if (status != 1) {
throw new PollingRaceConditionException(
"Race condition in polling workflow instances detected. " +
"Multiple pollers using same name (" + executorInfo.getExecutorGroup() +")");
throw new PollingRaceConditionException("Race condition in polling workflow instances detected. "
+ "Multiple pollers using same name (" + executorInfo.getExecutorGroup() + ")");
}
}
return ids;
}

private static class OptimisticLockKey implements Comparable<OptimisticLockKey>{
private static class OptimisticLockKey implements Comparable<OptimisticLockKey> {
public final int id;
public final Timestamp modified;

public OptimisticLockKey(int id, Timestamp modified) {
this.id = id;
this.modified = modified;
}

@Override
public int compareTo(OptimisticLockKey other) {
return this.id - other.id;
return this.id - other.id;
}
}

Expand Down

0 comments on commit c249e48

Please sign in to comment.