use of org.apache.flume.agent.embedded.EmbeddedAgent in project cdap-ingest by caskdata.
the class CdapFlumeIT method eventProcessingWithCdapFailTest.
/**
* Test simulate CDAP fail. CDAP port is swapped in runtime to simulate work with not accessible port.
*/
@Test
public void eventProcessingWithCdapFailTest() throws Exception {
String cdapPortStrValue = String.valueOf(streamReader.getCdapPort());
EmbeddedAgent agent = new EmbeddedAgent("test-flume");
Method method = agent.getClass().getDeclaredMethod("doConfigure", Map.class);
method.setAccessible(true);
Map<String, String> propertyMap = new HashMap<String, String>();
for (final String name : properties.stringPropertyNames()) {
propertyMap.put(name, properties.getProperty(name));
}
agent.configure(propertyMap);
agent.start();
method.invoke(agent, propertyMap);
long startTime = System.currentTimeMillis();
writeEvents(agent, 0, EVENT_FAIL_START_NUMBER);
Assert.assertNotEquals(cdapPortStrValue, INVALID_PORT);
propertyMap.put("sink1.port", INVALID_PORT);
method.invoke(agent, propertyMap);
writeEvents(agent, EVENT_FAIL_START_NUMBER, FAIL_EVENT_END_NUMBER);
propertyMap.put("sink1.port", cdapPortStrValue);
method.invoke(agent, propertyMap);
writeEvents(agent, FAIL_EVENT_END_NUMBER, EVENT_NUMBER);
Thread.sleep(SLEEP_INTERVAL);
agent.stop();
checkDeliveredEvents(startTime);
}
use of org.apache.flume.agent.embedded.EmbeddedAgent in project chassis by Kixeye.
the class FlumeLoggerLoader method initialize.
@PostConstruct
public void initialize() {
multicaster.addApplicationListener(loggingListener);
ConcurrentHashMap<String, String> flumeConfig = new ConcurrentHashMap<>();
List<String> sinks = new ArrayList<>();
for (String server : servers) {
String sinkName = server.replace(":", "-").replace(".", "_");
String[] servers = server.split(":", 2);
if (servers.length == 2) {
flumeConfig.put(sinkName + ".type", "avro");
flumeConfig.put(sinkName + ".channels", "channel-" + name);
flumeConfig.put(sinkName + ".hostname", servers[0]);
flumeConfig.put(sinkName + ".port", servers[1]);
} else {
logger.error("Invalid server format [{}], should be [hostname:port]", server);
}
sinks.add(sinkName);
}
// force some properties
flumeConfig.put("channel.type", "file");
flumeConfig.put("sinks", StringUtils.collectionToDelimitedString(sinks, " "));
flumeConfig.putIfAbsent("processor.type", serversUsage);
flumeConfig.put("channel.checkpointDir", SystemPropertyUtils.resolvePlaceholders("${user.dir}/flume-data/checkpoint"));
flumeConfig.put("channel.dataDirs", SystemPropertyUtils.resolvePlaceholders("${user.dir}/flume-data/data"));
agent = new EmbeddedAgent(name);
agent.configure(flumeConfig);
agent.start();
appender = new FlumeLogAppender(agent, serviceName);
installFlumeAppender();
}
use of org.apache.flume.agent.embedded.EmbeddedAgent in project cdap-ingest by caskdata.
the class CdapFlumeIT method baseEventProcessingTest.
@Test
public void baseEventProcessingTest() throws Exception {
EmbeddedAgent agent = new EmbeddedAgent("test-flume");
Map<String, String> propertyMap = new HashMap<String, String>();
for (final String name : properties.stringPropertyNames()) {
propertyMap.put(name, properties.getProperty(name));
}
agent.configure(propertyMap);
agent.start();
long startTime = System.currentTimeMillis();
writeEvents(agent, 0, EVENT_NUMBER);
Thread.sleep(SLEEP_INTERVAL);
agent.stop();
checkDeliveredEvents(startTime);
}
Aggregations