Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
title: Remove unused parameter pauseBeforeStart from leader election code
type: removed
authors:
- name: Pierre Salagnac
links:
- name: SOLR-18035
url: https://issues.apache.org/jira/browse/SOLR-18035
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void cancelElection() throws InterruptedException, KeeperException {
}
}

abstract void runLeaderProcess(boolean weAreReplacement, int pauseBeforeStartMs)
abstract void runLeaderProcess(boolean weAreReplacement)
throws KeeperException, InterruptedException;

public void checkIfIamLeaderFired() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ context.leaderSeqPath, watchedNode, getSeq(context.leaderSeqPath), context),

protected void runIamLeaderProcess(final ElectionContext context, boolean weAreReplacement)
throws KeeperException, InterruptedException {
context.runLeaderProcess(weAreReplacement, 0);
context.runLeaderProcess(weAreReplacement);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ public OverseerElectionContext(
}

@Override
void runLeaderProcess(boolean weAreReplacement, int pauseBeforeStartMs)
throws KeeperException, InterruptedException {
void runLeaderProcess(boolean weAreReplacement) throws KeeperException, InterruptedException {
if (isClosed) {
return;
}
Expand All @@ -63,14 +62,7 @@ void runLeaderProcess(boolean weAreReplacement, int pauseBeforeStartMs)
ZkNodeProps myProps = new ZkNodeProps(ID, id);

zkClient.makePath(leaderPath, Utils.toJSON(myProps), CreateMode.EPHEMERAL);
if (pauseBeforeStartMs > 0) {
try {
Thread.sleep(pauseBeforeStartMs);
} catch (InterruptedException e) {
Thread.interrupted();
log.warn("Wait interrupted ", e);
}
}

synchronized (this) {
if (!this.isClosed && !overseer.getZkController().getCoreContainer().isShutDown()) {
overseer.start(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ public ElectionContext copy() {
* weAreReplacement: has someone else been the leader already?
*/
@Override
void runLeaderProcess(boolean weAreReplacement, int pauseBeforeStart)
throws KeeperException, InterruptedException {
void runLeaderProcess(boolean weAreReplacement) throws KeeperException, InterruptedException {
String coreName = leaderProps.getStr(ZkStateReader.CORE_NAME_PROP);
ActionThrottle lt;
try (SolrCore core = cc.getCore(coreName)) {
Expand Down Expand Up @@ -296,7 +295,7 @@ void runLeaderProcess(boolean weAreReplacement, int pauseBeforeStart)
coreNodeName);
zkController.getShardTerms(collection, shardId).setTermEqualsToLeader(coreNodeName);
}
super.runLeaderProcess(weAreReplacement, 0);
super.runLeaderProcess(weAreReplacement);
try (SolrCore core = cc.getCore(coreName)) {
if (core != null) {
core.getCoreDescriptor().getCloudDescriptor().setLeader(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ public void cancelElection() throws InterruptedException, KeeperException {
}

@Override
void runLeaderProcess(boolean weAreReplacement, int pauseBeforeStartMs)
throws KeeperException, InterruptedException {
void runLeaderProcess(boolean weAreReplacement) throws KeeperException, InterruptedException {
// register as leader - if an ephemeral is already there, wait to see if it goes away

String parent = ZkMaintenanceUtils.getZkParent(leaderPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,8 @@ public TestLeaderElectionContext(
}

@Override
void runLeaderProcess(boolean weAreReplacement, int pauseBeforeStartMs)
throws KeeperException, InterruptedException {
super.runLeaderProcess(weAreReplacement, pauseBeforeStartMs);
void runLeaderProcess(boolean weAreReplacement) throws KeeperException, InterruptedException {
super.runLeaderProcess(weAreReplacement);
if (runLeaderDelay > 0) {
log.info("Sleeping for {}ms to simulate leadership takeover delay", runLeaderDelay);
Thread.sleep(runLeaderDelay);
Expand Down