Skip to content

Commit

Permalink
FLUME-2208. Jetty's default SocketSelector leaks File descriptors
Browse files Browse the repository at this point in the history
(Hari Shreedharan via Mike Percy)
  • Loading branch information
mpercy committed Oct 9, 2013
1 parent 20eed3f commit 02fc1a8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@
import org.apache.flume.Context;
import org.apache.flume.instrumentation.MonitorService;
import org.apache.flume.instrumentation.util.JMXPollUtil;
import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Request;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.AbstractHandler;
import org.mortbay.jetty.nio.SelectChannelConnector;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -55,9 +57,13 @@ public class HTTPMetricsServer implements MonitorService {

@Override
public void start() {
jettyServer = new Server(port);
jettyServer = new Server();
//We can use Contexts etc if we have many urls to handle. For one url,
//specifying a handler directly is the most efficient.
SelectChannelConnector connector = new SelectChannelConnector();
connector.setReuseAddress(true);
connector.setPort(port);
jettyServer.setConnectors(new Connector[] {connector});
jettyServer.setHandler(new HTTPMetricsHandler());
try {
jettyServer.start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.apache.flume.source.AbstractSource;
import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.bio.SocketConnector;
import org.mortbay.jetty.nio.SelectChannelConnector;
import org.mortbay.jetty.security.SslSocketConnector;
import org.mortbay.jetty.servlet.ServletHolder;
import org.slf4j.Logger;
Expand Down Expand Up @@ -174,9 +174,11 @@ public void start() {
SslSocketConnector sslSocketConnector = new SslSocketConnector();
sslSocketConnector.setKeystore(keyStorePath);
sslSocketConnector.setKeyPassword(keyStorePassword);
sslSocketConnector.setReuseAddress(true);
connectors[0] = sslSocketConnector;
} else {
SocketConnector connector = new SocketConnector();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setReuseAddress(true);
connectors[0] = connector;
}

Expand Down

0 comments on commit 02fc1a8

Please sign in to comment.