Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
yisheng-zhou committed Nov 20, 2024
1 parent 7bb4f30 commit 8bb3260
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class MemqZookeeperClient {
public static final String BROKERS = "/brokers";
public static final String TOPICS = "/topics";
public static final String GOVERNOR = "/governor";
private boolean refreshZkClientWhenException = true;
private boolean refreshZkClientOnException = true;
private String zkUrl;
private MemqCluster cluster;
private CuratorFramework zkClient;
Expand All @@ -26,12 +26,12 @@ public MemqZookeeperClient(MemqCluster cluster) throws Exception {
}
}

public void enableRefreshZkClientWhenException() {
this.refreshZkClientWhenException = true;
public void enableRefreshZkClientOnException() {
this.refreshZkClientOnException = true;
}

public void disableRefreshZkClientWhenException() {
this.refreshZkClientWhenException = false;
public void disableRefreshZkClientOnException() {
this.refreshZkClientOnException = false;
}

/**
Expand Down Expand Up @@ -61,7 +61,7 @@ public void refreshZkClient() throws Exception {

/**
* Get the children of a node in Zookeeper.
* When an exception occurs, the Zookeeper client is refreshed and the children are fetched again if the refreshZkClientWhenException flag is set.
* When an exception occurs, the Zookeeper client is refreshed and the children are fetched again if the refreshZkClientOnException flag is set.
* @param path The path of the node.
* @return List of children node names.
* @throws Exception
Expand All @@ -70,7 +70,7 @@ private List<String> getChildNodes(String path) throws Exception {
try {
return zkClient.getChildren().forPath(path);
} catch (Exception e) {
if (refreshZkClientWhenException) {
if (refreshZkClientOnException) {
refreshZkClient();
return zkClient.getChildren().forPath(path);
} else {
Expand All @@ -81,7 +81,7 @@ private List<String> getChildNodes(String path) throws Exception {

/**
* Get the data of a node in Zookeeper.
* When an exception occurs, the Zookeeper client is refreshed and the data is fetched again if the refreshZkClientWhenException flag is set.
* When an exception occurs, the Zookeeper client is refreshed and the data is fetched again if the refreshZkClientOnException flag is set.
* @param path The path of the node.
* @return The data of the node as a json string
* @throws Exception
Expand All @@ -90,7 +90,7 @@ private String getNodeData(String path) throws Exception {
try {
return new String(zkClient.getData().forPath(path));
} catch (Exception e) {
if (refreshZkClientWhenException) {
if (refreshZkClientOnException) {
refreshZkClient();
return new String(zkClient.getData().forPath(path));
} else {
Expand Down

0 comments on commit 8bb3260

Please sign in to comment.