return JesqueUtils.createKey(this.config.getNamespace(), parts);
}
protected WorkerInfo createWorker(final String workerName, final Jedis jedis)
throws ParseException, IOException {
final WorkerInfo workerInfo = new WorkerInfo();
workerInfo.setName(workerName);
final String[] nameParts = COLON_PATTERN.split(workerName, 3);
if (nameParts.length < 3) {
throw new ParseException("Malformed worker name: " + workerName, 0);
}
workerInfo.setHost(nameParts[0]);
workerInfo.setPid(nameParts[1]);
workerInfo.setQueues(new ArrayList<String>(Arrays.asList(COMMA_PATTERN.split(nameParts[2]))));
final String statusPayload = jedis.get(key(WORKER, workerName));
if (statusPayload != null) {
workerInfo.setStatus(ObjectMapperFactory.get().readValue(statusPayload, WorkerStatus.class));
final WorkerInfo.State state = (workerInfo.getStatus().isPaused())
? WorkerInfo.State.PAUSED
: WorkerInfo.State.WORKING;
workerInfo.setState(state);
} else {
workerInfo.setState(WorkerInfo.State.IDLE);
}
final String startedStr = jedis.get(key(WORKER, workerName, STARTED));
if (startedStr != null) {
workerInfo.setStarted(new CompositeDateFormat().parse(startedStr));
}
final String failedStr = jedis.get(key(STAT, FAILED, workerName));
if (failedStr != null) {
workerInfo.setFailed(Long.parseLong(failedStr));
} else {
workerInfo.setFailed(0L);
}
final String processedStr = jedis.get(key(STAT, PROCESSED, workerName));
if (processedStr != null) {
workerInfo.setProcessed(Long.parseLong(processedStr));
} else {
workerInfo.setProcessed(0L);
}
return workerInfo;
}