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 7c41204 commit 4a4d108
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class ZkLedgerAuditorManager implements LedgerAuditorManager {

private String myVote;

private static final String ELECTION_ZNODE = "auditorelection";
public 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,6 +19,7 @@
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 @@ -737,6 +738,10 @@ 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 @@ -23,8 +23,11 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import org.apache.bookkeeper.client.BookKeeperAdmin;
import org.apache.bookkeeper.conf.ServerConfiguration;
import org.apache.bookkeeper.replication.ReplicationException;
import org.apache.bookkeeper.test.BookKeeperClusterTestCase;
import org.apache.bookkeeper.tools.cli.commands.bookies.ClusterInfoCommand;
import org.apache.bookkeeper.tools.framework.CliFlags;
Expand Down Expand Up @@ -60,4 +63,16 @@ public void testClusterInfo() throws Exception {
assertTrue(info.isLedgerReplicationEnabled());
}

@Test
public void testRecoveryDisabled() throws Exception {
BookKeeperAdmin bookKeeperAdmin = new BookKeeperAdmin(super.bkc);
try {
bookKeeperAdmin.triggerAudit();
fail("should failed");
} catch (Exception e) {
assertTrue(e instanceof ReplicationException.UnavailableException);
assertTrue(e.getMessage().contains("Autorecovery is disabled. So giving up"));
}
}

}

0 comments on commit 4a4d108

Please sign in to comment.