Hey Pradeep, Recently we have made a fix where if the operator implements AutoMetric.Aggregator then it will be used as its aggregator. Please look at the OperatorAndAggregator class here: https://github.com/apache/incubator-apex-core/blob/devel-3/engine/src/test/java/com/datatorrent/stram/engine/AutoMetricTest.java
This is new change and will be in next release of Apex core. Thanks, Chandni On Thu, Jan 7, 2016 at 11:19 PM, Pradeep A. Dalvi <[email protected]> wrote: > Thanks Gaurav. > > From my understanding, currently we can have default Aggregator for > AutoMetrics. If we want to specify Custom Aggregator like > PercentageAggregator, it can be done only from Application. Please correct > me if I'm wrong. > In either case, if you could point me to some examples/sample it would be > really helpful. > > Thanks in advance, > Pradeep A. Dalvi > > On Thu, Jan 7, 2016 at 10:37 PM, Gaurav Gupta <[email protected]> > wrote: > >> Pradeep, >> >> Operator can implement Aggregator API and if no external Aggregator is >> set, it will be used to do the aggregations >> >> Thanks >> - Gaurav >> >> > On Jan 7, 2016, at 5:01 AM, Pradeep Dalvi < >> [email protected]> wrote: >> > >> > Thanks Chandni. >> > >> > From my understanding, Aggregators can be set from populateDAG of the >> > StreamingApplication. >> > I was wondering if there is a way to make AutoMetrics available from >> > Operator itself? Or at the module level? >> > >> > Thanks in advance, >> > Pradeep A. Dalvi >> > >> > On Tue, Jan 5, 2016 at 11:28 AM, Chandni Singh <[email protected] >> > >> > wrote: >> > >> >> Hi Pradeep, >> >> >> >> Adding dev@apex. >> >> >> >> In an operator defines these Metrics >> >> 1. total tuples >> >> 2. special tuples >> >> >> >> The percentage metric aggregator can be written like this >> >> >> >> public class PercentageAggregator implements AutoMetric.Aggregator >> >> { >> >> >> >> @Override >> >> public Map<String, Object> aggregate(long l, >> Collection<AutoMetric.PhysicalMetricsContext> collection) >> >> { >> >> long total = 0; >> >> long special = 0; >> >> for (AutoMetric.PhysicalMetricsContext context : collection) { >> >> total += (Long)context.getMetrics().get("total"); >> >> special += (Long)context.getMetrics().get("special"); >> >> } >> >> >> >> Map<String, Object> result = Maps.newHashMap(); >> >> result.put("specials_percent", (special / (total * 1.0)) * 100); >> >> return result; >> >> } >> >> } >> >> >> >> Chandni >> >> >> >> >> >> >> >> >> >> On Wed, Dec 30, 2015 at 9:16 PM, Pradeep Dalvi < >> >> [email protected]> wrote: >> >> >> >>> Has anyone used or have an idea about percentage aggregator of >> >>> autometrics? >> >>> Any pointer would be useful. >> >>> >> >>> Thanks, >> >>> Pradeep A. Dalvi >> >>> >> >>> >> >>> -- >> >>> Pradeep A. Dalvi >> >>> >> >>> Software Engineer >> >>> DataTorrent (India) >> >>> >> >>> >> >> >> > >> > >> > -- >> > Pradeep A. Dalvi >> > >> > Software Engineer >> > DataTorrent (India) >> >> >
