diff options
Diffstat (limited to 'jdisc_core/src/main/java/com')
6 files changed, 9 insertions, 123 deletions
diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/AbstractResource.java b/jdisc_core/src/main/java/com/yahoo/jdisc/AbstractResource.java index a131fc557c4..cabadafa8a0 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/AbstractResource.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/AbstractResource.java @@ -5,7 +5,6 @@ import com.yahoo.jdisc.handler.RequestHandler; import com.yahoo.jdisc.refcount.DebugReferencesByContextMap; import com.yahoo.jdisc.refcount.DebugReferencesWithStack; import com.yahoo.jdisc.refcount.DestructableResource; -import com.yahoo.jdisc.refcount.ReferencesByCount; import com.yahoo.jdisc.service.ClientProvider; import com.yahoo.jdisc.service.ServerProvider; import com.yahoo.jdisc.refcount.References; @@ -25,12 +24,10 @@ public abstract class AbstractResource implements SharedResource { protected AbstractResource() { DestructableResource destructable = new WrappedResource(this); - if (debug == Debug.SIMPLE) { - references = new DebugReferencesByContextMap(destructable, this); - } else if (debug == Debug.STACK) { + if (debug == Debug.STACK) { references = new DebugReferencesWithStack(destructable); } else { - references = new ReferencesByCount(destructable); + references = new DebugReferencesByContextMap(destructable, this); } } diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/Container.java b/jdisc_core/src/main/java/com/yahoo/jdisc/Container.java index f3ed16c65e7..e96f7f08fe8 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/Container.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/Container.java @@ -49,8 +49,10 @@ public interface Container extends SharedResource, Timer { * @return The appropriate instance of the given class. * @throws ConfigurationException If this injector cannot find or create the provider. * @throws ProvisionException If there was a runtime failure while providing an instance. + * @deprecated Use {@link #getInstance(Class)} instead. */ - <T> T getInstance(Key<T> key); + @Deprecated(forRemoval = true, since = "7") // TODO Vespa 8 remove + default <T> T getInstance(Key<T> key) { throw new UnsupportedOperationException(); } /** * Returns the appropriate instance for the given injection type. When feasible, avoid using this method in diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/SharedResource.java b/jdisc_core/src/main/java/com/yahoo/jdisc/SharedResource.java index 051cebee465..654402d181c 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/SharedResource.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/SharedResource.java @@ -39,7 +39,7 @@ public interface SharedResource { return Debug.valueOf(val); } catch (IllegalArgumentException e) { } } - return Debug.NO; + return Debug.SIMPLE; } /** diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/application/UriPattern.java b/jdisc_core/src/main/java/com/yahoo/jdisc/application/UriPattern.java index 4d9a843b8fb..1ddf91aee2b 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/application/UriPattern.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/application/UriPattern.java @@ -29,7 +29,6 @@ import java.util.regex.Pattern; */ public class UriPattern implements Comparable<UriPattern> { - public static final int DEFAULT_PRIORITY = 0; private static final Pattern PATTERN = Pattern.compile("([^:]+)://([^:/]+)(:((\\*)|([0-9]+)))?/(.*)", Pattern.UNICODE_CASE | Pattern.CANON_EQ); private final String pattern; @@ -38,9 +37,6 @@ public class UriPattern implements Comparable<UriPattern> { private final int port; private final GlobPattern path; - // TODO Vespa 8 jonmv remove - private final int priority; - /** * <p>Creates a new instance of this class that represents the given pattern string, with a priority of <code>0</code>. * The input string must be on the form <code><scheme>://<host>[:<port>]<path></code>, where @@ -59,31 +55,6 @@ public class UriPattern implements Comparable<UriPattern> { port = parseOrZero(matcher.group(4)); path = GlobPattern.compile(nonNullOrWildcard(matcher.group(7))); pattern = scheme + "://" + host + ":" + (port > 0 ? port : "*") + "/" + path; - this.priority = DEFAULT_PRIORITY; - } - - /** - * <p>Creates a new instance of this class that represents the given pattern string, with the given priority. The - * input string must be on the form <code><scheme>://<host>[:<port>]<path></code>, where - * '*' can be used as a wildcard character at any position.</p> - * - * @deprecated Use {@link #UriPattern(String)} and let's avoid another complication here. - * @param uri The pattern to parse. - * @param priority The priority of this pattern. - * @throws IllegalArgumentException If the pattern could not be parsed. - */ - @Deprecated(forRemoval = true, since = "7") - public UriPattern(String uri, int priority) { - Matcher matcher = PATTERN.matcher(uri); - if (!matcher.find()) { - throw new IllegalArgumentException(uri); - } - scheme = GlobPattern.compile(normalizeScheme(nonNullOrWildcard(matcher.group(1)))); - host = GlobPattern.compile(nonNullOrWildcard(matcher.group(2))); - port = parseOrZero(matcher.group(4)); - path = GlobPattern.compile(nonNullOrWildcard(matcher.group(7))); - pattern = scheme + "://" + host + ":" + (port > 0 ? port : "*") + "/" + path; - this.priority = priority; } /** @@ -135,10 +106,6 @@ public class UriPattern implements Comparable<UriPattern> { @Override public int compareTo(UriPattern rhs) { int cmp; - cmp = rhs.priority - priority; - if (cmp != 0) { - return cmp; - } cmp = scheme.compareTo(rhs.scheme); if (cmp != 0) { return cmp; diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/core/ContainerSnapshot.java b/jdisc_core/src/main/java/com/yahoo/jdisc/core/ContainerSnapshot.java index f3641f2475b..808c8e89b1b 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/core/ContainerSnapshot.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/core/ContainerSnapshot.java @@ -37,7 +37,10 @@ class ContainerSnapshot extends AbstractResource implements Container { this.containerReference = container.refer(context); } + /** @deprecated Use {@link #getInstance(Class)} instead. */ @Override + @Deprecated(forRemoval = true, since = "7") // TODO Vespa 8 remove + @SuppressWarnings("removal") public <T> T getInstance(Key<T> key) { return container.guiceInjector().getInstance(key); } diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/refcount/ReferencesByCount.java b/jdisc_core/src/main/java/com/yahoo/jdisc/refcount/ReferencesByCount.java deleted file mode 100644 index 0f417c81a8b..00000000000 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/refcount/ReferencesByCount.java +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.jdisc.refcount; - -import com.yahoo.jdisc.ResourceReference; -import com.yahoo.jdisc.SharedResource; - -import java.util.concurrent.atomic.AtomicInteger; - -/** - * Does reference counting by using atomic counting of references - * Default in production - * - * @author baldersheim - */ -public class ReferencesByCount implements References { - private final AtomicInteger refCount; - private final DestructableResource resource; - private final NoDebugResourceReference initialReference; - - public ReferencesByCount(DestructableResource resource) { - refCount = new AtomicInteger(1); - this.resource = resource; - initialReference = new NoDebugResourceReference(this); - } - - @Override - public void release() { - initialReference.close(); - } - - @Override - public int referenceCount() { - return refCount.get(); - } - - @Override - public ResourceReference refer(Object context) { - addRef(1); - return new NoDebugResourceReference(this); - } - - @Override - public String currentState() { - return "Active references: " + refCount.get() + "." - + " Resource reference debugging is turned off. Consider toggling the " - + SharedResource.SYSTEM_PROPERTY_NAME_DEBUG - + " system property to get debugging assistance with reference tracking."; - } - - private void removeRef() { - int refCount = addRef(-1); - if (refCount == 0) { - resource.close(); - } - } - - private int addRef(int value) { - while (true) { - int prev = refCount.get(); - if (prev == 0) { - throw new IllegalStateException(getClass().getName() + ".addRef(" + value + "):" - + " Object is already destroyed." - + " Consider toggling the " + SharedResource.SYSTEM_PROPERTY_NAME_DEBUG - + " system property to get debugging assistance with reference tracking."); - } - int next = prev + value; - if (refCount.compareAndSet(prev, next)) { - return next; - } - } - } - - private static class NoDebugResourceReference extends CloseableOnce { - private final ReferencesByCount resource; - - NoDebugResourceReference(final ReferencesByCount resource) { - this.resource = resource; - } - - @Override final void onClose() { resource.removeRef(); } - @Override References getReferences() { return resource; } - } -} |