Review Board 1.7.22


FLUME-721: Webapps 'autofindport' feature does not work

Review Request #1604 - Created Aug. 19, 2011 and submitted

Jonathan Hsieh
flume-721
Reviewers
Flume
aprabhakar, esammer
flume-git
This was previously posted at https://review.cloudera.org/r/1894/ and pushed because of timeout.  The patch actually was later then reverted because it had some problems with imports.  Since the previous patch had timed-out as opposed to being actually reviewed, I'm reposting for review.


  FLUME-721: Webapps 'autofindport' feature does not work
    
    This refactors the internal http server so that context are created by a callback object.
ran tests, they passed.
flume-core/src/main/java/com/cloudera/flume/agent/FlumeNode.java
Revision b8f2b67 New Change
[20] 31 lines
[+20]
32
import org.apache.commons.cli.Options;
32
import org.apache.commons.cli.Options;
33
import org.apache.commons.cli.ParseException;
33
import org.apache.commons.cli.ParseException;
34
import org.apache.commons.cli.PosixParser;
34
import org.apache.commons.cli.PosixParser;
35
import org.apache.hadoop.conf.Configuration;
35
import org.apache.hadoop.conf.Configuration;
36
import org.apache.hadoop.security.UserGroupInformation;
36
import org.apache.hadoop.security.UserGroupInformation;

    
   
37
import org.mortbay.jetty.handler.ContextHandlerCollection;
37
import org.slf4j.Logger;
38
import org.slf4j.Logger;
38
import org.slf4j.LoggerFactory;
39
import org.slf4j.LoggerFactory;
39

    
   
40

   
40
import com.cloudera.flume.VersionInfo;
41
import com.cloudera.flume.VersionInfo;
41
import com.cloudera.flume.agent.diskfailover.DiskFailoverManager;
42
import com.cloudera.flume.agent.diskfailover.DiskFailoverManager;
[+20] [20] 17 lines
[+20]
59
import com.cloudera.flume.util.FlumeVMInfo;
60
import com.cloudera.flume.util.FlumeVMInfo;
60
import com.cloudera.flume.util.SystemInfo;
61
import com.cloudera.flume.util.SystemInfo;
61
import com.cloudera.util.CheckJavaVersion;
62
import com.cloudera.util.CheckJavaVersion;
62
import com.cloudera.util.FileUtil;
63
import com.cloudera.util.FileUtil;
63
import com.cloudera.util.InternalHttpServer;
64
import com.cloudera.util.InternalHttpServer;

    
   
65
import com.cloudera.util.InternalHttpServer.ContextCreator;
64
import com.cloudera.util.NetUtils;
66
import com.cloudera.util.NetUtils;
65
import com.cloudera.util.Pair;
67
import com.cloudera.util.Pair;
66
import com.cloudera.util.StatusHttpServer.StackServlet;

   
67
import com.google.common.base.Preconditions;
68
import com.google.common.base.Preconditions;
68

    
   
