aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/WebDataHandler.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-12-13 15:51:33 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2020-12-13 15:51:33 -0800
commitbc3b09e48efb9a58d9aef111d4316dcd9c0a7038 (patch)
tree18179346c5838bae1fdabb4007f309aa598c7600 /src/main/java/org/traccar/WebDataHandler.java
parentd4f9561b978ea0410acc7a80a42137e13f06c846 (diff)
downloadtrackermap-server-bc3b09e48efb9a58d9aef111d4316dcd9c0a7038.tar.gz
trackermap-server-bc3b09e48efb9a58d9aef111d4316dcd9c0a7038.tar.bz2
trackermap-server-bc3b09e48efb9a58d9aef111d4316dcd9c0a7038.zip
Improve forwarding logging
Diffstat (limited to 'src/main/java/org/traccar/WebDataHandler.java')
-rw-r--r--src/main/java/org/traccar/WebDataHandler.java12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/main/java/org/traccar/WebDataHandler.java b/src/main/java/org/traccar/WebDataHandler.java
index a7ea0b2a5..678096d34 100644
--- a/src/main/java/org/traccar/WebDataHandler.java
+++ b/src/main/java/org/traccar/WebDataHandler.java
@@ -221,6 +221,7 @@ public class WebDataHandler extends BaseDataHandler {
}
private void send() {
+ LOGGER.debug("Position forwarding initiated");
if (json) {
try {
Entity<String> entity = Entity.entity(objectMapper.writeValueAsString(payload), mediaType);
@@ -233,7 +234,7 @@ public class WebDataHandler extends BaseDataHandler {
}
}
- private void retry() {
+ private void retry(Throwable throwable) {
boolean scheduled = false;
try {
if (retryEnabled && deliveryPending.get() <= retryLimit && retries < retryCount) {
@@ -242,27 +243,28 @@ public class WebDataHandler extends BaseDataHandler {
}
} finally {
int pending = scheduled ? deliveryPending.get() : deliveryPending.decrementAndGet();
- LOGGER.warn("Position forwarding failed: " + pending + " pending");
+ LOGGER.warn("Position forwarding failed: " + pending + " pending", throwable);
}
}
private void schedule() {
Main.getInjector().getInstance(Timer.class).newTimeout(
- this, retryDelay * (int) Math.pow(2, retries++), TimeUnit.MILLISECONDS);
+ this, retryDelay * (long) Math.pow(2, retries++), TimeUnit.MILLISECONDS);
}
@Override
public void completed(Response response) {
if (response.getStatusInfo().getFamily() == Response.Status.Family.SUCCESSFUL) {
deliveryPending.decrementAndGet();
+ LOGGER.debug("Position forwarding succeeded");
} else {
- retry();
+ retry(new RuntimeException("Status code 2xx expected"));
}
}
@Override
public void failed(Throwable throwable) {
- retry();
+ retry(throwable);
}
@Override