/** * Increases the current value of the specified @param metric by 1. * * @param taskId Metric belongs to this taskId * <p>TaskId is used to generate the path where the metric will be stored. */ private void incr(String taskId, String metric) { final String key = taskId + "/" + metric; String currentValue = pManager.getCurrentValue(key); if (currentValue == null) { currentValue = "0"; } int c = Integer.parseInt(currentValue); c += 1; pManager.updateValue(key, c + ""); }
/** * @return Progress for the specified taskId * @param taskId where progress refers to TaskId is also used to get the path where the progress * is stored. * @throws AccessDeniedOrObjectDoesNotExistException */ private String getProgress(String taskId) throws AccessDeniedOrObjectDoesNotExistException { final String key = taskId + "/" + PROGRESS_KEY; LOGGER.info("fetching progress for task with key {}", key); String currentValue = pManager.getCurrentValue(key); if (currentValue == null) { throw new AccessDeniedOrObjectDoesNotExistException( "Progress for taskId: [" + taskId + "] not found.."); } return currentValue; }