use of org.apache.metron.indexing.dao.metaalert.MetaAlertDao in project metron by apache.
the class IndexConfig method indexDao.
@Bean
public IndexDao indexDao() {
try {
String hbaseProviderImpl = environment.getProperty(MetronRestConstants.INDEX_HBASE_TABLE_PROVIDER_IMPL, String.class, null);
String indexDaoImpl = environment.getProperty(MetronRestConstants.INDEX_DAO_IMPL, String.class, null);
int searchMaxResults = environment.getProperty(MetronRestConstants.SEARCH_MAX_RESULTS, Integer.class, 1000);
int searchMaxGroups = environment.getProperty(MetronRestConstants.SEARCH_MAX_GROUPS, Integer.class, 1000);
String metaDaoImpl = environment.getProperty(MetronRestConstants.META_DAO_IMPL, String.class, null);
String metaDaoSort = environment.getProperty(MetronRestConstants.META_DAO_SORT, String.class, null);
AccessConfig config = new AccessConfig();
config.setMaxSearchResults(searchMaxResults);
config.setMaxSearchGroups(searchMaxGroups);
config.setGlobalConfigSupplier(() -> {
try {
return globalConfigService.get();
} catch (RestException e) {
throw new IllegalStateException("Unable to retrieve the global config.", e);
}
});
config.setIndexSupplier(IndexingCacheUtil.getIndexLookupFunction(cache, environment.getProperty(INDEX_WRITER_NAME)));
config.setTableProvider(TableProvider.create(hbaseProviderImpl, () -> new HTableProvider()));
config.setKerberosEnabled(environment.getProperty(MetronRestConstants.KERBEROS_ENABLED_SPRING_PROPERTY, Boolean.class, false));
if (indexDaoImpl == null) {
throw new IllegalStateException("You must provide an index DAO implementation via the " + INDEX_DAO_IMPL + " config");
}
IndexDao indexDao = IndexDaoFactory.combine(IndexDaoFactory.create(indexDaoImpl, config));
if (indexDao == null) {
throw new IllegalStateException("IndexDao is unable to be created.");
}
if (metaDaoImpl == null) {
// We're not using meta alerts.
return indexDao;
}
// Create the meta alert dao and wrap it around the index dao.
MetaAlertDao ret = (MetaAlertDao) IndexDaoFactory.create(metaDaoImpl, config).get(0);
ret.init(indexDao, Optional.ofNullable(metaDaoSort));
return ret;
} catch (RuntimeException re) {
throw re;
} catch (Exception e) {
throw new IllegalStateException("Unable to create index DAO: " + e.getMessage(), e);
}
}
Aggregations