}
public void run() {
long startTime, endTime;
while (true) {
EventWrapper eventWrapper = null;
try {
eventWrapper = workQueue.take();
if (s4Clock instanceof EventClock) {
EventClock eventClock = (EventClock) s4Clock;
eventClock.update(eventWrapper);
// To what time to update the clock
}
if (trackByKey) {
boolean foundOne = false;
for (CompoundKeyInfo compoundKeyInfo : eventWrapper.getCompoundKeys()) {
foundOne = true;
updateCount(eventWrapper.getStreamName() + " "
+ compoundKeyInfo.getCompoundKey());
}
if (!foundOne) {
updateCount(eventWrapper.getStreamName() + " *");
}
}
startTime = System.currentTimeMillis();
if (logger.isDebugEnabled()) {
logger.debug("STEP 5 (PEContainer): workQueue.take - "
+ eventWrapper.toString());
}
// Logger.getLogger("s4").debug(
// "Incoming: " + event.getEventName());
if (monitor != null) {
monitor.increment(pecontainer_ev_dq_ct.toString(),
1,
S4_CORE_METRICS.toString());
}
// printPlainPartitionInfoList(event.getCompoundKeyList());
boolean ctrlEvent = testControlEvent(eventWrapper);
// execute the PEs interested in this event
for (int i = 0; i < prototypeWrappers.size(); i++) {
if (logger.isDebugEnabled()) {
logger.debug("STEP 6 (PEContainer): prototypeWrappers("
+ i + ") - "
+ prototypeWrappers.get(i).toString() + " - "
+ eventWrapper.getStreamName());
}
// first check if this is a control message and handle it if
// so.
if (ctrlEvent) {
if (controlEventProcessor != null) {
controlEventProcessor.process(eventWrapper,
prototypeWrappers.get(i));
}
continue;
}
// otherwise, continue processing event.
List<EventAdvice> adviceList = adviceLists.get(i);
for (EventAdvice eventAdvice : adviceList) {
if (eventAdvice.getEventName().equals("*")
|| eventAdvice.getEventName()
.equals(eventWrapper.getStreamName())) {
// event name matches
} else {
continue;
}
if (eventAdvice.getKey().equals("*")) {
invokePE(prototypeWrappers.get(i).getPE("*"),
eventWrapper,
null);
continue;
}
for (CompoundKeyInfo compoundKeyInfo : eventWrapper.getCompoundKeys()) {
if (eventAdvice.getKey()
.equals(compoundKeyInfo.getCompoundKey())) {
invokePE(prototypeWrappers.get(i)
.getPE(compoundKeyInfo.getCompoundValue()),
eventWrapper,