Search in sources :

Example 1 with HadoopClusterConnection

use of org.talend.repository.model.hadoopcluster.HadoopClusterConnection in project tbd-studio-se by Talend.

the class HadoopClusterContextHandler method setPropertiesForContextMode.

@Override
public void setPropertiesForContextMode(String prefixName, Connection connection, Set<IConnParamName> paramSet) {
    if (connection == null) {
        return;
    }
    if (connection instanceof HadoopClusterConnection) {
        HadoopClusterConnection hadoopConn = (HadoopClusterConnection) connection;
        String originalVariableName = prefixName + ConnectionContextHelper.LINE;
        String hadoopVariableName = null;
        for (IConnParamName param : paramSet) {
            if (param instanceof EHadoopParamName) {
                EHadoopParamName hadoopConnectionParam = (EHadoopParamName) param;
                originalVariableName = prefixName + ConnectionContextHelper.LINE;
                hadoopVariableName = originalVariableName + hadoopConnectionParam;
                matchContextForAttribues(hadoopConn, hadoopConnectionParam, hadoopVariableName);
            }
        }
        String hadoopProperties = hadoopConn.getHadoopProperties();
        List<Map<String, Object>> propertiesAfterContext = transformHadoopPropertiesForContextMode(HadoopRepositoryUtil.getHadoopPropertiesList(hadoopProperties), prefixName);
        hadoopConn.setHadoopProperties(HadoopRepositoryUtil.getHadoopPropertiesJsonStr(propertiesAfterContext));
        // 
        String sparkProperties = hadoopConn.getSparkProperties();
        List<Map<String, Object>> sparkPropertiesAfterContext = transformHadoopPropertiesForContextMode(HadoopRepositoryUtil.getHadoopPropertiesList(sparkProperties), prefixName);
        hadoopConn.setSparkProperties(HadoopRepositoryUtil.getHadoopPropertiesJsonStr(sparkPropertiesAfterContext));
    }
}
Also used : EHadoopParamName(org.talend.metadata.managment.ui.utils.ExtendedNodeConnectionContextUtils.EHadoopParamName) IConnParamName(org.talend.metadata.managment.ui.model.IConnParamName) HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) Map(java.util.Map)

Example 2 with HadoopClusterConnection

use of org.talend.repository.model.hadoopcluster.HadoopClusterConnection in project tbd-studio-se by Talend.

the class HadoopClusterContextHandler method revertPropertiesForContextMode.