69

   
69
/**
70
/**
70
 * This is a configurable flume node.
71
 * This is a configurable flume node.
71
 * 
72
 * 
[+20] [20] 184 lines
[+20] [+] public ReportEvent getMetrics() {
256
    ReportManager.get().add(vmInfo);
257
    ReportManager.get().add(vmInfo);
257
    ReportManager.get().add(sysInfo);
258
    ReportManager.get().add(sysInfo);
258
    ReportManager.get().add(this);
259
    ReportManager.get().add(this);
259

    
   
260

   
260
    if (startHttp) {
261
    if (startHttp) {
261
      try {
262
      int nodePort = conf.getNodeStatusPort();
262
        http = new InternalHttpServer();
263
      String bindAddress = "0.0.0.0";
263

    
   
264
      ContextCreator cc = new ContextCreator() {
264
        http.addHandler(InternalHttpServer.createLogAppContext());
265
        @Override
265

    
   
266
        public void addContexts(ContextHandlerCollection handlers) {
266
        http.addHandler(InternalHttpServer.createServletContext(
267
          handlers.addHandler(InternalHttpServer.createLogAppContext());
267
            StackServlet.class, "/stacks", "/*", "stacks"));
268
          handlers.addHandler(InternalHttpServer.createStackSevletContext());
268

    
   

   
269
        http.setBindAddress("0.0.0.0");

   
270
        http.setPort(conf.getNodeStatusPort());

   
271
        String webAppRoot = FlumeConfiguration.get().getNodeWebappRoot();
269
          String webAppRoot = FlumeConfiguration.get().getNodeWebappRoot();
272
        http.setWebappDir(new File(webAppRoot));
270
          InternalHttpServer.addHandlersFromPaths(handlers,
273
        http.setScanForApps(true);
271
              new File(webAppRoot));
274

    
   

   
275
        http.start();

   
276
      } catch (Throwable t) {

   
277
        LOG.error("Unexpected exception/error thrown! " + t.getMessage(), t);

   
278
      }
272
        }

    
   
273
      };

    
   
274
      http = InternalHttpServer.startFindPortHttpServer(cc, bindAddress,

    
   
275
          nodePort);
279
    }
276
    }
280

    
   
277

   
281
    if (reportPusher != null) {
278
    if (reportPusher != null) {
282
      reportPusher.start();
279
      reportPusher.start();
283
    }
280
    }
[+20] [20] 85 lines
[+20] [+] public static void logEnvironment(Logger log) {
369
    }
366
    }
370
  }
367
  }
371

    
   
368

   
372
  /**
369
  /**
373
   * This function checks the agent logs dir to make sure that the process has
370
   * This function checks the agent logs dir to make sure that the process has
374
   * the ability to the directory if necessary, that the path if it does exist is
371
   * the ability to the directory if necessary, that the path if it does exist
375
   * a directory, and that it can in fact create files inside of the directory.
372
   * is a directory, and that it can in fact create files inside of the
376
   * If it fails any of these, it throws an exception.
373
   * directory. If it fails any of these, it throws an exception.
377
   * 
374
   * 
378
   * Finally, it checks to see if the path is in /tmp and warns the user that
375
   * Finally, it checks to see if the path is in /tmp and warns the user that
379
   * this may not be the best idea.
376
   * this may not be the best idea.
380
   */
377
   */
381
  public static void nodeConfigChecksOk() throws IOException {
378
  public static void nodeConfigChecksOk() throws IOException {
[+20] [20] 442 lines
flume-core/src/main/java/com/cloudera/flume/master/FlumeMaster.java
Revision 5c99c43 New Change
 
flume-core/src/main/java/com/cloudera/util/HttpServerTestUtils.java
New File
 
flume-core/src/main/java/com/cloudera/util/InternalHttpServer.java
Revision 1f41460 New Change
 
flume-core/src/main/java/com/cloudera/util/StatusHttpServer.java
Revision 58c0ece New Change
 
flume-core/src/test/java/com/cloudera/flume/agent/TestNodeJersey.java
Revision 2625a99 New Change
 
flume-core/src/test/java/com/cloudera/flume/master/TestMasterJersey.java
Revision 146cd33 New Change
 
flume-core/src/test/java/com/cloudera/util/InternalHttpServerTest.java
Revision b6a4cdd New Change
 
flume-core/src/test/java/com/cloudera/util/TestStatusHttpServer.java
Revision ac47ac5 New Change
 
flume-node-web/src/test/java/com/cloudera/flume/agent/TestBootstrap.java
Revision 8d241dd New Change
 
  1. flume-core/src/main/java/com/cloudera/flume/agent/FlumeNode.java: Loading...
  2. flume-core/src/main/java/com/cloudera/flume/master/FlumeMaster.java: Loading...
  3. flume-core/src/main/java/com/cloudera/util/HttpServerTestUtils.java: Loading...
  4. flume-core/src/main/java/com/cloudera/util/InternalHttpServer.java: Loading...
  5. flume-core/src/main/java/com/cloudera/util/StatusHttpServer.java: Loading...
  6. flume-core/src/test/java/com/cloudera/flume/agent/TestNodeJersey.java: Loading...
  7. flume-core/src/test/java/com/cloudera/flume/master/TestMasterJersey.java: Loading...
  8. flume-core/src/test/java/com/cloudera/util/InternalHttpServerTest.java: Loading...
  9. flume-core/src/test/java/com/cloudera/util/TestStatusHttpServer.java: Loading...
  10. flume-node-web/src/test/java/com/cloudera/flume/agent/TestBootstrap.java: Loading...