Search in sources :

Example 6 with IndexingWriterConfiguration

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);
}
Also used : JSONObject(org.json.simple.JSONObject) IndexingWriterConfiguration(org.apache.metron.common.configuration.writer.IndexingWriterConfiguration) WriterConfiguration(org.apache.metron.common.configuration.writer.WriterConfiguration) IndexingWriterConfiguration(org.apache.metron.common.configuration.writer.IndexingWriterConfiguration) JSONObject(org.json.simple.JSONObject) IndexingConfigurations(org.apache.metron.common.configuration.IndexingConfigurations) Test(org.junit.Test)

Example 7 with IndexingWriterConfiguration

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);
    }
}
Also used : IndexingWriterConfiguration(org.apache.metron.common.configuration.writer.IndexingWriterConfiguration) WriterConfiguration(org.apache.metron.common.configuration.writer.WriterConfiguration) IndexingWriterConfiguration(org.apache.metron.common.configuration.writer.IndexingWriterConfiguration) IndexingConfigurations(org.apache.metron.common.configuration.IndexingConfigurations) Test(org.junit.Test)

Example 8 with IndexingWriterConfiguration

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);
}
Also used : JSONObject(org.json.simple.JSONObject) IndexingWriterConfiguration(org.apache.metron.common.configuration.writer.IndexingWriterConfiguration) WriterConfiguration(org.apache.metron.common.configuration.writer.WriterConfiguration) IndexingWriterConfiguration(org.apache.metron.common.configuration.writer.IndexingWriterConfiguration) IndexingConfigurations(org.apache.metron.common.configuration.IndexingConfigurations) Test(org.junit.Test)

Example 9 with IndexingWriterConfiguration

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);
}
Also used : JSONObject(org.json.simple.JSONObject) IndexingWriterConfiguration(org.apache.metron.common.configuration.writer.IndexingWriterConfiguration) WriterConfiguration(org.apache.metron.common.configuration.writer.WriterConfiguration) IndexingWriterConfiguration(org.apache.metron.common.configuration.writer.IndexingWriterConfiguration) JSONObject(org.json.simple.JSONObject) IndexingConfigurations(org.apache.metron.common.configuration.IndexingConfigurations) Test(org.junit.Test)

Example 10 with IndexingWriterConfiguration

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);
}
Also used : JSONObject(org.json.simple.JSONObject) IndexingWriterConfiguration(org.apache.metron.common.configuration.writer.IndexingWriterConfiguration) WriterConfiguration(org.apache.metron.common.configuration.writer.WriterConfiguration) IndexingWriterConfiguration(org.apache.metron.common.configuration.writer.IndexingWriterConfiguration) JSONObject(org.json.simple.JSONObject) IndexingConfigurations(org.apache.metron.common.configuration.IndexingConfigurations) Test(org.junit.Test)

Aggregations

IndexingWriterConfiguration (org.apache.metron.common.configuration.writer.IndexingWriterConfiguration)22 IndexingConfigurations (org.apache.metron.common.configuration.IndexingConfigurations)19 Test (org.junit.Test)18 WriterConfiguration (org.apache.metron.common.configuration.writer.WriterConfiguration)16 JSONObject (org.json.simple.JSONObject)14 WriterToBulkWriter (org.apache.metron.writer.WriterToBulkWriter)3 ArrayList (java.util.ArrayList)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 HashMap (java.util.HashMap)1 DefaultFileNameFormat (org.apache.storm.hdfs.bolt.format.DefaultFileNameFormat)1 FileNameFormat (org.apache.storm.hdfs.bolt.format.FileNameFormat)1 Tuple (org.apache.storm.tuple.Tuple)1