Package io.s4.message

Examples of io.s4.message.Response


        // get the value for each keyInfo
        for (KeyInfo keyInfo : compoundKeyInfo.getKeyInfoList()) {
            Object value = null;
            Object record = event;
            List<?> list = null;
            Property property = null;
            for (KeyPathElement keyPathElement : keyInfo.getKeyPath()) {
                if (keyPathElement instanceof KeyPathElementIndex) {
                    record = list.get(((KeyPathElementIndex) keyPathElement).getIndex());
                    schema = property.getComponentProperty().getSchema();
                } else {
                    String keyPathElementName = ((KeyPathElementName) keyPathElement).getKeyName();
                    property = schema.getProperties().get(keyPathElementName);
                    value = null;
                    try {
                        value = property.getGetterMethod().invoke(record);
                    } catch (Exception e) {
                        Logger.getLogger("s4").error(e);
                        return;
                    }

                    if (value == null) {
                        Logger.getLogger("s4").error("Value for "
                                + keyPathElementName + " is null!");
                        return;
                    }

                    if (property.getType().isPrimitive() || property.isNumber()
                            || property.getType().equals(String.class)) {
                        keyValue.add(value);
                        if (saveKeyRecord) {
                            if (keyRecord == null) {
                                keyRecord = new ArrayList<Object>();
                            }
                            keyRecord.add(record);
                        }
                        continue;
                    } else if (property.isList()) {
                        try {
                            list = (List) property.getGetterMethod()
                                                  .invoke(record);
                        } catch (Exception e) {
                            Logger.getLogger("s4").error(e);
                            return;
                        }
                    } else {
                        try {
                            record = property.getGetterMethod().invoke(record);
                        } catch (Exception e) {
                            Logger.getLogger("s4").error(e);
                            return;
                        }
                        schema = property.getSchema();
                    }
                }
            }
        }
    }
View Full Code Here


            event = schema.getType().newInstance();

            for (Iterator it = jsonRecord.keys(); it.hasNext();) {
                String propertyName = (String) it.next();

                Property property = schema.getProperties().get(propertyName);

                if (property == null) {
                    continue; // not in schema, just continue
                }

                Method setterMethod = property.getSetterMethod();
                Object value = jsonRecord.get(propertyName);
                if (value.equals(JSONObject.NULL)) {
                    continue;
                }
View Full Code Here

        return null;
    }

    public Object makeList(Property property, JSONArray jsonArray) {
        Property componentProperty = property.getComponentProperty();

        int size = jsonArray.length();

        List<Object> list = new ArrayList<Object>(size);
View Full Code Here

        return list;
    }

    @SuppressWarnings("unchecked")
    public Object makeArray(Property property, JSONArray jsonArray) {
        Property componentProperty = property.getComponentProperty();
        Class clazz = componentProperty.getType();

        int size = jsonArray.length();

        Object array = Array.newInstance(clazz, size);
View Full Code Here

        String streamName = eventWrapper.getStreamName();
        String fieldName = eventClockStreamsMap.get(streamName);
        if (fieldName != null) {
            Object event = eventWrapper.getEvent();
            Schema schema = schemaContainer.getSchema(event.getClass());
            Property property = schema.getProperties().get(fieldName);
            if (property != null
                    && (property.getType().equals(Long.TYPE) || property
                            .getType().equals(Long.class))) {
                try {
                    eventTime = (Long) property.getGetterMethod().invoke(event);
                    updateTime(eventTime);
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }
View Full Code Here

        String inputFilename = (String) loArgs.get(0);

        EventEmitter emitter = null;

        SerializerDeserializer serDeser = new KryoSerDeser();

        CommLayerEmitter clEmitter = new CommLayerEmitter();
        clEmitter.setAppName(senderApplicationName);
        clEmitter.setListenerAppName(listenerApplicationName);
        clEmitter.setClusterManagerAddress(clusterManagerAddress);
View Full Code Here

        String inputFilename = (String) loArgs.get(0);

        EventEmitter emitter = null;

        SerializerDeserializer serDeser = new KryoSerDeser();

        CommLayerEmitter clEmitter = new CommLayerEmitter();
        clEmitter.setAppName(senderApplicationName);
        clEmitter.setListenerAppName(listenerApplicationName);
        clEmitter.setClusterManagerAddress(clusterManagerAddress);
View Full Code Here

     * @throws IOException
     *             if the underlying socket could not provide valid input and
     *             output streams.
     */
    public IOChannel createIOChannel(Socket socket) throws IOException {
        return new ByteArrayIOChannel(socket);
    }
View Full Code Here

        byte[] v;

        try {
            ClientConnection conn = null;

            ByteArrayIOChannel io = new ByteArrayIOChannel(s);

            v = io.recv();

            if (v == null || v.length == 0) {
                // no information => client initialization
                clientInit(io);
View Full Code Here

    private Map<String, Cloner> clonerMap = new HashMap<String, Cloner>();

    public void processEvent(Object event) {
        Object newEvent = event;
        if (transformers != null && transformers.length > 0) {
            Cloner cloner = clonerMap.get(event.getClass().getName());
            if (cloner == null) {
                ClonerGenerator cg = new ClonerGenerator();
                // generate byte code that knows how to call the clone method on
                // this event
                Class clonerClass = cg.generate(event.getClass());
                try {
                    cloner = (Cloner) clonerClass.newInstance();
                    clonerMap.put(event.getClass().getName(), cloner);
                } catch (InstantiationException ie) {
                    Logger.getLogger(this.getClass()).error(ie);
                    throw new RuntimeException(ie);
                } catch (IllegalAccessException ias) {
                    Logger.getLogger(this.getClass()).error(ias);
                    throw new RuntimeException(ias);
                }
            }
            newEvent = cloner.clone(event);
        }

        for (Transformer transformer : transformers) {
            newEvent = transformer.transform(newEvent);
            if (newEvent == null) {
View Full Code Here

TOP

Related Classes of io.s4.message.Response

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.