@Override
public void revertPropertiesForContextMode(Connection hadoopConn, ContextType contextType) {
    if (hadoopConn instanceof HadoopClusterConnection) {
        HadoopClusterConnection conn = (HadoopClusterConnection) hadoopConn;
        String nameNodeUri = TalendQuoteUtils.removeQuotes(ContextParameterUtils.getOriginalValue(contextType, conn.getNameNodeURI()));
        String jobTrackerUri = TalendQuoteUtils.removeQuotes(ContextParameterUtils.getOriginalValue(contextType, conn.getJobTrackerURI()));
        String rmScheduler = TalendQuoteUtils.removeQuotes(ContextParameterUtils.getOriginalValue(contextType, conn.getRmScheduler()));
        String jobHistory = TalendQuoteUtils.removeQuotes(ContextParameterUtils.getOriginalValue(contextType, conn.getJobHistory()));
        String stagingDir = TalendQuoteUtils.removeQuotes(ContextParameterUtils.getOriginalValue(contextType, conn.getStagingDirectory()));
        String nameNodePrin = TalendQuoteUtils.removeQuotes(ContextParameterUtils.getOriginalValue(contextType, conn.getPrincipal()));
        String jtOrRmPrin = TalendQuoteUtils.removeQuotes(ContextParameterUtils.getOriginalValue(contextType, conn.getValue(conn.getJtOrRmPrincipal(), false)));
        String jobHisPrin = TalendQuoteUtils.removeQuotes(ContextParameterUtils.getOriginalValue(contextType, conn.getJobHistoryPrincipal()));
        String userName = TalendQuoteUtils.removeQuotes(ContextParameterUtils.getOriginalValue(contextType, conn.getUserName()));
        String group = TalendQuoteUtils.removeQuotes(ContextParameterUtils.getOriginalValue(contextType, conn.getGroup()));
        String principal = TalendQuoteUtils.removeQuotes(ContextParameterUtils.getOriginalValue(contextType, conn.getKeytabPrincipal()));
        String keyTab = TalendQuoteUtils.removeQuotes(ContextParameterUtils.getOriginalValue(contextType, conn.getKeytab()));
        String cnUserName = TalendQuoteUtils.removeQuotes(ContextParameterUtils.getOriginalValue(contextType, conn.getClouderaNaviUserName()));
        String cnPassword = TalendQuoteUtils.removeQuotes(ContextParameterUtils.getOriginalValue(contextType, conn.getClouderaNaviPassword()));
        String cnUrl = TalendQuoteUtils.removeQuotes(ContextParameterUtils.getOriginalValue(contextType, conn.getClouderaNaviUrl()));
        String cnMetadataUrl = TalendQuoteUtils.removeQuotes(ContextParameterUtils.getOriginalValue(contextType, conn.getClouderaNaviMetadataUrl()));
        String cnClientUrl = TalendQuoteUtils.removeQuotes(ContextParameterUtils.getOriginalValue(contextType, conn.getClouderaNaviClientUrl()));
        String maprTPassword = TalendQuoteUtils.removeQuotes(ContextParameterUtils.getOriginalValue(contextType, conn.getMaprTPassword()));
        String maprTCluster = TalendQuoteUtils.removeQuotes(ContextParameterUtils.getOriginalValue(contextType, conn.getMaprTCluster()));
        String maprTDuration = TalendQuoteUtils.removeQuotes(ContextParameterUtils.getOriginalValue(contextType, conn.getMaprTDuration()));
        String maprTHomeDir = TalendQuoteUtils.removeQuotes(ContextParameterUtils.getOriginalValue(contextType, conn.getMaprTHomeDir()));
        String maprTHadoopLogin = TalendQuoteUtils.removeQuotes(ContextParameterUtils.getOriginalValue(contextType, conn.getMaprTHadoopLogin()));
        String webHDFSSSLTrustStorePath = TalendQuoteUtils.removeQuotes(ContextParameterUtils.getOriginalValue(contextType, conn.getWebHDFSSSLTrustStorePath()));
        String webHDFSSSLTrustStorePassword = TalendQuoteUtils.removeQuotes(ContextParameterUtils.getOriginalValue(contextType, conn.getWebHDFSSSLTrustStorePassword()));
        for (String paramKey : ((HadoopClusterConnection) hadoopConn).getParameters().keySet()) {
            String originalValue = ContextParameterUtils.getOriginalValue(contextType, conn.getParameters().get(paramKey));
            conn.getParameters().put(paramKey, originalValue);
        }
        String hadoopProperties = conn.getHadoopProperties();
        List<Map<String, Object>> propertiesAfterRevert = transformContextModeToHadoopProperties(HadoopRepositoryUtil.getHadoopPropertiesList(hadoopProperties), contextType);
        conn.setHadoopProperties(HadoopRepositoryUtil.getHadoopPropertiesJsonStr(propertiesAfterRevert));
        String sparkProperties = conn.getSparkProperties();
        List<Map<String, Object>> sparkPropertiesAfterRevert = transformContextModeToHadoopProperties(HadoopRepositoryUtil.getHadoopPropertiesList(sparkProperties), contextType);
        conn.setSparkProperties(HadoopRepositoryUtil.getHadoopPropertiesJsonStr(sparkPropertiesAfterRevert));
        conn.setNameNodeURI(nameNodeUri);
        conn.setJobTrackerURI(jobTrackerUri);
        conn.setRmScheduler(rmScheduler);
        conn.setJobHistory(jobHistory);
        conn.setStagingDirectory(stagingDir);
        conn.setPrincipal(nameNodePrin);
        conn.setJtOrRmPrincipal(jtOrRmPrin);
        conn.setJobHistoryPrincipal(jobHisPrin);
        conn.setUserName(userName);
        conn.setGroup(group);
        conn.setKeytab(keyTab);
        conn.setKeytabPrincipal(principal);
        conn.setClouderaNaviUserName(cnUserName);
        conn.setClouderaNaviPassword(cnPassword);
        conn.setClouderaNaviUrl(cnUrl);
        conn.setClouderaNaviMetadataUrl(cnMetadataUrl);
        conn.setClouderaNaviClientUrl(cnClientUrl);
        conn.setMaprTPassword(maprTPassword);
        conn.setMaprTCluster(maprTCluster);
        conn.setMaprTDuration(maprTDuration);
        conn.setMaprTHomeDir(maprTHomeDir);
        conn.setMaprTHadoopLogin(maprTHadoopLogin);
        conn.setWebHDFSSSLTrustStorePath(webHDFSSSLTrustStorePath);
        conn.setWebHDFSSSLTrustStorePassword(webHDFSSSLTrustStorePassword);
    }
}
Also used : HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) Map(java.util.Map)

