diff options
author | Jon Bratseth <bratseth@yahoo-inc.com> | 2017-11-28 21:35:16 +0100 |
---|---|---|
committer | Jon Bratseth <bratseth@yahoo-inc.com> | 2017-11-28 21:35:16 +0100 |
commit | 1d6791e6fa004ae80e85dbc6a6c7c2e4b8037a4f (patch) | |
tree | 650307f35d321145410248f703943ef7525f94fb /jdisc_core/src/main/java/com | |
parent | 0606896d63cc8bbe4919c7c37126fb9bc3f6e34e (diff) | |
parent | 7e8f8da8f249cf3c529cec8ecdcf13b69c99da13 (diff) |
Merge with master
Diffstat (limited to 'jdisc_core/src/main/java/com')
6 files changed, 52 insertions, 9 deletions
diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/Request.java b/jdisc_core/src/main/java/com/yahoo/jdisc/Request.java index 489a4c3dc10..7a76c588fb4 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/Request.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/Request.java @@ -287,7 +287,7 @@ public class Request extends AbstractResource { } /** - * <p>Returns the allocated number of milliseconds that this Request is allowed to exist. If no timeout has been set + * <p>Returns the allocated number of time units that this Request is allowed to exist. If no timeout has been set * for this Request, this method returns <em>null</em>.</p> * * @param unit The unit to return the timeout in. @@ -306,7 +306,7 @@ public class Request extends AbstractResource { * <em>null</em>.</p> * * @param unit The unit to return the time in. - * @return The number of milliseconds left until this Request times out, or <em>null</em>. + * @return The number of time units left until this Request times out, or <em>null</em>. */ public Long timeRemaining(TimeUnit unit) { if (timeout == null) { @@ -316,6 +316,16 @@ public class Request extends AbstractResource { } /** + * <p>Returns the time that this Request has existed so far. + * + * @param unit The unit to return the time in. + * @return The number of time units elapsed since this Request was created. + */ + public long timeElapsed(TimeUnit unit) { + return unit.convert(container().currentTimeMillis() - creationTime, TimeUnit.MILLISECONDS); + } + + /** * <p>Returns the time at which this Request was created. This is whatever value was returned by {@link * Timer#currentTimeMillis()} when constructing this.</p> * diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/application/BindingMatch.java b/jdisc_core/src/main/java/com/yahoo/jdisc/application/BindingMatch.java index 5d4974f2dc4..7318b1b38ae 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/application/BindingMatch.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/application/BindingMatch.java @@ -15,6 +15,7 @@ public class BindingMatch<T> { private final UriPattern.Match match; private final T target; + private final UriPattern matched; /** * <p>Constructs a new instance of this class.</p> @@ -22,12 +23,27 @@ public class BindingMatch<T> { * @param match The match information for this instance. * @param target The target of this match. * @throws NullPointerException If any argument is null. + * @deprecated use BindingMatch(UriPattern.Match match, T target, UriPattern matched) */ + @Deprecated public BindingMatch(UriPattern.Match match, T target) { + this(match, target, null); + } + + /** + * <p>Constructs a new instance of this class.</p> + * + * @param match The match information for this instance. + * @param target The target of this match. + * @param matched The matched URI pattern + * @throws NullPointerException If any argument is null. + */ + public BindingMatch(UriPattern.Match match, T target, UriPattern matched) { Objects.requireNonNull(match, "match"); Objects.requireNonNull(target, "target"); this.match = match; this.target = target; + this.matched = matched; } /** @@ -61,4 +77,14 @@ public class BindingMatch<T> { public T target() { return target; } + + /** + * <p>Returns the URI pattern that was matched.</p> + * + * @return The matched pattern. + */ + public UriPattern matched() { + return matched; + } + } diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/application/BindingSet.java b/jdisc_core/src/main/java/com/yahoo/jdisc/application/BindingSet.java index 7a21e204dd3..1e25846f63c 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/application/BindingSet.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/application/BindingSet.java @@ -38,9 +38,10 @@ public class BindingSet<T> implements Iterable<Map.Entry<UriPattern, T>> { */ public BindingMatch<T> match(URI uri) { for (Map.Entry<UriPattern, T> entry : bindings) { - UriPattern.Match match = entry.getKey().match(uri); + UriPattern pattern = entry.getKey(); + UriPattern.Match match = pattern.match(uri); if (match != null) { - return new BindingMatch<>(match, entry.getValue()); + return new BindingMatch<>(match, entry.getValue(), pattern); } } return null; diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/application/ContainerThread.java b/jdisc_core/src/main/java/com/yahoo/jdisc/application/ContainerThread.java index 4506a63ac6d..1e947d44fcd 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/application/ContainerThread.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/application/ContainerThread.java @@ -22,8 +22,8 @@ public class ContainerThread extends Thread { * Allocates a new ContainerThread object. This constructor calls the parent {@link Thread#Thread(Runnable)} * constructor. * - * @param target The object whose <code>run</code> method is called. - * @param consumer The MetricConsumer of this thread. + * @param target the object whose <code>run</code> method is called. + * @param consumer the MetricConsumer of this thread. */ public ContainerThread(Runnable target, MetricConsumer consumer) { super(target); @@ -56,6 +56,7 @@ public class ContainerThread extends Thread { public Thread newThread(Runnable target) { return new ContainerThread(target, provider.get()); } + } } diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/core/StandaloneMain.java b/jdisc_core/src/main/java/com/yahoo/jdisc/core/StandaloneMain.java index fc3997657dc..cd52a724275 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/core/StandaloneMain.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/core/StandaloneMain.java @@ -48,6 +48,8 @@ public class StandaloneMain { System.out.println("debug\tStopped ok."); System.exit(0); } catch (Exception e) { + System.out.print("debug\tUnexpected: "); + e.printStackTrace(); log.log(Level.SEVERE, "Unexpected: ", e); System.exit(6); } diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/test/ServerProviderConformanceTest.java b/jdisc_core/src/main/java/com/yahoo/jdisc/test/ServerProviderConformanceTest.java index d2b58090665..e7039e85e5e 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/test/ServerProviderConformanceTest.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/test/ServerProviderConformanceTest.java @@ -24,7 +24,6 @@ import java.io.StringWriter; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; -import java.net.URI; import java.nio.ByteBuffer; import java.util.HashSet; import java.util.Set; @@ -35,14 +34,18 @@ import java.util.concurrent.Executors; import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import java.util.logging.Logger; import java.util.stream.Stream; /** - * @author <a href="mailto:simon@yahoo-inc.com">Simon Thoresen Hult</a> + * @author Simon Thoresen Hult */ @SuppressWarnings("UnusedDeclaration") @Beta public abstract class ServerProviderConformanceTest { + + private static final Logger log = Logger.getLogger(ServerProviderConformanceTest.class.getName()); + private static final int NUM_RUNS_EACH_TEST = 10; /** @@ -2790,7 +2793,7 @@ public abstract class ServerProviderConformanceTest { serverProvider.release(); for (int i = 0; i < NUM_RUNS_EACH_TEST; ++i) { - System.out.println("Test run #" + i); + log.fine("Test run #" + i); requestHandler.reset(adapter.newResponseContent()); final U client = adapter.newClient(serverProvider); final boolean withRequestContent = requestType == RequestType.WITH_CONTENT; |