@@ -0,0 +1,2244 @@
+package com.rackspacecloud.blueflood.eventemitter;%0A%0Aimport com.github.nkzawa.emitter.Emitter;%0Aimport com.rackspacecloud.blueflood.types.BasicRollup;%0Aimport com.rackspacecloud.blueflood.types.Rollup;%0Aimport com.rackspacecloud.blueflood.types.Locator;%0Aimport org.codehaus.jackson.node.ObjectNode;%0Aimport org.codehaus.jackson.node.JsonNodeFactory;%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0Apublic class RollupEventEmitter %7B%0A%0A    private static Emitter instance = new Emitter();%0A    private static final Logger log = LoggerFactory.getLogger(RollupEventEmitter.class);%0A%0A%0A    public static Emitter getEmitterInstance() %7B%0A        return instance;%0A    %7D%0A%0A%0A    //TODO: Generalize this later%0A    public static void emitAsJSON (String event, Locator loc, Rollup rollup, String unit) %7B%0A      BasicRollup roll;%0A      if(rollup instanceof BasicRollup) %7B%0A        roll = (BasicRollup) rollup;%0A      %7D else %7B%0A        log.error(%22Expected basic rollup but received %22+rollup);%0A        return;%0A      %7D%0A      //Main container node%0A      ObjectNode rootNode = JsonNodeFactory.instance.objectNode();%0A      //Rollup node%0A      ObjectNode rollupNode = JsonNodeFactory.instance.objectNode();%0A      rollupNode.put(%22maxValue%22, roll.getMaxValue().toDouble());%0A      rollupNode.put(%22minValue%22, roll.getMinValue().toDouble());%0A      rollupNode.put(%22average%22, roll.getAverage().toDouble());%0A      rollupNode.put(%22variance%22, roll.getVariance().toDouble());%0A      rollupNode.put(%22count%22, roll.getCount());%0A      //Metadata Node%0A      ObjectNode metaNode = JsonNodeFactory.instance.objectNode();%0A      //Units Node%0A      ObjectNode unitsNode = JsonNodeFactory.instance.objectNode();%0A      unitsNode.put(%22name%22, unit);%0A      unitsNode.put(%22type%22, %22numeric%22);%0A      //Add units node to metadata node%0A      metaNode.put(%22units%22,unitsNode);%0A      //Fill up the root node%0A      try %7B%0A        rootNode.put(%22locator%22, loc.getTenantId() + %22.%22 + loc.getMetricName());%0A        rootNode.put(%22rollup%22, rollupNode);%0A        rootNode.put(%22metadata%22, metaNode);%0A      %7D catch (Exception e) %7B%0A        log.error(%22Error encountered while serializing rollup%22);%0A        return;%0A      %7D%0A      //Emit an stringified JSON object%0A      instance.emit(event, rootNode.toString());%0A    %7D%0A%0A%7D%0A

Add RollupEventEmitter