use of com.xrtb.commands.PixelClickConvertLog in project XRTB by benmfaul.
the class TestSpark method transmit.
public void transmit() throws Exception {
String crid = "111";
WinObject obj = new WinObject();
obj.cost = ".001";
obj.price = ".001";
obj.adId = "123";
obj.cridId = crid;
BidResponse br = new BidResponse();
br.adid = "123";
br.crid = crid;
br.cost = .001;
PixelClickConvertLog cmd = new PixelClickConvertLog();
cmd.ad_id = "123";
cmd.creative_id = crid;
ZPublisher wins = new ZPublisher("tcp://*:5572", "wins");
ZPublisher bids = new ZPublisher("tcp://*:5571", "bids");
ZPublisher clicks = new ZPublisher("tcp://*:5573", "clicks");
for (int j = 0; j < 1000; j++) {
wins.add(obj);
bids.add(br);
cmd.type = PixelClickConvertLog.CLICK;
clicks.add(cmd);
cmd.type = PixelClickConvertLog.PIXEL;
clicks.add(cmd);
}
}
use of com.xrtb.commands.PixelClickConvertLog 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));
}
}
Aggregations