Search in sources :

Example 21 with HadoopClusterConnectionItem

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

the class HadoopClusterConnectionRelationshipHandler method collect.

@Override
protected Set<Relation> collect(Item baseItem) {
    if (baseItem instanceof HadoopClusterConnectionItem) {
        HadoopClusterConnectionItem hcItem = (HadoopClusterConnectionItem) baseItem;
        HadoopClusterConnection connection = (HadoopClusterConnection) hcItem.getConnection();
        if (connection != null) {
            String version = connection.getDfVersion();
            if (StringUtils.isNotEmpty(version)) {
                if (DynamicDistributionManager.getInstance().isUsersDynamicDistribution(version)) {
                    Set<Relation> relationSet = new HashSet<Relation>();
                    Relation addedRelation = new Relation();
                    addedRelation.setId(version);
                    addedRelation.setType(RelationshipItemBuilder.DYNAMIC_DISTRIBUTION_RELATION);
                    addedRelation.setVersion(RelationshipItemBuilder.LATEST_VERSION);
                    relationSet.add(addedRelation);
                    return relationSet;
                }
            }
        }
    }
    if (baseItem instanceof DatabaseConnectionItem) {
        Connection connection = ((DatabaseConnectionItem) baseItem).getConnection();
        if (connection != null) {
            Object value = RepositoryToComponentProperty.getValue(connection, EParameterName.DB_VERSION.getName(), null);
            if (value instanceof String) {
                String version = (String) value;
                if (DynamicDistributionManager.getInstance().isUsersDynamicDistribution(version)) {
                    Set<Relation> relationSet = new HashSet<Relation>();
                    Relation addedRelation = new Relation();
                    addedRelation.setId(version);
                    addedRelation.setType(RelationshipItemBuilder.DYNAMIC_DISTRIBUTION_RELATION);
                    addedRelation.setVersion(RelationshipItemBuilder.LATEST_VERSION);
                    relationSet.add(addedRelation);
                    return relationSet;
                }
            }
        }
    }
    return Collections.emptySet();
}
Also used : Relation(org.talend.core.model.relationship.Relation) HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) 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 22 with HadoopClusterConnectionItem

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

the class ChangeHadoopConfJarNameMigrationTask method execute.

@Override
public ExecutionResult execute(Item item) {
    ILibraryManagerService libService = null;
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibraryManagerService.class)) {
        libService = (ILibraryManagerService) GlobalServiceRegister.getDefault().getService(ILibraryManagerService.class);
    }
    if (libService == null) {
        return ExecutionResult.NOTHING_TO_DO;
    }
    if (item instanceof HadoopClusterConnectionItem) {
        HadoopClusterConnectionItem hcItem = (HadoopClusterConnectionItem) item;
        HadoopClusterConnection connection = (HadoopClusterConnection) hcItem.getConnection();
        if (connection.getConfFile() == null) {
            String confJarName = HadoopParameterUtil.getConfsJarDefaultName(hcItem.getProperty().getId());
            if (!libService.contains(confJarName)) {
                return ExecutionResult.NOTHING_TO_DO;
            }
            File confsTempFolder = new File(HadoopConfsUtils.getConfsJarTempFolder());
            boolean retrieved = libService.retrieve(confJarName, confsTempFolder.getAbsolutePath(), false);
            File confJarFile = new File(confsTempFolder, confJarName);
            if (retrieved && confJarFile.exists()) {
                try {
                    connection.setConfFile(FileUtils.readFileToByteArray(confJarFile));
                    ProxyRepositoryFactory.getInstance().save(hcItem, true);
                    // Clear cache of the new confs jar name.
                    String newConfJarName = HadoopParameterUtil.getConfsJarDefaultName(hcItem.getProperty().getLabel());
                    HadoopConfsUtils.removeFromDeployedCache(hcItem, newConfJarName);
                    return ExecutionResult.SUCCESS_WITH_ALERT;
                } catch (Exception e) {
                    ExceptionHandler.process(e);
                    return ExecutionResult.FAILURE;
                }
            }
        }
    }
    return ExecutionResult.NOTHING_TO_DO;
}
Also used : ILibraryManagerService(org.talend.core.ILibraryManagerService) HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) HadoopClusterConnectionItem(org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem) File(java.io.File)

