Merge remote-tracking branch 'origin/master' into jetty-http2

This commit is contained in:
Greg Wilkins 2014-06-10 09:01:21 +02:00
commit 5883123d07
17 changed files with 217 additions and 84 deletions

View File

@ -9,7 +9,7 @@ server
etc/jetty-ssl.xml
[files]
http://git.eclipse.org/c/jetty/org.eclipse.jetty.project.git/plain/jetty-server/src/main/config/etc/keystore:etc/keystore
http://git.eclipse.org/c/jetty/org.eclipse.jetty.project.git/plain/jetty-server/src/main/config/etc/keystore|etc/keystore
[ini-template]
## SSL Keystore Configuration

View File

@ -375,15 +375,15 @@ public class Main
// Find any named ini file and check it follows the convention
Path start_ini = baseHome.getBasePath("start.ini");
String short_start_ini = baseHome.toShortForm(start_ini);
Path ini = start_d.resolve(name + ".ini");
String short_ini = baseHome.toShortForm(ini);
Path startd_ini = start_d.resolve(name + ".ini");
String short_startd_ini = baseHome.toShortForm(startd_ini);
StartIni module_ini = null;
if (FS.exists(ini))
if (FS.exists(startd_ini))
{
module_ini = new StartIni(ini);
module_ini = new StartIni(startd_ini);
if (module_ini.getLineMatches(Pattern.compile("--module=(.*, *)*" + name)).size() == 0)
{
StartLog.warn("ERROR: %s is not enabled in %s!",name,short_ini);
StartLog.warn("ERROR: %s is not enabled in %s!",name,short_startd_ini);
return;
}
}
@ -392,7 +392,7 @@ public class Main
boolean has_ini_lines = module.getInitialise().size() > 0;
// If it is not enabled or is transitive with ini template lines or toplevel and doesn't exist
if (!module.isEnabled() || (transitive && has_ini_lines) || (topLevel && !FS.exists(ini) && !appendStartIni))
if (!module.isEnabled() || (transitive && has_ini_lines) || (topLevel && !FS.exists(startd_ini) && !appendStartIni))
{
// File BufferedWriter
BufferedWriter writer = null;
@ -412,9 +412,9 @@ public class Main
// Create the directory if needed
FS.ensureDirectoryExists(start_d);
FS.ensureDirectoryWritable(start_d);
source = short_ini;
source = short_startd_ini;
StartLog.info("%-15s initialised in %s (created)",name,source);
writer = Files.newBufferedWriter(ini,StandardCharsets.UTF_8,StandardOpenOption.CREATE_NEW,StandardOpenOption.WRITE);
writer = Files.newBufferedWriter(startd_ini,StandardCharsets.UTF_8,StandardOpenOption.CREATE_NEW,StandardOpenOption.WRITE);
out = new PrintWriter(writer);
}
@ -463,9 +463,9 @@ public class Main
}
}
}
else if (FS.exists(ini))
else if (FS.exists(startd_ini))
{
StartLog.info("%-15s initialised in %s",name,short_ini);
StartLog.info("%-15s initialised in %s",name,short_startd_ini);
}
else
{
@ -475,7 +475,8 @@ public class Main
// Also list other places this module is enabled
for (String source : module.getSources())
{
if (!short_ini.equals(source))
StartLog.debug("also enabled in: %s",source);
if (!short_start_ini.equals(source))
{
StartLog.info("%-15s enabled in %s",name,baseHome.toShortForm(source));
}

View File

@ -23,12 +23,12 @@ import static org.eclipse.jetty.start.UsageException.*;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Stack;
import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -98,7 +98,7 @@ public final class Props implements Iterable<Prop>
return l;
}
private Map<String, Prop> props = new HashMap<>();
private Map<String, Prop> props = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
private List<String> sysPropTracking = new ArrayList<>();
public void addAll(Props other)
@ -114,7 +114,7 @@ public final class Props implements Iterable<Prop>
* @param arg the argument to parse for a potential property
* @param source the source for this argument (to track origin of property from)
*/
public void addPossibleProperty(String arg, String source)
public boolean addPossibleProperty(String arg, String source)
{
// Start property (syntax similar to System property)
if (arg.startsWith("-D"))
@ -125,15 +125,14 @@ public final class Props implements Iterable<Prop>
case 2:
setSystemProperty(assign[0],assign[1]);
setProperty(assign[0],assign[1],source);
break;
return true;
case 1:
setSystemProperty(assign[0],"");
setProperty(assign[0],"",source);
break;
return true;
default:
break;
return false;
}
return;
}
// Is this a raw property declaration?
@ -144,10 +143,11 @@ public final class Props implements Iterable<Prop>
String value = arg.substring(idx + 1);
setProperty(key,value,source);
return;
return true;
}
// All other strings are ignored
return false;
}
public String cleanReference(String property)

