Skip to content

Commit

Permalink
Merge pull request #241 from hiddenalpha/FixMissingErrorHandling-2025…
Browse files Browse the repository at this point in the history
…0120

Add missing error handling
  • Loading branch information
hiddenalpha authored Jan 21, 2025
2 parents 716a61b + 61da324 commit 1b25c0c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import io.vertx.core.json.JsonObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.swisspush.redisques.exception.NoStacktraceException;
import org.swisspush.redisques.lock.Lock;
import org.swisspush.redisques.util.LockUtil;
import org.swisspush.redisques.util.MetricMeter;
Expand All @@ -18,6 +19,7 @@
import java.net.UnknownHostException;
import java.util.concurrent.atomic.AtomicLong;

import static org.swisspush.redisques.util.DebugInfo.__WHERE__;
import static org.swisspush.redisques.util.RedisquesAPI.*;

public class MetricsCollector {
Expand Down Expand Up @@ -74,6 +76,10 @@ public MetricsCollector(Vertx vertx, String uid, String redisquesAddress,
public Future<Void> updateActiveQueuesCount() {
final Promise<Void> promise = Promise.promise();
acquireLock(UPDATE_ACTIVE_QUEUES_LOCK, createToken(UPDATE_ACTIVE_QUEUES_LOCK)).onComplete(lockEvent -> {
if (lockEvent.failed()) {
promise.fail(new NoStacktraceException(__WHERE__(), lockEvent.cause()));
return;
}
if(lockEvent.result()) {
log.info("About to update queues count with lock {}", UPDATE_ACTIVE_QUEUES_LOCK);
vertx.eventBus().request(redisquesAddress, buildGetQueuesCountOperation(), (Handler<AsyncResult<Message<JsonObject>>>) reply -> {
Expand All @@ -96,6 +102,10 @@ public Future<Void> updateActiveQueuesCount() {
public Future<Void> updateMaxQueueSize() {
final Promise<Void> promise = Promise.promise();
acquireLock(UPDATE_MAX_QUEUE_SIZE_LOCK, createToken(UPDATE_MAX_QUEUE_SIZE_LOCK)).onComplete(lockEvent -> {
if (lockEvent.failed()) {
promise.fail(new NoStacktraceException(__WHERE__(), lockEvent.cause()));
return;
}
if(lockEvent.result()) {
log.info("About to update max queue size with lock {}", UPDATE_MAX_QUEUE_SIZE_LOCK);
vertx.eventBus().request(redisquesAddress, buildMonitorOperation(true, 1), (Handler<AsyncResult<Message<JsonObject>>>) reply -> {
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/org/swisspush/redisques/util/DebugInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.swisspush.redisques.util;

public class DebugInfo {

public static String __WHERE__() { return __WHERE__(1); }

public static String __WHERE__(int numFramesToIgnore) {
var frame = Thread.currentThread().getStackTrace()[2 + numFramesToIgnore];
return frame.getClassName() + "." + frame.getMethodName() + "():L" + frame.getLineNumber();
}

}

0 comments on commit 1b25c0c

Please sign in to comment.