Skip to content

Commit

Permalink
remove transaction children atomically
Browse files Browse the repository at this point in the history
  • Loading branch information
moscicky committed Jul 30, 2024
1 parent 96aaf39 commit 384b536
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,6 @@ protected void touch(String path) throws Exception {
zookeeper.setData().forPath(path, oldData);
}

protected void removeIfExists(String path) throws Exception {
ensureConnected();
zookeeper.delete().quietly().guaranteed().deletingChildrenIfNeeded().forPath(path);
}

protected void remove(String path) throws Exception {
ensureConnected();
zookeeper.delete().guaranteed().deletingChildrenIfNeeded().forPath(path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,11 @@ public void removeTopic(TopicName topicName) {

try {
deleteInTransaction(pathsForRemoval);
} catch (Exception ex) {
throw new InternalProcessingException(ex);
} catch (Exception e) {
throw new InternalProcessingException(e);
}
}


@Override
public void updateTopic(Topic topic) {
ensureTopicExists(topic.getName());
Expand All @@ -147,28 +146,13 @@ public void touchTopic(TopicName topicName) {
ensureTopicExists(topicName);

logger.info("Touching topic: " + topicName.qualifiedName());
removeTopicChildren(topicName);
try {
touch(paths.topicPath(topicName));
} catch (Exception ex) {
throw new InternalProcessingException(ex);
}
}

private void removeTopicChildren(TopicName topicName) {
try {
removeIfExists(paths.topicPreviewPath(topicName));
} catch (Exception e) {
throw new InternalProcessingException(e);
}

try {
removeIfExists(paths.topicMetricsPath(topicName));
} catch (Exception e) {
throw new InternalProcessingException(e);
}
}

@Override
public Topic getTopicDetails(TopicName topicName) {
return getTopicDetails(topicName, false).get();
Expand Down

0 comments on commit 384b536

Please sign in to comment.