Skip to content

Commit

Permalink
[fix]Decommission command throws KeeperErrorCode exception when autoR…
Browse files Browse the repository at this point in the history
…ecovery is disabled
  • Loading branch information
315157973 committed Aug 25, 2024
1 parent 4a4d108 commit 4cfc860
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1553,7 +1553,16 @@ public void triggerAudit()
throw new UnavailableException("Autorecovery is disabled. So giving up!");
}

BookieId auditorId = getLedgerAuditorManager().getCurrentAuditor();
BookieId auditorId = null;
try {
auditorId = getLedgerAuditorManager().getCurrentAuditor();
} catch (IOException e) {
if (e.getCause() instanceof KeeperException.NoNodeException) {
LOG.error("Can not find node for {}", e.getCause().getMessage());
throw new UnavailableException("Autorecovery is disabled. So giving up!");
}
throw e;
}
if (auditorId == null) {
LOG.error("No auditor elected, though Autorecovery is enabled. So giving up.");
throw new UnavailableException("No auditor elected, though Autorecovery is enabled. So giving up.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class ZkLedgerAuditorManager implements LedgerAuditorManager {

private String myVote;

public static final String ELECTION_ZNODE = "auditorelection";
private static final String ELECTION_ZNODE = "auditorelection";

// Represents the index of the auditor node
private static final int AUDITOR_INDEX = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package org.apache.bookkeeper.meta;

import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.bookkeeper.meta.ZkLedgerAuditorManager.ELECTION_ZNODE;

import com.google.common.base.Joiner;
import com.google.common.util.concurrent.RateLimiter;
Expand Down Expand Up @@ -738,10 +737,6 @@ public boolean isLedgerReplicationEnabled()
LOG.debug("isLedgerReplicationEnabled()");
}
try {
String electionRoot = basePath + '/' + BookKeeperConstants.UNDER_REPLICATION_NODE + '/' + ELECTION_ZNODE;
if (zkc.exists(electionRoot, false) == null) {
return false;
}
return null == zkc.exists(basePath + '/'
+ BookKeeperConstants.DISABLE_NODE, false);
} catch (KeeperException ke) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@ public void testClusterInfo() throws Exception {
}

@Test
public void testRecoveryDisabled() throws Exception {
BookKeeperAdmin bookKeeperAdmin = new BookKeeperAdmin(super.bkc);
try {
public void testRecoveryDisabled() {
try (BookKeeperAdmin bookKeeperAdmin = new BookKeeperAdmin(super.bkc)) {
bookKeeperAdmin.triggerAudit();
fail("should failed");
} catch (Exception e) {
Expand Down

0 comments on commit 4cfc860

Please sign in to comment.