Search in sources :

Example 26 with Notification

use of com.hortonworks.streamline.streams.notification.Notification in project streamline by hortonworks.

the class NotificationServiceImpl method findNotifications.

@Override
public List<Notification> findNotifications(List<QueryParam> queryParams) {
    LOG.debug("findNotifications with queryParams {}", queryParams);
    CriteriaImpl<Notification> criteria = new CriteriaImpl<>(Notification.class);
    for (QueryParam qp : queryParams) {
        if (qp.name.equalsIgnoreCase(QUERY_PARAM_NUM_ROWS)) {
            criteria.setNumRows(Integer.parseInt(qp.value));
        } else if (qp.name.equals(QUERY_PARAM_START_TS)) {
            criteria.setStartTs(Long.parseLong(qp.value));
        } else if (qp.name.equals((QUERY_PARAM_END_TS))) {
            criteria.setEndTs(Long.parseLong(qp.value));
        } else if (qp.name.equals((QUERY_PARAM_DESC))) {
            criteria.setDescending(true);
        } else {
            criteria.addFieldRestriction(qp.name, qp.value);
        }
    }
    LOG.debug("Finding entities from notification store with criteria {}", criteria);
    return notificationStore.map(s -> s.findEntities(criteria)).orElse(Collections.emptyList());
}
Also used : Logger(org.slf4j.Logger) ProxyUtil(com.hortonworks.streamline.common.util.ProxyUtil) QueryParam(com.hortonworks.registries.common.QueryParam) LoggerFactory(org.slf4j.LoggerFactory) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Notification(com.hortonworks.streamline.streams.notification.Notification) HBaseNotificationStore(com.hortonworks.streamline.streams.notification.store.hbase.HBaseNotificationStore) CriteriaImpl(com.hortonworks.streamline.streams.notification.store.CriteriaImpl) List(java.util.List) Future(java.util.concurrent.Future) StreamlineEvent(com.hortonworks.streamline.streams.StreamlineEvent) Map(java.util.Map) Notifier(com.hortonworks.streamline.streams.notification.Notifier) Optional(java.util.Optional) Collections(java.util.Collections) NotificationStore(com.hortonworks.streamline.streams.notification.store.NotificationStore) NotificationContext(com.hortonworks.streamline.streams.notification.NotificationContext) CriteriaImpl(com.hortonworks.streamline.streams.notification.store.CriteriaImpl) QueryParam(com.hortonworks.registries.common.QueryParam) Notification(com.hortonworks.streamline.streams.notification.Notification)

Aggregations

Notification (com.hortonworks.streamline.streams.notification.Notification)26 Test (org.junit.Test)18 Expectations (mockit.Expectations)9 HashMap (java.util.HashMap)7 Verifications (mockit.Verifications)6 HBaseIntegrationTest (com.hortonworks.streamline.common.test.HBaseIntegrationTest)5 Notifier (com.hortonworks.streamline.streams.notification.Notifier)5 CriteriaImpl (com.hortonworks.streamline.streams.notification.store.CriteriaImpl)5 ArrayList (java.util.ArrayList)5 StreamlineEvent (com.hortonworks.streamline.streams.StreamlineEvent)4 ConsoleNotifier (com.hortonworks.streamline.streams.notifiers.ConsoleNotifier)4 StreamlineEventAdapter (com.hortonworks.streamline.streams.runtime.notification.StreamlineEventAdapter)4 Map (java.util.Map)3 TreeMap (java.util.TreeMap)3 MockUp (mockit.MockUp)3 Bytes (org.apache.hadoop.hbase.util.Bytes)3 Timed (com.codahale.metrics.annotation.Timed)2 QueryParam (com.hortonworks.registries.common.QueryParam)2 NotificationSink (com.hortonworks.streamline.streams.layout.component.impl.NotificationSink)2 NotificationContext (com.hortonworks.streamline.streams.notification.NotificationContext)2