/** * @param zkServers Zookeeper server string: host1:port1[,host2:port2,...] * @param groupID consumer group to update * @param offsets mapping of (topic and) partition to offset to push to Zookeeper */ public static void setOffsets(String zkServers, String groupID, Map<Pair<String,Integer>,Long> offsets) { ZkUtils zkUtils = ZkUtils.apply(zkServers, ZK_TIMEOUT_MSEC, ZK_TIMEOUT_MSEC, false); try { offsets.forEach((topicAndPartition, offset) -> { String topic = topicAndPartition.getFirst(); int partition = topicAndPartition.getSecond(); String partitionOffsetPath = "/consumers/" + groupID + "/offsets/" + topic + "/" + partition; zkUtils.updatePersistentPath(partitionOffsetPath, Long.toString(offset), ZkUtils$.MODULE$.defaultAcls(false, "")); }); } finally { zkUtils.close(); } }
/** * @param zkServers Zookeeper server string: host1:port1[,host2:port2,...] * @param groupID consumer group to update * @param offsets mapping of (topic and) partition to offset to push to Zookeeper */ public static void setOffsets(String zkServers, String groupID, Map<Pair<String,Integer>,Long> offsets) { ZkUtils zkUtils = ZkUtils.apply(zkServers, ZK_TIMEOUT_MSEC, ZK_TIMEOUT_MSEC, false); try { offsets.forEach((topicAndPartition, offset) -> { String topic = topicAndPartition.getFirst(); int partition = topicAndPartition.getSecond(); String partitionOffsetPath = "/consumers/" + groupID + "/offsets/" + topic + "/" + partition; zkUtils.updatePersistentPath(partitionOffsetPath, Long.toString(offset), ZkUtils$.MODULE$.defaultAcls(false, "")); }); } finally { zkUtils.close(); } }