use of com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess in project streamline by hortonworks.
the class StormMetadataServiceTest method buildNimbusComponentProcesses.
private List<ComponentProcess> buildNimbusComponentProcesses() {
ComponentProcess nimbus1 = new ComponentProcess();
nimbus1.setHost("localhost");
nimbus1.setPort(8080);
ComponentProcess nimbus2 = new ComponentProcess();
nimbus2.setHost("localhost");
nimbus2.setPort(8080);
return Lists.newArrayList(nimbus1, nimbus2);
}
use of com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess in project streamline by hortonworks.
the class EnvironmentService method createComponentProcess.
public ComponentProcess createComponentProcess(Component component, String host) {
ComponentProcess componentProcess = new ComponentProcess();
componentProcess.setId(this.dao.nextId(NAMESPACE_COMPONENT_PROCESS));
componentProcess.setComponentId(component.getId());
componentProcess.setHost(host);
componentProcess.setTimestamp(System.currentTimeMillis());
return componentProcess;
}
use of com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess in project streamline by hortonworks.
the class EnvironmentService method injectProtocolAndPortToComponent.
public void injectProtocolAndPortToComponent(Map<String, String> configurations, Component component, List<ComponentProcess> componentProcesses) {
try {
ComponentPropertyPattern componentPropertyPattern = ComponentPropertyPattern.valueOf(component.getName());
String value = configurations.get(componentPropertyPattern.getConnectionConfName());
if (value != null) {
Pattern parsePattern = componentPropertyPattern.getParsePattern();
LOG.debug("Connection configuration name: [{}], parse pattern: [{}]", value, parsePattern);
if (parsePattern != null) {
Matcher matcher = parsePattern.matcher(value);
if (matcher.matches()) {
String protocol = matcher.group(1);
String portStr = matcher.group(2);
if (!protocol.isEmpty()) {
for (ComponentProcess componentProcess : componentProcesses) {
componentProcess.setProtocol(protocol);
}
}
if (!portStr.isEmpty()) {
try {
int port = Integer.parseInt(portStr);
for (ComponentProcess componentProcess : componentProcesses) {
componentProcess.setPort(port);
}
} catch (NumberFormatException e) {
LOG.warn("Protocol/Port information [{}] for component {} has illegal format [{}]." + "skip assigning...", value, component.getName(), parsePattern);
// reset protocol information
for (ComponentProcess componentProcess : componentProcesses) {
componentProcess.setPort(null);
}
}
}
} else {
LOG.warn("Protocol/Port information [{}] for component {} doesn't seem to known format [{}]. " + "skipping assignment...", value, component.getName(), parsePattern);
}
}
} else {
LOG.warn("Protocol/Port related configuration ({}) is not set", componentPropertyPattern.getConnectionConfName());
}
} catch (IllegalArgumentException e) {
// don't know port related configuration
}
}
use of com.hortonworks.streamline.streams.cluster.catalog.ComponentProcess 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.streams.cluster.catalog.ComponentProcess 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);
}
Aggregations