Beispiel #1
0
 /** This is a synchronous close operation for the logical node. */
 public void close() throws IOException, InterruptedException {
   if (driver != null) {
     // stop the existing connector.
     nodeMsg = nodeName + "closing";
     driver.stop();
     // wait for driver thread to end.
     boolean success = driver.waitForAtLeastState(DriverState.IDLE, 30000);
     if (!success) {
       try {
         driver.cancel(); // signal driver to finish
         driver.join();
       } catch (InterruptedException e) {
         LOG.error("Unexpected interruption when closing logical node");
       }
     }
   }
 }
Beispiel #2
0
  /**
   * This stops any existing connection (source=>sink pumper), and then creates a new one with the
   * specified *already opened* source and sink arguments.
   */
  private void startNodeDriver() throws IOException {

    if (driver != null) {
      // stop the existing connector.
      driver.stop();
      try {
        // default is 30s.
        long timeout = FlumeConfiguration.get().getNodeCloseTimeout();
        if (!driver.join(timeout)) {
          LOG.error("Forcing driver to exit uncleanly");
          driver.cancel(); // taking too long, cancel the thread
        }
      } catch (InterruptedException e) {
        LOG.error("Previous driver took too long to close!", e);
      }
    }

    // this will be replaceable with multi-threaded queueing versions or other
    // mechanisms
    driver = new DirectDriver("logicalNode " + nodeName, src, snk);
    this.state.state = NodeState.ACTIVE;
    driver.start();
    reconfigures.incrementAndGet();
  }
Beispiel #3
0
  public ReportEvent getMetrics() {
    ReportEvent rpt = new ReportEvent(nodeName);
    rpt.setStringMetric("nodename", nodeName);
    rpt.setStringMetric("version", new Date(lastGoodCfg.timestamp).toString());
    rpt.setStringMetric("state", driver.getState().toString());
    rpt.setStringMetric("hostname", state.host);
    rpt.setStringMetric(
        "sourceConfig", (lastGoodCfg.sourceConfig == null) ? "" : lastGoodCfg.sourceConfig);
    rpt.setStringMetric(
        "sinkConfig", (lastGoodCfg.sinkConfig == null) ? "" : lastGoodCfg.sinkConfig);
    rpt.setStringMetric("message", nodeMsg);
    rpt.setLongMetric(A_RECONFIGURES, reconfigures.get());
    rpt.setStringMetric("physicalnode", state.physicalNode);

    return rpt;
  }