diff options
Diffstat (limited to 'jdisc_core/src/main')
22 files changed, 86 insertions, 577 deletions
diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/HeaderFields.java b/jdisc_core/src/main/java/com/yahoo/jdisc/HeaderFields.java index 500b1258735..5c35bed2cec 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/HeaderFields.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/HeaderFields.java @@ -8,7 +8,7 @@ import java.util.*; /** * This is an encapsulation of the header fields that belong to either a {@link Request} or a {@link Response}. It is * a multimap from String to String, with some additional methods for convenience. The keys of this map are compared by - * ignoring their case, so that <tt>get("foo")</tt> returns the same entry as <tt>get("FOO")</tt>. + * ignoring their case, so that <code>get("foo")</code> returns the same entry as <code>get("FOO")</code>. * * @author Simon Thoresen Hult */ @@ -121,7 +121,7 @@ public class HeaderFields implements Map<String, List<String>> { /** * <p>Adds all the entries of the given map to this. This is the same as calling {@link #add(String, List)} for each - * entry in <tt>values</tt>.</p> + * entry in <code>values</code>.</p> * * @param values The values to be added to this. */ @@ -137,8 +137,8 @@ public class HeaderFields implements Map<String, List<String>> { * * @param key The key of the entry to put. * @param value The value to put. - * @return The previous value associated with <tt>key</tt>, or <tt>null</tt> if there was no mapping for - * <tt>key</tt>. + * @return The previous value associated with <code>key</code>, or <code>null</code> if there was no mapping for + * <code>key</code>. */ public List<String> put(String key, String value) { ArrayList<String> list = new ArrayList<String>(1); 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 2a1967abd13..061d803b978 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/Request.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/Request.java @@ -120,7 +120,6 @@ public class Request extends AbstractResource { * * @return The container instance. */ - // TODO: Vespa 7 remove. public Container container() { return parent != null ? parent.container() : container; } 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 7318b1b38ae..98b0ef870e1 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 @@ -22,19 +22,6 @@ 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. */ @@ -62,7 +49,7 @@ public class BindingMatch<T> { * empty string. This method never returns null.</p> * * @param idx The index of the group to return. - * @return The (possibly empty) substring captured by the group during matching, never <tt>null</tt>. + * @return The (possibly empty) substring captured by the group during matching, never <code>null</code>. * @throws IndexOutOfBoundsException If there is no group in the match with the given index. */ public String group(int idx) { diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/application/MetricConsumer.java b/jdisc_core/src/main/java/com/yahoo/jdisc/application/MetricConsumer.java index d9bf67b530f..f060f1840ff 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/application/MetricConsumer.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/application/MetricConsumer.java @@ -39,7 +39,7 @@ import java.util.Map; public interface MetricConsumer { /** - * <p>Consume a call to <tt>Metric.set(String, Number, Metric.Context)</tt>.</p> + * <p>Consume a call to <code>Metric.set(String, Number, Metric.Context)</code>.</p> * * @param key The name of the metric to modify. * @param val The value to assign to the named metric. @@ -48,7 +48,7 @@ public interface MetricConsumer { public void set(String key, Number val, Metric.Context ctx); /** - * <p>Consume a call to <tt>Metric.add(String, Number, Metric.Context)</tt>.</p> + * <p>Consume a call to <code>Metric.add(String, Number, Metric.Context)</code>.</p> * * @param key The name of the metric to modify. * @param val The value to add to the named metric. @@ -57,9 +57,9 @@ public interface MetricConsumer { public void add(String key, Number val, Metric.Context ctx); /** - * <p>Creates a <tt>Metric.Context</tt> object that encapsulates the given properties. The returned Context object - * will be passed along every future call to <tt>set(String, Number, Metric.Context)</tt> and - * <tt>add(String, Number, Metric.Context)</tt> where the properties match those given here.</p> + * <p>Creates a <code>Metric.Context</code> object that encapsulates the given properties. The returned Context object + * will be passed along every future call to <code>set(String, Number, Metric.Context)</code> and + * <code>add(String, Number, Metric.Context)</code> where the properties match those given here.</p> * * @param properties The properties to incorporate in the context. * @return The created context. diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/application/OsgiFramework.java b/jdisc_core/src/main/java/com/yahoo/jdisc/application/OsgiFramework.java index 85d745d7aaf..5abc95cc610 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/application/OsgiFramework.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/application/OsgiFramework.java @@ -18,9 +18,9 @@ public interface OsgiFramework { /** * <p>Installs a bundle from the specified location. The specified location identifier will be used as the identity - * of the bundle. If a bundle containing the same location identifier is already installed, the <tt>Bundle</tt> + * of the bundle. If a bundle containing the same location identifier is already installed, the <code>Bundle</code> * object for that bundle is returned. All bundles listed in the {@link OsgiHeader#PREINSTALL_BUNDLE} manifest - * header are also installed. The bundle at index 0 of the returned list matches the <tt>bundleLocation</tt> + * header are also installed. The bundle at index 0 of the returned list matches the <code>bundleLocation</code> * argument.</p> * * <p><b>NOTE:</b> When this method installs more than one bundle, <em>AND</em> one of those bundles throw an @@ -29,8 +29,8 @@ public interface OsgiFramework { * BundleInstallationException} that contains the list of successfully installed bundles.</p> * * <p>It would be preferable if this method was exception-safe (that it would roll-back all installed bundles in the - * case of an exception), but that can not be implemented thread-safely since an <tt>Application</tt> may choose to - * install bundles concurrently through any available <tt>BundleContext</tt>.</p> + * case of an exception), but that can not be implemented thread-safely since an <code>Application</code> may choose to + * install bundles concurrently through any available <code>BundleContext</code>.</p> * * @param bundleLocation The location identifier of the bundle to install. * @return The list of Bundle objects installed, the object at index 0 matches the given location. @@ -41,7 +41,7 @@ public interface OsgiFramework { List<Bundle> installBundle(String bundleLocation) throws BundleException; /** - * <p>Starts the given {@link Bundle}s. The parameter <tt>privileged</tt> tells the framework whether or not + * <p>Starts the given {@link Bundle}s. The parameter <code>privileged</code> tells the framework whether or not * privileges are available, and is checked against the {@link OsgiHeader#PRIVILEGED_ACTIVATOR} header of each * Bundle being started. Any bundle that is a fragment is silently ignored.</p> * @@ -63,10 +63,10 @@ public interface OsgiFramework { /** * <p>Returns the BundleContext of this framework's system bundle. The returned BundleContext can be used by the - * caller to act on behalf of this bundle. This method may return <tt>null</tt> if it has no valid + * caller to act on behalf of this bundle. This method may return <code>null</code> if it has no valid * BundleContext.</p> * - * @return A <tt>BundleContext</tt> for the system bundle, or <tt>null</tt>. + * @return A <code>BundleContext</code> for the system bundle, or <code>null</code>. * @throws SecurityException If the caller does not have the appropriate permissions. */ BundleContext bundleContext(); diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/application/ResourcePool.java b/jdisc_core/src/main/java/com/yahoo/jdisc/application/ResourcePool.java index 279d99f63b7..ccbd1693b21 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/application/ResourcePool.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/application/ResourcePool.java @@ -87,8 +87,8 @@ public final class ResourcePool extends AbstractResource implements AutoCloseabl * destroyed, it will release the main reference to the resource (by calling {@link SharedResource#release()}).</p> * * @param t The SharedResource to add. - * @param <T> The class of parameter <tt>t</tt>. - * @return The parameter <tt>t</tt>, to allow inlined calls to this function. + * @param <T> The class of parameter <code>t</code>. + * @return The parameter <code>t</code>, to allow inlined calls to this function. */ public <T extends SharedResource> T add(T t) { try { @@ -147,8 +147,8 @@ public final class ResourcePool extends AbstractResource implements AutoCloseabl * {@link SharedResource#refer()} call.</p> * * @param t The SharedResource to retain and add. - * @param <T> The class of parameter <tt>t</tt>. - * @return The parameter <tt>t</tt>, to allow inlined calls to this function. + * @param <T> The class of parameter <code>t</code>. + * @return The parameter <code>t</code>, to allow inlined calls to this function. */ public <T extends SharedResource> T retain(T t) { resources.add(t.refer()); 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 89cb6412181..0e6e5d28260 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 @@ -40,7 +40,7 @@ public class UriPattern implements Comparable<UriPattern> { private final int priority; /** - * <p>Creates a new instance of this class that represents the given pattern string, with a priority of <tt>0</tt>. + * <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 * '*' can be used as a wildcard character at any position.</p> * @@ -207,7 +207,7 @@ public class UriPattern implements Comparable<UriPattern> { * the empty string. This method never returns null.</p> * * @param idx The index of the group to return. - * @return The (possibly empty) substring captured by the group during matching, never <tt>null</tt>. + * @return The (possibly empty) substring captured by the group during matching, never <code>null</code>. * @throws IndexOutOfBoundsException If there is no group in the match with the given index. */ public String group(int idx) { diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/application/package-info.java b/jdisc_core/src/main/java/com/yahoo/jdisc/application/package-info.java index 9308bc4d17a..c856712e1af 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/application/package-info.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/application/package-info.java @@ -148,5 +148,4 @@ $ sudo jdisc_start target/myapp.jar * @see com.yahoo.jdisc.handler * @see com.yahoo.jdisc.service */ -@com.yahoo.api.annotations.PublicApi package com.yahoo.jdisc.application; diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/client/package-info.java b/jdisc_core/src/main/java/com/yahoo/jdisc/client/package-info.java index e0a17245c1f..c328cc1e382 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/client/package-info.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/client/package-info.java @@ -5,5 +5,4 @@ * * @see com.yahoo.jdisc.client.ClientApplication */ -@com.yahoo.api.annotations.PublicApi package com.yahoo.jdisc.client; diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/core/ExportPackages.java b/jdisc_core/src/main/java/com/yahoo/jdisc/core/ExportPackages.java index e8e6373f2ed..7a09690b35d 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/core/ExportPackages.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/core/ExportPackages.java @@ -13,7 +13,6 @@ import java.io.FileInputStream; import java.io.FileWriter; import java.io.IOException; import java.nio.file.Files; -import java.nio.file.Paths; import java.util.HashMap; import java.util.Map; import java.util.Properties; @@ -36,45 +35,45 @@ public class ExportPackages { if (!fileName.endsWith(PROPERTIES_FILE)) { throw new IllegalArgumentException("Expected '" + PROPERTIES_FILE + "', got '" + fileName + "'."); } - StringBuilder out = new StringBuilder(); - out.append(getSystemPackages()).append(",") - .append("com.sun.security.auth,") - .append("com.sun.security.auth.module,") - .append("com.sun.management,") - .append("com.yahoo.jdisc,") - .append("com.yahoo.jdisc.application,") - .append("com.yahoo.jdisc.handler,") - .append("com.yahoo.jdisc.service,") - .append("com.yahoo.jdisc.statistics,") - .append("javax.inject;version=1.0.0,") // Included in guice, but not exported. Needed by container-jersey. - .append("org.aopalliance.intercept,") - .append("org.aopalliance.aop,") - .append("sun.misc,") - .append("sun.net.util,") - .append("sun.security.krb5,") - - // TODO: remove for Vespa 7 (xml-apis:xml-apis:1.4.01 is not a bundle, but exposed from system classpath on Java 9) - .append("org.w3c.dom.bootstrap,") - .append("org.w3c.dom.css,") - .append("org.w3c.dom.events,") - .append("org.w3c.dom.html,") - .append("org.w3c.dom.ls,") - .append("org.w3c.dom.ranges,") - .append("org.w3c.dom.stylesheets,") - .append("org.w3c.dom.traversal,") - .append("org.w3c.dom.views"); - - for (int i = 1; i < args.length; ++i) { - out.append(",").append(getExportedPackages(args[i])); - } + String exportPackages = getExportPackages(args); Properties props = new Properties(); - props.setProperty(EXPORT_PACKAGES, out.toString()); + props.setProperty(EXPORT_PACKAGES, exportPackages); try (FileWriter writer = new FileWriter(new File(fileName))) { props.store(writer, "generated by " + ExportPackages.class.getName()); } } + private static String getExportPackages(String[] jars) throws IOException { + StringBuilder out = new StringBuilder(); + out.append(getSystemPackages()).append(", ") + .append("com.yahoo.jdisc, ") + .append("com.yahoo.jdisc.application, ") + .append("com.yahoo.jdisc.handler, ") + .append("com.yahoo.jdisc.service, ") + .append("com.yahoo.jdisc.statistics, ") + .append("javax.inject;version=1.0.0, ") // Included in guice, but not exported. Needed by container-jersey. + .append("org.aopalliance.intercept, ") + .append("org.aopalliance.aop"); + + for (int i = 1; i < jars.length; ++i) { + out.append(", ").append(getExportedPackages(jars[i])); + } + + //TODO: temporary additions for backwards compatibility with Vespa 6. Remove when all apps have been built with 7 + out.append(", ") + .append("javax.annotation, ") + .append("javax.activation, ") + .append("javax.xml.bind.annotation.adapters, ") + .append("javax.xml.bind.annotation, ") + .append("javax.xml.bind.attachment, ") + .append("javax.xml.bind.helpers, ") + .append("javax.xml.bind.util, ") + .append("javax.xml.bind"); + + return out.toString(); + } + public static String readExportProperty() { Properties props = new Properties(); try { diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/core/FelixParams.java b/jdisc_core/src/main/java/com/yahoo/jdisc/core/FelixParams.java index 10dbd09792f..9b877f68efd 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/core/FelixParams.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/core/FelixParams.java @@ -12,10 +12,21 @@ import java.util.Map; */ public class FelixParams { - private final StringBuilder exportPackages = new StringBuilder(ExportPackages.readExportProperty()); + private final StringBuilder exportPackages; private String cachePath = null; private boolean loggerEnabled = true; + public FelixParams() { + this(ExportPackages.readExportProperty()); + } + + // For testing only + // Needed because the set of system packages is no longer constant between JVM invocations, + // since Felix 6 and JDK 9. + FelixParams(String exportPackages) { + this.exportPackages = new StringBuilder(exportPackages); + } + public FelixParams exportPackage(String pkg) { exportPackages.append(",").append(pkg); return this; diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/core/OsgiLogHandler.java b/jdisc_core/src/main/java/com/yahoo/jdisc/core/OsgiLogHandler.java index e72df8fc7e1..d774b857b49 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/core/OsgiLogHandler.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/core/OsgiLogHandler.java @@ -6,7 +6,9 @@ import org.osgi.framework.Bundle; import org.osgi.framework.ServiceReference; import org.osgi.service.log.LogService; +import java.util.Dictionary; import java.util.HashMap; +import java.util.Hashtable; import java.util.Map; import java.util.logging.Handler; import java.util.logging.Level; @@ -160,5 +162,11 @@ class OsgiLogHandler extends Handler { public int compareTo(Object o) { return 0; } + + @Override + public Dictionary<String, Object> getProperties() { + return new Hashtable<>(); + } + } } diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/handler/CallableRequestDispatch.java b/jdisc_core/src/main/java/com/yahoo/jdisc/handler/CallableRequestDispatch.java index cfbd4edcf8f..135a56f2d6b 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/handler/CallableRequestDispatch.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/handler/CallableRequestDispatch.java @@ -8,8 +8,8 @@ import java.util.concurrent.Callable; /** * This is a convenient subclass of {@link RequestDispatch} that implements the {@link Callable} interface. This * should be used in place of {@link RequestDispatch} if you intend to schedule its execution. Because {@link #call()} - * does not return until a {@link Response} becomes available, you can use the <tt>Future</tt> return value of - * <tt>ExecutorService.submit(Callable)</tt> to wait for it. + * does not return until a {@link Response} becomes available, you can use the <code>Future</code> return value of + * <code>ExecutorService.submit(Callable)</code> to wait for it. * * @author Simon Thoresen Hult */ diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/handler/CallableResponseDispatch.java b/jdisc_core/src/main/java/com/yahoo/jdisc/handler/CallableResponseDispatch.java index 0471e05a5f9..e92edf15bba 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/handler/CallableResponseDispatch.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/handler/CallableResponseDispatch.java @@ -9,7 +9,7 @@ import java.util.concurrent.Callable; * This is a convenient subclass of {@link ResponseDispatch} that implements the {@link Callable} interface. This * should be used in place of {@link ResponseDispatch} if you intend to schedule its execution. Because {@link #call()} * does not return until the entirety of the {@link Response} and its content have been consumed, you can use the - * <tt>Future</tt> return value of <tt>ExecutorService.submit(Callable)</tt> to wait for it to complete. + * <code>Future</code> return value of <code>ExecutorService.submit(Callable)</code> to wait for it to complete. * * @author Simon Thoresen Hult */ diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/handler/FutureConjunction.java b/jdisc_core/src/main/java/com/yahoo/jdisc/handler/FutureConjunction.java index 4380ad0cbd2..c48798ca2ab 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/handler/FutureConjunction.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/handler/FutureConjunction.java @@ -11,7 +11,7 @@ import java.util.concurrent.*; /** * <p>This class implements a Future<Boolean> that is conjunction of zero or more other Future<Boolean>s, - * i.e. it evaluates to <tt>true</tt> if, and only if, all its operands evaluate to <tt>true</tt>. To use this class, + * i.e. it evaluates to <code>true</code> if, and only if, all its operands evaluate to <code>true</code>. To use this class, * simply create an instance of it and add operands to it using the {@link #addOperand(ListenableFuture)} method.</p> * TODO: consider rewriting usage of FutureConjunction to use CompletableFuture instead. * diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/handler/RequestDispatch.java b/jdisc_core/src/main/java/com/yahoo/jdisc/handler/RequestDispatch.java index 211c5474fe6..3dc0961cdcb 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/handler/RequestDispatch.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/handler/RequestDispatch.java @@ -73,7 +73,7 @@ public abstract class RequestDispatch implements ListenableFuture<Response>, Res /** * <p>This methods calls {@link #newRequest()} to create a new {@link Request}, and then calls {@link - * Request#connect(ResponseHandler)} on that. This method uses a <tt>finally</tt> block to make sure that the + * Request#connect(ResponseHandler)} on that. This method uses a <code>finally</code> block to make sure that the * Request is always {@link Request#release() released}.</p> * * @return The ContentChannel to write the Request's content to. @@ -98,7 +98,7 @@ public abstract class RequestDispatch implements ListenableFuture<Response>, Res /** * <p>This method calls {@link #connect()} to establish a {@link ContentChannel} for the {@link Request}, and then * iterates through all the ByteBuffers returned by {@link #requestContent()} and writes them to that - * ContentChannel. This method uses a <tt>finally</tt> block to make sure that the ContentChannel is always {@link + * ContentChannel. This method uses a <code>finally</code> block to make sure that the ContentChannel is always {@link * ContentChannel#close(CompletionHandler) closed}.</p> * * <p>The returned Future will wait for all CompletionHandlers associated with the Request have been completed, and diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/handler/ResponseDispatch.java b/jdisc_core/src/main/java/com/yahoo/jdisc/handler/ResponseDispatch.java index e5e6b752716..22a77968dfd 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/handler/ResponseDispatch.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/handler/ResponseDispatch.java @@ -82,7 +82,7 @@ public abstract class ResponseDispatch extends ForwardingListenableFuture<Boolea /** * <p>This method calls {@link #connect(ResponseHandler)} to establish a {@link ContentChannel} for the {@link * Response}, and then iterates through all the ByteBuffers returned by {@link #responseContent()} and writes them - * to that ContentChannel. This method uses a <tt>finally</tt> block to make sure that the ContentChannel is always + * to that ContentChannel. This method uses a <code>finally</code> block to make sure that the ContentChannel is always * {@link ContentChannel#close(CompletionHandler) closed}.</p> * <p>The returned Future will wait for all CompletionHandlers associated with the Response have been * completed.</p> diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/handler/ThreadedRequestHandler.java b/jdisc_core/src/main/java/com/yahoo/jdisc/handler/ThreadedRequestHandler.java index a2bea1566de..6e2895f118b 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/handler/ThreadedRequestHandler.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/handler/ThreadedRequestHandler.java @@ -126,7 +126,7 @@ public abstract class ThreadedRequestHandler extends AbstractRequestHandler { /** * <p>Implement this method if you want to access the {@link Request}'s content using a {@link ContentInputStream}. * If you do not override this method, it will dispatch a {@link Response} to the {@link ResponseHandler} with a - * <tt>Response.Status.NOT_IMPLEMENTED</tt> status.</p> + * <code>Response.Status.NOT_IMPLEMENTED</code> status.</p> * * @param request The Request to handle. * @param responseHandler The handler to pass the corresponding {@link Response} to. diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/package-info.java b/jdisc_core/src/main/java/com/yahoo/jdisc/package-info.java index ff8dd242587..d1d842fa3f6 100644 --- a/jdisc_core/src/main/java/com/yahoo/jdisc/package-info.java +++ b/jdisc_core/src/main/java/com/yahoo/jdisc/package-info.java @@ -50,6 +50,5 @@ * @see com.yahoo.jdisc.service * @see com.yahoo.jdisc.test */ -// TODO: Vespa 7 remove internal classes (at least Container) out of this PublicApi package. @com.yahoo.api.annotations.PublicApi package com.yahoo.jdisc; 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 e7039e85e5e..7e913456074 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 @@ -49,7 +49,7 @@ public abstract class ServerProviderConformanceTest { private static final int NUM_RUNS_EACH_TEST = 10; /** - * <p>This interface declares the adapter between the general conformance test and an actual <tt>ServerProvider</tt> + * <p>This interface declares the adapter between the general conformance test and an actual <code>ServerProvider</code> * implementation. Every test runs as follows:</p> * <ol> * <li>{@link #newConfigModule()} is called to bind server-specific configuration.</li> @@ -59,7 +59,7 @@ public abstract class ServerProviderConformanceTest { * <li>{@link #validateResponse(Object)} is called once per call to {@link #executeRequest(Object, boolean)}.</li> * </ol> * - * @param <T> The <tt>ServerProvider</tt> under test. + * @param <T> The <code>ServerProvider</code> under test. * @param <U> An object that represents a remote client that can connect to the server. * @param <V> An object that holds the response generated by the client when executing a request. */ @@ -80,7 +80,7 @@ public abstract class ServerProviderConformanceTest { /** * <p>An instance of this exception is thrown within the conformance tests that imply that they will throw an - * exception. If your <tt>ServerProvider</tt> is capable of exposing such information, then this class is what you + * exception. If your <code>ServerProvider</code> is capable of exposing such information, then this class is what you * need to look for in the output.</p> */ public static class ConformanceException extends RuntimeException { diff --git a/jdisc_core/src/main/perl/vespa-jdisc-logfmt b/jdisc_core/src/main/perl/vespa-jdisc-logfmt deleted file mode 100755 index 655fd8da24c..00000000000 --- a/jdisc_core/src/main/perl/vespa-jdisc-logfmt +++ /dev/null @@ -1,277 +0,0 @@ -#!/usr/bin/env perl -# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -sub findhome { - # Try the VESPA_HOME env variable - return $ENV{'VESPA_HOME'} if defined $ENV{'VESPA_HOME'}; - if ( $0 =~ m{(.*)/bin[^/]*/[^/]*logfmt[^/]*$} ) { - return $1; - } - return "/opt/vespa"; -} - -my $VESPA_HOME = findhome(); - -# TODO: Remove on Vespa 7 - -use 5.006_001; -use strict; -use warnings; - -use File::Basename; -use Getopt::Long qw(:config no_ignore_case); - -my %showflags = ( - time => 1, - fmttime => 1, - msecs => 1, - usecs => 0, - host => 0, - level => 1, - pid => 0, - service => 1, - component => 1, - message => 1 - ); - -my %levelflags = ( - error => 1, - warning => 1, - info => 1, - debug => 0, - unknown => 0 - ); - -# Do not buffer the output -$| = 1; - -my $compore; -my $msgtxre; -my $onlypid; -my $onlysvc; -my $onlyhst; - -my $shortsvc; -my $shortcmp; - -my @optlevels; -my @optaddlevels; -my @optshow; -my $optaddlevels; -my $optlevels; -my $optfollow; -my $optnldequote; -my $opthelp = ''; - -my $bad = 0; - -GetOptions ('level|l=s' => \@optlevels, - 'add-level|L=s' => \@optaddlevels, - 'service|S=s' => \$onlysvc, - 'show|s=s' => \@optshow, - 'pid|p=s' => \$onlypid, - 'component|c=s' => \$compore, - 'message|m=s' => \$msgtxre, - 'help|h' => \$opthelp, - 'follow|f' => \$optfollow, - 'nldequote|N' => \$optnldequote, - 'host|H=s' => \$onlyhst, - 'truncateservice|ts' => \$shortsvc, - 'truncatecomponent|tc|t' => \$shortcmp, - ) or $bad=1; - -if ( @ARGV == 0 and ! -p STDIN) { - push(@ARGV, "$VESPA_HOME/logs/jdisc_core/jdisc_core.log"); -} - -if ( $optfollow ) { - my $filearg = ""; - if ( @ARGV > 1 ) { - print STDERR "ERROR: Cannot follow more than one file\n\n"; - $bad=1; - } else { - $filearg = shift @ARGV if (@ARGV > 0); - open(STDIN, "tail -F $filearg |") - or die "cannot open 'tail -F $filearg' as input pipe\n"; - } -} - -$optaddlevels = join(",", @optaddlevels ); -if ( $optaddlevels ) { - my @l = split(/,/, $optaddlevels); - my $l; - foreach $l ( @l ) { - $levelflags{$l} = 0; - } -} - -if ( $opthelp || $bad ) { - print STDERR "Usage: ", basename($0), " [options] [inputfile ...]\n", - "Options:\n", - " -l LEVELLIST\t--level=LEVELLIST\tselect levels to include\n", - " -L LEVELLIST\t--add-level=LEVELLIST\tdefine extra levels\n", - " -s FIELDLIST\t--show=FIELDLIST\tselect fields to print\n", - " -p PID\t--pid=PID\t\tselect messages from given PID\n", - " -S SERVICE\t--service=SERVICE\tselect messages from given SERVICE\n", - " -H HOST\t--host=HOST\t\tselect messages from given HOST\n", - " -c REGEX\t--component=REGEX\tselect components matching REGEX\n", - " -m REGEX\t--message=REGEX\t\tselect message text matching REGEX\n", - " -f\t\t--follow\t\tinvoke tail -F to follow input file\n", - " -N\t\t--nldequote\t\tdequote newlines in message text field\n", - " -t\t--tc\t--truncatecomponent\tchop component to 15 chars\n", - " \t--ts\t--truncateservice\tchop service to 9 chars\n", - "\n", - "FIELDLIST is comma separated, available fields:\n", - "\t time fmttime msecs usecs host level pid service component message\n", - "Available levels for LEVELLIST:\n", - "\t ", join(" ", sort keys(%levelflags)), "\n", - "for both lists, use 'all' for all possible values, and -xxx to disable xxx.\n"; - exit $bad; -} - -$optlevels = join(",", @optlevels ); -if ( $optlevels ) { - my $k; - unless ( $optlevels =~ s/^\+// or $optlevels =~ m/^-/ ) { - $levelflags{$_} = 0 foreach ( keys %levelflags ); - } - my @l = split(/,|(?=-)/, $optlevels); - my $l; - foreach $l ( @l ) { - my $v = 1; - my $minus = ""; - if ( $l =~ s/^-// ) { $v = 0; $minus = "-"; } - if ( $l eq "all" ) { - foreach $k ( keys %levelflags ) { - $levelflags{$k} = $v; - } - } elsif ( defined $levelflags{$l} ) { - $levelflags{$l} = $v; - } else { - print STDERR "bad level option '$minus$l'\n"; - exit 1; - } - } -} - -my $optshow; -$optshow = join(",", @optshow ); -if ( $optshow ) { - my $k; - unless ( $optshow =~ s/^\+// or $optshow =~ m/^-/ ) { - $showflags{$_} = 0 foreach ( keys %showflags ); - } - my @l = split(/,|(?=-)/, $optshow); - my $l; - foreach $l ( @l ) { - my $v = 1; - my $minus = ""; - if ( $l =~ s/^-// ) { $v = 0; $minus = "-"; } - if ( $l eq "all" ) { - foreach $k ( keys %showflags ) { - $showflags{$k} = $v; - } - } elsif ( defined $showflags{$l} ) { - $showflags{$l} = $v; - } else { - print STDERR "bad show option '$minus$l'\n"; - exit 1; - } - } -} - -while (<>) { - chomp; - if ( /^ - (\d+)\.?(\d*) # seconds, optional fractional seconds - \t - ([^\t]*) # host - \t - (\d+\/?\d*|\-\/\d+) # pid, optional tid - \t - ([^\t]*) # servicename - \t - ([^\t]*) # componentname - \t - (\w+) # level - \t - (.*) # message text - $/x ) - { - my $secs = $1; - my $usec = $2 . "000000"; # make sure we have atleast 6 digits - my $host = $3; - my $pidn = $4; - my $svcn = $5; - my $comp = $6; - my $levl = $7; - my $msgt = $8; - - if ( ! defined $levelflags{$levl} ) { - print STDERR "Warning: unknown level '$levl' in input\n"; - $levelflags{$levl} = 1; - } - next unless ( $levelflags{$levl} ); - - if ($compore && $comp !~ m/$compore/o) { next; } - if ($msgtxre && $msgt !~ m/$msgtxre/o) { next; } - if ($onlypid && $pidn ne $onlypid) { next; } - if ($onlysvc && $svcn ne $onlysvc) { next; } - if ($onlyhst && $host ne $onlyhst) { next; } - - $levl = "\U$levl"; - - my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday); - ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday)=localtime($secs); - my $datestr = sprintf("%04d-%02d-%02d", - 1900+$year, 1+$mon, $mday); - my $timestr = sprintf("%02d:%02d:%02d", - $hour, $min, $sec); - - if ( $showflags{"time"} || $showflags{"fmttime"} ) { - if ($showflags{"fmttime"} ) { - print "[$datestr $timestr"; - if ( $showflags{"usecs"} ) { - printf ".%.6s", $usec; - } elsif ( $showflags{"msecs"} ) { - printf ".%.3s", $usec; - } - print "] "; - } else { - printf "%s.%.6s ", $secs, $usec; - } - } - if ( $showflags{"host"} ) { - printf "%-8s ", $host; - } - if ( $showflags{"level"} ) { - printf "%-7s : ", $levl; - } - if ( $showflags{"pid"} ) { - printf "%5s ", $pidn; - } - if ( $showflags{"service"} ) { - if ( $shortsvc ) { - printf "%-9.9s ", $svcn; - } else { - printf "%-16s ", $svcn; - } - } - if ( $showflags{"component"} ) { - if ( $shortcmp ) { - printf "%-15.15s ", $comp; - } else { - printf "%s\t", $comp; - } - } - if ( $showflags{"message"} ) { - if ( $optnldequote ) { - $msgt = "\n\t${msgt}" if ( $msgt =~ s/\\n/\n\t/g ); - } - print $msgt; - } - print "\n"; - } else { - print STDERR "bad log line: '$_'\n"; - } -} diff --git a/jdisc_core/src/main/perl/vespa-jdisc-logfmt.1 b/jdisc_core/src/main/perl/vespa-jdisc-logfmt.1 deleted file mode 100644 index 2f855d94207..00000000000 --- a/jdisc_core/src/main/perl/vespa-jdisc-logfmt.1 +++ /dev/null @@ -1,215 +0,0 @@ -.\" Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -.\" $Id: logfmt.1,v 1.12 2007-06-19 09:37:25 daljord Exp $ -.\" -.Dd October 29, 2004 -.Dt VESPA-JDISC-LOGFMT \&1 "JDisc documentation" -.Os "Yahoo! JDisc" "2.3" -.Os -.Sh NAME -.Nm vespa-jdisc-logfmt -.Nd select and format messages from JDisc log files -.Sh SYNOPSIS -.Nm -.Op Fl L Ar levellist -.Op Fl l Ar levellist -.Op Fl s Ar fieldlist -.Op Fl p Ar pid -.Op Fl S Ar service -.Op Fl H Ar host -.Op Fl c Ar regex -.Op Fl m Ar regex -.Op Fl t -.Op Fl f -.Op Fl N -.Op Fl ts -.Op Ar -.Sh DESCRIPTION -The -.Nm -utility reads JDisc log files, select messages and writes a formatted -version of selected messages to the standard output. -.Pp -The options are as follows: -.Bl -tag -width ".It Fl l Ar levellist" -.It Fl L Ar levellist -Declares additional log levels that should be treated as known. These -levels are suppressed unless also given as argument to option -l. -.Ar levellist -is a comma separated list of level names. -.It Fl l Ar levellist -Select which log levels to select. -The default is to select "error", "warning" and "info" levels, and -suppress "debug" and "unknown" levels; but when using this option, only -the named levels will be selected. -The -.Ar levellist -is a comma separated list of level names. -The name -.Em all -may be used to add all known levels. -Prepending a minus sign will deselect the level named. -Starting the list with a plus sign will add and remove levels -from the current (or default) list of levels instead -of replacing it. -.It Fl s Ar fieldlist -Select which fields of log messages to show. -The order of the actual output fields is fixed. -When using this option, only the named fields will be shown. The -fieldlist is a comma separated list of field names. The name -.Em all -may be used to add all possible fields. -Prepending a minus sign will turn off display of the named field. -Starting the list with a plus sign will add and remove fields -from the current (or default) list of fields instead -of replacing it. -.Pp -The fields which may be named are: -.Bl -tag -width component -.It time -Print the time in seconds since the epoch. -Ignored if -.Em fmttime -is shown. -.It fmttime -Print the time in human-readable [YYYY-MM-DD HH:mm:ss] format. -Note that the time is printed in the local timezone; to get GMT -output use -.Nm "\*[q]env TZ=GMT vespa-jdisc-logfmt\*[q]" -as your command. -.It msecs -Add milliseconds after the seconds in -.Em time -and -.Em fmttime -output. Ignored if -.Em usecs -is in effect. -.It usecs -Add microseconds after the seconds in -.Em time -and -.Em fmttime -output. -.It host -Print the hostname field. -.It level -Print the level field (uppercased). -.It pid -Print the pid field. -.It service -Print the service field. -.It component -Print the component field. -.It message -Print the message text field. -You probably always want to add this. -.El -.Pp -Using this option several times works as if the given -.Ar fieldlist -arguments had been concatenated into one comma-separated list. -The default fields to show are as if -.Bk -.Op Fl s Ar fmttime,msecs,level,service,component,message -.Ek -had been given. -.It Fl p Ar pid -Select only messages where the pid field matches the -.Ar pid -string exactly. -.It Fl S Ar service -Select only messages where the service field matches the -.Ar service -string exactly. -.It Fl H Ar host -Select only messages where the hostname field matches the -.Ar host -string exactly. -.It Fl c Ar regex -Select only messages where the component field matches the -.Ar regex -given, using -.Xr perlre -regular expression matching. -.It Fl m Ar regex -Select only messages where the message text field matches the -.Ar regex -given, using -.Xr perlre -regular expression matching. -.It Fl f -Invoke tail -F to follow input file -.It Fl N -Dequote quoted newlines in the message text field to an actual newline plus tab. -.It Fl t -Format the component field (if shown) as a fixed-with string, -truncating if necessary. -.It Fl ts -Format the service field (if shown) as a fixed-with string, -truncating if necessary. -.El -.Sh EXAMPLES -The command: -.Pp -.Bd -literal -offset indent -vespa-jdisc-logfmt -l event -s service,message,fmttime,message -.Ed -.Pp -will display only messages with log level "event", -printing a human-readable time (without any fractional seconds), -the service generating the event and the event message, like this: -.Bd -literal -offset indent -[2004-12-07 18:43:01] config-sentinel starting/1 name="logd" -[2004-12-07 18:43:01] logd started/1 name="logdemon" -[2004-12-07 18:45:51] rtc starting/1 name="rtc.index0" -[2004-12-07 18:45:51] rtc.index0 started/1 name="flexindexer.index" -[2004-12-07 18:45:51] rtc.index0 stopping/1 name="flexindexer.index" why="done" -[2004-12-07 18:45:53] rtc stopped/1 name="rtc.index0" pid=50600 exitcode=0 -[2004-12-07 18:46:13] logd stopping/1 name="logdemon" why="done ok." -[2004-12-07 18:46:13] config-sentinel stopped/1 name="logd" pid=49633 exitcode=0 -.Ed -.Pp -Note that the second "message" item in the fieldlist is redundant, -and that order of printed field is fixed no matter what the fieldlist -order is. -.Pp -The command: -.Pp -.Bd -literal -offset indent -vespa-jdisc-logfmt -l all-info,-debug -s level \e - -s time,usecs,component,message -t -l -event -.Ed -.Pp -will display messages with log levels that are -.Em not -any of -.Em info, debug, -or -.Em event, -printing the time in seconds and microseconds, the log level, the -component name, and the message text, possibly somewhat like this: -.Bd -literal -offset indent -1102441382.530423 CONFIG : nc Config handle: 'pandora.0-rtx' -1102441551.471568 CONFIG : flexindexer.doc Adding document type typetest-0 -1102441573.148211 WARNING : logdemon stopping on signal 15 -1102441887.158000 WARNING : com.yahoo.fs4.m read exception -1102441935.569567 WARNING : rtc Dispatch inherited job failed for dir dispatch0 -1102442115.746001 WARNING : fdispatch Search node 172.24.94.75:10124 down -1102442474.205920 WARNING : rtx RTC (tcp/172.24.94.75:10161) : DOWN -1102442474.515877 WARNING : fdispatch Search node localhost:10128 down -1102442983.075669 ERROR : flexindexer.std Unable to find cluster map defaultcluster -.Ed -.Sh FILES -If no file argument is given, -.Nm -will read the last JDisc log file $VESPA_HOME/logs/jdisc_core/jdisc_core.log (this also works with the -.Fl f -option). -Otherwise, reads only the files given as arguments. -To read standard input, supply a single dash '-' as a file argument. -.Sh SEE ALSO -Documentation in the "log" module for input file format. -.Sh HISTORY -Developed as part of Vespa 1.1, later moved to JDisc 2.3. The default output -format reflects the old "fastlib" log formatting, with minor differences -and is intended to be human-readable, not parsed. |