Source:
public void fillEmptySubscription(final Map<Partition.PartitionKey, Long> partitionToOffset) { if (null == partitionToOffset) { log.error("Illegal partition offsets, won't create anything"); return; } try { log.info("Creating sessions root"); if (null != curatorFramework.checkExists().forPath(getSubscriptionPath("/sessions"))) { curatorFramework.delete().guaranteed().deletingChildrenIfNeeded().forPath(getSubscriptionPath("/sessions")); } curatorFramework.create().withMode(CreateMode.PERSISTENT).forPath(getSubscriptionPath("/sessions")); log.info("Creating topics"); if (null != curatorFramework.checkExists().forPath(getSubscriptionPath("/topics"))) { log.info("deleting topics recursively"); curatorFramework.delete().guaranteed().deletingChildrenIfNeeded().forPath(getSubscriptionPath("/topics")); } curatorFramework.create().withMode(CreateMode.PERSISTENT).forPath(getSubscriptionPath("/topics")); log.info("Creating partitions"); int counter = 0; for (final Map.Entry<Partition.PartitionKey, Long> p : partitionToOffset.entrySet()) { final String partitionPath = getPartitionPath(p.getKey()); curatorFramework.create().creatingParentsIfNeeded().withMode(CreateMode.PERSISTENT).forPath( partitionPath, serializeNode(null, null, Partition.State.UNASSIGNED)); curatorFramework.create().withMode(CreateMode.PERSISTENT).forPath( partitionPath + "/offset", (String.valueOf(p.getValue())).getBytes(CHARSET)); if (++counter % 100 == 0) { log.info("Created " + counter + " so far"); } } log.info("creating topology node"); curatorFramework.create().withMode(CreateMode.PERSISTENT).forPath(getSubscriptionPath("/topology"), "0".getBytes(CHARSET)); log.info("updating state"); curatorFramework.setData().forPath(getSubscriptionPath("/state"), STATE_INITIALIZED.getBytes(CHARSET)); } catch (final Exception e) { exceptionListener.accept(e); } }

Target:
public void fillEmptySubscription(final Map<Partition.PartitionKey, Long> partitionToOffset) { try { log.info("Creating sessions root"); if (null != curatorFramework.checkExists().forPath(getSubscriptionPath("/sessions"))) { curatorFramework.delete().guaranteed().deletingChildrenIfNeeded().forPath(getSubscriptionPath("/sessions")); } curatorFramework.create().withMode(CreateMode.PERSISTENT).forPath(getSubscriptionPath("/sessions")); log.info("Creating topics"); if (null != curatorFramework.checkExists().forPath(getSubscriptionPath("/topics"))) { log.info("deleting topics recursively"); curatorFramework.delete().guaranteed().deletingChildrenIfNeeded().forPath(getSubscriptionPath("/topics")); } curatorFramework.create().withMode(CreateMode.PERSISTENT).forPath(getSubscriptionPath("/topics")); log.info("Creating partitions"); int counter = 0; for (final Map.Entry<Partition.PartitionKey, Long> p : partitionToOffset.entrySet()) { final String partitionPath = getPartitionPath(p.getKey()); curatorFramework.create().creatingParentsIfNeeded().withMode(CreateMode.PERSISTENT).forPath( partitionPath, serializeNode(null, null, Partition.State.UNASSIGNED)); curatorFramework.create().withMode(CreateMode.PERSISTENT).forPath( partitionPath + "/offset", (String.valueOf(p.getValue())).getBytes(CHARSET)); if (++counter % 100 == 0) { log.info("Created " + counter + " so far"); } } log.info("creating topology node"); curatorFramework.create().withMode(CreateMode.PERSISTENT).forPath(getSubscriptionPath("/topology"), "0".getBytes(CHARSET)); log.info("updating state"); curatorFramework.setData().forPath(getSubscriptionPath("/state"), STATE_INITIALIZED.getBytes(CHARSET)); } catch (final Exception e) { throw new SubscriptionWrappedException(e); } }