diff --git a/src/main/java/com/uid2/optout/Main.java b/src/main/java/com/uid2/optout/Main.java index 160a2c4..3b8ddb6 100644 --- a/src/main/java/com/uid2/optout/Main.java +++ b/src/main/java/com/uid2/optout/Main.java @@ -26,8 +26,8 @@ import io.vertx.core.*; import io.vertx.core.http.HttpServerOptions; import io.vertx.core.json.JsonObject; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import io.vertx.micrometer.Label; import io.vertx.micrometer.MicrometerMetricsOptions; import io.vertx.micrometer.VertxPrometheusOptions; @@ -191,14 +191,14 @@ else if (!Utils.isProductionEnvironment()) { ConfigRetriever retriever = VertxUtils.createConfigRetriever(vertx); retriever.getConfig(ar -> { if (ar.failed()) { - LOGGER.fatal("Unable to read config: " + ar.cause().getMessage(), ar.cause()); + LOGGER.error("Unable to read config: " + ar.cause().getMessage(), ar.cause()); return; } try { Main app = new Main(vertx, ar.result()); app.run(args); } catch (Exception e) { - LOGGER.fatal("Unable to create/run application: " + e.getMessage(), e); + LOGGER.error("Unable to create/run application: " + e.getMessage(), e); vertx.close(); System.exit(1); } @@ -277,8 +277,8 @@ public void run(String[] args) throws IOException { LOGGER.info("OptOut service fully started..."); }) .onFailure(t -> { - LOGGER.fatal("Unable to bootstrap OptOutSerivce and its dependencies"); - LOGGER.fatal(t.getMessage(), new Exception(t)); + LOGGER.error("Unable to bootstrap OptOutSerivce and its dependencies"); + LOGGER.error(t.getMessage(), new Exception(t)); vertx.close(); System.exit(1); }); @@ -294,7 +294,7 @@ private Future uploadLastDelta(OptOutCloudSync cs, OptOutLogProducer logProducer return Future.succeededFuture(); } } catch (Exception ex) { - LOGGER.fatal("uploadLastDelta error: " + ex.getMessage(), ex); + LOGGER.error("uploadLastDelta error: " + ex.getMessage(), ex); return Future.failedFuture(ex); } @@ -315,7 +315,7 @@ private Future uploadLastDelta(OptOutCloudSync cs, OptOutLogProducer logProducer promise.complete(); } catch (Exception ex) { final String msg = "unable handle last delta upload: " + ex.getMessage(); - LOGGER.fatal(msg, ex); + LOGGER.error(msg, ex); promise.fail(new Exception(msg, ex)); } })); @@ -332,7 +332,7 @@ private Future uploadLastDelta(OptOutCloudSync cs, OptOutLogProducer logProducer int count = counter.incrementAndGet(); if (count >= 10) { - LOGGER.fatal("Unable to refresh from cloud storage and upload last delta..."); + LOGGER.error("Unable to refresh from cloud storage and upload last delta..."); vertx.close(); System.exit(1); return; diff --git a/src/main/java/com/uid2/optout/partner/OptOutPartnerEndpoint.java b/src/main/java/com/uid2/optout/partner/OptOutPartnerEndpoint.java index afab089..140ce12 100644 --- a/src/main/java/com/uid2/optout/partner/OptOutPartnerEndpoint.java +++ b/src/main/java/com/uid2/optout/partner/OptOutPartnerEndpoint.java @@ -6,8 +6,8 @@ import com.uid2.shared.optout.OptOutUtils; import io.vertx.core.Future; import io.vertx.core.Vertx; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.regex.Pattern; diff --git a/src/main/java/com/uid2/optout/tool/OptOutLogTool.java b/src/main/java/com/uid2/optout/tool/OptOutLogTool.java index 693cc49..8c7c8f7 100644 --- a/src/main/java/com/uid2/optout/tool/OptOutLogTool.java +++ b/src/main/java/com/uid2/optout/tool/OptOutLogTool.java @@ -12,8 +12,8 @@ import io.vertx.core.cli.CommandLine; import io.vertx.core.cli.Option; import io.vertx.core.json.JsonObject; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; diff --git a/src/main/java/com/uid2/optout/vertx/OptOutLogProducer.java b/src/main/java/com/uid2/optout/vertx/OptOutLogProducer.java index 47ab54e..f0ccb07 100644 --- a/src/main/java/com/uid2/optout/vertx/OptOutLogProducer.java +++ b/src/main/java/com/uid2/optout/vertx/OptOutLogProducer.java @@ -14,8 +14,8 @@ import io.vertx.core.eventbus.Message; import io.vertx.core.file.FileSystem; import io.vertx.core.json.JsonObject; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; @@ -115,7 +115,7 @@ public void start(Promise startPromise) throws Exception { this.deltaRotate(false).onComplete( ar -> startPromise.handle(ar)); } catch (Exception ex) { - LOGGER.fatal(ex.getMessage(), ex); + LOGGER.error(ex.getMessage(), ex); startPromise.fail(new Throwable(ex)); } @@ -125,7 +125,7 @@ public void start(Promise startPromise) throws Exception { this.healthComponent.setHealthStatus(true); }) .onFailure(e -> { - LOGGER.fatal("failed starting OptOutLogProducer", e); + LOGGER.error("failed starting OptOutLogProducer", e); this.healthComponent.setHealthStatus(false, e.getMessage()); }); } @@ -137,7 +137,7 @@ public void stop(Promise stopPromise) throws Exception { ar -> stopPromise.handle(ar)); stopPromise.future() .onSuccess(v -> LOGGER.info("stopped OptOutLogProducer")) - .onFailure(e -> LOGGER.fatal("failed stopping OptOutLogProducer", e)); + .onFailure(e -> LOGGER.error("failed stopping OptOutLogProducer", e)); } public String getLastDelta() { @@ -160,7 +160,7 @@ private Future deltaRotate(boolean shuttingDown) { ; blockingPromise.complete(); } catch (Exception ex) { - LOGGER.fatal(ex.getMessage(), ex); + LOGGER.error(ex.getMessage(), ex); blockingPromise.fail(new Throwable(ex)); } }, @@ -190,7 +190,7 @@ private void handleEntryAdd(Message entryMsg) { String body = entryMsg.body(); if (!body.contains(",")) { - LOGGER.fatal("unexpected optout entry format: " + body); + LOGGER.error("unexpected optout entry format: " + body); // fast fail if the message doesn't contain a comma (identity_hash,advertising_id) entryMsg.reply(false); return; @@ -198,7 +198,7 @@ private void handleEntryAdd(Message entryMsg) { String[] parts = body.split(","); if (parts.length != 3) { - LOGGER.fatal("unexpected optout entry format: " + body); + LOGGER.error("unexpected optout entry format: " + body); // fast fail if the message doesn't contain a comma (identity_hash,advertising_id) entryMsg.reply(false); return; @@ -206,7 +206,7 @@ private void handleEntryAdd(Message entryMsg) { byte[] identityHash = OptOutUtils.base64StringTobyteArray(parts[0]); if (identityHash == null) { - LOGGER.fatal("unexpected optout identity_hash: " + parts[0]); + LOGGER.error("unexpected optout identity_hash: " + parts[0]); // fast fail if the message doesn't contain a valid identity_hash entryMsg.reply(false); return; @@ -214,7 +214,7 @@ private void handleEntryAdd(Message entryMsg) { byte[] advertisingId = OptOutUtils.base64StringTobyteArray(parts[1]); if (advertisingId == null) { - LOGGER.fatal("unexpected optout identity_hash: " + parts[1]); + LOGGER.error("unexpected optout identity_hash: " + parts[1]); // fast fail if the message doesn't contain a valid advertising_id entryMsg.reply(false); return; @@ -224,7 +224,7 @@ private void handleEntryAdd(Message entryMsg) { try { timestampEpoch = Long.valueOf(parts[2]); } catch (NumberFormatException e) { - LOGGER.fatal("unexpected optout timestamp: " + parts[2]); + LOGGER.error("unexpected optout timestamp: " + parts[2]); // fast fail if the message doesn't contain a valid unix epoch timestamp for optout entry entryMsg.reply(false); return; @@ -312,7 +312,7 @@ private void writeLogBlocking(ArrayList batch) { buffer.flip(); this.fileChannel.write(buffer); } catch (Exception ex) { - LOGGER.fatal("write delta failed: " + ex.getMessage(), ex); + LOGGER.error("write delta failed: " + ex.getMessage(), ex); // report unhealthy status ++this.writeErrorsSinceDeltaOpen; @@ -361,7 +361,7 @@ private String deltaRotateBlocking(boolean shuttingDown) { } catch (Exception ex) { // report unhealthy status ++this.writeErrorsSinceDeltaOpen; - LOGGER.fatal("write last entry to delta failed: " + ex.getMessage(), ex); + LOGGER.error("write last entry to delta failed: " + ex.getMessage(), ex); assert false; } finally { buffer.clear(); @@ -374,7 +374,7 @@ private String deltaRotateBlocking(boolean shuttingDown) { } catch (Exception ex) { // report unhealthy status ++this.writeErrorsSinceDeltaOpen; - LOGGER.fatal("close delta file failed: " + ex.getMessage(), ex); + LOGGER.error("close delta file failed: " + ex.getMessage(), ex); assert false; } } @@ -389,7 +389,7 @@ private String deltaRotateBlocking(boolean shuttingDown) { } catch (Exception ex) { // report unhealthy status ++this.writeErrorsSinceDeltaOpen; - LOGGER.fatal("open delta file failed" + ex.getMessage(), ex); + LOGGER.error("open delta file failed" + ex.getMessage(), ex); assert false; } @@ -406,7 +406,7 @@ private String deltaRotateBlocking(boolean shuttingDown) { } catch (Exception ex) { // report unhealthy status ++this.writeErrorsSinceDeltaOpen; - LOGGER.fatal("write first entry to delta failed: " + ex.getMessage(), ex); + LOGGER.error("write first entry to delta failed: " + ex.getMessage(), ex); assert false; } finally { buffer.clear(); diff --git a/src/main/java/com/uid2/optout/vertx/OptOutSender.java b/src/main/java/com/uid2/optout/vertx/OptOutSender.java index f2e72b9..4fd8b13 100644 --- a/src/main/java/com/uid2/optout/vertx/OptOutSender.java +++ b/src/main/java/com/uid2/optout/vertx/OptOutSender.java @@ -14,8 +14,8 @@ import io.vertx.core.eventbus.EventBus; import io.vertx.core.eventbus.Message; import io.vertx.core.json.JsonObject; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.File; import java.nio.file.Files; @@ -121,7 +121,7 @@ public void start(Promise startPromise) throws Exception { startPromise.complete(); } } catch (Exception ex) { - LOGGER.fatal(ex.getMessage(), ex); + LOGGER.error(ex.getMessage(), ex); startPromise.fail(new Throwable(ex)); } @@ -131,7 +131,7 @@ public void start(Promise startPromise) throws Exception { this.healthComponent.setHealthStatus(true); }) .onFailure(e -> { - LOGGER.fatal("failed starting OptOutSender", e); + LOGGER.error("failed starting OptOutSender", e); this.healthComponent.setHealthStatus(false, e.getMessage()); }); } @@ -150,7 +150,7 @@ public void stop(Promise stopPromise) throws Exception { stopPromise.future() .onSuccess(v -> LOGGER.info("stopped OptOutSender")) - .onFailure(e -> LOGGER.fatal("failed stopping OptOutSender", e)); + .onFailure(e -> LOGGER.error("failed stopping OptOutSender", e)); } // returning name of the file that stores timestamp @@ -231,7 +231,7 @@ private void handleCloudDownloaded(Message msg) { this.processPendingFilesToConsolidate(Instant.now()); } catch (Exception ex) { - LOGGER.fatal("handleLogReplay failed unexpectedly: " + ex.getMessage(), ex); + LOGGER.error("handleLogReplay failed unexpectedly: " + ex.getMessage(), ex); } } @@ -295,7 +295,7 @@ private void kickOffDeltaReplayWithConsolidation(Instant nextTimestamp, ListexecuteBlocking(promise -> deltaReplayWithConsolidation(promise, deltasToConsolidate), ar -> { if (ar.failed()) { - LOGGER.fatal("delta consolidation failed", new Exception(ar.cause())); + LOGGER.error("delta consolidation failed", new Exception(ar.cause())); } else { updateProcessedDeltas(nextTimestamp, deltasToConsolidate); // once complete, check if we could start the next round @@ -327,7 +327,7 @@ private void updateProcessedDeltas(Instant nextTimestamp, List deltasCon return OptOutUtils.appendLinesToFile(vertx, this.processedDeltasFile, deltasConsolidated); }).onFailure(v -> { String filenames = String.join(",", deltasConsolidated); - LOGGER.fatal("unable to persistent last delta timestamp and/or processed delta filenames: " + nextTimestamp + ": " + filenames); + LOGGER.error("unable to persistent last delta timestamp and/or processed delta filenames: " + nextTimestamp + ": " + filenames); }); for (String deltaFile : deltasConsolidated) { @@ -362,7 +362,7 @@ private void deltaReplayWithConsolidation(Promise promise, List de OptOutPartition consolidatedDelta = heap.toPartition(true); deltaReplay(promise, consolidatedDelta, deltasToConsolidate); } catch (Exception ex) { - LOGGER.fatal("deltaReplay failed unexpectedly: " + ex.getMessage(), ex); + LOGGER.error("deltaReplay failed unexpectedly: " + ex.getMessage(), ex); // this error is a code logic error and needs to be fixed promise.fail(new Throwable(ex)); } @@ -387,7 +387,7 @@ private void deltaReplay(Promise promise, OptOutCollection store, List { if (ar.failed()) { - LOGGER.fatal("deltaReplay failed sending delta " + filenames + " to remote: " + this.remotePartner.name(), ar.cause()); + LOGGER.error("deltaReplay failed sending delta " + filenames + " to remote: " + this.remotePartner.name(), ar.cause()); LOGGER.error("deltaReplay has " + this.pendingFilesCount.get() + " pending file"); LOGGER.error("deltaReplay will restart in 3600s"); vertx.setTimer(1000 * 3600, i -> this.pendingAsyncOp.completeExceptionally(new Exception(ar.cause()))); @@ -405,13 +405,13 @@ private void deltaReplay(Promise promise, OptOutCollection store, List startPromise) throws Exception { .requestHandler(createRouter()) .listen(listenPort, result -> handleListenResult(startPromise, result)); } catch (Exception ex) { - LOGGER.fatal(ex.getMessage(), ex); + LOGGER.error(ex.getMessage(), ex); startPromise.fail(new Throwable(ex)); } @@ -117,7 +117,7 @@ public void start(Promise startPromise) throws Exception { LOGGER.info("started OptOutService"); }) .onFailure(e -> { - LOGGER.fatal("failed starting OptOutService", e); + LOGGER.error("failed starting OptOutService", e); this.healthComponent.setHealthStatus(false, e.getMessage()); }); } @@ -137,7 +137,7 @@ private void handleListenResult(Promise startPromise, AsyncResult[]> get(Function, HttpRequ resps[iterations] = resp; if (resp.statusCode() != 200) { - LOGGER.fatal("remote optout/write request " + uri + " returned " + resp.statusCode()); + LOGGER.error("remote optout/write request " + uri + " returned " + resp.statusCode()); } else if (succeeded.incrementAndGet() == quorum) { promise.complete(resps); return; } } else { - LOGGER.fatal("Failed sending request to " + uri, ar.cause()); + LOGGER.error("Failed sending request to " + uri, ar.cause()); } if (completed.incrementAndGet() == this.uris.length) { diff --git a/src/main/java/com/uid2/optout/web/RetryingWebClient.java b/src/main/java/com/uid2/optout/web/RetryingWebClient.java index 9a5e2af..32e0789 100644 --- a/src/main/java/com/uid2/optout/web/RetryingWebClient.java +++ b/src/main/java/com/uid2/optout/web/RetryingWebClient.java @@ -5,8 +5,8 @@ import io.vertx.core.Vertx; import io.vertx.core.buffer.Buffer; import io.vertx.core.http.HttpMethod; -import io.vertx.core.logging.Logger; -import io.vertx.core.logging.LoggerFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import io.vertx.ext.web.client.HttpRequest; import io.vertx.ext.web.client.HttpResponse; import io.vertx.ext.web.client.WebClient; @@ -78,7 +78,7 @@ public Future send(Function, HttpRequest> requ promise.fail("retry count exceeded for sending to " + this.uri); } } catch (Exception ex) { - LOGGER.fatal("unexpected exception: " + ex.getMessage(), ex); + LOGGER.error("unexpected exception: " + ex.getMessage(), ex); promise.fail(new Throwable(ex)); } });