Search in sources :

Example 56 with HadoopClusterConnection

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

the class HadoopConfsUtils method getConfsJarDefaultNames.

/**
 * Get all conf jars names. If the connection is in context mode each context group will has one conf jar, otherwise
 * there will be only one conf jar.
 *
 * @param connectionItem
 * @param createJarIfNotExist
 *
 * @return
 */
public static Set<String> getConfsJarDefaultNames(HadoopClusterConnectionItem connectionItem, boolean createJarIfNotExist) {
    Set<String> jarNames = new HashSet<>();
    HadoopClusterConnection connection = (HadoopClusterConnection) connectionItem.getConnection();
    if (connection.isContextMode()) {
        ContextItem contextItem = ContextUtils.getContextItemById2(connection.getContextId());
        if (contextItem != null) {
            EList<ContextType> contexts = contextItem.getContext();
            for (ContextType contextType : contexts) {
                jarNames.add(HadoopConfsUtils.getConfsJarDefaultName(connectionItem, createJarIfNotExist, contextType.getName()));
            }
        }
    } else {
        jarNames.add(HadoopConfsUtils.getConfsJarDefaultName(connectionItem, createJarIfNotExist));
    }
    return jarNames;
}
Also used : ContextItem(org.talend.core.model.properties.ContextItem) ContextType(org.talend.designer.core.model.utils.emf.talendfile.ContextType) HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) HashSet(java.util.HashSet)

Example 57 with HadoopClusterConnection

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

the class HadoopConfsUtils method createAndDeployConfJar.

private static void createAndDeployConfJar(HadoopClusterConnectionItem connectionItem, String confJarId, String confJarName) throws IOException {
    // If the conf jar has been deployed before then no need to deploy again.
    if (containsInDeployedCache(connectionItem, confJarName)) {
        return;
    }
    byte[] confFileBA = null;
    HadoopClusterConnection connection = (HadoopClusterConnection) connectionItem.getConnection();
    if (connection.isContextMode()) {
        ContextItem contextItem = ContextUtils.getContextItemById2(connection.getContextId());
        if (contextItem != null) {
            EMap<String, byte[]> confFiles = connection.getConfFiles();
            EList<ContextType> contexts = contextItem.getContext();
            for (ContextType contextType : contexts) {
                String contextName = contextType.getName();
                byte[] bs = confFiles.get(contextName);
                if (confJarId.endsWith(contextName) && bs != null) {
                    confFileBA = bs;
                    break;
                }
            }
        }
        if (confFileBA == null) {
            // either conf jar name is wrong or it is a old item.
            // then take the old hadoop conf file content.
            confFileBA = connection.getConfFile();
        }
    } else {
        confFileBA = connection.getConfFile();
    }
    if (confFileBA != null) {
        File confsTempFolder = new File(getConfsJarTempFolder());
        File confFile = new File(confsTempFolder, confJarName);
        FileUtils.writeByteArrayToFile(confFile, confFileBA);
        if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibraryManagerService.class)) {
            ILibraryManagerService libService = GlobalServiceRegister.getDefault().getService(ILibraryManagerService.class);
            if (libService != null && libService.isJarNeedToBeDeployed(confFile)) {
                if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibrariesService.class)) {
                    ILibrariesService service = GlobalServiceRegister.getDefault().getService(ILibrariesService.class);
                    if (service != null) {
                        // Only deploy a new jar, no need to reset all
                        service.deployLibrary(confFile.toURI().toURL());
                        addToDeployedCache(connectionItem, confJarName);
                    }
                }
            }
        }
    }
}
Also used : ContextItem(org.talend.core.model.properties.ContextItem) ContextType(org.talend.designer.core.model.utils.emf.talendfile.ContextType) ILibraryManagerService(org.talend.core.ILibraryManagerService) ILibrariesService(org.talend.core.model.general.ILibrariesService) HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) File(java.io.File)

Example 58 with HadoopClusterConnection

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

the class GoogleDataprocInfoForm method initCommonProperties.

private void initCommonProperties(HadoopServiceProperties properties) {
    HadoopClusterConnection connection = getConnection();
    ContextType contextType = null;
    if (getConnection().isContextMode()) {
        contextType = ConnectionContextHelper.getContextTypeForContextMode(connection, connection.getContextName(), false);
    }
    properties.setContextType(contextType);
    properties.setRelativeHadoopClusterId(connectionItem.getProperty().getId());
    properties.setRelativeHadoopClusterLabel(connectionItem.getProperty().getLabel());
    properties.setDistribution(connection.getDistribution());
    properties.setVersion(connection.getDfVersion());
    properties.setUseKrb(connection.isEnableKerberos());
}
Also used : ContextType(org.talend.designer.core.model.utils.emf.talendfile.ContextType) HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection)

Example 59 with HadoopClusterConnection

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

the class KnoxInfoForm method initCommonProperties.

private void initCommonProperties(HadoopServiceProperties properties) {
    HadoopClusterConnection connection = getConnection();
    ContextType contextType = null;
    if (getConnection().isContextMode()) {
        contextType = ConnectionContextHelper.getContextTypeForContextMode(connection, connection.getContextName(), false);
    }
    properties.setContextType(contextType);
    properties.setRelativeHadoopClusterId(connectionItem.getProperty().getId());
    properties.setRelativeHadoopClusterLabel(connectionItem.getProperty().getLabel());
    properties.setDistribution(connection.getDistribution());
    properties.setVersion(connection.getDfVersion());
    properties.setUseKrb(connection.isEnableKerberos());
}
Also used : ContextType(org.talend.designer.core.model.utils.emf.talendfile.ContextType) HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection)

Example 60 with HadoopClusterConnection

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

the class HadoopClusterService method containedByCluster.

@Override
public boolean containedByCluster(Connection hadoopClusterConnection, Connection hadoopSubConnection) {
    if (hadoopClusterConnection != null && hadoopSubConnection != null && hadoopClusterConnection instanceof HadoopClusterConnection) {
        HadoopClusterConnection hcConnection = (HadoopClusterConnection) hadoopClusterConnection;
        HadoopClusterConnection relativeHCConnection = HCRepositoryUtil.getRelativeHadoopClusterConnection(hadoopSubConnection);
        if (hcConnection.equals(relativeHCConnection)) {
            return true;
        }
    }
    return false;
}
Also used : 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