Search in sources :

Example 36 with HadoopClusterConnection

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

the class StandardHCInfoForm method updateForm.

@Override
public void updateForm() {
    HadoopClusterConnection connection = getConnection();
    final DistributionVersion distributionVersion = getDistributionVersion();
    if (distributionVersion.distribution.useCustom()) {
        hideControl(customGroup, false);
        String authModeName = connection.getAuthMode();
        if (authModeName != null) {
            EAuthenticationMode authMode = EAuthenticationMode.getAuthenticationByName(authModeName, false);
            switch(authMode) {
                case KRB:
                    kerberosBtn.setEnabled(true);
                    namenodePrincipalText.setEditable(kerberosBtn.isEnabled() && kerberosBtn.getSelection());
                    jtOrRmPrincipalText.setEditable(namenodePrincipalText.getEditable());
                    jobHistoryPrincipalText.setEditable(isJobHistoryPrincipalEditable());
                    keytabBtn.setEnabled(kerberosBtn.isEnabled() && kerberosBtn.getSelection());
                    keytabPrincipalText.setEditable(keytabBtn.isEnabled() && keytabBtn.getSelection());
                    keytabText.setEditable(keytabBtn.isEnabled() && keytabBtn.getSelection());
                    keytabPrincipalText.setHideWidgets(!(kerberosBtn.isEnabled() && kerberosBtn.getSelection() && keytabBtn.isEnabled() && keytabBtn.getSelection()));
                    keytabText.setVisible(kerberosBtn.isEnabled() && kerberosBtn.getSelection() && keytabBtn.isEnabled() && keytabBtn.getSelection());
                    userNameText.setEditable(false);
                    groupText.setEditable(false);
                    // userNameText.setHideWidgets(true);
                    userNameText.setVisible(false);
                    groupText.setHideWidgets(true);
                    hideKerberosControl(!kerberosBtn.getSelection());
                    hideMaprTicketControl(true);
                    maprTPasswordText.setEditable(false);
                    break;
                case UGI:
                    kerberosBtn.setEnabled(true);
                    namenodePrincipalText.setEditable(kerberosBtn.isEnabled() && kerberosBtn.getSelection());
                    jtOrRmPrincipalText.setEditable(namenodePrincipalText.getEditable());
                    jobHistoryPrincipalText.setEditable(namenodePrincipalText.getEditable());
                    keytabBtn.setEnabled(kerberosBtn.isEnabled() && kerberosBtn.getSelection());
                    keytabPrincipalText.setEditable(keytabBtn.isEnabled() && keytabBtn.getSelection());
                    keytabText.setEditable(keytabBtn.isEnabled() && keytabBtn.getSelection());
                    keytabPrincipalText.setHideWidgets(!(kerberosBtn.isEnabled() && kerberosBtn.getSelection() && keytabBtn.isEnabled() && keytabBtn.getSelection()));
                    keytabText.setVisible(kerberosBtn.isEnabled() && kerberosBtn.getSelection() && keytabBtn.isEnabled() && keytabBtn.getSelection());
                    userNameText.setEditable(!(kerberosBtn.isEnabled() && kerberosBtn.getSelection()));
                    groupText.setEditable(true);
                    userNameText.setHideWidgets(kerberosBtn.isEnabled() && kerberosBtn.getSelection());
                    groupText.setHideWidgets(false);
                    hideKerberosControl(!kerberosBtn.getSelection());
                    // maprt
                    hideMaprTicketChildControl(!maprTBtn.getSelection());
                    maprTPasswordText.setEditable(maprTBtn.isEnabled() && (maprTBtn.getSelection() && !(kerberosBtn.isEnabled() && kerberosBtn.getSelection())));
                    break;
                default:
                    kerberosBtn.setEnabled(false);
                    namenodePrincipalText.setEditable(false);
                    jtOrRmPrincipalText.setEditable(false);
                    jobHistoryPrincipalText.setEditable(false);
                    keytabBtn.setEnabled(false);
                    keytabPrincipalText.setEditable(false);
                    keytabText.setEditable(false);
                    userNameText.setEditable(true);
                    groupText.setEditable(false);
                    userNameText.setHideWidgets(false);
                    groupText.setHideWidgets(true);
                    hideKerberosControl(true);
                    hideMaprTicketControl(true);
                    maprTPasswordText.setEditable(false);
                    break;
            }
        }
    } else {
        hideControl(customGroup, true);
        kerberosBtn.setEnabled(isCurrentHadoopVersionSupportSecurity());
        namenodePrincipalText.setEditable(kerberosBtn.isEnabled() && kerberosBtn.getSelection());
        jtOrRmPrincipalText.setEditable(namenodePrincipalText.getEditable());
        jobHistoryPrincipalText.setEditable(isJobHistoryPrincipalEditable());
        keytabBtn.setEnabled(kerberosBtn.isEnabled() && kerberosBtn.getSelection());
        keytabPrincipalText.setEditable(keytabBtn.isEnabled() && keytabBtn.getSelection());
        keytabText.setEditable(keytabBtn.isEnabled() && keytabBtn.getSelection());
        keytabPrincipalText.setHideWidgets(!(kerberosBtn.isEnabled() && kerberosBtn.getSelection() && keytabBtn.isEnabled() && keytabBtn.getSelection()));
        keytabText.setVisible(kerberosBtn.isEnabled() && kerberosBtn.getSelection() && keytabBtn.isEnabled() && keytabBtn.getSelection());
        groupText.setEditable(isCurrentHadoopVersionSupportGroup());
        userNameText.setEditable(!kerberosBtn.getSelection());
        if (isCurrentHadoopVersionSupportGroup()) {
            userNameText.setHideWidgets(kerberosBtn.getSelection());
        } else {
            userNameText.setVisible(!kerberosBtn.getSelection());
        }
        groupText.setHideWidgets(!isCurrentHadoopVersionSupportGroup());
        hideKerberosControl(!kerberosBtn.getSelection());
        // maprt
        hideControl(maprTBtn, !isCurrentHadoopVersionSupportMapRTicket());
        maprTBtn.setEnabled(isCurrentHadoopVersionSupportMapRTicket());
        maprTPasswordText.setEditable(maprTBtn.isEnabled() && (maprTBtn.getSelection() && !(kerberosBtn.isEnabled() && kerberosBtn.getSelection())));
        maprTClusterText.setEditable(maprTBtn.isEnabled() && maprTBtn.getSelection());
        maprTDurationText.setEditable(maprTBtn.isEnabled() && maprTBtn.getSelection());
        setMaprTHomeDirBtn.setEnabled(maprTBtn.isEnabled() && maprTBtn.getSelection());
        setHadoopLoginBtn.setEnabled(maprTBtn.isEnabled() && maprTBtn.getSelection());
        preloadAuthentificationBtn.setEnabled(maprTBtn.isEnabled() && maprTBtn.getSelection());
        hideMaprTicketChildControl(!maprTBtn.getSelection());
    }
    updateMRRelatedContent();
    updateConnectionContent();
    hideWebHDFSControl(!isCurrentHadoopVersionSupportWebHDFS());
    if (isContextMode()) {
        adaptFormToEditable();
    }
    hideFieldsOnSparkMode();
}
Also used : DistributionVersion(org.talend.hadoop.distribution.model.DistributionVersion) EAuthenticationMode(org.talend.core.hadoop.version.EAuthenticationMode) HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection)