View File

@ -0,0 +1,97 @@
//
// ========================================================================
// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.start;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.jetty.start.RawArgs.Entry;
public class RawArgs implements Iterable<Entry>
{
public class Entry
{
private String line;
private String origin;
private Entry(String line, String origin)
{
this.line = line;
this.origin = origin;
}
public String getLine()
{
return line;
}
public String getOrigin()
{
return origin;
}
public boolean startsWith(String val)
{
return line.startsWith(val);
}
}
/**
* All of the args, in argument order
*/
private List<Entry> args = new ArrayList<>();
public void addAll(List<String> lines, Path sourceFile)
{
String source = sourceFile.toAbsolutePath().toString();
for (String line : lines)
{
addArg(line,source);
}
}
public void addArg(final String rawline, final String source)
{
if (rawline == null)
{
return;
}
String line = rawline.trim();
if (line.length() == 0)
{
return;
}
args.add(new Entry(line,source));
}
@Override
public Iterator<Entry> iterator()
{
return args.iterator();
}
public int size()
{
return args.size();
}
}

View File

@ -639,9 +639,9 @@ public class StartArgs
while (iter.hasPrevious())
{
ConfigSource source = iter.previous();
for (String arg : source.getArgs())
for (RawArgs.Entry arg : source.getArgs())
{
parse(arg,source.getId());
parse(arg.getLine(),arg.getOrigin());
}
}
}

View File

@ -96,9 +96,9 @@ public class StartLog
String logFileName = cmdLineSource.getProperty("start-log-file");
for (String arg : cmdLineSource.getArgs())
for (RawArgs.Entry arg : cmdLineSource.getArgs())
{
if ("--debug".equals(arg))
if ("--debug".equals(arg.getLine()))
{
debug = true;
continue;
@ -106,14 +106,14 @@ public class StartLog
if (arg.startsWith("--start-log-file"))
{
logFileName = Props.getValue(arg);
logFileName = Props.getValue(arg.getLine());
continue;
}
}
if (logFileName != null)
{
Path logfile = baseHome.getBasePath(logFileName);
Path logfile = baseHome.getPath(logFileName);
initLogFile(logfile);
}
}

View File

