use of co.cask.cdap.common.stream.notification.StreamSizeNotification in project cdap by caskdata.
the class StreamSizeSchedulerTest method createMetricsPublisher.
@Override
protected StreamMetricsPublisher createMetricsPublisher(final StreamId streamId) {
final NotificationFeedId feed = new NotificationFeedId(streamId.getNamespace(), Constants.Notification.Stream.STREAM_FEED_CATEGORY, streamId.getStream() + "Size");
return new StreamMetricsPublisher() {
long totalSize;
@Override
public void increment(long size) throws Exception {
metricStore.add(new MetricValues(ImmutableMap.of(Constants.Metrics.Tag.NAMESPACE, streamId.getNamespace(), Constants.Metrics.Tag.STREAM, streamId.getStream()), "collect.bytes", TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()), size, MetricType.COUNTER));
totalSize += size;
notificationService.publish(feed, new StreamSizeNotification(System.currentTimeMillis(), totalSize));
}
};
}
Aggregations