Review Board 1.7.22


FLUME-2208. Jetty's default SocketSelector leaks File descriptors

Review Request #14547 - Created Oct. 8, 2013 and updated

Hari Shreedharan
FLUME-2208
Reviewers
Flume
flume-git
Use SelectChannelConnector instead of SocketChannelConnector fixes the issue
All tests pass
flume-ng-core/src/main/java/org/apache/flume/instrumentation/http/HTTPMetricsServer.java
Revision 373e344 New Change
[20] 26 lines
[+20]
27
import javax.servlet.http.HttpServletRequest;
27
import javax.servlet.http.HttpServletRequest;
28
import javax.servlet.http.HttpServletResponse;
28
import javax.servlet.http.HttpServletResponse;
29
import org.apache.flume.Context;
29
import org.apache.flume.Context;
30
import org.apache.flume.instrumentation.MonitorService;
30
import org.apache.flume.instrumentation.MonitorService;
31
import org.apache.flume.instrumentation.util.JMXPollUtil;
31
import org.apache.flume.instrumentation.util.JMXPollUtil;

    
   
32
import org.mortbay.jetty.Connector;
32
import org.mortbay.jetty.Request;
33
import org.mortbay.jetty.Request;
33
import org.mortbay.jetty.Server;
34
import org.mortbay.jetty.Server;
34
import org.mortbay.jetty.handler.AbstractHandler;
35
import org.mortbay.jetty.handler.AbstractHandler;

    
   
36
import org.mortbay.jetty.nio.SelectChannelConnector;
35
import org.slf4j.Logger;
37
import org.slf4j.Logger;
36
import org.slf4j.LoggerFactory;
38
import org.slf4j.LoggerFactory;
37

    
   
39

   
38
/**
40
/**
39
 * A Monitor service implementation that runs a web server on a configurable
41
 * A Monitor service implementation that runs a web server on a configurable
[+20] [20] 13 lines
[+20] [+] public class HTTPMetricsServer implements MonitorService {
53
  public static int DEFAULT_PORT = 41414;
55
  public static int DEFAULT_PORT = 41414;
54
  public static String CONFIG_PORT = "port";
56
  public static String CONFIG_PORT = "port";
55

    
   
57

   
56
  @Override
58
  @Override
57
  public void start() {
59
  public void start() {
58
    jettyServer = new Server(port);
60
    jettyServer = new Server();
59
    //We can use Contexts etc if we have many urls to handle. For one url,
61
    //We can use Contexts etc if we have many urls to handle. For one url,
60
    //specifying a handler directly is the most efficient.
62
    //specifying a handler directly is the most efficient.

    
   
63
    SelectChannelConnector connector = new SelectChannelConnector();

    
   
64
    connector.setReuseAddress(true);

    
   
65
    connector.setPort(port);

    
   
66
    jettyServer.setConnectors(new Connector[] {connector});
61
    jettyServer.setHandler(new HTTPMetricsHandler());
67
    jettyServer.setHandler(new HTTPMetricsHandler());
62
    try {
68
    try {
63
      jettyServer.start();
69
      jettyServer.start();
64
      while (!jettyServer.isStarted()) {
70
      while (!jettyServer.isStarted()) {
65
        Thread.sleep(500);
71
        Thread.sleep(500);
[+20] [20] 63 lines
flume-ng-core/src/main/java/org/apache/flume/source/http/HTTPSource.java
Revision de79e8b New Change
 
  1. flume-ng-core/src/main/java/org/apache/flume/instrumentation/http/HTTPMetricsServer.java: Loading...
  2. flume-ng-core/src/main/java/org/apache/flume/source/http/HTTPSource.java: Loading...