Package io.s4.message

Examples of io.s4.message.Response


        }
        if (property.isList()) {
            List list = (List) value;
            // TODO: handle case where key does not include property of
            // component type
            Schema componentSchema = property.getComponentProperty()
                                             .getSchema();
            int listLength = list.size();
            for (int i = 0; i < listLength; i++) {
                Object listEntry = list.get(i);
                KeyInfo keyInfoForListEntry = keyInfo.copy();
View Full Code Here


            } catch (Exception e) {
                e.printStackTrace();
                throw new RuntimeException(e);
            }

            Schema newEventSchema = schemaContainer.getSchema(newEvent.getClass());

            for (String streamName : eventsToJoin.keySet()) {
                Object partialEvent = eventsToJoin.get(streamName);
                Schema partialEventSchema = schemaContainer.getSchema(partialEvent.getClass());

                List<String> includeFields = eventFields.get(streamName);
                if (includeFields.size() == 1
                        && includeFields.get(0).equals("*")) {
                    for (Property partialEventProperty : partialEventSchema.getProperties()
                                                                           .values()) {
                        copyField(partialEventProperty.getName(),
                                  partialEventSchema,
                                  newEventSchema,
                                  partialEvent,
View Full Code Here

    public void processEvent(Object event) {
        long currentTime = getCurrentTime();
        long maybeCurrentTime = -1;
        if (timestampFields != null) {
            Schema schema = schemaContainer.getSchema(event.getClass());
            String fieldName = timestampFields.get(getStreamName());
            if (fieldName != null) {
                Property property = schema.getProperties().get(fieldName);
                if (property != null
                        && (property.getType().equals(Long.TYPE) || property.getType()
                                                                            .equals(Long.class))) {
                    try {
                        maybeCurrentTime = (Long) property.getGetterMethod()
View Full Code Here

            return;
        }

        keyValue = new ArrayList<Object>();

        Schema schema = schemaContainer.getSchema(event.getClass());

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

                JSONObject jsonEventTypeInfo = classInfo.getJSONObject(className);
                int classIndex = (Integer) jsonEventTypeInfo.getInt("classIndex");
                String streamName = jsonEventTypeInfo.getString("streamName");

                Class clazz = Class.forName(className);
                Schema schema = new Schema(clazz);
                eventTypeInfoMap.put(classIndex, new EventTypeInfo(schema,
                                                                   streamName));
            }
        } catch (JSONException je) {
            je.printStackTrace();
View Full Code Here

        long eventTime = -1;
        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);
View Full Code Here

            if (debug) {
                System.out.println("Using fast path!");
            }
            fastPath = true;
            KeyInfo keyInfo = new KeyInfo();
            Property property = schema.getProperties().get(simpleKeyName);
            if (property == null) {
                return null;
            }

            Object value = null;
            try {
                value = property.getGetterMethod().invoke(event);
            } catch (Exception e) {
                if (debug) {
                    e.printStackTrace();
                }
            }
View Full Code Here

                                       List<String> keyNameElements,
                                       int elementIndex,
                                       List<KeyInfo> keyInfoList,
                                       KeyInfo keyInfo) {
        String keyElement = keyNameElements.get(elementIndex);
        Property property = schema.getProperties().get(keyElement);
        if (property == null) {
            return null;
        }

        keyInfo.addElementToPath(keyElement);

        Object value = null;
        try {
            value = property.getGetterMethod().invoke(record);
        } catch (Exception e) {
            if (debug) {
                System.out.println("key element is " + keyElement);
                e.printStackTrace();
            }
        }

        if (value == null) {
            return null; // return a null KeyInfo list if we hit a null value
        }
        if (property.isList()) {
            List list = (List) value;
            // TODO: handle case where key does not include property of
            // component type
            Schema componentSchema = property.getComponentProperty()
                                             .getSchema();
            int listLength = list.size();
            for (int i = 0; i < listLength; i++) {
                Object listEntry = list.get(i);
                KeyInfo keyInfoForListEntry = keyInfo.copy();
                keyInfoForListEntry.addElementToPath(i);
                Object partialList = getKeyValues(listEntry,
                                                  componentSchema,
                                                  keyNameElements,
                                                  elementIndex + 1,
                                                  keyInfoList,
                                                  keyInfoForListEntry);
                if (partialList == null) {
                    return null;
                }
            }
        } else if (property.getSchema() != null) {
            return getKeyValues(value,
                                property.getSchema(),
                                keyNameElements,
                                elementIndex + 1,
                                keyInfoList,
                                keyInfo);
        } else {
View Full Code Here

        }
    }

    private void copyField(String propertyName, Schema sourceSchema,
                           Schema targetSchema, Object source, Object target) {
        Property sourceProperty = sourceSchema.getProperties()
                                              .get(propertyName);
        Property targetProperty = targetSchema.getProperties()
                                              .get(propertyName);

        if (sourceProperty == null || targetProperty == null
                || !sourceProperty.getType().equals(targetProperty.getType())) {
            throw new RuntimeException("Specified property " + propertyName
                    + " doesn't exist or is not consistent");
        }

        try {
            Object sourceValue = sourceProperty.getGetterMethod()
                                               .invoke(source);
            if (sourceValue == null) {
                return;
            }
            if (sourceProperty.getType().isPrimitive()) {
                if (sourceValue instanceof Number) {
                    if (((Number) sourceValue).doubleValue() == 0.0) {
                        return;
                    }
                }
                if (sourceValue instanceof Boolean) {
                    if (((Boolean) sourceValue).equals(Boolean.FALSE)) {
                        return;
                    }
                }
            }
            targetProperty.getSetterMethod().invoke(target, sourceValue);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

        long maybeCurrentTime = -1;
        if (timestampFields != null) {
            Schema schema = schemaContainer.getSchema(event.getClass());
            String fieldName = timestampFields.get(getStreamName());
            if (fieldName != null) {
                Property property = schema.getProperties().get(fieldName);
                if (property != null
                        && (property.getType().equals(Long.TYPE) || property.getType()
                                                                            .equals(Long.class))) {
                    try {
                        maybeCurrentTime = (Long) property.getGetterMethod()
                                                          .invoke(event);
                    } catch (Exception e) {
                        throw new RuntimeException(e);
                    }
                }
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.