in priam/src/main/java/com/netflix/priam/identity/DoubleRing.java [54:95]
public void doubleSlots() {
Set<PriamInstance> local = getInstancesInSameRegion();
// delete all
for (PriamInstance data : local) factory.delete(data);
int hash = tokenManager.regionOffset(instanceInfo.getRegion());
// move existing slots.
for (PriamInstance data : local) {
int slot = (data.getId() - hash) * 2;
factory.create(
data.getApp(),
hash + slot,
data.getInstanceId(),
data.getHostName(),
data.getHostIP(),
data.getRac(),
data.getVolumes(),
data.getToken());
}
int new_ring_size = local.size() * 2;
for (PriamInstance data : getInstancesInSameRegion()) {
// if max then rotate.
int currentSlot = data.getId() - hash;
int new_slot =
currentSlot + 3 > new_ring_size
? (currentSlot + 3) - new_ring_size
: currentSlot + 3;
String token =
tokenManager.createToken(new_slot, new_ring_size, instanceInfo.getRegion());
factory.create(
data.getApp(),
new_slot + hash,
InstanceIdentity.DUMMY_INSTANCE_ID,
instanceInfo.getHostname(),
config.usePrivateIP() ? instanceInfo.getPrivateIP() : instanceInfo.getHostIP(),
data.getRac(),
null,
token);
}
}