use of org.apache.metron.integration.UnableToStartException in project metron by apache.
the class ZKServerComponent method start.
@Override
public void start() throws UnableToStartException {
try {
testZkServer = new TestingServer(true);
zookeeperUrl = testZkServer.getConnectString();
if (postStartCallback.isPresent()) {
postStartCallback.get().accept(this);
}
} catch (Exception e) {
throw new UnableToStartException("Unable to start TestingServer", e);
}
}
use of org.apache.metron.integration.UnableToStartException in project metron by apache.
the class SolrComponent method start.
@Override
public void start() throws UnableToStartException {
try {
File baseDir = Files.createTempDirectory("solrcomponent").toFile();
baseDir.deleteOnExit();
miniSolrCloudCluster = new MiniSolrCloudCluster(1, baseDir.toPath(), JettyConfig.builder().setPort(port).build());
for (String name : collections.keySet()) {
String configPath = collections.get(name);
miniSolrCloudCluster.uploadConfigSet(new File(configPath).toPath(), name);
CollectionAdminRequest.createCollection(name, 1, 1).process(miniSolrCloudCluster.getSolrClient());
}
if (postStartCallback != null) {
postStartCallback.apply(this);
}
} catch (Exception e) {
throw new UnableToStartException(e.getMessage(), e);
}
}
use of org.apache.metron.integration.UnableToStartException in project metron by apache.
the class ElasticSearchComponent method start.
@Override
public void start() throws UnableToStartException {
File logDir = new File(indexDir, "/logs");
File dataDir = new File(indexDir, "/data");
try {
cleanDir(logDir);
cleanDir(dataDir);
} catch (IOException e) {
throw new UnableToStartException("Unable to clean log or data directories", e);
}
Settings.Builder settingsBuilder = Settings.builder().put("cluster.name", "metron").put("path.logs", logDir.getAbsolutePath()).put("path.data", dataDir.getAbsolutePath()).put("path.home", indexDir.getAbsoluteFile()).put("transport.type", "netty4").put("http.enabled", "true");
if (extraElasticSearchSettings != null) {
settingsBuilder = settingsBuilder.put(extraElasticSearchSettings);
}
node = new TestNode(settingsBuilder.build(), asList(Netty4Plugin.class));
client = node.client();
try {
node.start();
} catch (NodeValidationException e) {
throw new UnableToStartException("Error starting ES node.", e);
}
waitForCluster(client, ClusterHealthStatus.YELLOW, STARTUP_TIMEOUT);
for (Mapping m : Optional.ofNullable(mappings).orElse(new ArrayList<>())) {
client.admin().indices().prepareCreate(m.index).addMapping(m.docType, m.mapping).get();
}
indexDao = new ElasticsearchDao().withRefreshPolicy(WriteRequest.RefreshPolicy.WAIT_UNTIL);
indexDao.init(accessConfig);
}
use of org.apache.metron.integration.UnableToStartException in project metron by apache.
the class TestConfig method componentRunner.
@Bean(destroyMethod = "stop")
public ComponentRunner componentRunner(ZKServerComponent zkServerComponent, KafkaComponent kafkaWithZKComponent) {
ComponentRunner runner = new ComponentRunner.Builder().withComponent("zk", zkServerComponent).withCustomShutdownOrder(new String[] { "search", "zk" }).build();
try {
runner.start();
File globalConfigFile = new File("src/test/resources/zookeeper/global.json");
try (BufferedReader r = new BufferedReader(new InputStreamReader(new FileInputStream(globalConfigFile), StandardCharsets.UTF_8))) {
String globalConfig = IOUtils.toString(r);
ConfigurationsUtils.writeGlobalConfigToZookeeper(globalConfig.getBytes(StandardCharsets.UTF_8), zkServerComponent.getConnectionString());
} catch (Exception e) {
throw new IllegalStateException("Unable to upload global config", e);
}
} catch (UnableToStartException e) {
e.printStackTrace();
}
return runner;
}
use of org.apache.metron.integration.UnableToStartException in project metron by apache.
the class ParserTopologyComponent method start.
@Override
public void start() throws UnableToStartException {
try {
final Map<String, Object> stormConf = new HashMap<>();
stormConf.put(Config.TOPOLOGY_DEBUG, true);
ParserTopologyBuilder.ParserTopology topologyBuilder = ParserTopologyBuilder.build(topologyProperties.getProperty(ZKServerComponent.ZOOKEEPER_PROPERTY), Optional.ofNullable(brokerUrl), sensorTypes, (x, y) -> Collections.nCopies(sensorTypes.size(), 1), (x, y) -> Collections.nCopies(sensorTypes.size(), 1), (x, y) -> 1, (x, y) -> 1, (x, y) -> 1, (x, y) -> 1, (x, y) -> Collections.nCopies(sensorTypes.size(), new HashMap<>()), (x, y) -> null, (x, y) -> outputTopic, (x, y) -> errorTopic, (x, y) -> {
Config c = new Config();
c.putAll(stormConf);
return c;
});
stormCluster = new LocalCluster();
stormCluster.submitTopology(getTopologyName(), stormConf, topologyBuilder.getBuilder().createTopology());
} catch (Exception e) {
throw new UnableToStartException("Unable to start parser topology for sensorTypes: " + sensorTypes, e);
}
}
Aggregations