-
Notifications
You must be signed in to change notification settings - Fork 293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
3.11vnodesupport #623
base: 3.11
Are you sure you want to change the base?
3.11vnodesupport #623
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ | |
import com.netflix.priam.utils.ITokenManager; | ||
import com.netflix.priam.utils.RetryableCallable; | ||
import com.netflix.priam.utils.Sleeper; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
|
@@ -78,6 +79,8 @@ public boolean test(PriamInstance input) { | |
}; | ||
|
||
private PriamInstance myInstance; | ||
private String backupIdentifier; | ||
private boolean outOfService = false; | ||
private boolean isReplace = false; | ||
private boolean isTokenPregenerated = false; | ||
private String replacedIp = ""; | ||
|
@@ -104,7 +107,7 @@ public InstanceIdentity(IPriamInstanceFactory factory, IMembership membership, I | |
init(); | ||
} | ||
|
||
public PriamInstance getInstance() { | ||
PriamInstance getInstance() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Token was previously used both as the initial_token and as the identifier of a node's backup in the context of the entire cluster. When using vnodes, I don't need an initial token, but I do still need an identifier for the backup, so I wanted to separate these two concerns. Because the backup identifier is redundant with data already in SDB, it felt better not to put in in the PriamInstance class, and instead use PriamInstance purely as the Data Access DTO, but InstanceIdentity as the business model. |
||
return myInstance; | ||
} | ||
|
||
|
@@ -118,7 +121,7 @@ public PriamInstance retriableCall() throws Exception { | |
for (PriamInstance ins : deadInstances) { | ||
logger.info("[Dead] Iterating though the hosts: {}", ins.getInstanceId()); | ||
if (ins.getInstanceId().equals(config.getInstanceName())) { | ||
ins.setOutOfService(true); | ||
outOfService = true; | ||
logger.info("[Dead] found that this node is dead." | ||
+ " application: {}" | ||
+ ", id: {}" | ||
|
@@ -242,6 +245,13 @@ public void forEachExecution() { | |
} | ||
|
||
logger.info("My token: {}", myInstance.getToken()); | ||
|
||
if (myInstance.getToken() == null || myInstance.getToken().isEmpty()) { | ||
backupIdentifier = "virual" + Integer.toString(myInstance.getId()); | ||
} else | ||
{ | ||
backupIdentifier = myInstance.getToken(); | ||
} | ||
} | ||
|
||
private void populateRacMap() { | ||
|
@@ -304,4 +314,44 @@ public String getReplacedIp() { | |
private static boolean isInstanceDummy(PriamInstance instance) { | ||
return instance.getInstanceId().equals(DUMMY_INSTANCE_ID); | ||
} | ||
|
||
public boolean isOutOfService() | ||
{ | ||
return outOfService; | ||
} | ||
|
||
public String getBackupIdentifier() | ||
{ | ||
return backupIdentifier; | ||
} | ||
|
||
public void setBackupIdentifier(String backupIdentifier) | ||
{ | ||
this.backupIdentifier = backupIdentifier; | ||
} | ||
|
||
public String getToken() | ||
{ | ||
return myInstance.getToken(); | ||
} | ||
|
||
public String getInstanceId() | ||
{ | ||
return myInstance.getInstanceId(); | ||
} | ||
|
||
public String getHostIP() | ||
{ | ||
return myInstance.getHostIP(); | ||
} | ||
|
||
public String getHostName() | ||
{ | ||
return myInstance.getHostName(); | ||
} | ||
|
||
public boolean isExternallyDefinedToken() | ||
{ | ||
return StringUtils.isNotBlank(getToken()); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I needed to allow token to not be set, but still distinguish between Priam being fully initialized but not having a token and it not running at all.
I could have instead differentiated these two cases with a 500 when it hasn't fully initialized, and make this startup agent treat 500s different than a 204.