Package io.s4.comm.zk

Examples of io.s4.comm.zk.ZkQueue


        return null;
    }

    private void clientInit(ByteArrayIOChannel io) throws IOException {
        String uuid = UUID.randomUUID().toString();
        Info proto = clientStub.getProtocolInfo();

        HashMap<String, Object> info = new HashMap<String, Object>();
        info.put("uuid", uuid);
        info.put("protocol", proto);
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

    }

    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,
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

            }
        }

        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

                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

            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

                        continue;
                    }

                    Status status = getStatus(jsonObject);

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

    public void init() {
        System.err.println("appName=" + appName);
        process = new ListenerProcess(clusterManagerAddress, appName);
        process.setDeserializer(new PassThroughDeserializer());
        CommEventCallback callbackHandler = new CommEventCallback() {
            @Override
            public void handleCallback(Map<String, Object> event) {
                if (event != null) {
                    CommLayerState state = (CommLayerState) event.get("state");
                    if (state != null) {
View Full Code Here

        process.setDeserializer(new PassThroughDeserializer());
        CommEventCallback callbackHandler = new CommEventCallback() {
            @Override
            public void handleCallback(Map<String, Object> event) {
                if (event != null) {
                    CommLayerState state = (CommLayerState) event.get("state");
                    if (state != null) {
                        if (state == CommLayerState.INITIALIZED) {
                            logger.info("Communication layer initialized: source:"
                                    + event.get("source"));
                        } else if (state == CommLayerState.BROKEN) {
View Full Code Here

TOP

Related Classes of io.s4.comm.zk.ZkQueue

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.