Search in sources :

Example 26 with HadoopClusterConnectionItem

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

the class HadoopClusterImportHandler method afterImportingItems.

@Override
public void afterImportingItems(IProgressMonitor monitor, ResourcesManager resManager, ImportItem importItem) {
    super.afterImportingItems(monitor, resManager, importItem);
    Item item = importItem.getItem();
    if (item instanceof HadoopClusterConnectionItem) {
        // Deploy the conf jars if needed.
        HadoopConfsUtils.getConfsJarDefaultNames((HadoopClusterConnectionItem) item, true);
    }
}
Also used : 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) HadoopClusterConnectionItem(org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem)

Example 27 with HadoopClusterConnectionItem

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

the class HadoopClusterRepositoryContentHandler method deleteNode.

@Override
protected void deleteNode(Item item) throws Exception {
    final IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    Project project = new Project(ProjectManager.getInstance().getProject(item.getProperty()));
    HadoopClusterConnectionItem hadoopClusterItem = (HadoopClusterConnectionItem) item;
    HadoopClusterConnection connection = (HadoopClusterConnection) hadoopClusterItem.getConnection();
    List<String> connectionList = connection.getConnectionList();
    for (String connId : connectionList) {
        IRepositoryViewObject repObj = null;
        try {
            repObj = factory.getLastVersion(project, connId);
        } catch (PersistenceException e) {
        // do nothing.
        }
        if (repObj != null) {
            factory.deleteObjectPhysical(repObj);
        }
    }
    connection.getConnectionList().clear();
    factory.save(hadoopClusterItem);
    // Disconnect db connection to hadoop cluster.
    String clusterId = hadoopClusterItem.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)) {
                dbConnection.getParameters().put(ConnParameterKeys.CONN_PARA_KEY_HADOOP_CLUSTER_ID, null);
                factory.save(dbItem);
            }
        }
    }
}
Also used : IProject(org.eclipse.core.resources.IProject) Project(org.talend.core.model.general.Project) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) HadoopClusterConnectionItem(org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem)

Example 28 with HadoopClusterConnectionItem

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

the class HadoopClusterRepositoryContentHandler method create.

@Override
public Resource create(IProject project, Item item, int classifierID, IPath path) throws PersistenceException {
    Resource itemResource = null;
    if (item.eClass() == HadoopClusterPackage.Literals.HADOOP_CLUSTER_CONNECTION_ITEM) {
        ERepositoryObjectType type = HadoopClusterRepositoryNodeType.HADOOPCLUSTER;
        itemResource = create(project, (HadoopClusterConnectionItem) item, path, type);
    }
    return itemResource;
}
Also used : Resource(org.eclipse.emf.ecore.resource.Resource) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) HadoopClusterConnectionItem(org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem)

Example 29 with HadoopClusterConnectionItem

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

the class HCRepositoryUtil method setupConnectionToHadoopCluster.

/**
 * DOC ycbai Comment method "setupConnectionToHadoopCluster".
 *
 * Setup the relation from hadoop subnode to hadoop cluster.
 *
 * @param node
 * @param connectionID
 * @throws PersistenceException
 */
public static void setupConnectionToHadoopCluster(IRepositoryNode node, String connectionID) throws PersistenceException {
    HadoopClusterConnectionItem hcConnectionItem = getHCConnectionItemFromRepositoryNode(node);
    setupConnectionToHadoopCluster(hcConnectionItem, connectionID);
}
Also used : HadoopClusterConnectionItem(org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem)

Example 30 with HadoopClusterConnectionItem

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

the class HCRepositoryUtil method getHCConnectionItemFromRepositoryNode.

/**
 * DOC ycbai Comment method "getHCConnectionItemFromRepositoryNode".
 *
 * Get the HadoopClusterConnectionItem from RepositoryNode recursively.
 *
 * @param node
 * @return
 */
public static HadoopClusterConnectionItem getHCConnectionItemFromRepositoryNode(IRepositoryNode node) {
    IRepositoryViewObject viewObject = node.getObject();
    ERepositoryObjectType repositoryObjectType = viewObject != null ? viewObject.getRepositoryObjectType() : null;
    if (viewObject != null && repositoryObjectType != null && (repositoryObjectType.equals(ERepositoryObjectType.METADATA_CONNECTIONS) || repositoryObjectType.equals(HadoopClusterRepositoryNodeType.HADOOPCLUSTER) || isHadoopSubItem(repositoryObjectType, node))) {
        final Property property = viewObject.getProperty();
        if (property != null) {
            Item item = property.getItem();
            if (item instanceof HadoopClusterConnectionItem) {
                return (HadoopClusterConnectionItem) item;
            } else if (item instanceof ConnectionItem) {
                return getRelativeHadoopClusterItem(item);
            }
        }
    } else if (isHadoopFolderNode(node)) {
        return getHCConnectionItemFromRepositoryNode(node.getParent());
    }
    return null;
}
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) HadoopClusterConnectionItem(org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) HadoopSubConnectionItem(org.talend.repository.model.hadoopcluster.HadoopSubConnectionItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) Property(org.talend.core.model.properties.Property) HadoopClusterConnectionItem(org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem)

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