distribution.put(path, item);
}
//Second pass - assignment
for (String member : members) {
try {
WorkerNode node = mapper.readValue(curator.get().getData().forPath(member), WorkerNode.class);
Collection<String> assignedItems = distribution.get(member);
if (assignedItems != null) {
node.setItems(assignedItems.toArray(new String[assignedItems.size()]));
} else {
node.setItems(new String[0]);
}
String targetPath = ZkPath.TASK_MEMBER_PARTITIONS.getPath(node.getContainer(), context.getId());
curator.get().setData().forPath(targetPath, mapper.writeValueAsBytes(node));
} catch (Exception ex) {
LOGGER.error("Error while assigning work", ex);
}
}