azkaban ExecutorManager源码剖析

azkaban 有三大模块,azkaban-common,azkaban-exec-server,azkaban-web-server.

  • azkaban-common是公共模块,比如访问数据库,trigger管理工具,邮件工具,以及job.

  • azkaban-exec-server是执行器,主要用于执行任务

  • azkaban-web-server是调度中心,用于任务展示、编辑,调度任务

azkaban-common ExecutorManager

ExecutorManager是用于管理执行器的job

  /**
   * 创建ExecutorManager
   * @param loader
   * @return
   * @throws ExecutorManagerException
     */
  static ExecutorManager createExecutor(ExecutorLoader loader) throws ExecutorManagerException{

    Props props = new Props();
    props.put(ExecutorManager.AZKABAN_USE_MULTIPLE_EXECUTORS, "true");
    props.put(ExecutorManager.AZKABAN_QUEUEPROCESSING_ENABLED, "false");

      loader.addExecutor("localhost", 12345);
      loader.addExecutor("localhost", 12346);
    return new ExecutorManager(props, loader, new HashMap());
  }


  public static void main(String[] args) {
    try {
      ExecutorLoader loader =  new MockExecutorLoader();
      ExecutorManager manager = createExecutor(loader);
      System.out.println(manager.getAllActiveExecutors().size());
      System.out.println(manager.getQueuedFlowSize());
      System.out.println(manager.isQueueProcessorThreadActive());


      //添加flow,执行flow
      ExecutableFlow flow1 =  TestUtils.createExecutableFlow("exectest1", "exec1");
      flow1.setExecutionId(1);
      User user = TestUtils.getTestUser();
      manager.submitExecutableFlow(flow1,user.getUserId());

      System.out.println(loader.fetchQueuedFlows().size());

    }catch (Exception e){

      System.out.println(e.getMessage());
    }

  }

输出

2
0
false
1

你可能感兴趣的:(azkaban ExecutorManager源码剖析)