@ -23,8 +23,6 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -32,6 +30,7 @@ import org.eclipse.jetty.start.BaseHome;
import org.eclipse.jetty.start.FS;
import org.eclipse.jetty.start.Props;
import org.eclipse.jetty.start.Props.Prop;
import org.eclipse.jetty.start.RawArgs;
import org.eclipse.jetty.start.UsageException;
/**
@ -42,17 +41,18 @@ public class CommandLineConfigSource implements ConfigSource
public static final String ORIGIN_INTERNAL_FALLBACK = "<internal-fallback>";
public static final String ORIGIN_CMD_LINE = "<command-line>";
private final List<String> args;
private final RawArgs args;
private final Props props;
private final Path homePath;
private final Path basePath;
public CommandLineConfigSource(String rawargs[])
{
this.args = Arrays.asList(rawargs);
this.args = new RawArgs();
this.props = new Props();
for (String arg : args)
for (String arg : rawargs)
{
this.args.addArg(arg,ORIGIN_CMD_LINE);
this.props.addPossibleProperty(arg,ORIGIN_CMD_LINE);
}
@ -179,7 +179,7 @@ public class CommandLineConfigSource implements ConfigSource
}
@Override
public List<String> getArgs()
public RawArgs getArgs()
{
return args;
}

View File

@ -18,9 +18,8 @@
package org.eclipse.jetty.start.config;
import java.util.List;
import org.eclipse.jetty.start.Props;
import org.eclipse.jetty.start.RawArgs;
/**
* A Configuration Source
@ -57,7 +56,7 @@ public interface ConfigSource
*
* @return the list of Arguments for this ConfigSource
*/
public List<String> getArgs();
public RawArgs getArgs();
/**
* The properties for this ConfigSource

View File

@ -31,6 +31,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.eclipse.jetty.start.FS;
import org.eclipse.jetty.start.Props;
import org.eclipse.jetty.start.RawArgs;
import org.eclipse.jetty.start.Props.Prop;
import org.eclipse.jetty.start.UsageException;
@ -67,11 +68,11 @@ public class ConfigSources implements Iterable<ConfigSource>
updateProps();
// look for --include-jetty-dir entries
for (String arg : source.getArgs())
for (RawArgs.Entry arg : source.getArgs())
{
if (arg.startsWith("--include-jetty-dir"))
{
String ref = getValue(arg);
String ref = getValue(arg.getLine());
String dirName = props.expand(ref);
Path dir = FS.toPath(dirName);
DirConfigSource dirsource = new DirConfigSource(ref,dir,sourceWeight.incrementAndGet(),true);

View File

@ -33,6 +33,7 @@ import org.eclipse.jetty.start.FS;
import org.eclipse.jetty.start.NaturalSort;
import org.eclipse.jetty.start.PathMatchers;
import org.eclipse.jetty.start.Props;
import org.eclipse.jetty.start.RawArgs;
import org.eclipse.jetty.start.UsageException;
import org.eclipse.jetty.start.Props.Prop;
import org.eclipse.jetty.start.StartIni;
@ -71,7 +72,7 @@ public class DirConfigSource implements ConfigSource
private final String id;
private final Path dir;
private final int weight;
private final List<String> args;
private final RawArgs args;
private final Props props;
/**
@ -95,7 +96,7 @@ public class DirConfigSource implements ConfigSource
this.weight = weight;
this.props = new Props();
this.args = new ArrayList<>();
this.args = new RawArgs();
if (canHaveArgs)
{
@ -103,7 +104,7 @@ public class DirConfigSource implements ConfigSource
if (FS.canReadFile(iniFile))
{
StartIni ini = new StartIni(iniFile);
args.addAll(ini.getLines());
args.addAll(ini.getLines(),iniFile);
parseAllArgs(ini.getLines(),iniFile.toString());
}
@ -138,7 +139,7 @@ public class DirConfigSource implements ConfigSource
{
StartLog.debug("Reading %s/start.d/%s - %s",id,diniFile.getFileName(),diniFile);
StartIni ini = new StartIni(diniFile);
args.addAll(ini.getLines());
args.addAll(ini.getLines(),diniFile);
parseAllArgs(ini.getLines(),diniFile.toString());
}
}
@ -194,7 +195,7 @@ public class DirConfigSource implements ConfigSource
}
@Override
public List<String> getArgs()
public RawArgs getArgs()
{
return args;
}

View File

@ -98,6 +98,7 @@ Module Management:
modules. This may download a file from the network if the
module provides a URL.
Startup / Shutdown Command Line:
--------------------------------
@ -120,44 +121,26 @@ Properties:
Jetty server has stopped. If not specified, the stopper will wait
indefinitely. Use in conjunction with the --stop option.
Advanced Commands:
------------------
--download=<http-uri>:<location>
Advanced usage, If the file does not exist at the given
location, download it from the given http URI.
Note: location is always relative to ${jetty.base}
--lib=<classpath>
Add arbitrary classpath entries to the the server classpath.
--include-jetty-dir=<path>
Include an extra jetty directory to use as a source
for configuration details. This directory behaves similarly
to ${jetty.base} but sits at a layer between ${jetty.base}
and ${jetty.home}. This allows for some complex hierarchies
of configuration details.
System Properties:
------------------
These are set with a command line like "java -Dname=value ..." and are
accessible via the java.lang.System#getProperty(String) API.
Some key system properties are:
org.eclipse.jetty.util.log.class=[class]
A Low Level Jetty Logger Implementation to use
(default: org.eclipse.jetty.util.log.Slf4jLog)
[name|hierarchy].LEVEL=[loglevel]
Change loglevel for the stderr and javautil Loggers. Slf4j
and other loggers must be separately configured for debug.
For example: Dorg.eclipse.jetty.LEVEL=DEBUG
(default: INFO)
org.eclipse.jetty.util.log.IGNORED=[boolean]
Ignored exceptions are logged, independent of DEBUG settings
(default: false)
org.eclipse.jetty.util.log.SOURCE=[boolean]
The source location of logs is logged in the stderr Logger.
(default: false)
com.sun.management.jmxremote
Enable remote JMX management in Sun JVMS.
--download=<http-uri>|<location>
Advanced usage, If the file does not exist at the given
location, download it from the given http URI.
Notes: location is always relative to ${jetty.base}.
you might need to escape the slash "\|" to use
this on some environments.
Properties:
@ -180,6 +163,18 @@ Properties:
Defaults:
---------
A ${jetty.base}/start.ini file and/or ${jetty.base|/start.d/*.ini files may be
used to specify default arguments to start.jar. In case of a conflict between
the command line, and ini files, the command line will win.
Command line arguments can come from any jetty configuration directory
(except ${jetty.home}), such as ${jetty.base} and any added jetty directories
(see --include-jetty-dir=<path>).
The contents of <path>/start.ini and <path>/start.d/*.ini are all used
to build up your command line arguments.
In case of a conflict, the resolution of who wins, will look like this.
1) <command-line itself>
2) ${jetty.base}/start.ini
3) ${jetty.base}/start.d/*.ini
4) <jetty-dir>/start.ini
5) <jetty-dir>/start.d/*.ini
For more information on startup, see the online documentation at
http://www.eclipse.org/jetty/documentation/

View File

@ -124,7 +124,7 @@ public class ConfigurationAssert
{
if (darg.uri != null)
{
actualDownloads.add(String.format("%s:%s",darg.uri,darg.location));
actualDownloads.add(String.format("%s|%s",darg.uri,darg.location));
}
}
assertContainsUnordered("Downloads",expectedDownloads,actualDownloads);

View File

@ -31,7 +31,7 @@ PROP|jetty.truststore.password=sundae
PROP|java.version=1.7.0_21
# The Downloads
DOWNLOAD|http://central.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.5.v20130313/npn-boot-1.1.5.v20130313.jar:lib/npn/npn-boot-1.1.5.v20130313.jar
DOWNLOAD|http://central.maven.org/maven2/org/mortbay/jetty/npn/npn-boot/1.1.5.v20130313/npn-boot-1.1.5.v20130313.jar|lib/npn/npn-boot-1.1.5.v20130313.jar
# The Bootlib
BOOTLIB|-Xbootclasspath/p:lib/npn/npn-boot-1.1.5.v20130313.jar

View File

@ -1,5 +1,4 @@
# The XMLs we expect (order is important)
XML|${jetty.home}/etc/jetty-logging.xml
XML|${jetty.home}/etc/jetty.xml
XML|${jetty.home}/etc/jetty-http.xml
@ -23,4 +22,11 @@ PROP|jetty.port=9090
# Other File References
FILE|logs/
FILE|resources/
FILE|resources/
# Downloads
DOWNLOAD|http://central.maven.org/maven2/org/slf4j/slf4j-api/1.6.6/slf4j-api-1.6.6.jar|lib/logging/slf4j-api-1.6.6.jar
DOWNLOAD|http://repo1.maven.org/maven2/ch/qos/logback/logback-core/1.0.7/logback-core-1.0.7.jar|lib/logging/logback-core-1.0.7.jar
DOWNLOAD|http://repo1.maven.org/maven2/ch/qos/logback/logback-classic/1.0.7/logback-classic-1.0.7.jar|lib/logging/logback-classic-1.0.7.jar
DOWNLOAD|https://raw.githubusercontent.com/jetty-project/logging-modules/master/logback/logback.xml|resources/logback.xml
DOWNLOAD|https://raw.githubusercontent.com/jetty-project/logging-modules/master/logback/jetty-logging.properties|resources/jetty-logging.properties

View File

@ -0,0 +1,20 @@
#
# Jetty with logback logging
#
[depend]
resources
[files]
logs/
resources/
http://central.maven.org/maven2/org/slf4j/slf4j-api/1.6.6/slf4j-api-1.6.6.jar|lib/logging/slf4j-api-1.6.6.jar
http://repo1.maven.org/maven2/ch/qos/logback/logback-core/1.0.7/logback-core-1.0.7.jar|lib/logging/logback-core-1.0.7.jar
http://repo1.maven.org/maven2/ch/qos/logback/logback-classic/1.0.7/logback-classic-1.0.7.jar|lib/logging/logback-classic-1.0.7.jar
https://raw.githubusercontent.com/jetty-project/logging-modules/master/logback/logback.xml|resources/logback.xml
https://raw.githubusercontent.com/jetty-project/logging-modules/master/logback/jetty-logging.properties|resources/jetty-logging.properties
[lib]
lib/logging/**.jar
resources/

View File

@ -0,0 +1,2 @@
# Configure Jetty for SLf4j Logging
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.Slf4jLog

View File

@ -22,6 +22,8 @@ import java.io.Closeable;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.util.concurrent.CancellationException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;
@ -157,9 +159,9 @@ public class SharedBlockingCallback
{
if (_state == null)
{
// TODO remove before release
// TODO remove when feedback received on 435322
if (cause==null)
LOG.warn("null failed cause ",new Throwable());
LOG.warn("null failed cause (please report stack trace) ",new Throwable());
_state = cause==null?FAILED:cause;
_complete.signalAll();
}
@ -188,7 +190,16 @@ public class SharedBlockingCallback
try
{
while (_state == null)
_complete.await();
{
// TODO remove this debug timout!
// This is here to help debug 435322,
if (!_complete.await(10,TimeUnit.MINUTES))
{
IOException x = new IOException("DEBUG timeout");
LOG.warn("Blocked too long (please report!!!) "+this, x);
_state=x;
}
}
if (_state == SUCCEEDED)
return;