use of org.apache.metron.common.configuration.IndexingConfigurations 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.IndexingConfigurations 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.IndexingConfigurations 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);
}
use of org.apache.metron.common.configuration.IndexingConfigurations in project metron by apache.
the class SensorIndexingConfigServiceImplTest method getAllIndicesWithOnlyParsers.
@Test
public void getAllIndicesWithOnlyParsers() throws RestException {
ParserConfigurations parserConfiguration = mock(ParserConfigurations.class);
when(parserConfiguration.getTypes()).thenReturn(ImmutableList.of("bro", "snort"));
IndexingConfigurations indexingConfiguration = mock(IndexingConfigurations.class);
when(indexingConfiguration.getTypes()).thenReturn(Collections.emptyList());
when(indexingConfiguration.getIndex(eq("bro"), eq("elasticsearch"))).thenReturn(null);
when(indexingConfiguration.getIndex(eq("snort"), eq("elasticsearch"))).thenReturn(null);
when(indexingConfiguration.isEnabled(eq("snort"), eq("elasticsearch"))).thenReturn(true);
when(indexingConfiguration.isEnabled(eq("bro"), eq("elasticsearch"))).thenReturn(true);
when(cache.get(eq(ParserConfigurations.class))).thenReturn(parserConfiguration);
when(cache.get(eq(IndexingConfigurations.class))).thenReturn(indexingConfiguration);
List<String> indices = new ArrayList<String>();
Iterables.addAll(indices, sensorIndexingConfigService.getAllIndices("elasticsearch"));
Assert.assertEquals(2, indices.size());
Assert.assertTrue(indices.contains("bro"));
Assert.assertTrue(indices.contains("snort"));
}
use of org.apache.metron.common.configuration.IndexingConfigurations in project metron by apache.
the class SensorIndexingConfigServiceImplTest method getAllIndicesWithOnlyIndexing.
@Test
public void getAllIndicesWithOnlyIndexing() throws RestException {
ParserConfigurations parserConfiguration = mock(ParserConfigurations.class);
when(parserConfiguration.getTypes()).thenReturn(Collections.emptyList());
IndexingConfigurations indexingConfiguration = mock(IndexingConfigurations.class);
// rename bro, include snort by default configs, and disable yaf
when(indexingConfiguration.getTypes()).thenReturn(ImmutableList.of("bro", "snort", "yaf"));
when(indexingConfiguration.getIndex(eq("bro"), eq("elasticsearch"))).thenReturn("renamed_bro");
when(indexingConfiguration.getIndex(eq("snort"), eq("elasticsearch"))).thenReturn(null);
when(indexingConfiguration.isEnabled(eq("snort"), eq("elasticsearch"))).thenReturn(true);
when(indexingConfiguration.isEnabled(eq("bro"), eq("elasticsearch"))).thenReturn(true);
when(indexingConfiguration.isEnabled(eq("yaf"), eq("elasticsearch"))).thenReturn(false);
when(cache.get(eq(ParserConfigurations.class))).thenReturn(parserConfiguration);
when(cache.get(eq(IndexingConfigurations.class))).thenReturn(indexingConfiguration);
List<String> indices = new ArrayList<String>();
Iterables.addAll(indices, sensorIndexingConfigService.getAllIndices("elasticsearch"));
Assert.assertEquals(2, indices.size());
Assert.assertTrue(indices.contains("renamed_bro"));
Assert.assertTrue(indices.contains("snort"));
}
Aggregations