This is an automated email from the ASF dual-hosted git repository. heneveld pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/brooklyn-server.git
commit 750a63a9bbcc70b332254fa8b434311449ff3bf4 Author: Alex Heneveld <[email protected]> AuthorDate: Tue Sep 14 22:30:35 2021 +0100 suppress more warnings on planned rebind interruption --- .../BrooklynMementoPersisterToObjectStore.java | 17 +++++++---- .../mgmt/rebind/RebindExceptionHandlerImpl.java | 35 ++++++++++++++++++++++ .../brooklyn/util/exceptions/Exceptions.java | 2 +- .../exceptions/RuntimeInterruptedException.java | 9 ++---- 4 files changed, 50 insertions(+), 13 deletions(-) diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/persist/BrooklynMementoPersisterToObjectStore.java b/core/src/main/java/org/apache/brooklyn/core/mgmt/persist/BrooklynMementoPersisterToObjectStore.java index e3b3540..31e2019 100644 --- a/core/src/main/java/org/apache/brooklyn/core/mgmt/persist/BrooklynMementoPersisterToObjectStore.java +++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/persist/BrooklynMementoPersisterToObjectStore.java @@ -568,10 +568,17 @@ public class BrooklynMementoPersisterToObjectStore implements BrooklynMementoPer @Override public void run() { try { - visitor.visit(type, objectIdAndData.getKey(), objectIdAndData.getValue()); - } catch (Exception e) { - Exceptions.propagateIfFatal(e); - exceptionHandler.onLoadMementoFailed(type, "memento "+objectIdAndData.getKey()+" "+phase+" error", e); + try { + visitor.visit(type, objectIdAndData.getKey(), objectIdAndData.getValue()); + } catch (Exception e) { + Exceptions.propagateIfFatal(e); + if (Thread.currentThread().isInterrupted()) { + throw new RuntimeInterruptedException("Interruption discovered", e); + } + exceptionHandler.onLoadMementoFailed(type, "memento " + objectIdAndData.getKey() + " " + phase + " error", e); + } + } catch (RuntimeInterruptedException e) { + LOG.debug("Ending persistence on interruption, probably cancelled when server about to transition: "+e); } } } @@ -594,7 +601,7 @@ public class BrooklynMementoPersisterToObjectStore implements BrooklynMementoPer if (future.isDone()) { try { future.get(); - } catch (InterruptedException e2) { + } catch (InterruptedException|RuntimeInterruptedException e2) { throw Exceptions.propagate(e2); } catch (ExecutionException e2) { LOG.warn("Problem loading memento ("+phase+"): "+e2, e2); diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/RebindExceptionHandlerImpl.java b/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/RebindExceptionHandlerImpl.java index a705748..30b2984 100644 --- a/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/RebindExceptionHandlerImpl.java +++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/RebindExceptionHandlerImpl.java @@ -44,6 +44,7 @@ import org.apache.brooklyn.util.collections.MutableList; import org.apache.brooklyn.util.collections.QuorumCheck; import org.apache.brooklyn.util.collections.QuorumCheck.QuorumChecks; import org.apache.brooklyn.util.exceptions.Exceptions; +import org.apache.brooklyn.util.exceptions.RuntimeInterruptedException; import org.apache.brooklyn.util.text.Strings; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -166,6 +167,10 @@ public class RebindExceptionHandlerImpl implements RebindExceptionHandler { @Override public void onLoadMementoFailed(BrooklynObjectType type, String msg, Exception e) { Exceptions.propagateIfFatal(e); + if (Thread.currentThread().isInterrupted()) { + throw new RuntimeInterruptedException("Interruption discovered when loading memento, "+msg); + } + String errmsg = "problem loading memento: "+msg; switch (type) { @@ -193,6 +198,9 @@ public class RebindExceptionHandlerImpl implements RebindExceptionHandler { @Override public Entity onDanglingEntityRef(String id) { + if (Thread.currentThread().isInterrupted()) { + throw new RuntimeInterruptedException("Interruption discovered when recording dangling entity "+id); + } missingEntities.add(id); if (danglingRefFailureMode == RebindManager.RebindFailureMode.FAIL_FAST) { throw new IllegalStateException("No entity found with id "+id); @@ -204,6 +212,9 @@ public class RebindExceptionHandlerImpl implements RebindExceptionHandler { @Override public Location onDanglingLocationRef(String id) { + if (Thread.currentThread().isInterrupted()) { + throw new RuntimeInterruptedException("Interruption discovered when recording dangling location "+id); + } missingLocations.add(id); if (danglingRefFailureMode == RebindManager.RebindFailureMode.FAIL_FAST) { throw new IllegalStateException("No location found with id "+id); @@ -215,6 +226,10 @@ public class RebindExceptionHandlerImpl implements RebindExceptionHandler { @Override public Policy onDanglingPolicyRef(String id) { + if (Thread.currentThread().isInterrupted()) { + throw new RuntimeInterruptedException("Interruption discovered when recording dangling policy "+id); + } + missingPolicies.add(id); if (danglingRefFailureMode == RebindManager.RebindFailureMode.FAIL_FAST) { throw new IllegalStateException("No policy found with id "+id); @@ -226,6 +241,10 @@ public class RebindExceptionHandlerImpl implements RebindExceptionHandler { @Override public Enricher onDanglingEnricherRef(String id) { + if (Thread.currentThread().isInterrupted()) { + throw new RuntimeInterruptedException("Interruption discovered when recording dangling enricher "+id); + } + missingEnrichers.add(id); if (danglingRefFailureMode == RebindManager.RebindFailureMode.FAIL_FAST) { throw new IllegalStateException("No enricher found with id "+id); @@ -237,6 +256,10 @@ public class RebindExceptionHandlerImpl implements RebindExceptionHandler { @Override public Feed onDanglingFeedRef(String id) { + if (Thread.currentThread().isInterrupted()) { + throw new RuntimeInterruptedException("Interruption discovered when recording dangling feed "+id); + } + missingFeeds.add(id); if (danglingRefFailureMode == RebindManager.RebindFailureMode.FAIL_FAST) { throw new IllegalStateException("No feed found with id "+id); @@ -248,6 +271,10 @@ public class RebindExceptionHandlerImpl implements RebindExceptionHandler { @Override public CatalogItem<?, ?> onDanglingCatalogItemRef(String id) { + if (Thread.currentThread().isInterrupted()) { + throw new RuntimeInterruptedException("Interruption discovered when recording dangling catalog item "+id); + } + missingCatalogItems.add(id); if (danglingRefFailureMode == RebindManager.RebindFailureMode.FAIL_FAST) { throw new IllegalStateException("No catalog item found with id "+id); @@ -264,6 +291,10 @@ public class RebindExceptionHandlerImpl implements RebindExceptionHandler { @Override public BrooklynObject onDanglingUntypedItemRef(String id) { + if (Thread.currentThread().isInterrupted()) { + throw new RuntimeInterruptedException("Interruption discovered when recording dangling untyped item "+id); + } + missingUntypedItems.add(id); if (danglingRefFailureMode == RebindManager.RebindFailureMode.FAIL_FAST) { throw new IllegalStateException("No item found with id "+id); @@ -413,6 +444,10 @@ public class RebindExceptionHandlerImpl implements RebindExceptionHandler { } protected void onErrorImpl(String errmsg, Exception e) { + if (Thread.currentThread().isInterrupted()) { + throw new RuntimeInterruptedException("Interruption discovered when recording error: "+errmsg); + } + if (rebindFailureMode == RebindManager.RebindFailureMode.FAIL_FAST) { throw new IllegalStateException("Rebind: aborting due to "+errmsg, e); } else { diff --git a/utils/common/src/main/java/org/apache/brooklyn/util/exceptions/Exceptions.java b/utils/common/src/main/java/org/apache/brooklyn/util/exceptions/Exceptions.java index 4d3946c..b91279b 100644 --- a/utils/common/src/main/java/org/apache/brooklyn/util/exceptions/Exceptions.java +++ b/utils/common/src/main/java/org/apache/brooklyn/util/exceptions/Exceptions.java @@ -186,7 +186,7 @@ public class Exceptions { */ public static void propagateIfInterrupt(Throwable throwable) { if (throwable instanceof InterruptedException) { - throw new RuntimeInterruptedException((InterruptedException) throwable); + throw new RuntimeInterruptedException(throwable); } else if (throwable instanceof RuntimeInterruptedException) { Thread.currentThread().interrupt(); throw (RuntimeInterruptedException) throwable; diff --git a/utils/common/src/main/java/org/apache/brooklyn/util/exceptions/RuntimeInterruptedException.java b/utils/common/src/main/java/org/apache/brooklyn/util/exceptions/RuntimeInterruptedException.java index f207001..600d830 100644 --- a/utils/common/src/main/java/org/apache/brooklyn/util/exceptions/RuntimeInterruptedException.java +++ b/utils/common/src/main/java/org/apache/brooklyn/util/exceptions/RuntimeInterruptedException.java @@ -38,17 +38,12 @@ public class RuntimeInterruptedException extends RuntimeException { Thread.currentThread().interrupt(); } - public RuntimeInterruptedException(InterruptedException cause) { + public RuntimeInterruptedException(Throwable cause) { super(cause); Thread.currentThread().interrupt(); } - public RuntimeInterruptedException(String msg, InterruptedException cause) { - super(msg, cause); - Thread.currentThread().interrupt(); - } - - public RuntimeInterruptedException(String msg, RuntimeInterruptedException cause) { + public RuntimeInterruptedException(String msg, Throwable cause) { super(msg, cause); Thread.currentThread().interrupt(); }
