Search in sources :

Example 26 with HadoopClusterConnection

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

the class HadoopClusterService method updateConfJarsByContextGroup.

@Override
public boolean updateConfJarsByContextGroup(ContextItem contextItem, Map<String, String> contextGroupRanamedMap) {
    boolean updated = false;
    try {
        List<IRepositoryViewObject> allHadoopClusterRepObjs = ProxyRepositoryFactory.getInstance().getAll(ProjectManager.getInstance().getCurrentProject(), getHadoopClusterType());
        for (IRepositoryViewObject repObj : allHadoopClusterRepObjs) {
            HadoopClusterConnectionItem hcItem = (HadoopClusterConnectionItem) repObj.getProperty().getItem();
            HadoopClusterConnection hcConnection = (HadoopClusterConnection) hcItem.getConnection();
            if (hcConnection.isUseCustomConfs()) {
                String contextId = hcConnection.getContextId();
                if (contextId != null && contextId.equals(contextItem.getProperty().getId())) {
                    boolean renamed = HadoopConfsUtils.renameContextGroups(hcConnection, contextGroupRanamedMap);
                    if (renamed) {
                        HadoopConfsUtils.getConfsJarDefaultNames(hcItem, true);
                    }
                }
            }
        }
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
    }
    return updated;
}
Also used : IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) HadoopClusterConnectionItem(org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem)

Example 27 with HadoopClusterConnection

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

the class HadoopClusterService method getCustomConfsJar.

@Override
public Optional<HadoopConfJarBean> getCustomConfsJar(ConnectionItem connectionItem, boolean createJarIfNotExist, boolean addExtraIds) {
    if (connectionItem instanceof HadoopClusterConnectionItem) {
        HadoopClusterConnectionItem item = (HadoopClusterConnectionItem) connectionItem;
        HadoopClusterConnection connection = (HadoopClusterConnection) item.getConnection();
        if (connection != null && connection.isUseCustomConfs()) {
            String extraIds = null;
            boolean isContextMode = connection.isContextMode();
            if (addExtraIds && isContextMode) {
                ContextType contextType = ConnectionContextHelper.getContextTypeForContextMode(connection, true);
                extraIds = contextType.getName();
            }
            String defaultName = null;
            if (extraIds == null) {
                defaultName = HadoopConfsUtils.getConfsJarDefaultName(item, createJarIfNotExist);
            } else {
                defaultName = HadoopConfsUtils.getConfsJarDefaultName(item, createJarIfNotExist, extraIds);
            }
            return Optional.of(new HadoopConfJarBean(isContextMode, connection.isUseCustomConfs() && HCParameterUtil.isOverrideHadoopConfs(connection), HCParameterUtil.getHadoopConfSpecificJar(connection, false), HCParameterUtil.getHadoopConfSpecificJar(connection, true), defaultName));
        }
    }
    return Optional.ofNullable(null);
}
Also used : ContextType(org.talend.designer.core.model.utils.emf.talendfile.ContextType) HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) HadoopClusterConnectionItem(org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem) HadoopConfJarBean(org.talend.core.hadoop.HadoopConfJarBean)

Example 28 with HadoopClusterConnection

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

the class HadoopClusterService method isUseDynamicConfJar.

@Override
public boolean isUseDynamicConfJar(String id) {
    Item item = getHadoopClusterItemById(id);
    if (item instanceof HadoopClusterConnectionItem) {
        HadoopClusterConnectionItem hcItem = (HadoopClusterConnectionItem) item;
        HadoopClusterConnection hcConnection = (HadoopClusterConnection) hcItem.getConnection();
        return hcConnection.isUseCustomConfs() && !ProcessorUtilities.isExportAsOSGI();
    }
    return false;
}
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) HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) HadoopClusterConnectionItem(org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem)

Example 29 with HadoopClusterConnection

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

the class HadoopClusterService method getSubitemIdsOfHadoopCluster.

@Override
public List<String> getSubitemIdsOfHadoopCluster(Item item) {
    if (!isHadoopClusterItem(item)) {
        return new ArrayList<>();
    }
    HadoopClusterConnectionItem clusterConnectionItem = (HadoopClusterConnectionItem) item;
    HadoopClusterConnection clusterConnection = (HadoopClusterConnection) clusterConnectionItem.getConnection();
    return clusterConnection.getConnectionList();
}
Also used : ArrayList(java.util.ArrayList) HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) HadoopClusterConnectionItem(org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem)

Example 30 with HadoopClusterConnection

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

the class HadoopClusterService method useCustomConfsJarIfNeeded.

@Override
public void useCustomConfsJarIfNeeded(List<ModuleNeeded> modulesNeeded, String clusterId) {
    Item item = getHadoopClusterItemById(clusterId);
    if (item instanceof HadoopClusterConnectionItem) {
        HadoopClusterConnectionItem connectionItem = (HadoopClusterConnectionItem) item;
        HadoopClusterConnection connection = (HadoopClusterConnection) connectionItem.getConnection();
        if (connection.isUseCustomConfs()) {
            Set<String> confsJarNames = HadoopConfsUtils.getConfsJarDefaultNames(connectionItem, true);
            Consumer<String> action = null;
            if (HCParameterUtil.isOverrideHadoopConfs(connection)) {
                action = (confsJarName) -> removeHadoopConfJar(modulesNeeded, confsJarName);
            } else {
                action = (confsJarName) -> addConfsModule(modulesNeeded, connection, confsJarName);
            }
            for (String confsJarName : confsJarNames) {
                action.accept(confsJarName);
            }
        }
    }
}
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) HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) HadoopClusterConnectionItem(org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem)

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