Skip to content

Commit

Permalink
Fix to update cluster nodes in consistent hash ring in getCurrentNode…
Browse files Browse the repository at this point in the history
…Name (qubole#467)
  • Loading branch information
Harmandeep Singh authored Oct 7, 2020
1 parent c82bd58 commit 46c8440
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions rubix-spi/src/main/java/com/qubole/rubix/spi/ClusterManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,18 @@ public List<String> getNodes()

public String getCurrentNodeName()
{
if (currentNodeName == null) {
// getNodes() updates the currentNodeName
List<String> nodes = getNodes();
if (nodes == null) {
log.error("Initialization not done for Cluster Type: " + getClusterType());
throw new RuntimeException("Unable to find current node name");
}
}
// refresh cluster nodes first, which updates currentNodeName if it is not set.
refreshClusterNodes();
return currentNodeName;
}

private void refreshClusterNodes()
{
// getNodes() updates the currentNodeName
List<String> nodes = getNodes();
if (nodes == null) {
log.error("Initialization not done for Cluster Type: " + getClusterType());
throw new RuntimeException("Unable to find current node name");
}
}
}

0 comments on commit 46c8440

Please sign in to comment.