Package io.s4.comm.zk

Examples of io.s4.comm.zk.ZkQueue


        }
    }

    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

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

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.