use of org.apache.metron.common.zookeeper.ConfigurationsCache in project metron by apache.
the class SolrUpdateDaoTest method setupBefore.
@BeforeAll
public static void setupBefore() {
accessConfig.setGlobalConfigSupplier(() -> new HashMap<String, Object>() {
{
put(SOLR_ZOOKEEPER, "zookeeper:2181");
}
});
IndexingConfigurations indexingConfigs = mock(IndexingConfigurations.class);
ConfigurationsCache cache = mock(ConfigurationsCache.class);
Map<String, Object> broIndexingConfig = new HashMap<String, Object>() {
{
put("solr", new HashMap<String, Object>() {
{
}
});
}
};
when(indexingConfigs.getSensorIndexingConfig("bro")).thenReturn(broIndexingConfig);
when(cache.get(IndexingConfigurations.class)).thenReturn(indexingConfigs);
accessConfig.setIndexSupplier(IndexingCacheUtil.getIndexLookupFunction(cache, "solr"));
}
use of org.apache.metron.common.zookeeper.ConfigurationsCache in project metron by apache.
the class IndexingCacheUtilTest method getIndexLookupFunctionShouldDefaultToSensorType.
@Test
public void getIndexLookupFunctionShouldDefaultToSensorType() {
IndexingConfigurations indexingConfigs = mock(IndexingConfigurations.class);
ConfigurationsCache cache = mock(ConfigurationsCache.class);
Map<String, Object> broIndexingConfig = new HashMap<String, Object>() {
{
put("writer", new HashMap<String, Object>() {
{
put("index", "bro_index");
}
});
}
};
when(indexingConfigs.getSensorIndexingConfig("bro")).thenReturn(broIndexingConfig);
when(cache.get(IndexingConfigurations.class)).thenReturn(indexingConfigs);
assertEquals("snort", IndexingCacheUtil.getIndexLookupFunction(cache, "writer").apply("snort"), "Should default to sensor type on missing sensor config");
assertEquals("bro", IndexingCacheUtil.getIndexLookupFunction(cache, "someWriter").apply("bro"), "Should default to sensor type on missing writer config");
}
use of org.apache.metron.common.zookeeper.ConfigurationsCache in project metron by apache.
the class IndexingCacheUtilTest method getIndexLookupFunctionShouldReturnConfiguredIndex.
@Test
public void getIndexLookupFunctionShouldReturnConfiguredIndex() {
IndexingConfigurations indexingConfigs = mock(IndexingConfigurations.class);
ConfigurationsCache cache = mock(ConfigurationsCache.class);
Map<String, Object> broIndexingConfig = new HashMap<String, Object>() {
{
put("writer", new HashMap<String, Object>() {
{
put("index", "bro_index");
}
});
}
};
when(indexingConfigs.getSensorIndexingConfig("bro")).thenReturn(broIndexingConfig);
when(cache.get(IndexingConfigurations.class)).thenReturn(indexingConfigs);
assertEquals("bro_index", IndexingCacheUtil.getIndexLookupFunction(cache, "writer").apply("bro"));
}
Aggregations