use of org.apache.metron.indexing.dao.MultiIndexDao in project metron by apache.
the class ElasticsearchMetaAlertDao method init.
/**
* Initializes this implementation by setting the supplied IndexDao and also setting a separate ElasticsearchDao.
* This is needed for some specific Elasticsearch functions (looking up an index from a GUID for example).
* @param indexDao The DAO to wrap for our queries
* @param threatSort The summary aggregation of the child threat triage scores used
* as the overall threat triage score for the metaalert. This
* can be either max, min, average, count, median, or sum.
*/
@Override
public void init(IndexDao indexDao, Optional<String> threatSort) {
if (indexDao instanceof MultiIndexDao) {
this.indexDao = indexDao;
MultiIndexDao multiIndexDao = (MultiIndexDao) indexDao;
for (IndexDao childDao : multiIndexDao.getIndices()) {
if (childDao instanceof ElasticsearchDao) {
this.elasticsearchDao = (ElasticsearchDao) childDao;
}
}
} else if (indexDao instanceof ElasticsearchDao) {
this.indexDao = indexDao;
this.elasticsearchDao = (ElasticsearchDao) indexDao;
} else {
throw new IllegalArgumentException("Need an ElasticsearchDao when using ElasticsearchMetaAlertDao");
}
if (threatSort.isPresent()) {
this.threatSort = threatSort.get();
}
}
Aggregations