Search in sources :

Example 1 with HadoopClusterConnectionItem

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

the class HCRepositoryUtil method getHadoopClusterItemBySubitemId.

public static HadoopClusterConnectionItem getHadoopClusterItemBySubitemId(String subitemId) {
    ProjectManager projectManager = ProjectManager.getInstance();
    HadoopClusterConnectionItem item = getHadoopClusterItemBySubitemId(projectManager.getCurrentProject(), subitemId);
    if (item == null) {
        // if not exist in current project, try to find it from reference projects
        List<Project> allReferencedProjects = projectManager.getAllReferencedProjects();
        for (Project referencedProject : allReferencedProjects) {
            item = getHadoopClusterItemBySubitemId(referencedProject, subitemId);
            if (item != null) {
                break;
            }
        }
    }
    return item;
}
Also used : Project(org.talend.core.model.general.Project) HadoopClusterConnectionItem(org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem) ProjectManager(org.talend.repository.ProjectManager)

Example 2 with HadoopClusterConnectionItem

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

the class HCRepositoryUtil method getSubitemsOfHadoopCluster.

/**
 * DOC ycbai Comment method "getSubitemsOfHadoopCluster".
 *
 * Get subitems of hadoop cluster like hdfs, hcatalog, hive etc.
 *
 * @param item
 * @return
 * @throws PersistenceException
 */
public static Set<Item> getSubitemsOfHadoopCluster(Item item) throws PersistenceException {
    Set<Item> subItems = new HashSet<Item>();
    if (item.eClass() != HadoopClusterPackage.Literals.HADOOP_CLUSTER_CONNECTION_ITEM) {
        return subItems;
    }
    Project project = new Project(ProjectManager.getInstance().getProject(item.getProperty()));
    HadoopClusterConnectionItem clusterConnectionItem = (HadoopClusterConnectionItem) item;
    HadoopClusterConnection clusterConnection = (HadoopClusterConnection) clusterConnectionItem.getConnection();
    EList<String> connectionList = clusterConnection.getConnectionList();
    for (String connId : connectionList) {
        if (connId != null) {
            IRepositoryViewObject repObj = ProxyRepositoryFactory.getInstance().getLastVersion(project, connId);
            if (repObj != null && repObj.getProperty() != null) {
                Item subItem = repObj.getProperty().getItem();
                if (subItem != null) {
                    subItems.add(subItem);
                }
            }
        }
    }
    String clusterId = clusterConnectionItem.getProperty().getId();
    List<IRepositoryViewObject> repObjs = ProxyRepositoryFactory.getInstance().getAll(project, ERepositoryObjectType.METADATA_CONNECTIONS);
    for (IRepositoryViewObject repObj : repObjs) {
        if (repObj != null && repObj.getProperty() != null) {
            DatabaseConnectionItem dbItem = (DatabaseConnectionItem) repObj.getProperty().getItem();
            DatabaseConnection dbConnection = (DatabaseConnection) dbItem.getConnection();
            String hcId = dbConnection.getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HADOOP_CLUSTER_ID);
            if (clusterId.equals(hcId)) {
                subItems.add(dbItem);
            }
        }
    }
    return subItems;
}
Also used : 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) Project(org.talend.core.model.general.Project) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) HadoopClusterConnectionItem(org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem) HashSet(java.util.HashSet) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem)

Example 3 with HadoopClusterConnectionItem

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

the class CreateMaprdbAction method hideAction.

@Override
protected boolean hideAction(RepositoryNode node) {
    HadoopClusterConnectionItem hcConnectionItem = HCRepositoryUtil.getHCConnectionItemFromRepositoryNode(node);
    if (hcConnectionItem != null) {
        HadoopClusterConnection hcConnection = (HadoopClusterConnection) hcConnectionItem.getConnection();
        DistributionBean maprdbDistribution = HadoopDistributionsHelper.MAPRDB.getDistribution(hcConnection.getDistribution(), false);
        if (maprdbDistribution != null) {
            IHDistributionVersion hdVersion = maprdbDistribution.getHDVersion(hcConnection.getDfVersion(), false);
            if (hdVersion != null) {
                // found, don't hide
                if (GlobalServiceRegister.getDefault().isServiceRegistered(IHadoopDistributionService.class)) {
                    IHadoopDistributionService hadoopService = (IHadoopDistributionService) GlobalServiceRegister.getDefault().getService(IHadoopDistributionService.class);
                    if (hadoopService != null) {
                        return !hadoopService.doSupportMapRTicket(hdVersion);
                    }
                }
            }
        }
    }
    return true;
}
Also used : IHadoopDistributionService(org.talend.core.hadoop.IHadoopDistributionService) 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 4 with HadoopClusterConnectionItem

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

