Search in sources :

Example 1 with PixelLog

use of com.xrtb.commands.PixelLog in project XRTB by benmfaul.

the class Spark method processClickAndPixel.

/**
	 * Process clicks and pixels.
	 * 
	 * @param ev
	 *            PixelClickConvertLog. The object to be counted.
	 * @throws ExceptioncampName
	 *             on atomic access errors.
	 */
public void processClickAndPixel(Object x) throws Exception {
    PixelClickConvertLog ev;
    if (x instanceof PixelLog) {
        ev = (PixelClickConvertLog) x;
        ev = new PixelLog(ev.payload, ev.instance);
    } else {
        ev = (PixelClickConvertLog) x;
        ev = new ClickLog(ev.payload, ev.instance);
    }
    Map m = new HashMap();
    m.put("time", ev.time);
    String type = null;
    AcctCreative creat = getRecord(ev.ad_id, ev.creative_id);
    if (creat == null) {
        creat = new AcctCreative("unknown", ev.ad_id, ev.creative_id);
        creatives.add(creat);
        accountHash.put(ev.ad_id + ":" + ev.creative_id, creat);
    }
    m.put("campaign", creat.campaignName);
    m.put("creative", creat.name);
    synchronized (creat) {
        if (ev.type == PixelClickConvertLog.CLICK) {
            creat.clicks.incrementAndGet();
            clicks.incrementAndGet();
            Integer y = creat.slices.clicks.get(ev.exchange);
            if (y == null)
                y = new Integer(0);
            creat.slices.clicks.put(ev.exchange, y);
        } else if (ev.type == PixelClickConvertLog.PIXEL) {
            ;
            creat.pixels.incrementAndGet();
            pixels.incrementAndGet();
            Integer y = creat.slices.pixels.get(ev.exchange);
            if (y == null)
                y = new Integer(0);
            creat.slices.pixels.put(ev.exchange, y);
        } else {
        }
    }
    if (ev.type == PixelClickConvertLog.CLICK && CLICKFILE != null) {
        String content = mapper.writer().writeValueAsString(ev);
        logger.offer(new LogObject(CLICKFILE, content));
    }
    if (ev.type == PixelClickConvertLog.PIXEL && PIXELFILE != null) {
        String content = mapper.writer().writeValueAsString(ev);
        logger.offer(new LogObject(PIXELFILE, content));
    }
}
Also used : HashMap(java.util.HashMap) PixelClickConvertLog(com.xrtb.commands.PixelClickConvertLog) PixelLog(com.xrtb.commands.PixelLog) ClickLog(com.xrtb.commands.ClickLog) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

ClickLog (com.xrtb.commands.ClickLog)1 PixelClickConvertLog (com.xrtb.commands.PixelClickConvertLog)1 PixelLog (com.xrtb.commands.PixelLog)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1