Ejemplo n.º 1
0
  public FlumeNode(
      FlumeConfiguration conf, String nodeName, MasterRPC rpc, boolean startHttp, boolean oneshot) {
    this.physicalNodeName = nodeName;
    rpcMan = rpc;
    instance = this;
    this.startHttp = startHttp;
    this.nodesMan = new LogicalNodeManager(nodeName);

    File defaultDir = new File(conf.getAgentLogsDir(), getPhysicalNodeName());
    WALManager walMan = new NaiveFileWALManager(defaultDir);
    this.walMans.put(getPhysicalNodeName(), walMan);
    this.failoverMans.put(getPhysicalNodeName(), new NaiveFileFailoverManager(defaultDir));

    // no need for liveness tracker if a one shot execution.
    this.collectorAck = new CollectorAckListener(rpcMan);
    if (!oneshot) {
      this.liveMan = new LivenessManager(nodesMan, rpcMan, new FlumeNodeWALNotifier(this.walMans));
      this.reportPusher = new MasterReportPusher(conf, simpleReportManager, rpcMan);

    } else {
      this.liveMan = null;
      this.reportPusher = null;
    }

    // initializing ChokeController
    this.chokeMan = new ChokeManager();

    this.vmInfo = new FlumeVMInfo(PHYSICAL_NODE_REPORT_PREFIX + this.getPhysicalNodeName() + ".");
    this.sysInfo = new SystemInfo(PHYSICAL_NODE_REPORT_PREFIX + this.getPhysicalNodeName() + ".");
  }
Ejemplo n.º 2
0
 public WALManager addWalManager(String walnode) {
   Preconditions.checkArgument(walnode != null);
   FlumeConfiguration conf = FlumeConfiguration.get();
   WALManager wm = new NaiveFileWALManager(new File(new File(conf.getAgentLogsDir()), walnode));
   synchronized (walMans) {
     walMans.put(walnode, wm);
     return wm;
   }
 }
Ejemplo n.º 3
0
 public DiskFailoverManager addDFOManager(String dfonode) {
   Preconditions.checkArgument(dfonode != null);
   FlumeConfiguration conf = FlumeConfiguration.get();
   DiskFailoverManager wm =
       new NaiveFileFailoverManager(new File(new File(conf.getAgentLogsDir()), dfonode));
   synchronized (failoverMans) {
     failoverMans.put(dfonode, wm);
     return wm;
   }
 }
Ejemplo n.º 4
0
  /**
   * This function checks the agent logs dir to make sure that the process has the ability to the
   * directory if necessary, that the path if it does exist is a directory, and that it can in fact
   * create files inside of the directory. If it fails any of these, it throws an exception.
   *
   * <p>Finally, it checks to see if the path is in /tmp and warns the user that this may not be the
   * best idea.
   */
  public static void nodeConfigChecksOk() throws IOException {
    // TODO (jon) if we add more checks in here, make the different managers
    // responsible for throwing an Exception on construction instead.

    FlumeConfiguration conf = FlumeConfiguration.get();

    String s = conf.getAgentLogsDir();
    File f = new File(s);

    if (!FileUtil.makeDirs(f)) {
      throw new IOException("Path to Log dir cannot be created: '" + s + "'.  Check permissions?");
    }

    if (!f.isDirectory()) {
      throw new IOException("Log dir '" + s + "' already exists as a file.  Check log dir path.");
    }

    File f2 = null;
    try {
      f2 = File.createTempFile("initcheck", ".test", f);
    } catch (IOException e) {
      throw new IOException("Failure to write in log directory: '" + s + "'.  Check permissions?");
    }
    if (!f2.delete()) {
      throw new IOException(
          "Unable to delete "
              + f2
              + " from log directory "
              + "(but writing succeeded) - something is strange here");
    }

    File tmp = new File("/tmp");
    File cur = f;
    while (cur != null) {
      if (cur.equals(tmp)) {
        LOG.warn("Log directory is writing inside of /tmp.  This data may not survive reboot!");
        break;
      }
      cur = cur.getParentFile();
    }
  }