use of com.hortonworks.streamline.streams.notification.Notification in project streamline by hortonworks.
the class NotificationBolt method process.
@Override
protected void process(Tuple tuple) {
Notification notification = new StreamlineEventAdapter((StreamlineEvent) tuple.getValueByField(StreamlineEvent.STREAMLINE_EVENT));
notificationContext.track(notification.getId(), tuple);
// send to notifier
notificationService.notify(notificationSink.getNotifierName(), notification);
}
use of com.hortonworks.streamline.streams.notification.Notification in project streamline by hortonworks.
the class NotificationsResource method updateNotificationStatus.
@PUT
@Path("/notifications/{id}/{status}")
@Timed
public Response updateNotificationStatus(@PathParam("id") String notificationId, @PathParam("status") Notification.Status status, @Context SecurityContext securityContext) {
SecurityUtil.checkRole(authorizer, securityContext, Roles.ROLE_NOTIFICATION_USER);
Notification updateNotification = notificationService.updateNotificationStatus(notificationId, status);
return WSUtils.respondEntity(updateNotification, OK);
}
use of com.hortonworks.streamline.streams.notification.Notification in project streamline by hortonworks.
the class NotificationsResource method getNotificationById.
@GET
@Path("/notifications/{id}")
@Timed
public Response getNotificationById(@PathParam("id") String id, @Context SecurityContext securityContext) {
// We do a role based authorization since the notifications does not have object permissions right now.
// It can be enhanced later if required.
SecurityUtil.checkRole(authorizer, securityContext, Roles.ROLE_NOTIFICATION_USER);
Notification result = notificationService.getNotification(id);
if (result != null) {
return WSUtils.respondEntity(result, OK);
}
throw EntityNotFoundException.byId(id);
}
use of com.hortonworks.streamline.streams.notification.Notification in project streamline by hortonworks.
the class NotificationStatusIndexMapper method status.
@Override
public List<TableMutation> status(Notification notification, Notification.Status status) {
// insert a new row
Notification updated = new NotificationImpl.Builder(notification).status(status).build();
List<TableMutation> tableMutations = tableMutations(updated);
// delete existing
for (byte[] rowKey : getRowKeys(notification)) {
Delete delete = new Delete(rowKey);
tableMutations.add(new TableMutationImpl(getTableName(), delete));
}
LOG.trace("TableMutations for status update {}", tableMutations);
return tableMutations;
}
use of com.hortonworks.streamline.streams.notification.Notification in project streamline by hortonworks.
the class AbstractNotificationMapper method entity.
@Override
public Notification entity(Result result) {
String id = getNotificationId(result);
Map<String, Object> fieldsAndValues = new HashMap<>();
for (Map.Entry<byte[], byte[]> entry : result.getFamilyMap(CF_FIELDS).entrySet()) {
fieldsAndValues.put(Bytes.toString(entry.getKey()), serializer.deserialize(entry.getValue()));
}
List<String> eventIds = new ArrayList<>();
for (Map.Entry<byte[], byte[]> entry : result.getFamilyMap(CF_EVENTIDS).entrySet()) {
eventIds.add(Bytes.toString(entry.getKey()));
}
List<String> dataSourceIds = new ArrayList<>();
for (Map.Entry<byte[], byte[]> entry : result.getFamilyMap(CF_DATASOURCE_IDS).entrySet()) {
dataSourceIds.add(Bytes.toString(entry.getKey()));
}
String ruleId = Bytes.toString(result.getFamilyMap(CF_RULEID).firstEntry().getKey());
Notification.Status status = Notification.Status.valueOf(Bytes.toString(result.getValue(CF_STATUS, CQ_STATUS)));
String notifierName = Bytes.toString(result.getFamilyMap(CF_NOTIFIER_NAME).firstEntry().getKey());
long ts = Long.parseLong(Bytes.toString(result.getFamilyMap(CF_TIMESTAMP).firstEntry().getKey()));
Notification notification = new NotificationImpl.Builder(fieldsAndValues).id(id).eventIds(eventIds).dataSourceIds(dataSourceIds).ruleId(ruleId).notifierName(notifierName).timestamp(ts).status(status).build();
LOG.trace("Created Notification {} from Result {}", notification, result);
return notification;
}
Aggregations