comparison artifact-database/src/main/java/de/intevation/artifactdatabase/rest/Standalone.java @ 262:5cab846eb2a3

flys/issue65: Set number of max. restlet threads to 1024 and make it configurable. artifacts/trunk@1943 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 18 May 2011 10:10:11 +0000
parents b2115f484edb
children c0fb96f88ad1
comparison
equal deleted inserted replaced
261:f3d970a832ff 262:5cab846eb2a3
47 /** 47 /**
48 * The default port of the HTTP server: 8181 48 * The default port of the HTTP server: 8181
49 */ 49 */
50 public static final int DEFAULT_PORT = 8181; 50 public static final int DEFAULT_PORT = 8181;
51 51
52 public static final String MAX_THREADS =
53 "/artifact-database/rest-server/max-threads/text()";
54
55 public static final String MAX_THREADS_DEFAULT =
56 "1024";
57
52 /** 58 /**
53 * Builds a RestApp wrapped around the given artifact database, 59 * Builds a RestApp wrapped around the given artifact database,
54 * and bind this application to HTTP server. The HTTP server 60 * and bind this application to HTTP server. The HTTP server
55 * is configured by the global configuration. If no port is 61 * is configured by the global configuration. If no port is
56 * given by the configuration the default port is used. If 62 * given by the configuration the default port is used. If
60 * REST application. 66 * REST application.
61 */ 67 */
62 public static void startAsServer(ArtifactDatabase db) { 68 public static void startAsServer(ArtifactDatabase db) {
63 String portString = Config.getStringXPath(REST_PORT); 69 String portString = Config.getStringXPath(REST_PORT);
64 String listenString = Config.getStringXPath(LISTEN_INTERFACE); 70 String listenString = Config.getStringXPath(LISTEN_INTERFACE);
71 String maxThreads = Config.getStringXPath(MAX_THREADS);
65 72
66 int port = DEFAULT_PORT; 73 int port = DEFAULT_PORT;
67 74
68 if (portString != null) { 75 if (portString != null) {
69 try { 76 try {
91 server = new Server(Protocol.HTTP, port); 98 server = new Server(Protocol.HTTP, port);
92 } 99 }
93 100
94 component.getServers().add(server); 101 component.getServers().add(server);
95 102
96 server.getContext().getParameters().add("maxThreads", "512"); 103 server.getContext().getParameters().add(
104 "maxThreads", maxThreads != null
105 ? maxThreads
106 : MAX_THREADS_DEFAULT);
97 107
98 component.getDefaultHost().attach(app); 108 component.getDefaultHost().attach(app);
99 109
100 logger.info("Starting rest HTTP server on " 110 logger.info("Starting rest HTTP server on "
101 + (listenString != null ? listenString : "*") 111 + (listenString != null ? listenString : "*")

http://dive4elements.wald.intevation.org