public Long srem(String key, String member) { logger.trace("srem {} {}", key, member); Long retVal = dynoClient.srem(key, member); return retVal; }
public void sRem(String key, String value) { call(jedis -> jedis.srem(key, value)); }
public Long srem(String key, String member) { logger.trace("srem {} {}", key, member); Long retVal = dynoClient.srem(key, member); return retVal; }
public void sRem(String key, String value) { call(jedis -> jedis.srem(key, value)); }
public boolean remove(String... strs) { try { return getJedisCommands(groupName).srem(key,strs) == 1; } finally{ getJedisProvider(groupName).release(); } }
@Override public void updateStatus(ExecutionType type, @Nonnull String id, @Nonnull ExecutionStatus status) { ImmutablePair<String, RedisClientDelegate> pair = fetchKey(id); RedisClientDelegate delegate = pair.getRight(); String key = pair.getLeft(); delegate.withCommandsClient(c -> { Map<String, String> data = new HashMap<>(); data.put("status", status.name()); if (status == ExecutionStatus.RUNNING) { data.put("canceled", "false"); data.put("startTime", String.valueOf(currentTimeMillis())); } else if (status.isComplete() && c.hget(key, "startTime") != null) { data.put("endTime", String.valueOf(currentTimeMillis())); } if (status == BUFFERED) { c.sadd(allBufferedExecutionsKey(type), id); } else { c.srem(allBufferedExecutionsKey(type), id); } c.hmset(key, data); }); }
@Override public void cancel(ExecutionType type, @Nonnull String id, String user, String reason) { ImmutablePair<String, RedisClientDelegate> pair = fetchKey(id); RedisClientDelegate delegate = pair.getRight(); delegate.withCommandsClient(c -> { Map<String, String> data = new HashMap<>(); data.put("canceled", "true"); if (StringUtils.isNotEmpty(user)) { data.put("canceledBy", user); } if (StringUtils.isNotEmpty(reason)) { data.put("cancellationReason", reason); } ExecutionStatus currentStatus = ExecutionStatus.valueOf(c.hget(pair.getLeft(), "status")); if (currentStatus == ExecutionStatus.NOT_STARTED) { data.put("status", ExecutionStatus.CANCELED.name()); } c.hmset(pair.getLeft(), data); c.srem(allBufferedExecutionsKey(type), id); }); }
c.zrem(lookupKey, executionId); } else { c.srem(lookupKey, executionId);
private void deleteInternal(RedisClientDelegate delegate, ExecutionType type, String id) { delegate.withCommandsClient(c -> { String key = executionKey(type, id); try { String application = c.hget(key, "application"); String appKey = appKey(type, application); c.srem(appKey, id); c.srem(allBufferedExecutionsKey(type), id); if (type == PIPELINE) { String pipelineConfigId = c.hget(key, "pipelineConfigId"); c.zrem(executionsByPipelineKey(pipelineConfigId), id); } } catch (ExecutionNotFoundException ignored) { // do nothing } finally { c.del(key); c.srem(alljobsKey(type), id); } }); }
public void addToHistory(DefaultTaskStatus status, JedisTask task) { String historyId = "taskHistory:" + task.getId(); Map<String, String> data = new HashMap<>(); data.put("phase", status.getPhase()); data.put("status", status.getStatus()); data.put("state", status.getState().toString()); String hist; try { hist = mapper.writeValueAsString(data); } catch (JsonProcessingException e) { throw new RuntimeException("Failed converting task history to json", e); } retry(() -> redisClientDelegate.withCommandsClient(client -> { client.rpush(historyId, hist); client.expire(historyId, TASK_TTL); if (status.isCompleted()) { client.srem(RUNNING_TASK_KEY, task.getId()); } }), format("Adding status history to task %s: %s", task.getId(), status)); }
@Override public void pause(ExecutionType type, @Nonnull String id, String user) { ImmutablePair<String, RedisClientDelegate> pair = fetchKey(id); RedisClientDelegate delegate = pair.getRight(); delegate.withCommandsClient(c -> { ExecutionStatus currentStatus = ExecutionStatus.valueOf(c.hget(pair.getLeft(), "status")); if (currentStatus != ExecutionStatus.RUNNING) { throw new UnpausablePipelineException(format( "Unable to pause pipeline that is not RUNNING (executionId: %s, currentStatus: %s)", id, currentStatus )); } PausedDetails pausedDetails = new PausedDetails(); pausedDetails.setPausedBy(user); pausedDetails.setPauseTime(currentTimeMillis()); Map<String, String> data = new HashMap<>(); try { data.put("paused", mapper.writeValueAsString(pausedDetails)); } catch (JsonProcessingException e) { throw new ExecutionSerializationException("Failed converting pausedDetails to json", e); } data.put("status", ExecutionStatus.PAUSED.toString()); c.hmset(pair.getLeft(), data); c.srem(allBufferedExecutionsKey(type), id); }); }
@Override public void resume(ExecutionType type, @Nonnull String id, String user, boolean ignoreCurrentStatus) { ImmutablePair<String, RedisClientDelegate> pair = fetchKey(id); RedisClientDelegate delegate = pair.getRight(); delegate.withCommandsClient(c -> { ExecutionStatus currentStatus = ExecutionStatus.valueOf(c.hget(pair.getLeft(), "status")); if (!ignoreCurrentStatus && currentStatus != ExecutionStatus.PAUSED) { throw new UnresumablePipelineException(format( "Unable to resume pipeline that is not PAUSED (executionId: %s, currentStatus: %s)", id, currentStatus )); } try { PausedDetails pausedDetails = mapper.readValue(c.hget(pair.getLeft(), "paused"), PausedDetails.class); pausedDetails.setResumedBy(user); pausedDetails.setResumeTime(currentTimeMillis()); Map<String, String> data = new HashMap<>(); data.put("paused", mapper.writeValueAsString(pausedDetails)); data.put("status", ExecutionStatus.RUNNING.toString()); c.hmset(pair.getLeft(), data); c.srem(allBufferedExecutionsKey(type), id); } catch (IOException e) { throw new ExecutionSerializationException("Failed converting pausedDetails to json", e); } }); }
c.sadd(allBufferedExecutionsKey(execution.getType()), execution.getId()); } else { c.srem(allBufferedExecutionsKey(execution.getType()), execution.getId());