use of com.hortonworks.streamline.common.Config in project streamline by hortonworks.
the class KafkaServiceRegistrar method createKafkaBrokerComponent.
private Pair<Component, List<ComponentProcess>> createKafkaBrokerComponent(Config config, Map<String, String> flattenConfigMap) {
if (!config.contains(PARAM_LISTENERS)) {
throw new IllegalArgumentException("Required parameter " + PARAM_LISTENERS + " not present.");
}
Map<String, String> confMap = new HashMap<>();
confMap.put(PARAM_LISTENERS, config.getString(PARAM_LISTENERS));
Component kafkaBroker = new Component();
kafkaBroker.setName(COMPONENT_KAFKA_BROKER);
List<KafkaBrokerListeners.ListenersPropEntry> parsedProps = new KafkaBrokerListeners.ListenersPropParsed(confMap).getParsedProps();
List<ComponentProcess> componentProcesses = parsedProps.stream().map(propEntry -> {
ComponentProcess cp = new ComponentProcess();
cp.setHost(propEntry.getHost());
cp.setPort(propEntry.getPort());
cp.setProtocol(propEntry.getProtocol().name());
return cp;
}).collect(toList());
return new Pair<>(kafkaBroker, componentProcesses);
}
use of com.hortonworks.streamline.common.Config in project streamline by hortonworks.
the class StormServiceRegistrar method createNimbusComponent.
private Pair<Component, List<ComponentProcess>> createNimbusComponent(Config config, Map<String, String> flatConfigMap) {
if (!config.contains(PARAM_NIMBUS_SEEDS)) {
throw new IllegalArgumentException("Required parameter " + PARAM_NIMBUS_SEEDS + " not present.");
}
if (!config.contains(PARAM_NIMBUS_THRIFT_PORT)) {
throw new IllegalArgumentException("Required parameter " + PARAM_NIMBUS_THRIFT_PORT + " not present.");
}
String nimbusSeeds;
try {
nimbusSeeds = config.getString(PARAM_NIMBUS_SEEDS);
} catch (ClassCastException e) {
throw new IllegalArgumentException("Required parameter " + PARAM_NIMBUS_SEEDS + " should be a string.");
}
Number nimbusThriftPort = readNumberFromConfig(config, PARAM_NIMBUS_THRIFT_PORT);
Component nimbus = new Component();
nimbus.setName(COMPONENT_NIMBUS);
List<ComponentProcess> componentProcesses = Arrays.stream(nimbusSeeds.split(",")).map(nimbusHost -> {
ComponentProcess cp = new ComponentProcess();
cp.setHost(nimbusHost);
cp.setPort(nimbusThriftPort.intValue());
return cp;
}).collect(toList());
return new Pair<>(nimbus, componentProcesses);
}
use of com.hortonworks.streamline.common.Config in project streamline by hortonworks.
the class HBaseServiceRegistrarTest method testRegister.
@Test
public void testRegister() throws Exception {
Cluster cluster = getTestCluster(1L);
HBaseServiceRegistrar registrar = initializeServiceRegistrar();
try (InputStream is = getClass().getClassLoader().getResourceAsStream(HBASE_SITE_XML_FILE_PATH)) {
ManualServiceRegistrar.ConfigFileInfo hiveSiteXml = new ManualServiceRegistrar.ConfigFileInfo(HBASE_SITE_XML, is);
registrar.register(cluster, new Config(), Lists.newArrayList(hiveSiteXml));
}
Service hbaseService = environmentService.getServiceByName(cluster.getId(), Constants.HBase.SERVICE_NAME);
assertNotNull(hbaseService);
ServiceConfiguration hbaseSiteConf = environmentService.getServiceConfigurationByName(hbaseService.getId(), CONFIGURATION_NAME_HBASE_SITE);
assertNotNull(hbaseSiteConf);
}
use of com.hortonworks.streamline.common.Config in project streamline by hortonworks.
the class HBaseServiceRegistrarTest method testRegister_requiredPropertyNotPresent.
@Test
public void testRegister_requiredPropertyNotPresent() throws Exception {
Cluster cluster = getTestCluster(1L);
HBaseServiceRegistrar registrar = initializeServiceRegistrar();
try (InputStream is = getClass().getClassLoader().getResourceAsStream(HBASE_SITE_XML_BADCASE_FILE_PATH)) {
ManualServiceRegistrar.ConfigFileInfo hbaseSiteXml = new ManualServiceRegistrar.ConfigFileInfo(HBASE_SITE_XML, is);
registrar.register(cluster, new Config(), Lists.newArrayList(hbaseSiteXml));
fail("Should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// OK
Service hbaseService = environmentService.getServiceByName(cluster.getId(), Constants.HBase.SERVICE_NAME);
assertNull(hbaseService);
}
}
use of com.hortonworks.streamline.common.Config in project streamline by hortonworks.
the class HDFSServiceRegistrarTest method testRegister_hdfs_site_xml_notPresent.
@Test
public void testRegister_hdfs_site_xml_notPresent() throws Exception {
Cluster cluster = getTestCluster(1L);
HDFSServiceRegistrar registrar = initializeServiceRegistrar();
try (InputStream is = getClass().getClassLoader().getResourceAsStream(CORE_SITE_XML_FILE_PATH)) {
ManualServiceRegistrar.ConfigFileInfo coreSiteXml = new ManualServiceRegistrar.ConfigFileInfo(CORE_SITE_XML, is);
registrar.register(cluster, new Config(), Lists.newArrayList(coreSiteXml));
fail("Should throw IllegalArgumentException");
} catch (IllegalArgumentException e) {
// OK
Service hdfsService = environmentService.getServiceByName(cluster.getId(), Constants.HDFS.SERVICE_NAME);
assertNull(hdfsService);
}
}
Aggregations