Search in sources :

Example 31 with HadoopClusterConnectionItem

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

the class CreateHBaseAction method hideAction.

@Override
protected boolean hideAction(RepositoryNode node) {
    HadoopClusterConnectionItem hcConnectionItem = HCRepositoryUtil.getHCConnectionItemFromRepositoryNode(node);
    if (hcConnectionItem != null) {
        HadoopClusterConnection hcConnection = (HadoopClusterConnection) hcConnectionItem.getConnection();
        DistributionBean hbaseDistribution = HadoopDistributionsHelper.HBASE.getDistribution(hcConnection.getDistribution(), false);
        if (hbaseDistribution != null) {
            IHDistributionVersion hdVersion = hbaseDistribution.getHDVersion(hcConnection.getDfVersion(), false);
            if (hdVersion != null) {
                // found, don't hide
                return false;
            }
        }
    }
    return true;
}
Also used : IHDistributionVersion(org.talend.core.runtime.hd.IHDistributionVersion) HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) HadoopClusterConnectionItem(org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem) DistributionBean(org.talend.hadoop.distribution.model.DistributionBean)

Example 32 with HadoopClusterConnectionItem

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

the class AbstractHadoopSubnodeRepositoryContentHandler method deleteNode.

@Override
protected void deleteNode(Item item) throws Exception {
    if (item instanceof HadoopSubConnectionItem) {
        HadoopSubConnectionItem hadoopSubConnectionItem = (HadoopSubConnectionItem) item;
        HadoopClusterConnectionItem hadoopClusterItem = HCRepositoryUtil.getRelativeHadoopClusterItem(hadoopSubConnectionItem);
        if (hadoopClusterItem != null) {
            HCRepositoryUtil.removeFromHadoopCluster(hadoopClusterItem, hadoopSubConnectionItem.getProperty().getId());
        }
    }
}
Also used : HadoopSubConnectionItem(org.talend.repository.model.hadoopcluster.HadoopSubConnectionItem) HadoopClusterConnectionItem(org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem)

Example 33 with HadoopClusterConnectionItem

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

the class HDFSConnectionCreator method initializeConnectionParameters.

@Override
protected void initializeConnectionParameters(Connection conn) {
    if (!(conn instanceof HDFSConnection)) {
        return;
    }
    HDFSConnection connection = (HDFSConnection) conn;
    if (relativeHadoopClusterItem instanceof HadoopClusterConnectionItem) {
        HadoopClusterConnection hcConnection = (HadoopClusterConnection) ((HadoopClusterConnectionItem) relativeHadoopClusterItem).getConnection();
        String userName = ConnectionContextHelper.getParamValueOffContext(hcConnection, hcConnection.getUserName());
        if (userName != null) {
            connection.setUserName(userName);
        }
    }
    connection.setRowSeparator(IExtractSchemaService.DEFAULT_ROW_SEPARATOR);
    connection.setFieldSeparator(IExtractSchemaService.DEFAULT_FIELD_SEPARATOR);
}
Also used : HDFSConnection(org.talend.repository.model.hdfs.HDFSConnection) HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) HadoopClusterConnectionItem(org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem)

Example 34 with HadoopClusterConnectionItem

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

the class HadoopClusterService method copyHadoopCluster.

