Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/main/java/com/uid2/optout/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
});
Expand All @@ -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);
}

Expand All @@ -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));
}
}));
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/uid2/optout/tool/OptOutLogTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
32 changes: 16 additions & 16 deletions src/main/java/com/uid2/optout/vertx/OptOutLogProducer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -115,7 +115,7 @@ public void start(Promise<Void> 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));
}

Expand All @@ -125,7 +125,7 @@ public void start(Promise<Void> 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());
});
}
Expand All @@ -137,7 +137,7 @@ public void stop(Promise<Void> 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() {
Expand All @@ -160,7 +160,7 @@ private Future<Void> deltaRotate(boolean shuttingDown) {
;
blockingPromise.complete();
} catch (Exception ex) {
LOGGER.fatal(ex.getMessage(), ex);
LOGGER.error(ex.getMessage(), ex);
blockingPromise.fail(new Throwable(ex));
}
},
Expand Down Expand Up @@ -190,31 +190,31 @@ private void handleEntryAdd(Message<String> 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;
}

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;
}

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;
}

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;
Expand All @@ -224,7 +224,7 @@ private void handleEntryAdd(Message<String> 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;
Expand Down Expand Up @@ -312,7 +312,7 @@ private void writeLogBlocking(ArrayList<Message> 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;

Expand Down Expand Up @@ -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();
Expand All @@ -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;
}
}
Expand All @@ -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;
}

Expand All @@ -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();
Expand Down
24 changes: 12 additions & 12 deletions src/main/java/com/uid2/optout/vertx/OptOutSender.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -121,7 +121,7 @@ public void start(Promise<Void> startPromise) throws Exception {
startPromise.complete();
}
} catch (Exception ex) {
LOGGER.fatal(ex.getMessage(), ex);
LOGGER.error(ex.getMessage(), ex);
startPromise.fail(new Throwable(ex));
}

Expand All @@ -131,7 +131,7 @@ public void start(Promise<Void> 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());
});
}
Expand All @@ -150,7 +150,7 @@ public void stop(Promise<Void> 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
Expand Down Expand Up @@ -231,7 +231,7 @@ private void handleCloudDownloaded(Message<String> msg) {

this.processPendingFilesToConsolidate(Instant.now());
} catch (Exception ex) {
LOGGER.fatal("handleLogReplay failed unexpectedly: " + ex.getMessage(), ex);
LOGGER.error("handleLogReplay failed unexpectedly: " + ex.getMessage(), ex);
}
}

Expand Down Expand Up @@ -295,7 +295,7 @@ private void kickOffDeltaReplayWithConsolidation(Instant nextTimestamp, List<Str
vertx.<Void>executeBlocking(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
Expand Down Expand Up @@ -327,7 +327,7 @@ private void updateProcessedDeltas(Instant nextTimestamp, List<String> 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) {
Expand Down Expand Up @@ -362,7 +362,7 @@ private void deltaReplayWithConsolidation(Promise<Void> promise, List<String> 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));
}
Expand All @@ -387,7 +387,7 @@ private void deltaReplay(Promise<Void> promise, OptOutCollection store, List<Str

lastOp.onComplete(ar -> {
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())));
Expand All @@ -405,13 +405,13 @@ private void deltaReplay(Promise<Void> promise, OptOutCollection store, List<Str
this.pendingAsyncOp.get();
promise.complete();
} catch (Exception ex) {
LOGGER.fatal(ex);
LOGGER.error("deltaReplay failed unexpectedly: " + ex.getMessage(), ex);
promise.fail(ex);
} finally {
this.pendingAsyncOp = null;
}
} 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));
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/uid2/optout/vertx/OptOutServiceVerticle.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import io.vertx.core.eventbus.Message;
import io.vertx.core.http.*;
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.ext.web.Router;
import io.vertx.ext.web.RoutingContext;
import io.vertx.ext.web.handler.BodyHandler;
Expand Down Expand Up @@ -108,7 +108,7 @@ public void start(Promise<Void> 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));
}

Expand All @@ -117,7 +117,7 @@ public void start(Promise<Void> 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());
});
}
Expand All @@ -137,7 +137,7 @@ private void handleListenResult(Promise<Void> startPromise, AsyncResult<HttpServ
if (result.succeeded()) {
startPromise.complete();
} else {
LOGGER.fatal("listen failed: " + result.cause());
LOGGER.error("listen failed: " + result.cause());
startPromise.fail(new Throwable(result.cause()));
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/uid2/optout/vertx/PartnerConfigMonitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import io.vertx.core.Promise;
import io.vertx.core.Vertx;
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.InputStream;
import java.util.ArrayList;
Expand Down Expand Up @@ -93,7 +93,7 @@ public long loadContent(JsonObject metadata) throws Exception {
if (dr.succeeded()) {
newDeployIdMap.put(ef.name(), dr.result());
} else {
LOGGER.fatal("Failed to deploy OptOutSender: " + ef.name());
LOGGER.error("Failed to deploy OptOutSender: " + ef.name());
}
});
}
Expand Down
Loading