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));
}
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"));
}
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);
}
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<>()));
}
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());
}
Aggregations