Example 3 with HadoopClusterConnection

use of org.talend.repository.model.hadoopcluster.HadoopClusterConnection in project tbd-studio-se by Talend.

the class HadoopClusterContextHandler method createContextParameters.

@Override
public List<IContextParameter> createContextParameters(String prefixName, Connection connection, Set<IConnParamName> paramSet) {
    List<IContextParameter> varList = new ArrayList<IContextParameter>();
    if (connection instanceof HadoopClusterConnection) {
        HadoopClusterConnection conn = (HadoopClusterConnection) connection;
        String paramPrefix = prefixName + ConnectionContextHelper.LINE;
        String paramName = null;
        for (IConnParamName param : paramSet) {
            if (param instanceof EHadoopParamName) {
                EHadoopParamName hadoopParam = (EHadoopParamName) param;
                paramName = paramPrefix + hadoopParam;
                switch(hadoopParam) {
                    case NameNodeUri:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getNameNodeURI());
                        break;
                    case JobTrackerUri:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getJobTrackerURI());
                        break;
                    case ResourceManager:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getJobTrackerURI());
                        break;
                    case ResourceManagerScheduler:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getRmScheduler());
                        break;
                    case JobHistory:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getJobHistory());
                        break;
                    case StagingDirectory:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getStagingDirectory());
                        break;
                    case NameNodePrin:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getPrincipal());
                        break;
                    case JTOrRMPrin:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getJtOrRmPrincipal());
                        break;
                    case JobHistroyPrin:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getJobHistoryPrincipal());
                        break;
                    case User:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getUserName());
                        break;
                    case Group:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getGroup());
                        break;
                    case Principal:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getKeytabPrincipal());
                        break;
                    case KeyTab:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getKeytab());
                        break;
                    case maprTPassword:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getMaprTPassword(), JavaTypesManager.PASSWORD);
                        break;
                    case maprTCluster:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getMaprTCluster());
                        break;
                    case maprTDuration:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getMaprTDuration(), JavaTypesManager.LONG);
                        break;
                    case maprTHomeDir:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getMaprTHomeDir());
                        break;
                    case maprTHadoopLogin:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getMaprTHadoopLogin());
                        break;
                    case WebHostName:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_WEB_HCAT_HOSTNAME));
                        break;
                    case WebPort:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_WEB_HCAT_PORT));
                        break;
                    case WebUser:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_WEB_HCAT_USERNAME));
                        break;
                    case WebJobResFolder:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_WEB_HCAT_JOB_RESULT_FOLDER));
                        break;
                    case HDIUser:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HDI_USERNAME));
                        break;
                    case HDIPassword:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HDI_PASSWORD), JavaTypesManager.PASSWORD);
                        break;
                    case KeyAzureHost:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_AZURE_HOSTNAME));
                        break;
                    case KeyAzureContainer:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_AZURE_CONTAINER));
                        break;
                    case KeyAzuresUser:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_AZURE_USERNAME));
                        break;
                    case KeyAzurePassword:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_AZURE_PASSWORD), JavaTypesManager.PASSWORD);
                        break;
                    case KeyAzureDeployBlob:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_AZURE_DEPLOY_BLOB));
                        break;
                    case GoogleProjectId:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_GOOGLE_PROJECT_ID));
                        break;
                    case GoogleClusterId:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_GOOGLE_CLUSTER_ID));
                        break;
                    case GoogleRegion:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_GOOGLE_REGION));
                        break;
                    case GoogleJarsBucket:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_GOOGLE_JARS_BUCKET));
                        break;
                    case PathToGoogleCredentials:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_PATH_TO_GOOGLE_CREDENTIALS));
                        break;
                    case DataBricksEndpoint:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_DATABRICKS_ENDPOINT));
                        break;
                    case DataBricksCloudProvider:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_DATABRICKS_CLOUD_PROVIDER));
                        break;
                    case DatabricksRunMode:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_DATABRICKS_RUN_MODE));
                        break;
                    case DataBricksClusterId:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_DATABRICKS_CLUSTER_ID));
                        break;
                    case DataBricksToken:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_DATABRICKS_TOKEN), JavaTypesManager.PASSWORD);
                        break;
                    case DataBricksDBFSDepFolder:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_DATABRICKS_DBFS_DEP_FOLDER));
                        break;
                    case setHadoopConf:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SET_HADOOP_CONF), JavaTypesManager.BOOLEAN);
                        break;
                    case hadoopConfSpecificJar:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HADOOP_CONF_SPECIFIC_JAR));
                        break;
                    case WebHDFSSSLTrustStorePath:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getWebHDFSSSLTrustStorePath());
                        break;
                    case WebHDFSSSLTrustStorePassword:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getWebHDFSSSLTrustStorePassword(), JavaTypesManager.PASSWORD);
                        break;
                    case UseKnox:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_USE_KNOX));
                        break;
                    case SparkMode:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SPARK_MODE));
                        break;
                    case KnoxUrl:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KNOX_URL));
                        break;
                    case KnoxUsername:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KNOX_USER));
                        break;
                    case KnoxPassword:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KNOX_PASSWORD), JavaTypesManager.PASSWORD);
                        break;
                    case KnoxDirectory:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_KNOX_DIRECTORY));
                        break;
                    case SynapseHostName:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SYNAPSE_HOST));
                        break;
                    case SynapseAuthToken:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SYNAPSE_AUTH_TOKEN), JavaTypesManager.PASSWORD);
                        break;
                    case SynapseSparkPools:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SYNAPSE_SPARK_POOLS));
                        break;
                    case SynapseFsHostName:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SYNAPSE_FS_HOSTNAME));
                        break;
                    case SynapseFsContainer:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SYNAPSE_FS_CONTAINER));
                        break;
                    case SynapseFsUserName:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SYNAPSE_FS_USERNAME));
                        break;
                    case SynapseFsPassword:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SYNAPSE_FS_PASSWORD), JavaTypesManager.PASSWORD);
                        break;
                    case SynapseDeployBlob:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_SYNAPSE_DEPLOY_BLOB));
                        break;
                    case SynapseDriverMemory:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_DRIVER_MEMORY));
                        break;
                    case SynapseDriverCores:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_DRIVER_CORES));
                        break;
                    case SynapseExecutorMemory:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_EXECUTOR_MEMORY));
                        break;
                    case UseTuningProperties:
                        ConnectionContextHelper.createParameters(varList, paramName, conn.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_TUNING_PROPERTIES));
                        break;
                    default:
                }
            }
        }
        createHadoopPropertiesContextVariable(prefixName, varList, conn.getHadoopProperties());
        createHadoopPropertiesContextVariable(prefixName, varList, conn.getSparkProperties());
    }
    return varList;
}
Also used : ArrayList(java.util.ArrayList) EHadoopParamName(org.talend.metadata.managment.ui.utils.ExtendedNodeConnectionContextUtils.EHadoopParamName) IConnParamName(org.talend.metadata.managment.ui.model.IConnParamName) HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) IContextParameter(org.talend.core.model.process.IContextParameter)

