Esempio n. 1
0
  /**
   * Do a single specific action.
   *
   * @param actionName name of the action
   * @param projectMeta project meta
   * @param rootProcess root process of the project
   * @param packages target packages
   */
  public void doSingleAction(
      String actionName, ProjectMeta projectMeta, RootProcess rootProcess, List<String> packages) {
    // construct action from factory
    Action actionObj = actionFactory.createAction(actionName, projectMeta);

    rootProcess.doSupervisedAction(actionObj, packages);
  }
Esempio n. 2
0
  public void startMaster(boolean consoleFlag) {
    try {
      reactor = Reactor.getInstance(ReactorStrategy.MULTI_THREAD);
      eventWatcher = new EventWatcher(reactor);
      zk = new ZooKeeper(zkAddress, 3000, eventWatcher);
      eventWatcher.bind(zk);

      logger.debug("zooking bind: " + zkAddress);
    } catch (IOException e) {
      logger.error("Create zk error: " + e.getMessage());
      zk = null;
      return;
    }

    try {
      localAddr = InetAddress.getLocalHost().getHostAddress();
    } catch (UnknownHostException e1) {
      // do nothing
    }

    actionFactory = ActionFactory.bind(zk);

    eventHandler = new ProcessEventHandler(eventPauseSet, rootProcessMap);
    reactor.registerEvent(
        eventHandler,
        EventTypes.PROCESS_STARTED,
        EventTypes.PROCESS_STOPPED,
        EventTypes.PROCESS_RESTARTED);

    slaveStatusWatcher = new SlaveStatusWatcher(slaveTargetMap, zk);
    try {
      String slavesPath = Utils.constructString(Global.ARC_ROOT, Global.ARC_SLAVE);
      if (Utils.checkNode(zk, slavesPath)) {
        // load slave status from zookeeper
        List<String> slaves = zk.getChildren(slavesPath, slaveStatusWatcher);
        for (String addr : slaves) {
          SlaveTarget slaveTarget = slaveTargetMap.get(addr);
          String slaveStatusPath = Utils.getSlaveStatusPath(addr);
          if (slaveTarget == null && Utils.checkNode(zk, slaveStatusPath)) {
            slaveTarget = new SlaveTarget(addr);
            slaveTarget.setStatus(SlaveStatus.ONLINE);

            slaveTargetMap.put(addr, slaveTarget);

            zk.getData(slaveStatusPath, slaveStatusWatcher, null);

            LogUtils.logInfoLine(Utils.constructString("slave -> ", addr, " online"));
          }
        }
      }
    } catch (KeeperException e) {
      throw new ZooKeeperException(e);
    } catch (InterruptedException e) {
      throw new ZooKeeperException(e);
    }

    // start user console
    console = new MasterConsole(this);
    if (consoleFlag) {
      console.start();
    }
  }