use of org.apache.metron.common.configuration.writer.IndexingWriterConfiguration in project metron by apache.
the class HdfsWriterTest method testGetHdfsPathEmptyString.
@Test
@SuppressWarnings("unchecked")
public void testGetHdfsPathEmptyString() {
WriterConfiguration config = new IndexingWriterConfiguration(WRITER_NAME, new IndexingConfigurations());
HdfsWriter writer = new HdfsWriter().withFileNameFormat(testFormat);
writer.init(new HashMap<String, String>(), createTopologyContext(), config);
JSONObject message = new JSONObject();
Object result = writer.getHdfsPathExtension(SENSOR_NAME, "", message);
writer.close();
Assert.assertEquals(SENSOR_NAME, result);
}
use of org.apache.metron.common.configuration.writer.IndexingWriterConfiguration in project metron by apache.
the class HdfsWriterTest method testGetSourceHandlerOpenFilesOverMax.
@Test(expected = IllegalStateException.class)
public void testGetSourceHandlerOpenFilesOverMax() throws IOException {
int maxFiles = 2;
IndexingConfigurations indexingConfig = new IndexingConfigurations();
WriterConfiguration config = new IndexingWriterConfiguration(WRITER_NAME, indexingConfig);
HdfsWriter writer = new HdfsWriter().withFileNameFormat(testFormat).withMaxOpenFiles(maxFiles);
writer.init(new HashMap<String, String>(), createTopologyContext(), config);
for (int i = 0; i < maxFiles + 1; i++) {
writer.getSourceHandler(SENSOR_NAME, Integer.toString(i), null);
}
}
use of org.apache.metron.common.configuration.writer.IndexingWriterConfiguration in project metron by apache.
the class HdfsWriterTest method testGetHdfsPathNonString.
@Test(expected = IllegalArgumentException.class)
public void testGetHdfsPathNonString() {
WriterConfiguration config = new IndexingWriterConfiguration(WRITER_NAME, new IndexingConfigurations());
HdfsWriter writer = new HdfsWriter().withFileNameFormat(testFormat);
writer.init(new HashMap<String, String>(), createTopologyContext(), config);
JSONObject message = new JSONObject();
writer.getHdfsPathExtension(SENSOR_NAME, "{'key':'value'}", message);
}
use of org.apache.metron.common.configuration.writer.IndexingWriterConfiguration in project metron by apache.
the class HdfsWriterTest method testGetHdfsPathFormatConstant.
@Test
@SuppressWarnings("unchecked")
public void testGetHdfsPathFormatConstant() {
WriterConfiguration config = new IndexingWriterConfiguration(WRITER_NAME, new IndexingConfigurations());
HdfsWriter writer = new HdfsWriter().withFileNameFormat(testFormat);
writer.init(new HashMap<String, String>(), createTopologyContext(), config);
JSONObject message = new JSONObject();
Object result = writer.getHdfsPathExtension(SENSOR_NAME, "FORMAT('/test/folder/')", message);
writer.close();
Assert.assertEquals("/test/folder/", result);
}
use of org.apache.metron.common.configuration.writer.IndexingWriterConfiguration in project metron by apache.
the class HdfsWriterTest method testGetHdfsPathConstant.
@Test
@SuppressWarnings("unchecked")
public void testGetHdfsPathConstant() {
WriterConfiguration config = new IndexingWriterConfiguration(WRITER_NAME, new IndexingConfigurations());
HdfsWriter writer = new HdfsWriter().withFileNameFormat(testFormat);
writer.init(new HashMap<String, String>(), createTopologyContext(), config);
JSONObject message = new JSONObject();
Object result = writer.getHdfsPathExtension(SENSOR_NAME, "'new'", message);
writer.close();
Assert.assertEquals("new", result);
}
Aggregations