Example 4 with HadoopClusterConnection

use of org.talend.repository.model.hadoopcluster.HadoopClusterConnection in project tbd-studio-se by Talend.

the class HCRepositoryUtil method getSubitemsOfHadoopCluster.

/**
 * DOC ycbai Comment method "getSubitemsOfHadoopCluster".
 *
 * Get subitems of hadoop cluster like hdfs, hcatalog, hive etc.
 *
 * @param item
 * @return
 * @throws PersistenceException
 */
public static Set<Item> getSubitemsOfHadoopCluster(Item item) throws PersistenceException {
    Set<Item> subItems = new HashSet<Item>();
    if (item.eClass() != HadoopClusterPackage.Literals.HADOOP_CLUSTER_CONNECTION_ITEM) {
        return subItems;
    }
    Project project = new Project(ProjectManager.getInstance().getProject(item.getProperty()));
    HadoopClusterConnectionItem clusterConnectionItem = (HadoopClusterConnectionItem) item;
    HadoopClusterConnection clusterConnection = (HadoopClusterConnection) clusterConnectionItem.getConnection();
    EList<String> connectionList = clusterConnection.getConnectionList();
    for (String connId : connectionList) {
        if (connId != null) {
            IRepositoryViewObject repObj = ProxyRepositoryFactory.getInstance().getLastVersion(project, connId);
            if (repObj != null && repObj.getProperty() != null) {
                Item subItem = repObj.getProperty().getItem();
                if (subItem != null) {
                    subItems.add(subItem);
                }
            }
        }
    }
    String clusterId = clusterConnectionItem.getProperty().getId();
    List<IRepositoryViewObject> repObjs = ProxyRepositoryFactory.getInstance().getAll(project, ERepositoryObjectType.METADATA_CONNECTIONS);
    for (IRepositoryViewObject repObj : repObjs) {
        if (repObj != null && repObj.getProperty() != null) {
            DatabaseConnectionItem dbItem = (DatabaseConnectionItem) repObj.getProperty().getItem();
            DatabaseConnection dbConnection = (DatabaseConnection) dbItem.getConnection();
            String hcId = dbConnection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HADOOP_CLUSTER_ID);
            if (clusterId.equals(hcId)) {
                subItems.add(dbItem);
            }
        }
    }
    return subItems;
}
Also used : HadoopClusterConnectionItem(org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem) Item(org.talend.core.model.properties.Item) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) HadoopSubConnectionItem(org.talend.repository.model.hadoopcluster.HadoopSubConnectionItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Project(org.talend.core.model.general.Project) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) HadoopClusterConnectionItem(org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem) HashSet(java.util.HashSet) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem)

