Ejemplo n.º 1
0
 @Override
 protected boolean hideAction(RepositoryNode node) {
   HadoopClusterConnectionItem hcConnectionItem =
       HCRepositoryUtil.getHCConnectionItemFromRepositoryNode(node);
   if (hcConnectionItem != null) {
     HadoopClusterConnection hcConnection =
         (HadoopClusterConnection) hcConnectionItem.getConnection();
     DistributionBean hdfsDistribution =
         HadoopDistributionsHelper.HDFS.getDistribution(hcConnection.getDistribution(), false);
     if (hdfsDistribution != null) {
       IHDistributionVersion hdVersion =
           hdfsDistribution.getHDVersion(hcConnection.getDfVersion(), false);
       if (hdVersion != null) { // found, don't hide
         return false;
       }
     }
   }
   return true;
 }
  private Object getHCatalogRepositoryValue(
      HCatalogConnection connection, String value, IMetadataTable table, String targetComponent) {
    HadoopClusterConnection hcConnection =
        HCRepositoryUtil.getRelativeHadoopClusterConnection(connection);
    if (hcConnection == null) {
      return null;
    }

    if (EHCatalogRepositoryToComponent.DISTRIBUTION.getRepositoryValue().equals(value)) {
      return hcConnection.getDistribution();
    } else if (EHCatalogRepositoryToComponent.HCAT_VERSION.getRepositoryValue().equals(value)) {
      return hcConnection.getDfVersion();
    } else if (EHCatalogRepositoryToComponent.TEMPLETON_HOST.getRepositoryValue().equals(value)) {
      return getRepositoryValueOfStringType(
          connection, StringUtils.trimToNull(connection.getHostName()));
    } else if (EHCatalogRepositoryToComponent.TEMPLETON_PORT.getRepositoryValue().equals(value)) {
      return getRepositoryValueOfStringType(
          connection, StringUtils.trimToNull(connection.getPort()));
    } else if (EHCatalogRepositoryToComponent.USE_KRB.getRepositoryValue().equals(value)) {
      return hcConnection.isEnableKerberos();
    } else if (EHCatalogRepositoryToComponent.KRB_PRINC.getRepositoryValue().equals(value)) {
      return getRepositoryValueOfStringType(
          connection, StringUtils.trimToNull(connection.getKrbPrincipal()));
    } else if (EHCatalogRepositoryToComponent.KRB_REALM.getRepositoryValue().equals(value)) {
      return getRepositoryValueOfStringType(
          connection, StringUtils.trimToNull(connection.getKrbRealm()));
    } else if (EHCatalogRepositoryToComponent.NAMENODE_PRINCIPAL
        .getRepositoryValue()
        .equals(value)) {
      return getRepositoryValueOfStringType(
          hcConnection, StringUtils.trimToNull(hcConnection.getPrincipal()));
    } else if (EHCatalogRepositoryToComponent.USE_KEYTAB.getRepositoryValue().equals(value)) {
      return hcConnection.isUseKeytab();
    } else if (EHCatalogRepositoryToComponent.KEYTAB_PRINCIPAL.getRepositoryValue().equals(value)) {
      return getRepositoryValueOfStringType(
          hcConnection, StringUtils.trimToNull(hcConnection.getKeytabPrincipal()));
    } else if (EHCatalogRepositoryToComponent.KEYTAB_PATH.getRepositoryValue().equals(value)) {
      return getRepositoryValueOfStringType(
          hcConnection, StringUtils.trimToNull(hcConnection.getKeytab()));
    } else if (EHCatalogRepositoryToComponent.DATABASE_NAME.getRepositoryValue().equals(value)) {
      return getRepositoryValueOfStringType(
          connection, StringUtils.trimToNull(connection.getDatabase()));
    } else if (EHCatalogRepositoryToComponent.USERNAME.getRepositoryValue().equals(value)) {
      return getRepositoryValueOfStringType(
          connection, StringUtils.trimToNull(connection.getUserName()));
    } else if (EHCatalogRepositoryToComponent.ROWSEPARATOR.getRepositoryValue().equals(value)) {
      return getRepositoryValueOfStringType(
          connection, StringUtils.trimToNull(connection.getRowSeparator()));
    } else if (EHCatalogRepositoryToComponent.FIELDSEPARATOR.getRepositoryValue().equals(value)) {
      return getRepositoryValueOfStringType(
          connection, StringUtils.trimToNull(connection.getFieldSeparator()));
    } else if (EHCatalogRepositoryToComponent.LOCAL.getRepositoryValue().equals(value)) {
      return false;
    } else if (EHCatalogRepositoryToComponent.MAPREDUCE.getRepositoryValue().equals(value)) {
      return true;
    } else if (EHCatalogRepositoryToComponent.PIG_VERSION.getRepositoryValue().equals(value)) {
      return hcConnection.getDfVersion();
    } else if (EHCatalogRepositoryToComponent.MAPRED_JOB_TRACKER.getRepositoryValue().equals(value)
        || EHCatalogRepositoryToComponent.MAPRED_RESOURCE_MANAGER.getRepositoryValue().equals(value)
        || EHCatalogRepositoryToComponent.RESOURCE_MANAGER.getRepositoryValue().equals(value)) {
      return getRepositoryValueOfStringType(
          hcConnection, StringUtils.trimToNull(hcConnection.getJobTrackerURI()));
    } else if (EHCatalogRepositoryToComponent.FS_DEFAULT_NAME.getRepositoryValue().equals(value)) {
      return getRepositoryValueOfStringType(
          hcConnection, StringUtils.trimToNull(hcConnection.getNameNodeURI()));
    } else if (EHCatalogRepositoryToComponent.JOBTRACKER_PRINCIPAL
        .getRepositoryValue()
        .equals(value)) {
      return getRepositoryValueOfStringType(
          connection, StringUtils.trimToNull(connection.getKrbPrincipal()));
    } else if (EHCatalogRepositoryToComponent.LOAD.getRepositoryValue().equals(value)) {
      return HCATALOG_LOAD;
    } else if (EHCatalogRepositoryToComponent.STORE.getRepositoryValue().equals(value)) {
      return HCATALOG_STORE;
    } else if (EHCatalogRepositoryToComponent.HADOOP_CUSTOM_JARS
        .getRepositoryValue()
        .equals(value)) {
      if (targetComponent != null && targetComponent.startsWith("tPig")) {
        return hcConnection.getParameters().get(ECustomVersionGroup.PIG_HCATALOG.getName());
      }
      return HCVersionUtil.getCompCustomJarsParamFromRep(hcConnection, ECustomVersionGroup.COMMON);
    } else if (EHCatalogRepositoryToComponent.HADOOP_ADVANCED_PROPERTIES
        .getRepositoryValue()
        .equals(value)) {
      return HadoopRepositoryUtil.getHadoopPropertiesFullList(
          connection, connection.getHadoopProperties(), true);
    }

    return null;
  }