Search in sources :

Example 1 with SolrDao

use of org.apache.metron.solr.dao.SolrDao in project metron by apache.

the class SolrRetrieveLatestIntegrationTest method testGetBrokenMapping.

@Test
public void testGetBrokenMapping() throws IOException {
    AccessConfig accessConfig = new AccessConfig();
    Map<String, Object> globalConfig = new HashMap<>();
    globalConfig.put(SOLR_ZOOKEEPER, solrComponent.getZookeeperUrl());
    accessConfig.setGlobalConfigSupplier(() -> globalConfig);
    // Map the sensor name to the collection name for test.
    accessConfig.setIndexSupplier(s -> null);
    dao = new SolrDao();
    dao.init(accessConfig);
    Document actual = dao.getLatest("message_1_bro", TEST_SENSOR);
    assertNull(actual);
}
Also used : HashMap(java.util.HashMap) SolrDao(org.apache.metron.solr.dao.SolrDao) AccessConfig(org.apache.metron.indexing.dao.AccessConfig) Document(org.apache.metron.indexing.dao.update.Document) Test(org.junit.jupiter.api.Test)

Example 2 with SolrDao

use of org.apache.metron.solr.dao.SolrDao in project metron by apache.

the class SolrRetrieveLatestIntegrationTest method setup.

@BeforeEach
public void setup() throws Exception {
    solrComponent.addCollection(TEST_COLLECTION, "./src/test/resources/config/test/conf");
    solrComponent.addCollection(BRO_SENSOR, "./src/main/config/schema/bro");
    AccessConfig accessConfig = new AccessConfig();
    Map<String, Object> globalConfig = new HashMap<>();
    globalConfig.put(SOLR_ZOOKEEPER, solrComponent.getZookeeperUrl());
    accessConfig.setGlobalConfigSupplier(() -> globalConfig);
    // Map the sensor name to the collection name for test.
    accessConfig.setIndexSupplier(s -> s.equals(TEST_SENSOR) ? TEST_COLLECTION : s);
    dao = new SolrDao();
    dao.init(accessConfig);
    addData(BRO_SENSOR, BRO_SENSOR, expectedTimestamp);
    addData(TEST_COLLECTION, TEST_SENSOR, expectedTimestamp);
}
Also used : HashMap(java.util.HashMap) SolrDao(org.apache.metron.solr.dao.SolrDao) AccessConfig(org.apache.metron.indexing.dao.AccessConfig) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with SolrDao

use of org.apache.metron.solr.dao.SolrDao in project metron by apache.

the class SolrUpdateIntegrationTest method setup.

@BeforeEach
public void setup() throws Exception {
    solrComponent.addCollection(SENSOR_NAME, "./src/test/resources/config/test/conf");
    solrComponent.addCollection("error", "./src/main/config/schema/error");
    Map<String, Object> globalConfig = createGlobalConfig();
    globalConfig.put(HBaseDao.HBASE_TABLE, TABLE_NAME);
    globalConfig.put(HBaseDao.HBASE_CF, CF);
    CuratorFramework client = ConfigurationsUtils.getClient(solrComponent.getZookeeperUrl());
    client.start();
    ZKConfigurationsCache cache = new ZKConfigurationsCache(client);
    cache.start();
    AccessConfig accessConfig = new AccessConfig();
    accessConfig.setGlobalConfigSupplier(() -> globalConfig);
    accessConfig.setIndexSupplier(s -> s);
    accessConfig.setIndexSupplier(IndexingCacheUtil.getIndexLookupFunction(cache, "solr"));
    SolrDao dao = new SolrDao();
    dao.init(accessConfig);
    setDao(dao);
}
Also used : CuratorFramework(org.apache.curator.framework.CuratorFramework) SolrDao(org.apache.metron.solr.dao.SolrDao) ZKConfigurationsCache(org.apache.metron.common.zookeeper.ZKConfigurationsCache) AccessConfig(org.apache.metron.indexing.dao.AccessConfig)

Example 4 with SolrDao

use of org.apache.metron.solr.dao.SolrDao in project metron by apache.

the class SolrSearchIntegrationTest method createDao.

protected static IndexDao createDao() {
    AccessConfig config = new AccessConfig();
    config.setMaxSearchResults(100);
    config.setMaxSearchGroups(100);
    config.setGlobalConfigSupplier(() -> new HashMap<String, Object>() {

        {
            put(SOLR_ZOOKEEPER, solrComponent.getZookeeperUrl());
        }
    });
    config.setIndexSupplier(sensorType -> sensorType);
    IndexDao dao = new SolrDao();
    dao.init(config);
    return dao;
}
Also used : SolrDao(org.apache.metron.solr.dao.SolrDao) AccessConfig(org.apache.metron.indexing.dao.AccessConfig) IndexDao(org.apache.metron.indexing.dao.IndexDao)

Aggregations

AccessConfig (org.apache.metron.indexing.dao.AccessConfig)4 SolrDao (org.apache.metron.solr.dao.SolrDao)4 HashMap (java.util.HashMap)2 CuratorFramework (org.apache.curator.framework.CuratorFramework)1 ZKConfigurationsCache (org.apache.metron.common.zookeeper.ZKConfigurationsCache)1 IndexDao (org.apache.metron.indexing.dao.IndexDao)1 Document (org.apache.metron.indexing.dao.update.Document)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 Test (org.junit.jupiter.api.Test)1