Example 23 with HadoopClusterConnectionItem

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

the class UpdateHadoopConfsForContextualHadoopClusterMigrationTask method execute.

@Override
public ExecutionResult execute(Item item) {
    if (item instanceof HadoopClusterConnectionItem) {
        boolean isModified = false;
        HadoopClusterConnectionItem hcItem = (HadoopClusterConnectionItem) item;
        try {
            isModified = HadoopConfsUtils.updateContextualHadoopConfs(hcItem);
            if (isModified) {
                ProxyRepositoryFactory.getInstance().save(hcItem, true);
                return ExecutionResult.SUCCESS_WITH_ALERT;
            }
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
            return ExecutionResult.FAILURE;
        }
    }
    return ExecutionResult.NOTHING_TO_DO;
}
Also used : PersistenceException(org.talend.commons.exception.PersistenceException) HadoopClusterConnectionItem(org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem)

Example 24 with HadoopClusterConnectionItem

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

the class CreateHadoopDBNodeAction method getWizard.

/*
     * (non-Javadoc)
     *
     * @see
     * org.talend.repository.hadoopcluster.action.common.CreateHadoopNodeAction#getWizard(org.eclipse.ui.IWorkbench,
     * boolean, org.talend.repository.model.RepositoryNode, java.lang.String[])
     */
@Override
protected IWizard getWizard(IWorkbench workbench, boolean isCreate, RepositoryNode node, String[] existingNames) {
    if (isCreate) {
        RepositoryNode dbRootNode = (RepositoryNode) node.getRoot().getRootRepositoryNode(ERepositoryObjectType.METADATA_CONNECTIONS);
        HadoopClusterConnectionItem hcConnectionItem = HCRepositoryUtil.getHCConnectionItemFromRepositoryNode(node);
        Map<String, String> initMap = new HashMap<String, String>();
        initConnectionParameters(initMap, hcConnectionItem);
        return new DatabaseWizard(workbench, isCreate, dbRootNode, existingNames, initMap);
    } else {
        return new DatabaseWizard(workbench, isCreate, node, existingNames);
    }
}
Also used : HashMap(java.util.HashMap) DatabaseWizard(org.talend.repository.ui.wizards.metadata.connection.database.DatabaseWizard) RepositoryNode(org.talend.repository.model.RepositoryNode) HadoopFolderRepositoryNode(org.talend.repository.hadoopcluster.node.HadoopFolderRepositoryNode) HadoopClusterConnectionItem(org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem)

Example 25 with HadoopClusterConnectionItem

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

the class HadoopClusterTokenCollector method getTokenDetailsForCurrentProject.

@Override
protected JSONObject getTokenDetailsForCurrentProject() throws Exception {
    JSONObject typesHadoop = new JSONObject();
    for (IRepositoryViewObject rvo : ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.getType(HADOOPCLUSTER))) {
        HadoopClusterConnectionItem item = (HadoopClusterConnectionItem) rvo.getProperty().getItem();
        HadoopClusterConnection connection = (HadoopClusterConnection) item.getConnection();
        // $NON-NLS-1$
        String distrib = connection.getDistribution() + "/" + connection.getDfVersion();
        int nbDbTypes = 1;
        if (typesHadoop.has(distrib)) {
            nbDbTypes = typesHadoop.getInt(distrib);
            nbDbTypes++;
        }
        typesHadoop.put(distrib, nbDbTypes);
    }
    JSONObject hadoopCluster = new JSONObject();
    JSONObject types = new JSONObject();
    types.put("types", typesHadoop);
    hadoopCluster.put(HADOOPCLUSTER, types);
    return hadoopCluster;
}
Also used : JSONObject(us.monoid.json.JSONObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) 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