Skip to content

Commit

Permalink
remove log4j dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
AnonHxy committed Jul 28, 2024
1 parent 79585ff commit 8ca7f88
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 14 deletions.
4 changes: 0 additions & 4 deletions bookkeeper-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@
<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,7 +21,6 @@
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 @@ -51,8 +50,6 @@ 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 All @@ -77,8 +74,9 @@ public static CompletableFuture<Void> startComponent(LifecycleComponent componen
component.setExceptionHandler((t, e) -> {
log.error("Triggered exceptionHandler of Component: {} because of Exception in Thread: {}",
component.getName(), t, e);
System.err.println(e.getMessage());
// start the shutdown hook when an uncaught exception happen in the lifecycle component.
FutureUtils.complete(future, null);
shutdownHookThread.start();
});

component.publishInfo(new ComponentInfoPublisher());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
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 @@ -340,7 +339,7 @@ static int doMain(String[] args) {
server = buildAutoRecoveryServer(new BookieConfiguration(conf));
} catch (Exception e) {
LOG.error("Failed to build AutoRecovery Server", e);
LogManager.shutdown();
System.err.println(e.getMessage());
return ExitCode.SERVER_EXCEPTION;
}

Expand All @@ -351,8 +350,10 @@ static int doMain(String[] args) {
Thread.currentThread().interrupt();
// the server is interrupted
LOG.info("AutoRecovery server is interrupted. Exiting ...");
System.err.println(ie.getMessage());
} catch (ExecutionException ee) {
LOG.error("Error in bookie shutdown", ee.getCause());
System.err.println(ee.getMessage());
return ExitCode.SERVER_EXCEPTION;
}
return ExitCode.OK;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
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 @@ -223,7 +222,7 @@ static int doMain(String[] args) {
server = buildBookieServer(new BookieConfiguration(conf));
} catch (Exception e) {
log.error("Failed to build bookie server", e);
LogManager.shutdown();
System.err.println(e.getMessage());
return ExitCode.SERVER_EXCEPTION;
}

Expand All @@ -234,8 +233,10 @@ static int doMain(String[] args) {
Thread.currentThread().interrupt();
// the server is interrupted
log.info("Bookie server is interrupted. Exiting ...");
System.err.println(ie.getMessage());
} catch (ExecutionException ee) {
log.error("Error in bookie shutdown", ee.getCause());
System.err.println(ee.getMessage());
return ExitCode.SERVER_EXCEPTION;
}
return ExitCode.OK;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
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 @@ -171,7 +170,7 @@ static int doMain(String[] args) {
grpcUseHostname);
} catch (Exception e) {
log.error("Invalid storage configuration", e);
LogManager.shutdown();
System.err.println(e.getMessage());
return ExitCode.INVALID_CONF.code();
}

Expand All @@ -183,8 +182,10 @@ static int doMain(String[] args) {
// the server is interrupted.
Thread.currentThread().interrupt();
log.info("Storage server is interrupted. Exiting ...");
System.err.println(e.getMessage());
} catch (ExecutionException e) {
log.info("Storage server is exiting ...");
System.err.println(e.getMessage());
}
return ExitCode.OK.code();
}
Expand Down

0 comments on commit 8ca7f88

Please sign in to comment.