Skip to content

Commit

Permalink
Merge pull request #818 from cthumuluru/3.11
Browse files Browse the repository at this point in the history
Changing the list in TokenRetrievalUtils to use wildcards.
  • Loading branch information
cthumuluru authored May 15, 2019
2 parents 8dbfe47 + 76936a1 commit 2d2bf82
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ public PriamInstance get() throws Exception {
|| super.isInstanceDummy(priamInstance)) continue;
// TODO: If instance is in SHUTTING_DOWN mode, it might not show up in asg
// instances (if cloud control plane is having issues), thus, we should not try
// to
// replace the instance as it will lead to "Cannot replace a live node" issue.
// to replace the instance as it will lead to "Cannot replace a live node"
// issue.

logger.info("Found dead instance: {}", priamInstance.toString());

Expand All @@ -122,7 +122,6 @@ public PriamInstance get() throws Exception {

// Lets not replace the instance if gossip info is not merging!!
if (replacedIp == null) return null;

logger.info(
"Will try to replace token: {} with replacedIp (from gossip info): {} instead of ip from Token database: {}",
priamInstance.getToken(),
Expand All @@ -131,6 +130,10 @@ public PriamInstance get() throws Exception {
} catch (GossipParseException e) {
// In case of gossip exception, fallback to IP in token database.
this.replacedIp = priamInstance.getHostIP();
logger.info(
"Will try to replace token: {} with replacedIp from Token database: {}",
priamInstance.getToken(),
priamInstance.getHostIP());
}

PriamInstance result;
Expand All @@ -153,7 +156,8 @@ public PriamInstance get() throws Exception {
+ " , will sleep for "
+ sleepTime
+ " millisecs before we retry.");
Thread.currentThread().sleep(sleepTime);
Thread.sleep(sleepTime);

throw ex;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ public class TokenRetrieverUtils {
* gossip info.
*/
public static String inferTokenOwnerFromGossip(
List<PriamInstance> allIds, String token, String dc) throws GossipParseException {
List<? extends PriamInstance> allIds, String token, String dc)
throws GossipParseException {
// Avoid using dead instance who we are trying to replace (duh!!)
// Avoid other regions instances to avoid communication over public ip address.
List<PriamInstance> eligibleInstances =
List<? extends PriamInstance> eligibleInstances =
allIds.stream()
.filter(priamInstance -> !priamInstance.getToken().equalsIgnoreCase(token))
.filter(priamInstance -> priamInstance.getDC().equalsIgnoreCase(dc))
Expand Down

0 comments on commit 2d2bf82

Please sign in to comment.