summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2024-01-23 10:37:50 +0100
committerSimon Rettberg2024-01-23 10:37:50 +0100
commit8ad9bfcf79b222cb6f8b6c783b0624d3a97e6d23 (patch)
tree979dc6484a71c2a071a23179d1db655b7c88f509
parent[server] "using old data" message is confusing, only show if >= 1d (diff)
downloadtutor-module-8ad9bfcf79b222cb6f8b6c783b0624d3a97e6d23.tar.gz
tutor-module-8ad9bfcf79b222cb6f8b6c783b0624d3a97e6d23.tar.xz
tutor-module-8ad9bfcf79b222cb6f8b6c783b0624d3a97e6d23.zip
[server] Tweak thrift call retry logic
-rw-r--r--dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/App.java12
1 files changed, 10 insertions, 2 deletions
diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/App.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/App.java
index 898f75e9..e88ed876 100644
--- a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/App.java
+++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/App.java
@@ -35,6 +35,7 @@ import org.openslx.bwlp.sat.thrift.cache.VirtualizerList;
import org.openslx.bwlp.sat.util.Configuration;
import org.openslx.bwlp.sat.util.Identity;
import org.openslx.bwlp.sat.web.WebServer;
+import org.openslx.bwlp.thrift.iface.TAuthorizationException;
import org.openslx.bwlp.thrift.iface.TInvalidTokenException;
import org.openslx.sat.thrift.version.Version;
import org.openslx.thrifthelper.ThriftManager;
@@ -97,16 +98,23 @@ public class App {
ThriftManager.setMasterErrorCallback(new ErrorCallback() {
+ /**
+ * Return true to retry call, false otherwise.
+ */
@Override
public boolean thriftError(int failCount, String method, Throwable t) {
+ // t == null means no connection could be established
if (failFastMethods.contains(method))
- return false;
+ return t != null && failCount <= 1;
if (failCount > 2 || t == null) {
LOGGER.warn("Thrift Client error for " + method + ", FAIL.");
return false;
}
- if (t instanceof TInvalidTokenException)
+ if ((t instanceof TInvalidTokenException)
+ || (t instanceof TAuthorizationException)
+ || !(t instanceof TException)) {
return false;
+ }
if (((TException) t).getCause() == null) {
LOGGER.info("Thrift error " + t.toString() + " for " + method + ", retrying...");
} else {