Search in sources :

Example 11 with HDFSConnection

use of org.talend.repository.model.hdfs.HDFSConnection in project tbd-studio-se by Talend.

the class ExtractHDFSSchemaManager method extractColumns.

public List<MetadataColumn> extractColumns(HDFSConnection connection, ClassLoader classLoader, IHDFSNode node) throws Exception {
    List<MetadataColumn> columns = new ArrayList<MetadataColumn>();
    if (connection == null || node == null || node.getType() != EHadoopFileTypes.FILE) {
        return columns;
    }
    HDFSFile file = (HDFSFile) node;
    HDFSConnectionBean connectionBean = HDFSModelUtil.convert2HDFSConnectionBean(connection);
    Object filePath = getHDFSFilePath(connectionBean, classLoader, file.getPath());
    IExtractSchemaService<HDFSConnection> service = ExtractHDFSMetaServiceFactory.getService(connectionBean, classLoader, filePath);
    return service.extractColumns(connection, node);
}
Also used : MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) HDFSFile(org.talend.designer.hdfsbrowse.model.HDFSFile) HDFSConnectionBean(org.talend.designer.hdfsbrowse.model.HDFSConnectionBean) ArrayList(java.util.ArrayList) HDFSConnection(org.talend.repository.model.hdfs.HDFSConnection)

Example 12 with HDFSConnection

use of org.talend.repository.model.hdfs.HDFSConnection 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 13 with HDFSConnection

use of org.talend.repository.model.hdfs.HDFSConnection in project tbd-studio-se by Talend.

the class HDFSConnectionCreator method create.

@Override
public ConnectionItem create(Map<String, Map<String, String>> initParams) throws CoreException {
    HDFSConnection connection = HDFSFactory.eINSTANCE.createHDFSConnection();
    Property connectionProperty = PropertiesFactory.eINSTANCE.createProperty();
    setPropertyParameters(connectionProperty);
    initializeConnectionParameters(connection);
    HadoopSubConnectionItem connectionItem = HDFSFactory.eINSTANCE.createHDFSConnectionItem();
    connectionItem.setProperty(connectionProperty);
    connectionItem.setConnection(connection);
    appendToHadoopCluster(connectionItem);
    return connectionItem;
}
Also used : HDFSConnection(org.talend.repository.model.hdfs.HDFSConnection) Property(org.talend.core.model.properties.Property) HadoopSubConnectionItem(org.talend.repository.model.hadoopcluster.HadoopSubConnectionItem)

Example 14 with HDFSConnection

use of org.talend.repository.model.hdfs.HDFSConnection in project tbd-studio-se by Talend.

the class PushHDFSIntoHadoopClusterMigrationTask method getClusterName.

/*
     * (non-Javadoc)
     *
     * @see
     * org.talend.repository.hadoopcluster.model.migration.AbstractHadoopClusterMigrationTask#getClusterName(org.talend
     * .repository.model.hadoopcluster.HadoopConnection)
     */
@Override
protected String getClusterName(HadoopSubConnection hadoopConnection) {
    StringBuffer cnBuffer = new StringBuffer();
    HDFSConnection connection = (HDFSConnection) hadoopConnection;
    EHadoopVersion4Drivers version = EHadoopVersion4Drivers.indexOfByVersion(connection.getDfVersion());
    if (version != null) {
        cnBuffer.append(version.getVersionValue());
        cnBuffer.append(UNDER_LINE);
    }
    String nameNodeURI = connection.getNameNodeURI();
    if (nameNodeURI != null) {
        cnBuffer.append(HadoopParameterUtil.getHostNameFromNameNodeURI(nameNodeURI));
    }
    String clusterName = cnBuffer.toString();
    // $NON-NLS-1$
    clusterName = clusterName.replaceAll("[^a-zA-Z0-9_]", UNDER_LINE);
    return clusterName;
}
Also used : HDFSConnection(org.talend.repository.model.hdfs.HDFSConnection) EHadoopVersion4Drivers(org.talend.core.hadoop.version.EHadoopVersion4Drivers)

Example 15 with HDFSConnection

use of org.talend.repository.model.hdfs.HDFSConnection in project tbd-studio-se by Talend.

the class CreateHDFSSchemaAction method doRun.

@Override
protected void doRun() {
    if (repositoryNode == null) {
        repositoryNode = getCurrentRepositoryNode();
    }
    HDFSConnection connection = null;
    MetadataTable metadataTable = null;
    boolean creation = false;
    if (repositoryNode.getType() == ENodeType.REPOSITORY_ELEMENT) {
        ERepositoryObjectType nodeType = (ERepositoryObjectType) repositoryNode.getProperties(EProperties.CONTENT_TYPE);
        String metadataTableLabel = (String) repositoryNode.getProperties(EProperties.LABEL);
        HDFSConnectionItem item = null;
        if (nodeType == ERepositoryObjectType.METADATA_CON_TABLE) {
            item = (HDFSConnectionItem) repositoryNode.getObject().getProperty().getItem();
            connection = (HDFSConnection) item.getConnection();
            metadataTable = TableHelper.findByLabel(connection, metadataTableLabel);
            creation = false;
        } else if (nodeType == HDFSRepositoryNodeType.HDFS) {
            item = (HDFSConnectionItem) repositoryNode.getObject().getProperty().getItem();
            connection = (HDFSConnection) item.getConnection();
            creation = true;
        } else {
            return;
        }
        boolean isOK = true;
        if (creation) {
            isOK = checkHDFSConnection((HDFSConnection) item.getConnection());
        }
        if (isOK) {
            openHDFSSchemaWizard(item, metadataTable, false, creation);
        }
    }
}
Also used : MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) HDFSConnection(org.talend.repository.model.hdfs.HDFSConnection) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) HDFSConnectionItem(org.talend.repository.model.hdfs.HDFSConnectionItem)

Aggregations

HDFSConnection (org.talend.repository.model.hdfs.HDFSConnection)16 ArrayList (java.util.ArrayList)6 Map (java.util.Map)5 IConnParamName (org.talend.metadata.managment.ui.model.IConnParamName)4 EHadoopParamName (org.talend.metadata.managment.ui.utils.ExtendedNodeConnectionContextUtils.EHadoopParamName)4 HashSet (java.util.HashSet)2 List (java.util.List)2 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)2 IContextParameter (org.talend.core.model.process.IContextParameter)2 ContextItem (org.talend.core.model.properties.ContextItem)2 Property (org.talend.core.model.properties.Property)2 ConectionAdaptContextVariableModel (org.talend.core.ui.context.model.table.ConectionAdaptContextVariableModel)2 HDFSConnectionBean (org.talend.designer.hdfsbrowse.model.HDFSConnectionBean)2 HDFSConnectionItem (org.talend.repository.model.hdfs.HDFSConnectionItem)2 Test (org.junit.Test)1 EHadoopVersion4Drivers (org.talend.core.hadoop.version.EHadoopVersion4Drivers)1 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)1 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)1 HDFSFile (org.talend.designer.hdfsbrowse.model.HDFSFile)1 HadoopClusterConnection (org.talend.repository.model.hadoopcluster.HadoopClusterConnection)1