Example #1
0
 @Override
 public void process(Exchange exchange) throws Exception {
   // need to remember auth as Hadoop will override that, which otherwise means the Auth is broken
   // afterwards
   Configuration auth = HdfsComponent.getJAASConfiguration();
   try {
     doProcess(exchange);
   } finally {
     HdfsComponent.setJAASConfiguration(auth);
   }
 }
Example #2
0
  @Override
  protected void doStart() throws Exception {
    // need to remember auth as Hadoop will override that, which otherwise means the Auth is broken
    // afterwards
    Configuration auth = HdfsComponent.getJAASConfiguration();
    try {
      super.doStart();

      // setup hdfs if configured to do on startup
      if (getEndpoint().getConfig().isConnectOnStartup()) {
        ostream = setupHdfs(true);
      }

      SplitStrategy idleStrategy = null;
      for (SplitStrategy strategy : config.getSplitStrategies()) {
        if (strategy.type == SplitStrategyType.IDLE) {
          idleStrategy = strategy;
          break;
        }
      }
      if (idleStrategy != null) {
        scheduler =
            getEndpoint()
                .getCamelContext()
                .getExecutorServiceManager()
                .newSingleThreadScheduledExecutor(this, "HdfsIdleCheck");
        log.debug(
            "Creating IdleCheck task scheduled to run every {} millis",
            config.getCheckIdleInterval());
        scheduler.scheduleAtFixedRate(
            new IdleCheck(idleStrategy),
            config.getCheckIdleInterval(),
            config.getCheckIdleInterval(),
            TimeUnit.MILLISECONDS);
      }
    } finally {
      HdfsComponent.setJAASConfiguration(auth);
    }
  }