Exemplo n.º 1
0
  @Override
  public RepeatStatus executeStep(
      ChunkContext chunkContext, JobExecutionStatusHolder jobExecutionStatusHolder)
      throws Exception {

    // This step is only for app manager like ClouderaMgr and Ambari
    String clusterName =
        getJobParameters(chunkContext).getString(JobConstants.CLUSTER_NAME_JOB_PARAM);

    SoftwareManager softwareMgr = softwareMgrs.getSoftwareManagerByClusterName(clusterName);

    String appMgrName = softwareMgr.getName();
    if (Constants.IRONFAN.equals(appMgrName)) {
      // we do not config any local repo for Ironfan
      return RepeatStatus.FINISHED;
    }

    ClusterCreate clusterConfig =
        clusterManager.getClusterConfigMgr().getClusterConfig(clusterName);
    String localRepoURL = clusterConfig.getLocalRepoURL();
    logger.info("Use the following URL as the local yum server:" + localRepoURL);

    if (!CommonUtil.isBlank(localRepoURL)) {
      // Setup local repo file on each node for ClouderaMgr/Ambari.
      logger.info(
          "ConfigLocalRepoStep: start to setup local repo on each node for ClouderaMgr/Ambari.");

      List<NodeEntity> nodes = getNodesToBeSetLocalRepo(chunkContext, clusterName);
      String appMgrRepoID =
          Configuration.getString(
              Constants.SERENGETI_NODE_YUM_CLOUDERA_MANAGER_REPO_ID,
              Constants.NODE_APPMANAGER_YUM_CLOUDERA_MANAGER_REPO_ID);
      if (appMgrName.equals(Constants.AMBARI_PLUGIN_TYPE)) {
        appMgrRepoID =
            Configuration.getString(
                Constants.SERENGETI_NODE_YUM_AMBARI_REPO_ID,
                Constants.NODE_APPMANAGER_YUM_AMBARI_REPO_ID);
      }

      setLocalRepoService.setLocalRepoForNodes(clusterName, nodes, appMgrRepoID, localRepoURL);
    }

    return RepeatStatus.FINISHED;
  }