Skip to content

Commit

Permalink
Shutdown log before bookie exit to flush async log
Browse files Browse the repository at this point in the history
  • Loading branch information
AnonHxy committed Jul 28, 2024
1 parent e5c418e commit 2c35cc0
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bookkeeper-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
<artifactId>bookkeeper-common</artifactId>
<name>Apache BookKeeper :: Common</name>
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.bookkeeper.stats</groupId>
<artifactId>bookkeeper-stats-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.concurrent.CompletableFuture;
import lombok.extern.slf4j.Slf4j;
import org.apache.bookkeeper.common.concurrent.FutureUtils;
import org.apache.logging.log4j.LogManager;

/**
* Utils to start components.
Expand Down Expand Up @@ -50,6 +51,8 @@ public void run() {
log.error("Failed to close component {} in shutdown hook gracefully, Exiting anyway",
component.getName(), e);
future.completeExceptionally(e);
} finally {
LogManager.shutdown();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.logging.log4j.LogManager;
import org.apache.zookeeper.KeeperException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -339,6 +340,7 @@ static int doMain(String[] args) {
server = buildAutoRecoveryServer(new BookieConfiguration(conf));
} catch (Exception e) {
LOG.error("Failed to build AutoRecovery Server", e);
LogManager.shutdown();
return ExitCode.SERVER_EXCEPTION;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.logging.log4j.LogManager;

/**
* A bookie server is a server that run bookie and serving rpc requests.
Expand Down Expand Up @@ -222,6 +223,7 @@ static int doMain(String[] args) {
server = buildBookieServer(new BookieConfiguration(conf));
} catch (Exception e) {
log.error("Failed to build bookie server", e);
LogManager.shutdown();
return ExitCode.SERVER_EXCEPTION;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.distributedlog.DistributedLogConfiguration;
import org.apache.logging.log4j.LogManager;

/**
* A storage server is a server that run storage service and serving rpc requests.
Expand Down Expand Up @@ -170,6 +171,7 @@ static int doMain(String[] args) {
grpcUseHostname);
} catch (Exception e) {
log.error("Invalid storage configuration", e);
LogManager.shutdown();
return ExitCode.INVALID_CONF.code();
}

Expand Down

0 comments on commit 2c35cc0

Please sign in to comment.