diff options
author | Håkon Hallingstad <hakon@verizonmedia.com> | 2020-10-20 21:43:41 +0200 |
---|---|---|
committer | Håkon Hallingstad <hakon@verizonmedia.com> | 2020-10-20 21:43:41 +0200 |
commit | a4ef47ec0fa4d0bf4e535d7b5646b0bcddeb3152 (patch) | |
tree | 894bc4c9e95a215859ad42daaefae3b034e7a2a2 | |
parent | f810022dd96bba240923e7276f5d15f76d58ad36 (diff) |
Remove locating code
3 files changed, 3 insertions, 67 deletions
diff --git a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/model/ScopedApplicationApi.java b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/model/ScopedApplicationApi.java index 6f47e862ac3..33e709248f3 100644 --- a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/model/ScopedApplicationApi.java +++ b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/model/ScopedApplicationApi.java @@ -3,6 +3,9 @@ package com.yahoo.vespa.orchestrator.model; import com.yahoo.vespa.orchestrator.status.ApplicationLock; +/** + * @author hakon + */ class ScopedApplicationApi implements AutoCloseable { private final ApplicationApi applicationApi; private final ApplicationLock lock; diff --git a/zkfacade/src/main/java/com/yahoo/vespa/curator/stats/LockStats.java b/zkfacade/src/main/java/com/yahoo/vespa/curator/stats/LockStats.java index e9cb37ae02c..0c51cfc685d 100644 --- a/zkfacade/src/main/java/com/yahoo/vespa/curator/stats/LockStats.java +++ b/zkfacade/src/main/java/com/yahoo/vespa/curator/stats/LockStats.java @@ -4,7 +4,6 @@ package com.yahoo.vespa.curator.stats; import java.util.Comparator; import java.util.List; import java.util.Map; -import java.util.Objects; import java.util.Optional; import java.util.PriorityQueue; import java.util.concurrent.ConcurrentHashMap; @@ -120,68 +119,4 @@ public class LockStats { } } - - private static volatile String CURRENT_TEST_ID = null; - - public void invokingAcquire(Thread thread) { - // HACK: Try to see if this is the first invocation on a new test method. If so verify - // the #acquires = #releases, or otherwise some intervening tests broke them - getTestId(thread).ifPresent(testId -> { - if (Objects.equals(testId, CURRENT_TEST_ID)) { - return; - } - - // New test, verify balance between acquired and released. - metricsByLockPath.forEach((lockPath, lockMetrics) -> { - int numAcquired = lockMetrics.getCumulativeAcquireSucceededCount(); - int numReleased = lockMetrics.getCumulativeReleaseCount(); - if (numAcquired != numReleased) { - // ensure next test does not fail - clearForTesting(); - - throw new IllegalStateException("Detected in " + testId + ": lock path " + - lockPath + " has been acquired " + numAcquired + " times and released " + - numReleased + " times. The problem is the test " + CURRENT_TEST_ID + - ", or later tests leading up to this"); - } - }); - - CURRENT_TEST_ID = testId; - }); - } - - private static Optional<String> getTestId(Thread thread) { - // The stack trace is of the following form: - // - // ... - // com.yahoo.vespa.curator.stats.LockTest.nestedLocks(LockTest.java:191) - // ... - // org.junit.runner.JUnitCore.run(JUnitCore.java:xyz) - // ... - // - // And we'd like to return the test ID "com.yahoo.vespa.curator.stats.LockTest.nestedLocks". - - StackTraceElement[] elements = thread.getStackTrace(); - for (int index = 0; index < elements.length; ++index) { - if (stackFrameMethod(elements[index]).equals("org.junit.runner.JUnitCore.run")) { - while (index --> 0) { - String qualifiedMethod = stackFrameMethod(elements[index]); - if (qualifiedMethod.startsWith("com.yahoo.vespa.")) { - return Optional.of(qualifiedMethod); - } - } - - // Failed to find jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 - throw new IllegalStateException("Bad stack trace!?"); - } - } - - // Failed to find org.junit.runners.model.FrameworkMethod$1.runReflectiveCall, which may happen - // in a spawned thread. - return Optional.empty(); - } - - private static String stackFrameMethod(StackTraceElement element) { - return element.getClassName() + "." + element.getMethodName(); - } } diff --git a/zkfacade/src/main/java/com/yahoo/vespa/curator/stats/ThreadLockStats.java b/zkfacade/src/main/java/com/yahoo/vespa/curator/stats/ThreadLockStats.java index 087c133a44c..70442e4833d 100644 --- a/zkfacade/src/main/java/com/yahoo/vespa/curator/stats/ThreadLockStats.java +++ b/zkfacade/src/main/java/com/yahoo/vespa/curator/stats/ThreadLockStats.java @@ -68,8 +68,6 @@ public class ThreadLockStats { /** Mutable method (see class doc) */ public void invokingAcquire(String lockPath, Duration timeout) { - LockStats.getGlobal().invokingAcquire(thread); - boolean reentry = lockAttemptsStack.stream().anyMatch(lockAttempt -> lockAttempt.getLockPath().equals(lockPath)); if (!reentry) { |