@Override
public void copyHadoopCluster(final Item sourceItem, final IPath path, String newName) throws PersistenceException, BusinessException {
    if (isHadoopClusterItem(sourceItem)) {
        IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
        HadoopClusterConnectionItem sourceClusterItem = (HadoopClusterConnectionItem) sourceItem;
        HadoopClusterConnectionItem targetClusterItem = null;
        if (StringUtils.isNotBlank(newName)) {
            targetClusterItem = (HadoopClusterConnectionItem) factory.copy(sourceClusterItem, path, newName);
        } else {
            targetClusterItem = (HadoopClusterConnectionItem) factory.copy(sourceClusterItem, path, true);
        }
        HadoopClusterConnection targetClusterConnection = (HadoopClusterConnection) targetClusterItem.getConnection();
        targetClusterConnection.getConnectionList().clear();
        String targetClusterId = targetClusterItem.getProperty().getId();
        Set<Item> sourceSubitems = HCRepositoryUtil.getSubitemsOfHadoopCluster(sourceClusterItem);
        for (Item subitem : sourceSubitems) {
            Item newSubitem = factory.copy(subitem, path, true);
            if (newSubitem instanceof HadoopSubConnectionItem) {
                ((HadoopSubConnection) ((HadoopSubConnectionItem) newSubitem).getConnection()).setRelativeHadoopClusterId(targetClusterId);
                targetClusterConnection.getConnectionList().add(newSubitem.getProperty().getId());
            } else if (subitem instanceof DatabaseConnectionItem) {
                ((DatabaseConnection) ((DatabaseConnectionItem) newSubitem).getConnection()).getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HADOOP_CLUSTER_ID, targetClusterId);
            }
            factory.save(newSubitem);
        }
        factory.save(targetClusterItem);
    }
}
Also used : ContextItem(org.talend.core.model.properties.ContextItem) 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) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) HadoopSubConnection(org.talend.repository.model.hadoopcluster.HadoopSubConnection) HadoopClusterConnectionItem(org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem) HadoopSubConnectionItem(org.talend.repository.model.hadoopcluster.HadoopSubConnectionItem) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem)

Example 35 with HadoopClusterConnectionItem

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

the class AdaptDeprecatedHadoopVersionsMigrationTask method execute.

@Override
public ExecutionResult execute(Item item) {
    if (item instanceof HadoopClusterConnectionItem) {
        DistributionBean[] distributions = HadoopDistributionsHelper.HADOOP.getDistributions();
        if (distributions != null && distributions.length > 0) {
            boolean modified = false;
            HadoopClusterConnectionItem hcItem = (HadoopClusterConnectionItem) item;
            HadoopClusterConnection hcConnection = (HadoopClusterConnection) hcItem.getConnection();
            DistributionBean distributionBean = HadoopDistributionsHelper.HADOOP.getDistribution(hcConnection.getDistribution(), false);
            if (distributionBean == null) {
                distributionBean = distributions[0];
                hcConnection.setDistribution(distributionBean.getName());
                modified = true;
            }
            String version = hcConnection.getDfVersion();
            DistributionVersion distributionVersion = distributionBean.getVersion(version, false);
            if (distributionVersion == null) {
                DistributionVersion[] versions = distributionBean.getVersions();
                if (versions != null && versions.length > 0) {
                    hcConnection.setDfVersion(versions[0].getVersion());
                    modified = true;
                }
            }
            if (modified) {
                try {
                    ProxyRepositoryFactory.getInstance().save(hcItem, true);
                    return ExecutionResult.SUCCESS_NO_ALERT;
                } catch (PersistenceException e) {
                    ExceptionHandler.process(e);
                    return ExecutionResult.FAILURE;
                }
            }
        }
    }
    return ExecutionResult.NOTHING_TO_DO;
}
Also used : DistributionVersion(org.talend.hadoop.distribution.model.DistributionVersion) PersistenceException(org.talend.commons.exception.PersistenceException) HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) HadoopClusterConnectionItem(org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem) DistributionBean(org.talend.hadoop.distribution.model.DistributionBean)

Aggregations

HadoopClusterConnectionItem (org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem)39 HadoopClusterConnection (org.talend.repository.model.hadoopcluster.HadoopClusterConnection)28 DatabaseConnectionItem (org.talend.core.model.properties.DatabaseConnectionItem)11 HadoopSubConnectionItem (org.talend.repository.model.hadoopcluster.HadoopSubConnectionItem)10 Item (org.talend.core.model.properties.Item)9 ConnectionItem (org.talend.core.model.properties.ConnectionItem)7 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)6 DistributionBean (org.talend.hadoop.distribution.model.DistributionBean)6 ContextItem (org.talend.core.model.properties.ContextItem)5 IHDistributionVersion (org.talend.core.runtime.hd.IHDistributionVersion)5 Test (org.junit.Test)4 PersistenceException (org.talend.commons.exception.PersistenceException)4 Project (org.talend.core.model.general.Project)4 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)4 ArrayList (java.util.ArrayList)3 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)3 Property (org.talend.core.model.properties.Property)3 HashSet (java.util.HashSet)2 Path (org.eclipse.core.runtime.Path)2 Connection (org.talend.core.model.metadata.builder.connection.Connection)2