Example 37 with HadoopClusterConnection

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

the class StandardHCInfoForm method initCommonProperties.

private void initCommonProperties(HadoopServiceProperties properties) {
    properties.setItem(this.connectionItem);
    HadoopClusterConnection connection = getConnection();
    ContextType contextType = null;
    if (getConnection().isContextMode()) {
        contextType = ConnectionContextHelper.getContextTypeForContextMode(connection, true);
    }
    properties.setContextType(contextType);
    properties.setDistribution(connection.getDistribution());
    properties.setVersion(connection.getDfVersion());
    properties.setGroup(connection.getGroup());
    properties.setUseKrb(connection.isEnableKerberos());
    properties.setCustom(connection.isUseCustomVersion());
    properties.setUseCustomConfs(connection.isUseCustomConfs());
    properties.setPrincipal(connection.getPrincipal());
    properties.setJtOrRmPrincipal(connection.getJtOrRmPrincipal());
    properties.setJobHistoryPrincipal(connection.getJobHistoryPrincipal());
    properties.setUseKeytab(connection.isUseKeytab());
    properties.setKeytabPrincipal(connection.getKeytabPrincipal());
    properties.setKeytab(connection.getKeytab());
    properties.setHadoopProperties(HadoopRepositoryUtil.getHadoopPropertiesWithOriginalValue(connection.getHadoopProperties(), contextType, false));
    properties.setRelativeHadoopClusterId(connectionItem.getProperty().getId());
    properties.setRelativeHadoopClusterLabel(connectionItem.getProperty().getLabel());
    properties.setMaprT(connection.isEnableMaprT());
    properties.setUserName(connection.getUserName());
    properties.setMaprTPassword(connection.getMaprTPassword());
    properties.setMaprTCluster(connection.getMaprTCluster());
    properties.setMaprTDuration(connection.getMaprTDuration());
    properties.setSetMaprTHomeDir(connection.isSetMaprTHomeDir());
    properties.setSetHadoopLogin(connection.isSetHadoopLogin());
    properties.setPreloadAuthentification(connection.isPreloadAuthentification());
    properties.setMaprTHomeDir(connection.getMaprTHomeDir());
    properties.setMaprTHadoopLogin(connection.getMaprTHadoopLogin());
    properties.setSetHadoopConf(connection.isUseCustomConfs() && HCParameterUtil.isOverrideHadoopConfs(connection));
    properties.setHadoopConfSpecificJar(ContextParameterUtils.getOriginalValue(contextType, Optional.ofNullable(connection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HADOOP_CONF_SPECIFIC_JAR)).orElse("")));
    properties.setUseWebHDFSSSL(connection.isUseWebHDFSSSL());
    properties.setWebHDFSSSLTrustStorePath(connection.getWebHDFSSSLTrustStorePath());
    properties.setWebHDFSSSLTrustStorePassword(connection.getWebHDFSSSLTrustStorePassword());
}
Also used : ContextType(org.talend.designer.core.model.utils.emf.talendfile.ContextType) HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection)

