From 8ad9bfcf79b222cb6f8b6c783b0624d3a97e6d23 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 23 Jan 2024 10:37:50 +0100 Subject: [server] Tweak thrift call retry logic --- .../src/main/java/org/openslx/bwlp/sat/App.java | 12 ++++++++++-- 1 file 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 { -- cgit v1.2.3-55-g7522