Package io.s4.collector

Examples of io.s4.collector.EventWrapper


   @Test
   public void testCloneAndInitialize() {
       MockPE prototype = new MockPE();
       prototype.setInitMethod("testInitialize");
      
       PrototypeWrapper prototypeWrapper = new PrototypeWrapper(prototype, new WallClock());

       assertEquals(0, prototype.getInitializeCount());
       MockPE instance = (MockPE)prototypeWrapper.getPE("asd");
       assertNotNull(instance);
      
View Full Code Here


                        continue;
                    }

                    Status status = getStatus(jsonObject);

                    EventWrapper ew = new EventWrapper(streamName, status, null);
                    for (org.apache.s4.listener.EventHandler handler : handlers) {
                        try {
                            handler.processEvent(ew);
                        } catch (Exception e) {
                            Logger.getLogger("s4")
View Full Code Here

                inputReader = new FileReader(inputFilename);
            }
            br = new BufferedReader(inputReader);
            String inputLine = null;
            boolean firstLine = true;
            EventWrapper eventWrapper = null;
            for (startTime = System.nanoTime(); (inputLine = br.readLine()) != null; startTime = System.nanoTime()) {
                if (firstLine) {
                    JSONObject jsonRecord = new JSONObject(inputLine);
                    createEventTypeInfo(jsonRecord);
                    System.out.println(eventTypeInfoMap);
                    if (eventTypeInfoMap.size() == 0) {
                        return;
                    }
                    firstLine = false;
                    continue;
                }

                try {
                    JSONObject jsonRecord = new JSONObject(inputLine);
                    int classIndex = jsonRecord.getInt("_index");
                    EventTypeInfo eventTypeInfo = eventTypeInfoMap.get(classIndex);
                    if (eventTypeInfo == null) {
                        System.err.printf("Invalid _index value %d\n",
                                          classIndex);
                        return;
                    }

                    Object event = makeRecord(jsonRecord,
                                              eventTypeInfo.getSchema());
                    eventWrapper = new EventWrapper(eventTypeInfo.getStreamName(),
                                                    event,
                                                    new ArrayList<CompoundKeyInfo>());
                    // System.out.println(eventWrapper.getStreamName() + ": " +
                    // eventWrapper.getEvent());
                } catch (Exception e) {
View Full Code Here

    }

    public void run() {
        long startTime, endTime;
        while (true) {
            EventWrapper eventWrapper = null;
            try {
                eventWrapper = workQueue.take();
                if (clock instanceof EventClock) {
                    EventClock eventClock = (EventClock) clock;
                    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());

                if (eventWrapper.getStreamName().endsWith("_checkpointing")
                        || eventWrapper.getStreamName().endsWith("_recovery")) {
                    // in that case, we don't need to iterate over all prototypes and advises:
                    // the target PE is specified in the event
                    handleCheckpointingOrRecovery(eventWrapper);
                } else {

                    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
View Full Code Here

        stub.init();

        while (true) {
            Thread.sleep(10000);
            TestReturnType r = new TestReturnType(100, 200);
            adapter.eventReader.queueWork(new EventWrapper("TESTSTREAM",
                                                           r,
                                                           null));
        }
    }
View Full Code Here

                }
                listByPartitionNumber.add(partitionInfo);
            }

            for (int partitionId : pInfoMap.keySet()) {
                EventWrapper eventWrapper = new EventWrapper(streamName,
                                                             event,
                                                             pInfoMap.get(partitionId));
                counts[partitionId]++;
                eventEmitter.emit(partitionId, eventWrapper);
            }
View Full Code Here

        CompoundKeyInfo compoundKeyInfo = new CompoundKeyInfo();
        compoundKeyInfo.setCompoundKey("key");
        compoundKeyInfo.setCompoundValue("value");
        List<CompoundKeyInfo> compoundKeyInfos = new ArrayList<CompoundKeyInfo>();
        compoundKeyInfos.add(compoundKeyInfo);
        EventWrapper eventWrapper = new EventWrapper(streamName, event,
                compoundKeyInfos);
        eventEmitter.emit(partitionId, eventWrapper);
    }
View Full Code Here

    }

    public void injectEvent(Object event, String streamName, int partitionId,
            List<CompoundKeyInfo> compoundKeyInfos) throws JSONException {

        EventWrapper eventWrapper = new EventWrapper(streamName, event,
                compoundKeyInfos);
        eventEmitter.emit(partitionId, eventWrapper);
    }
View Full Code Here

            String jevent = json.getString("object");

            Object obj = GsonUtil.get().fromJson(jevent, clazz);

            return new EventWrapper(streamName, keyNames, obj);

        } catch (JSONException e) {
            logger.error("problem with event JSON", e);
        } catch (ObjectBuilder.Exception e) {
            logger.error("failed to build object from JSON", e);
View Full Code Here

            }
        }

        public void processMessage(byte[] rawMessage) {
            // convert the byte array into an event object
            EventWrapper eventWrapper = null;
            try {
                eventWrapper = (EventWrapper) serDeser.deserialize(rawMessage);

            } catch (RuntimeException rte) {
                Logger.getLogger("s4")
View Full Code Here

TOP

Related Classes of io.s4.collector.EventWrapper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.