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);
}
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);
}
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;
}
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;
}
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);
}
}
}
Aggregations