Search in sources :

Example 1 with TimedEvent

use of org.bedework.sysevents.events.TimedEvent in project bw-calendar-engine by Bedework.

the class DataValues method update.

/**
 * @param ev
 */
public void update(final SysEvent ev) {
    SysCode sc = ev.getSysCode();
    if (ev instanceof TimedEvent) {
        TimedEvent te = (TimedEvent) ev;
        String lbl = te.getLabel();
        DataAvg dv = timedValuesMap.get(lbl);
        if (dv == null) {
            dv = new DataAvg(lbl, ev.getSysCode());
            timedValuesMap.put(lbl, dv);
        }
        dv.inc(te.getMillis());
        return;
    }
    if (ev instanceof MillisecsEvent) {
        DataAvg dv = dvMap.get(sc);
        if (dv != null) {
            dv.inc(((MillisecsEvent) ev).getMillis());
        }
        return;
    }
    if (sc == SysCode.STATS) {
        StatsEvent se = (StatsEvent) ev;
        String sname = se.getName();
        DataAvg da = statMap.get(sname);
        if (da == null) {
            da = new DataAvg(sname, sc);
            statMap.put(sname, da);
        }
        StatType st = StatsEvent.getStatType(sname);
        if (st != StatType.lnum) {
            da.inc(1);
        } else if (se.getLongValue() != null) {
            da.inc(se.getLongValue());
        }
        return;
    }
}
Also used : MillisecsEvent(org.bedework.sysevents.events.MillisecsEvent) TimedEvent(org.bedework.sysevents.events.TimedEvent) StatType(org.bedework.sysevents.events.StatsEvent.StatType) StatsEvent(org.bedework.sysevents.events.StatsEvent) SysCode(org.bedework.sysevents.events.SysEventBase.SysCode)

Example 2 with TimedEvent

use of org.bedework.sysevents.events.TimedEvent in project bw-calendar-engine by Bedework.

the class JmsNotificationsHandlerImpl method post.

@Override
public void post(final SysEventBase ev) throws NotificationException {
    if (debug) {
        debug(ev.toString());
    }
    long start = System.currentTimeMillis();
    send: {
        if (ev instanceof MillisecsEvent) {
            monitor.post(ev);
            if ((ev instanceof TimedEvent) || (ev instanceof HttpEvent)) {
                break send;
            }
        }
        syslog.post(ev);
        boolean changeEvent = false;
        for (final Attribute attr : ev.getMessageAttributes()) {
            if (!"changeEvent".equals(attr.name)) {
                continue;
            }
            changeEvent = Boolean.valueOf(attr.value);
            break;
        }
        if (changeEvent) {
            changes.post(ev);
        }
        if (ev instanceof EntityQueuedEvent) {
            final EntityQueuedEvent eqe = (EntityQueuedEvent) ev;
            if (((EntityQueuedEvent) ev).getInBox()) {
                scheduleIn.post(ev);
            } else {
                scheduleOut.post(ev);
                break send;
            }
        }
        if (ev instanceof ScheduleUpdateEvent) {
            scheduleIn.post(ev);
        }
    }
    // send
    sends++;
    sendTime += System.currentTimeMillis() - start;
    if ((sends % 100) == 0) {
        debug("Sends: " + sends + " avg: " + sendTime / sends);
    }
}
Also used : EntityQueuedEvent(org.bedework.sysevents.events.EntityQueuedEvent) MillisecsEvent(org.bedework.sysevents.events.MillisecsEvent) Attribute(org.bedework.sysevents.events.SysEventBase.Attribute) TimedEvent(org.bedework.sysevents.events.TimedEvent) HttpEvent(org.bedework.sysevents.events.HttpEvent) ScheduleUpdateEvent(org.bedework.sysevents.events.ScheduleUpdateEvent)

Aggregations

MillisecsEvent (org.bedework.sysevents.events.MillisecsEvent)2 TimedEvent (org.bedework.sysevents.events.TimedEvent)2 EntityQueuedEvent (org.bedework.sysevents.events.EntityQueuedEvent)1 HttpEvent (org.bedework.sysevents.events.HttpEvent)1 ScheduleUpdateEvent (org.bedework.sysevents.events.ScheduleUpdateEvent)1 StatsEvent (org.bedework.sysevents.events.StatsEvent)1 StatType (org.bedework.sysevents.events.StatsEvent.StatType)1 Attribute (org.bedework.sysevents.events.SysEventBase.Attribute)1 SysCode (org.bedework.sysevents.events.SysEventBase.SysCode)1