Search in sources :

Example 71 with HadoopClusterConnection

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

the class HCRepositoryUtilTest method testGetHadoopDbParameters.

@Test
public void testGetHadoopDbParameters() {
    HadoopClusterConnectionItem hcItem = ClusterTestUtil.createDefaultHadoopClusterItem();
    HadoopClusterConnection hcConnection = (HadoopClusterConnection) hcItem.getConnection();
    String NAME_NODE = "namenode";
    hcConnection.setNameNodeURI(NAME_NODE);
    Map<String, String> dbParameters = HCRepositoryUtil.getHadoopDbParameters(hcItem);
    assertEquals(NAME_NODE, dbParameters.get(ConnParameterKeys.CONN_PARA_KEY_NAME_NODE_URL));
}
Also used : HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) HadoopClusterConnectionItem(org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem) Test(org.junit.Test)

Example 72 with HadoopClusterConnection

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

the class HadoopClusterContextHandlerTest method testGetConAdditionPropertiesForContextMode.

@Test
public void testGetConAdditionPropertiesForContextMode() {
    // $NON-NLS-1$
    String hadoopPropertiesJsonStr = "[{\"PROPERTY\":\"hadoopProp\",\"VALUE\":\"hadoopPropValue\"}]";
    // $NON-NLS-1$
    String sparkPropertiesJsonStr = "[{\"PROPERTY\":\"sparkProp\",\"VALUE\":\"sparkPropValue\"}]";
    HadoopClusterConnectionItem hadoopClusterItem = ClusterTestUtil.createDefaultHadoopClusterItem();
    HadoopClusterConnection hadoopClusterConn = (HadoopClusterConnection) hadoopClusterItem.getConnection();
    hadoopClusterConn.setHadoopProperties(hadoopPropertiesJsonStr);
    hadoopClusterConn.setSparkProperties(sparkPropertiesJsonStr);
    Set<String> additionProperties = contextHandler.getConAdditionPropertiesForContextMode(hadoopClusterConn);
    // $NON-NLS-1$
    assertTrue(additionProperties.contains("hadoopProp"));
    // $NON-NLS-1$
    assertTrue(additionProperties.contains("sparkProp"));
}
Also used : HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) HadoopClusterConnectionItem(org.talend.repository.model.hadoopcluster.HadoopClusterConnectionItem) Test(org.junit.Test)

Example 73 with HadoopClusterConnection

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

the class HadoopConfsUtilsTest method testGetConfsJarDefaultNames.

@Test
public void testGetConfsJarDefaultNames() throws PersistenceException {
    HadoopClusterConnection hadoopClusterConnection = (HadoopClusterConnection) hcConnectionItem.getConnection();
    String clusterLabel = hcConnectionItem.getProperty().getLabel();
    // not context mode
    Set<String> confsJarNames = HadoopConfsUtils.getConfsJarDefaultNames(hcConnectionItem);
    assertEquals(1, confsJarNames.size());
    String expectConfsJarName = HadoopParameterUtil.getConfsJarDefaultName(clusterLabel);
    assertEquals(expectConfsJarName, confsJarNames.toArray()[0]);
    // context mode
    List<ContextType> contexts = new ArrayList<>();
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    List<String> contextNames = Arrays.asList("TEST", "DEV", "PROD");
    for (String contextName : contextNames) {
        contexts.add(ClusterTestUtil.createContextType(contextName));
    }
    ContextItem contextItem = ClusterTestUtil.createContextItem(clusterLabel, contexts, true);
    hadoopClusterConnection.setContextMode(true);
    hadoopClusterConnection.setContextId(contextItem.getProperty().getId());
    confsJarNames = HadoopConfsUtils.getConfsJarDefaultNames(hcConnectionItem);
    assertEquals(3, confsJarNames.size());
    for (String contextName : contextNames) {
        // $NON-NLS-1$
        assertTrue(confsJarNames.contains(HadoopParameterUtil.getConfsJarDefaultName(clusterLabel + "_" + contextName)));
    }
    ClusterTestUtil.deleteItem(contextItem);
}
Also used : ContextType(org.talend.designer.core.model.utils.emf.talendfile.ContextType) ContextItem(org.talend.core.model.properties.ContextItem) HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) Test(org.junit.Test)

Example 74 with HadoopClusterConnection

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

the class HadoopConfsUtilsTest method testRenameContextGroups_ranamedMapIsNull.

@Test
public void testRenameContextGroups_ranamedMapIsNull() {
    HadoopClusterConnection hcConnection = (HadoopClusterConnection) hcConnectionItem.getConnection();
    assertFalse(HadoopConfsUtils.renameContextGroups(hcConnection, null));
    assertFalse(HadoopConfsUtils.renameContextGroups(hcConnection, new HashMap<>()));
}
Also used : HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) Test(org.junit.Test)

Example 75 with HadoopClusterConnection

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

the class HadoopConfsUtilsTest method testBuildAndDeployConfsJar.

@Test
public void testBuildAndDeployConfsJar() throws IOException {
    HadoopClusterConnection hcConnection = (HadoopClusterConnection) hcConnectionItem.getConnection();
    // $NON-NLS-1$ //$NON-NLS-2$
    File testConfJarDir = File.createTempFile("testConfDir", "tmp");
    testConfJarDir.delete();
    testConfJarDir.mkdirs();
    testConfJarDir.deleteOnExit();
    // $NON-NLS-1$
    String testConfJarName = "testConf";
    // $NON-NLS-1$
    String testContextGroup = "TEST";
    HadoopConfsUtils.buildAndDeployConfsJar(hcConnectionItem, null, testConfJarDir.getAbsolutePath(), testConfJarName);
    assertNotNull(hcConnection.getConfFile());
    // Context mode
    hcConnection.setContextMode(true);
    HadoopConfsUtils.buildAndDeployConfsJar(hcConnectionItem, testContextGroup, testConfJarDir.getAbsolutePath(), testConfJarName);
    assertNotNull(hcConnection.getConfFiles());
    assertEquals(1, hcConnection.getConfFiles().size());
    hcConnection.getConfFiles().clear();
    // If connection is context mode but context group is null then will not save conf jar.
    HadoopConfsUtils.buildAndDeployConfsJar(hcConnectionItem, null, testConfJarDir.getAbsolutePath(), testConfJarName);
    assertEquals(0, hcConnection.getConfFiles().size());
}
Also used : HadoopClusterConnection(org.talend.repository.model.hadoopcluster.HadoopClusterConnection) File(java.io.File) Test(org.junit.Test)

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