the class CreateHiveAction method hideAction.

@Override
protected boolean hideAction(RepositoryNode node) {
    HadoopClusterConnectionItem hcConnectionItem = HCRepositoryUtil.getHCConnectionItemFromRepositoryNode(node);
    if (hcConnectionItem != null) {
        HadoopClusterConnection hcConnection = (HadoopClusterConnection) hcConnectionItem.getConnection();
        DistributionBean hiveDistribution = HadoopDistributionsHelper.HIVE.getDistribution(hcConnection.getDistribution(), false);
        if (hiveDistribution != null) {
            IHDistributionVersion hdVersion = hiveDistribution.getHDVersion(hcConnection.getDfVersion(), false);
            if (hdVersion != null && !IMicrosoftHDInsightDistribution.DISTRIBUTION_NAME.equals(hdVersion.getDistribution().getName())) {
                // found and not HD Insight, 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 5 with HadoopClusterConnectionItem

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

the class HadoopClusterImportHandler method findRelatedImportItems.

@Override
public List<ImportItem> findRelatedImportItems(IProgressMonitor monitor, ResourcesManager resManager, ImportItem importItem, ImportItem[] allImportItemRecords) throws Exception {
    List<ImportItem> relatedItemRecords = new ArrayList<ImportItem>();
    relatedItemRecords.addAll(super.findRelatedImportItems(monitor, resManager, importItem, allImportItemRecords));
    if (GlobalServiceRegister.getDefault().isServiceRegistered(IHadoopClusterService.class)) {
        IHadoopClusterService hadoopClusterService = (IHadoopClusterService) GlobalServiceRegister.getDefault().getService(IHadoopClusterService.class);
        final Item item = importItem.getItem();
        if (hadoopClusterService != null && hadoopClusterService.isHadoopClusterItem(item)) {
            resolveItem(resManager, importItem);
            HadoopClusterConnection hcConnection = (HadoopClusterConnection) ((HadoopClusterConnectionItem) item).getConnection();
            String clusterId = item.getProperty().getId();
            for (ImportItem ir : allImportItemRecords) {
                resolveItem(resManager, ir);
                Item subItem = ir.getItem();
                String hcId = null;
                if (subItem instanceof HadoopSubConnectionItem) {
                    hcId = ((HadoopSubConnection) ((HadoopSubConnectionItem) subItem).getConnection()).getRelativeHadoopClusterId();
                } else if (subItem instanceof DatabaseConnectionItem) {
                    hcId = ((DatabaseConnection) ((DatabaseConnectionItem) subItem).getConnection()).getParameters().get(ConnParameterKeys.CONN_PARA_KEY_HADOOP_CLUSTER_ID);
                }
                if (clusterId.equals(hcId)) {
                    if (subItem instanceof HadoopSubConnectionItem) {
                        EList<String> connectionList = hcConnection.getConnectionList();
                        String subItemId = subItem.getProperty().getId();
                        if (!connectionList.contains(subItemId)) {
                            connectionList.add(subItemId);
                        }
                    }
                    relatedItemRecords.add(ir);
                }
            }
        }
    }
    return relatedItemRecords;
}
Also used : ImportItem(org.talend.repository.items.importexport.handlers.model.ImportItem) HadoopClusterConnectionItem(org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem) HadoopSubConnectionItem(org.talend.repository.model.hadoopcluster.HadoopSubConnectionItem) Item(org.talend.core.model.properties.Item) ImportItem(org.talend.repository.items.importexport.handlers.model.ImportItem) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) IHadoopClusterService(org.talend.core.hadoop.IHadoopClusterService) ArrayList(java.util.ArrayList) HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) HadoopSubConnectionItem(org.talend.repository.model.hadoopcluster.HadoopSubConnectionItem) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem)

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