Skip to content

Commit

Permalink
MINOR:code optimization in QuorumController (#13697)
Browse files Browse the repository at this point in the history
1. add hint in switch item "BROKER_LOGGER" in ConfigResourceExistenceChecker, otherwise, it will be classified as default break and deleted directly. I don’t know if adding hint is better than deleting directly.
2. delete some unused variables and methods.
3. add the "@test" mark to a method in unit test that is forgotten.

Reviewers: dengziming <dengziming1993@gmail.com>
  • Loading branch information
hudeqi committed May 12, 2023
1 parent a7c9842 commit 440bed2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ class ConfigResourceExistenceChecker implements Consumer<ConfigResource> {
public void accept(ConfigResource configResource) {
switch (configResource.type()) {
case BROKER_LOGGER:
// BROKER_LOGGER are always allowed.
break;
case BROKER:
// Cluster configs are always allowed.
Expand Down Expand Up @@ -433,15 +434,6 @@ private NotControllerException newPreMigrationException() {
}
}

public static int exceptionToApparentController(NotControllerException e) {
if (e.getMessage().startsWith(ACTIVE_CONTROLLER_EXCEPTION_TEXT_PREFIX)) {
return Integer.parseInt(e.getMessage().substring(
ACTIVE_CONTROLLER_EXCEPTION_TEXT_PREFIX.length()));
} else {
return -1;
}
}

private void handleEventEnd(String name, long startProcessingTimeNs) {
long endProcessingTime = time.nanoseconds();
long deltaNs = endProcessingTime - startProcessingTimeNs;
Expand Down Expand Up @@ -1586,11 +1578,6 @@ private void resetToEmptyState() {
*/
private final FaultHandler fatalFaultHandler;

/**
* The slf4j log context, used to create new loggers.
*/
private final LogContext logContext;

/**
* The slf4j logger.
*/
Expand Down Expand Up @@ -1823,7 +1810,6 @@ private QuorumController(
boolean zkMigrationEnabled
) {
this.fatalFaultHandler = fatalFaultHandler;
this.logContext = logContext;
this.log = logContext.logger(QuorumController.class);
this.nodeId = nodeId;
this.clusterId = clusterId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ public void testFenceMultipleBrokers() throws Throwable {
}
}

@Test
public void testBalancePartitionLeaders() throws Throwable {
List<Integer> allBrokers = Arrays.asList(1, 2, 3);
List<Integer> brokersToKeepUnfenced = Arrays.asList(1, 2);
Expand Down

0 comments on commit 440bed2

Please sign in to comment.