Example 38 with HadoopClusterConnection

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

the class AbstractHadoopSubConnectionCreator method appendToHadoopCluster.

protected void appendToHadoopCluster(HadoopSubConnectionItem connectionItem) {
    HadoopSubConnection connection = (HadoopSubConnection) connectionItem.getConnection();
    HadoopClusterConnection hcConnection = (HadoopClusterConnection) ((HadoopClusterConnectionItem) relativeHadoopClusterItem).getConnection();
    if (hcConnection != null) {
        connection.setRelativeHadoopClusterId(relativeHadoopClusterId);
        hcConnection.getConnectionList().add(connectionItem.getProperty().getId());
    }
}
Also used : HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) HadoopSubConnection(org.talend.repository.model.hadoopcluster.HadoopSubConnection)

Example 39 with HadoopClusterConnection

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

the class AbstractHadoopClusterMigrationTask method convert.

protected void convert(ConnectionItem item) throws Exception {
    IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    Connection connection = item.getConnection();
    if (connection instanceof HadoopSubConnection) {
        HadoopSubConnection hadoopSubConnection = (HadoopSubConnection) connection;
        String relClusterId = hadoopSubConnection.getRelativeHadoopClusterId();
        if (StringUtils.isNotBlank(relClusterId)) {
            modified[0] = false;
            return;
        } else {
            modified[0] = true;
        }
        HadoopClusterConnection hcConn = null;
        HadoopClusterConnectionItem hcConnItem = null;
        String migratedHCName = getClusterName(hadoopSubConnection);
        List<IRepositoryViewObject> hcRepObjs = factory.getAll(HadoopClusterRepositoryNodeType.HADOOPCLUSTER);
        for (IRepositoryViewObject repObj : hcRepObjs) {
            if (repObj != null && repObj.getProperty() != null && migratedHCName.equals(repObj.getProperty().getLabel())) {
                hcConnItem = (HadoopClusterConnectionItem) repObj.getProperty().getItem();
                break;
            }
        }
        if (hcConnItem == null) {
            hcConn = HadoopClusterFactory.eINSTANCE.createHadoopClusterConnection();
            Property connectionProperty = PropertiesFactory.eINSTANCE.createProperty();
            connectionProperty.setAuthor(((RepositoryContext) CoreRuntimePlugin.getInstance().getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getUser());
            connectionProperty.setVersion(VersionUtils.DEFAULT_VERSION);
            // $NON-NLS-1$
            connectionProperty.setStatusCode("");
            hcConnItem = HadoopClusterFactory.eINSTANCE.createHadoopClusterConnectionItem();
            hcConnItem.setProperty(connectionProperty);
            hcConnItem.setConnection(hcConn);
            connectionProperty.setLabel(migratedHCName);
            hcConn.setName(migratedHCName);
            hcConn.setLabel(migratedHCName);
            String nextId = factory.getNextId();
            connectionProperty.setId(nextId);
            // $NON-NLS-1$
            factory.create(hcConnItem, new Path(""));
        }
        if (hcConn == null) {
            hcConn = (HadoopClusterConnection) hcConnItem.getConnection();
        }
        initCluster(hcConn, hadoopSubConnection);
        factory.save(hcConnItem);
        if (hcConnItem != null) {
            hadoopSubConnection.setRelativeHadoopClusterId(hcConnItem.getProperty().getId());
            factory.save(item);
            HCRepositoryUtil.setupConnectionToHadoopCluster(hcConnItem, item.getProperty().getId());
        }
    }
}
Also used : Path(org.eclipse.core.runtime.Path) HadoopSubConnection(org.talend.repository.model.hadoopcluster.HadoopSubConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) HadoopSubConnection(org.talend.repository.model.hadoopcluster.HadoopSubConnection) HadoopClusterConnectionItem(org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 40 with HadoopClusterConnection

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

the class HadoopClusterConnectionRelationshipHandler method collect.

@Override
protected Set<Relation> collect(Item baseItem) {
    if (baseItem instanceof HadoopClusterConnectionItem) {
        HadoopClusterConnectionItem hcItem = (HadoopClusterConnectionItem) baseItem;
        HadoopClusterConnection connection = (HadoopClusterConnection) hcItem.getConnection();
        if (connection != null) {
            String version = connection.getDfVersion();
            if (StringUtils.isNotEmpty(version)) {
                if (DynamicDistributionManager.getInstance().isUsersDynamicDistribution(version)) {
                    Set<Relation> relationSet = new HashSet<Relation>();
                    Relation addedRelation = new Relation();
                    addedRelation.setId(version);
                    addedRelation.setType(RelationshipItemBuilder.DYNAMIC_DISTRIBUTION_RELATION);
                    addedRelation.setVersion(RelationshipItemBuilder.LATEST_VERSION);
                    relationSet.add(addedRelation);
                    return relationSet;
                }
            }
        }
    }
    if (baseItem instanceof DatabaseConnectionItem) {
        Connection connection = ((DatabaseConnectionItem) baseItem).getConnection();
        if (connection != null) {
            Object value = RepositoryToComponentProperty.getValue(connection, EParameterName.DB_VERSION.getName(), null);
            if (value instanceof String) {
                String version = (String) value;
                if (DynamicDistributionManager.getInstance().isUsersDynamicDistribution(version)) {
                    Set<Relation> relationSet = new HashSet<Relation>();
                    Relation addedRelation = new Relation();
                    addedRelation.setId(version);
                    addedRelation.setType(RelationshipItemBuilder.DYNAMIC_DISTRIBUTION_RELATION);
                    addedRelation.setVersion(RelationshipItemBuilder.LATEST_VERSION);
                    relationSet.add(addedRelation);
                    return relationSet;
                }
            }
        }
    }
    return Collections.emptySet();
}
Also used : Relation(org.talend.core.model.relationship.Relation) HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) 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)

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