Example 5 with HadoopClusterConnection

use of org.talend.repository.model.hadoopcluster.HadoopClusterConnection in project tbd-studio-se by Talend.

the class HCRepositoryUtil method getHadoopDbParameters.

public static Map<String, String> getHadoopDbParameters(HadoopClusterConnectionItem clusterItem) {
    Map<String, String> parameters = new HashMap<>();
    if (clusterItem == null) {
        return parameters;
    }
    HadoopClusterConnection hcConnection = (HadoopClusterConnection) clusterItem.getConnection();
    parameters.put(ConnParameterKeys.CONN_PARA_KEY_HADOOP_CLUSTER_ID, clusterItem.getProperty().getId());
    parameters.put(ConnParameterKeys.CONN_PARA_KEY_NAME_NODE_URL, hcConnection.getNameNodeURI());
    parameters.put(ConnParameterKeys.CONN_PARA_KEY_JOB_TRACKER_URL, hcConnection.getJobTrackerURI());
    parameters.put(ConnParameterKeys.CONN_PARA_KEY_USE_YARN, String.valueOf(hcConnection.isUseYarn()));
    parameters.put(ConnParameterKeys.CONN_PARA_KEY_USE_CUSTOM_CONFS, String.valueOf(hcConnection.isUseCustomConfs()));
    parameters.put(ConnParameterKeys.CONN_PARA_KEY_USE_KRB, String.valueOf(hcConnection.isEnableKerberos()));
    parameters.put(ConnParameterKeys.CONN_PARA_KEY_NAME_NODE_PRINCIPAL, hcConnection.getPrincipal());
    parameters.put(ConnParameterKeys.CONN_PARA_KEY_JOB_TRACKER_PRINCIPAL, hcConnection.getJtOrRmPrincipal());
    parameters.put(ConnParameterKeys.CONN_PARA_KEY_JOB_HISTORY_PRINCIPAL, hcConnection.getJobHistoryPrincipal());
    parameters.put(ConnParameterKeys.CONN_PARA_KEY_RESOURCEMANAGER_SCHEDULER_ADDRESS, hcConnection.getRmScheduler());
    parameters.put(ConnParameterKeys.CONN_PARA_KEY_JOBHISTORY_ADDRESS, hcConnection.getJobHistory());
    parameters.put(ConnParameterKeys.CONN_PARA_KEY_STAGING_DIRECTORY, hcConnection.getStagingDirectory());
    parameters.put(ConnParameterKeys.CONN_PARA_KEY_USE_DATANODE_HOSTNAME, String.valueOf(hcConnection.isUseDNHost()));
    parameters.put(ConnParameterKeys.CONN_PARA_KEY_DB_SERVER, HadoopParameterUtil.getHostNameFromNameNodeURI(ConnectionContextHelper.getParamValueOffContext(hcConnection, hcConnection.getNameNodeURI())));
    parameters.put(ConnParameterKeys.CONN_PARA_KEY_USERNAME, hcConnection.getUserName());
    parameters.put(ConnParameterKeys.CONN_PARA_KEY_HIVE_DISTRIBUTION, hcConnection.getDistribution());
    parameters.put(ConnParameterKeys.CONN_PARA_KEY_HIVE_VERSION, hcConnection.getDfVersion());
    parameters.put(ConnParameterKeys.CONN_PARA_KEY_HBASE_DISTRIBUTION, hcConnection.getDistribution());
    parameters.put(ConnParameterKeys.CONN_PARA_KEY_HBASE_VERSION, hcConnection.getDfVersion());
    parameters.put(ConnParameterKeys.CONN_PARA_KEY_MAPRDB_DISTRIBUTION, hcConnection.getDistribution());
    parameters.put(ConnParameterKeys.CONN_PARA_KEY_MAPRDB_VERSION, hcConnection.getDfVersion());
    // 
    parameters.put(ConnParameterKeys.CONN_PARA_KEY_HIVE_GOOGLE_PROJECT_ID, hcConnection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_GOOGLE_PROJECT_ID));
    parameters.put(ConnParameterKeys.CONN_PARA_KEY_HIVE_GOOGLE_CLUSTER_ID, hcConnection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_GOOGLE_CLUSTER_ID));
    parameters.put(ConnParameterKeys.CONN_PARA_KEY_HIVE_GOOGLE_REGION, hcConnection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_GOOGLE_REGION));
    parameters.put(ConnParameterKeys.CONN_PARA_KEY_HIVE_GOOGLE_JARS_BUCKET, hcConnection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_GOOGLE_JARS_BUCKET));
    parameters.put(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_DEFINE_PATH_TO_GOOGLE_CREDENTIALS, hcConnection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_DEFINE_PATH_TO_GOOGLE_CREDENTIALS));
    parameters.put(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_PATH_TO_GOOGLE_CREDENTIALS, hcConnection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_PATH_TO_GOOGLE_CREDENTIALS));
    if (hcConnection.isEnableKerberos()) {
        parameters.put(ConnParameterKeys.CONN_PARA_KEY_USEKEYTAB, String.valueOf(hcConnection.isUseKeytab()));
        if (hcConnection.isUseKeytab()) {
            parameters.put(ConnParameterKeys.CONN_PARA_KEY_KEYTAB_PRINCIPAL, hcConnection.getKeytabPrincipal());
            parameters.put(ConnParameterKeys.CONN_PARA_KEY_KEYTAB, hcConnection.getKeytab());
        }
    }
    if (hcConnection.isUseWebHDFSSSL()) {
        parameters.put(ConnParameterKeys.CONN_PARA_KEY_USE_WEBHDFS_SSL, String.valueOf(hcConnection.isUseWebHDFSSSL()));
        parameters.put(ConnParameterKeys.CONN_PARA_KEY_WEBHDFS_SSL_TRUST_STORE_PATH, hcConnection.getWebHDFSSSLTrustStorePath());
        parameters.put(ConnParameterKeys.CONN_PARA_KEY_WEBHDFS_SSL_TRUST_STORE_PASSWORD, hcConnection.getWebHDFSSSLTrustStorePassword());
    }
    // hbase/hive/maprdb
    parameters.put(ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_USE_MAPRTICKET, String.valueOf(hcConnection.isEnableMaprT()));
    parameters.put(ConnParameterKeys.CONN_PARA_KEY_MAPRDB_AUTHENTICATION_USE_MAPRTICKET, String.valueOf(hcConnection.isEnableMaprT()));
    parameters.put(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_USE_MAPRTICKET, String.valueOf(hcConnection.isEnableMaprT()));
    if (hcConnection.isEnableMaprT()) {
        parameters.put(ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_USERNAME, hcConnection.getUserName());
        parameters.put(ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_MAPRTICKET_PASSWORD, hcConnection.getMaprTPassword());
        parameters.put(ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_MAPRTICKET_CLUSTER, hcConnection.getMaprTCluster());
        parameters.put(ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_MAPRTICKET_DURATION, hcConnection.getMaprTDuration());
        parameters.put(ConnParameterKeys.CONN_PARA_KEY_MAPRDB_AUTHENTICATION_USERNAME, hcConnection.getUserName());
        parameters.put(ConnParameterKeys.CONN_PARA_KEY_MAPRDB_AUTHENTICATION_MAPRTICKET_PASSWORD, hcConnection.getMaprTPassword());
        parameters.put(ConnParameterKeys.CONN_PARA_KEY_MAPRDB_AUTHENTICATION_MAPRTICKET_CLUSTER, hcConnection.getMaprTCluster());
        parameters.put(ConnParameterKeys.CONN_PARA_KEY_MAPRDB_AUTHENTICATION_MAPRTICKET_DURATION, hcConnection.getMaprTDuration());
        parameters.put(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_USERNAME, hcConnection.getUserName());
        parameters.put(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_MAPRTICKET_PASSWORD, hcConnection.getMaprTPassword());
        parameters.put(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_MAPRTICKET_CLUSTER, hcConnection.getMaprTCluster());
        parameters.put(ConnParameterKeys.CONN_PARA_KEY_HIVE_AUTHENTICATION_MAPRTICKET_DURATION, hcConnection.getMaprTDuration());
        parameters.put(ConnParameterKeys.CONN_PARA_KEY_MAPRTICKET_SETMAPRHOMEDIR, String.valueOf(hcConnection.isSetMaprTHomeDir()));
        parameters.put(ConnParameterKeys.CONN_PARA_KEY_MAPRTICKET_MAPRHOMEDIR, ConnectionContextHelper.getParamValueOffContext(hcConnection, hcConnection.getMaprTHomeDir()));
        parameters.put(ConnParameterKeys.CONN_PARA_KEY_MAPRTICKET_SETMAPRHADOOPLOGIN, String.valueOf(hcConnection.isSetHadoopLogin()));
        parameters.put(ConnParameterKeys.CONN_PARA_KEY_MAPRTICKET_MAPRHADOOPLOGIN, ConnectionContextHelper.getParamValueOffContext(hcConnection, hcConnection.getMaprTHadoopLogin()));
    }
    return parameters;
}
Also used : HashMap(java.util.HashMap) HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection)

Aggregations

HadoopClusterConnection (org.talend.repository.model.hadoopcluster.HadoopClusterConnection)78 HadoopClusterConnectionItem (org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem)30 Test (org.junit.Test)15 ContextItem (org.talend.core.model.properties.ContextItem)14 ContextType (org.talend.designer.core.model.utils.emf.talendfile.ContextType)13 DatabaseConnectionItem (org.talend.core.model.properties.DatabaseConnectionItem)9 ArrayList (java.util.ArrayList)7 Map (java.util.Map)7 Item (org.talend.core.model.properties.Item)7 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)7 DistributionBean (org.talend.hadoop.distribution.model.DistributionBean)7 ConnectionItem (org.talend.core.model.properties.ConnectionItem)6 HadoopSubConnectionItem (org.talend.repository.model.hadoopcluster.HadoopSubConnectionItem)6 File (java.io.File)5 IHDistributionVersion (org.talend.core.runtime.hd.IHDistributionVersion)5 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 List (java.util.List)4 PersistenceException (org.talend.commons.exception.PersistenceException)4 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)4