Example usage for org.apache.thrift.protocol TProtocol readI64

List of usage examples for org.apache.thrift.protocol TProtocol readI64

Introduction

In this page you can find the example usage for org.apache.thrift.protocol TProtocol readI64.

Prototype

public abstract long readI64() throws TException;

Source Link

Usage

From source file:backtype.storm.generated.BoltStats.java

License:Apache License

public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
    org.apache.thrift.protocol.TField field;
    iprot.readStructBegin();// ww  w.j a v a2 s .  c om
    while (true) {
        field = iprot.readFieldBegin();
        if (field.type == org.apache.thrift.protocol.TType.STOP) {
            break;
        }
        switch (field.id) {
        case 1: // ACKED
            if (field.type == org.apache.thrift.protocol.TType.MAP) {
                {
                    org.apache.thrift.protocol.TMap _map45 = iprot.readMapBegin();
                    this.acked = new HashMap<String, Map<GlobalStreamId, Long>>(2 * _map45.size);
                    for (int _i46 = 0; _i46 < _map45.size; ++_i46) {
                        String _key47; // required
                        Map<GlobalStreamId, Long> _val48; // required
                        _key47 = iprot.readString();
                        {
                            org.apache.thrift.protocol.TMap _map49 = iprot.readMapBegin();
                            _val48 = new HashMap<GlobalStreamId, Long>(2 * _map49.size);
                            for (int _i50 = 0; _i50 < _map49.size; ++_i50) {
                                GlobalStreamId _key51; // required
                                long _val52; // required
                                _key51 = new GlobalStreamId();
                                _key51.read(iprot);
                                _val52 = iprot.readI64();
                                _val48.put(_key51, _val52);
                            }
                            iprot.readMapEnd();
                        }
                        this.acked.put(_key47, _val48);
                    }
                    iprot.readMapEnd();
                }
            } else {
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
            }
            break;
        case 2: // FAILED
            if (field.type == org.apache.thrift.protocol.TType.MAP) {
                {
                    org.apache.thrift.protocol.TMap _map53 = iprot.readMapBegin();
                    this.failed = new HashMap<String, Map<GlobalStreamId, Long>>(2 * _map53.size);
                    for (int _i54 = 0; _i54 < _map53.size; ++_i54) {
                        String _key55; // required
                        Map<GlobalStreamId, Long> _val56; // required
                        _key55 = iprot.readString();
                        {
                            org.apache.thrift.protocol.TMap _map57 = iprot.readMapBegin();
                            _val56 = new HashMap<GlobalStreamId, Long>(2 * _map57.size);
                            for (int _i58 = 0; _i58 < _map57.size; ++_i58) {
                                GlobalStreamId _key59; // required
                                long _val60; // required
                                _key59 = new GlobalStreamId();
                                _key59.read(iprot);
                                _val60 = iprot.readI64();
                                _val56.put(_key59, _val60);
                            }
                            iprot.readMapEnd();
                        }
                        this.failed.put(_key55, _val56);
                    }
                    iprot.readMapEnd();
                }
            } else {
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
            }
            break;
        case 3: // PROCESS_MS_AVG
            if (field.type == org.apache.thrift.protocol.TType.MAP) {
                {
                    org.apache.thrift.protocol.TMap _map61 = iprot.readMapBegin();
                    this.process_ms_avg = new HashMap<String, Map<GlobalStreamId, Double>>(2 * _map61.size);
                    for (int _i62 = 0; _i62 < _map61.size; ++_i62) {
                        String _key63; // required
                        Map<GlobalStreamId, Double> _val64; // required
                        _key63 = iprot.readString();
                        {
                            org.apache.thrift.protocol.TMap _map65 = iprot.readMapBegin();
                            _val64 = new HashMap<GlobalStreamId, Double>(2 * _map65.size);
                            for (int _i66 = 0; _i66 < _map65.size; ++_i66) {
                                GlobalStreamId _key67; // required
                                double _val68; // required
                                _key67 = new GlobalStreamId();
                                _key67.read(iprot);
                                _val68 = iprot.readDouble();
                                _val64.put(_key67, _val68);
                            }
                            iprot.readMapEnd();
                        }
                        this.process_ms_avg.put(_key63, _val64);
                    }
                    iprot.readMapEnd();
                }
            } else {
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
            }
            break;
        case 4: // EXECUTED
            if (field.type == org.apache.thrift.protocol.TType.MAP) {
                {
                    org.apache.thrift.protocol.TMap _map69 = iprot.readMapBegin();
                    this.executed = new HashMap<String, Map<GlobalStreamId, Long>>(2 * _map69.size);
                    for (int _i70 = 0; _i70 < _map69.size; ++_i70) {
                        String _key71; // required
                        Map<GlobalStreamId, Long> _val72; // required
                        _key71 = iprot.readString();
                        {
                            org.apache.thrift.protocol.TMap _map73 = iprot.readMapBegin();
                            _val72 = new HashMap<GlobalStreamId, Long>(2 * _map73.size);
                            for (int _i74 = 0; _i74 < _map73.size; ++_i74) {
                                GlobalStreamId _key75; // required
                                long _val76; // required
                                _key75 = new GlobalStreamId();
                                _key75.read(iprot);
                                _val76 = iprot.readI64();
                                _val72.put(_key75, _val76);
                            }
                            iprot.readMapEnd();
                        }
                        this.executed.put(_key71, _val72);
                    }
                    iprot.readMapEnd();
                }
            } else {
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
            }
            break;
        case 5: // EXECUTE_MS_AVG
            if (field.type == org.apache.thrift.protocol.TType.MAP) {
                {
                    org.apache.thrift.protocol.TMap _map77 = iprot.readMapBegin();
                    this.execute_ms_avg = new HashMap<String, Map<GlobalStreamId, Double>>(2 * _map77.size);
                    for (int _i78 = 0; _i78 < _map77.size; ++_i78) {
                        String _key79; // required
                        Map<GlobalStreamId, Double> _val80; // required
                        _key79 = iprot.readString();
                        {
                            org.apache.thrift.protocol.TMap _map81 = iprot.readMapBegin();
                            _val80 = new HashMap<GlobalStreamId, Double>(2 * _map81.size);
                            for (int _i82 = 0; _i82 < _map81.size; ++_i82) {
                                GlobalStreamId _key83; // required
                                double _val84; // required
                                _key83 = new GlobalStreamId();
                                _key83.read(iprot);
                                _val84 = iprot.readDouble();
                                _val80.put(_key83, _val84);
                            }
                            iprot.readMapEnd();
                        }
                        this.execute_ms_avg.put(_key79, _val80);
                    }
                    iprot.readMapEnd();
                }
            } else {
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
            }
            break;
        default:
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
        }
        iprot.readFieldEnd();
    }
    iprot.readStructEnd();
    validate();
}

From source file:backtype.storm.generated.ExecutorStats.java

License:Apache License

public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
    org.apache.thrift.protocol.TField field;
    iprot.readStructBegin();/*from  ww w .j  av  a2s . c  om*/
    while (true) {
        field = iprot.readFieldBegin();
        if (field.type == org.apache.thrift.protocol.TType.STOP) {
            break;
        }
        switch (field.id) {
        case 1: // EMITTED
            if (field.type == org.apache.thrift.protocol.TType.MAP) {
                {
                    org.apache.thrift.protocol.TMap _map125 = iprot.readMapBegin();
                    this.emitted = new HashMap<String, Map<String, Long>>(2 * _map125.size);
                    for (int _i126 = 0; _i126 < _map125.size; ++_i126) {
                        String _key127; // required
                        Map<String, Long> _val128; // required
                        _key127 = iprot.readString();
                        {
                            org.apache.thrift.protocol.TMap _map129 = iprot.readMapBegin();
                            _val128 = new HashMap<String, Long>(2 * _map129.size);
                            for (int _i130 = 0; _i130 < _map129.size; ++_i130) {
                                String _key131; // required
                                long _val132; // required
                                _key131 = iprot.readString();
                                _val132 = iprot.readI64();
                                _val128.put(_key131, _val132);
                            }
                            iprot.readMapEnd();
                        }
                        this.emitted.put(_key127, _val128);
                    }
                    iprot.readMapEnd();
                }
            } else {
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
            }
            break;
        case 2: // TRANSFERRED
            if (field.type == org.apache.thrift.protocol.TType.MAP) {
                {
                    org.apache.thrift.protocol.TMap _map133 = iprot.readMapBegin();
                    this.transferred = new HashMap<String, Map<String, Long>>(2 * _map133.size);
                    for (int _i134 = 0; _i134 < _map133.size; ++_i134) {
                        String _key135; // required
                        Map<String, Long> _val136; // required
                        _key135 = iprot.readString();
                        {
                            org.apache.thrift.protocol.TMap _map137 = iprot.readMapBegin();
                            _val136 = new HashMap<String, Long>(2 * _map137.size);
                            for (int _i138 = 0; _i138 < _map137.size; ++_i138) {
                                String _key139; // required
                                long _val140; // required
                                _key139 = iprot.readString();
                                _val140 = iprot.readI64();
                                _val136.put(_key139, _val140);
                            }
                            iprot.readMapEnd();
                        }
                        this.transferred.put(_key135, _val136);
                    }
                    iprot.readMapEnd();
                }
            } else {
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
            }
            break;
        case 3: // SPECIFIC
            if (field.type == org.apache.thrift.protocol.TType.STRUCT) {
                this.specific = new ExecutorSpecificStats();
                this.specific.read(iprot);
            } else {
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
            }
            break;
        default:
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
        }
        iprot.readFieldEnd();
    }
    iprot.readStructEnd();
    validate();
}

From source file:backtype.storm.generated.JavaObjectArg.java

License:Apache License

@Override
protected Object readValue(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TField field)
        throws org.apache.thrift.TException {
    _Fields setField = _Fields.findByThriftId(field.id);
    if (setField != null) {
        switch (setField) {
        case INT_ARG:
            if (field.type == INT_ARG_FIELD_DESC.type) {
                Integer int_arg;
                int_arg = iprot.readI32();
                return int_arg;
            } else {
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
                return null;
            }//  ww  w. j  av a2 s. c  o m
        case LONG_ARG:
            if (field.type == LONG_ARG_FIELD_DESC.type) {
                Long long_arg;
                long_arg = iprot.readI64();
                return long_arg;
            } else {
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
                return null;
            }
        case STRING_ARG:
            if (field.type == STRING_ARG_FIELD_DESC.type) {
                String string_arg;
                string_arg = iprot.readString();
                return string_arg;
            } else {
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
                return null;
            }
        case BOOL_ARG:
            if (field.type == BOOL_ARG_FIELD_DESC.type) {
                Boolean bool_arg;
                bool_arg = iprot.readBool();
                return bool_arg;
            } else {
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
                return null;
            }
        case BINARY_ARG:
            if (field.type == BINARY_ARG_FIELD_DESC.type) {
                ByteBuffer binary_arg;
                binary_arg = iprot.readBinary();
                return binary_arg;
            } else {
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
                return null;
            }
        case DOUBLE_ARG:
            if (field.type == DOUBLE_ARG_FIELD_DESC.type) {
                Double double_arg;
                double_arg = iprot.readDouble();
                return double_arg;
            } else {
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
                return null;
            }
        default:
            throw new IllegalStateException(
                    "setField wasn't null, but didn't match any of the case statements!");
        }
    } else {
        org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
        return null;
    }
}

From source file:backtype.storm.generated.SpoutStats.java

License:Apache License

public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
    org.apache.thrift.protocol.TField field;
    iprot.readStructBegin();/* w  ww . ja v a 2 s  .c  o  m*/
    while (true) {
        field = iprot.readFieldBegin();
        if (field.type == org.apache.thrift.protocol.TType.STOP) {
            break;
        }
        switch (field.id) {
        case 1: // ACKED
            if (field.type == org.apache.thrift.protocol.TType.MAP) {
                {
                    org.apache.thrift.protocol.TMap _map95 = iprot.readMapBegin();
                    this.acked = new HashMap<String, Map<String, Long>>(2 * _map95.size);
                    for (int _i96 = 0; _i96 < _map95.size; ++_i96) {
                        String _key97; // required
                        Map<String, Long> _val98; // required
                        _key97 = iprot.readString();
                        {
                            org.apache.thrift.protocol.TMap _map99 = iprot.readMapBegin();
                            _val98 = new HashMap<String, Long>(2 * _map99.size);
                            for (int _i100 = 0; _i100 < _map99.size; ++_i100) {
                                String _key101; // required
                                long _val102; // required
                                _key101 = iprot.readString();
                                _val102 = iprot.readI64();
                                _val98.put(_key101, _val102);
                            }
                            iprot.readMapEnd();
                        }
                        this.acked.put(_key97, _val98);
                    }
                    iprot.readMapEnd();
                }
            } else {
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
            }
            break;
        case 2: // FAILED
            if (field.type == org.apache.thrift.protocol.TType.MAP) {
                {
                    org.apache.thrift.protocol.TMap _map103 = iprot.readMapBegin();
                    this.failed = new HashMap<String, Map<String, Long>>(2 * _map103.size);
                    for (int _i104 = 0; _i104 < _map103.size; ++_i104) {
                        String _key105; // required
                        Map<String, Long> _val106; // required
                        _key105 = iprot.readString();
                        {
                            org.apache.thrift.protocol.TMap _map107 = iprot.readMapBegin();
                            _val106 = new HashMap<String, Long>(2 * _map107.size);
                            for (int _i108 = 0; _i108 < _map107.size; ++_i108) {
                                String _key109; // required
                                long _val110; // required
                                _key109 = iprot.readString();
                                _val110 = iprot.readI64();
                                _val106.put(_key109, _val110);
                            }
                            iprot.readMapEnd();
                        }
                        this.failed.put(_key105, _val106);
                    }
                    iprot.readMapEnd();
                }
            } else {
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
            }
            break;
        case 3: // COMPLETE_MS_AVG
            if (field.type == org.apache.thrift.protocol.TType.MAP) {
                {
                    org.apache.thrift.protocol.TMap _map111 = iprot.readMapBegin();
                    this.complete_ms_avg = new HashMap<String, Map<String, Double>>(2 * _map111.size);
                    for (int _i112 = 0; _i112 < _map111.size; ++_i112) {
                        String _key113; // required
                        Map<String, Double> _val114; // required
                        _key113 = iprot.readString();
                        {
                            org.apache.thrift.protocol.TMap _map115 = iprot.readMapBegin();
                            _val114 = new HashMap<String, Double>(2 * _map115.size);
                            for (int _i116 = 0; _i116 < _map115.size; ++_i116) {
                                String _key117; // required
                                double _val118; // required
                                _key117 = iprot.readString();
                                _val118 = iprot.readDouble();
                                _val114.put(_key117, _val118);
                            }
                            iprot.readMapEnd();
                        }
                        this.complete_ms_avg.put(_key113, _val114);
                    }
                    iprot.readMapEnd();
                }
            } else {
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
            }
            break;
        default:
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
        }
        iprot.readFieldEnd();
    }
    iprot.readStructEnd();
    validate();
}

From source file:com.alibaba.dubbo.rpc.protocol.thrift.ext.MultiServiceProcessor.java

License:Open Source License

public boolean process(TProtocol in, TProtocol out) throws TException {

    short magic = in.readI16();

    if (magic != ThriftCodec.MAGIC) {
        logger.error(new StringBuilder(24).append("Unsupported magic ").append(magic).toString());
        return false;
    }/*from   w  w  w .  ja v  a  2 s  . co m*/

    in.readI32();
    in.readI16();
    byte version = in.readByte();
    String serviceName = in.readString();
    long id = in.readI64();

    ByteArrayOutputStream bos = new ByteArrayOutputStream(1024);

    TIOStreamTransport transport = new TIOStreamTransport(bos);

    TProtocol protocol = protocolFactory.getProtocol(transport);

    TProcessor processor = processorMap.get(serviceName);

    if (processor == null) {
        logger.error(new StringBuilder(32).append("Could not find processor for service ").append(serviceName)
                .toString());
        return false;
    }

    // todo if exception
    boolean result = processor.process(in, protocol);

    ByteArrayOutputStream header = new ByteArrayOutputStream(512);

    TIOStreamTransport headerTransport = new TIOStreamTransport(header);

    TProtocol headerProtocol = protocolFactory.getProtocol(headerTransport);

    headerProtocol.writeI16(magic);
    headerProtocol.writeI32(Integer.MAX_VALUE);
    headerProtocol.writeI16(Short.MAX_VALUE);
    headerProtocol.writeByte(version);
    headerProtocol.writeString(serviceName);
    headerProtocol.writeI64(id);
    headerProtocol.getTransport().flush();

    out.writeI16(magic);
    out.writeI32(bos.size() + header.size());
    out.writeI16((short) (0xffff & header.size()));
    out.writeByte(version);
    out.writeString(serviceName);
    out.writeI64(id);

    out.getTransport().write(bos.toByteArray());
    out.getTransport().flush();

    return result;

}

From source file:com.alibaba.dubbo.rpc.protocol.thrift.ThriftCodec.java

License:Open Source License

private Object decode(TProtocol protocol) throws IOException {

    // version/*from  w  w  w .  j a v  a2  s.c  om*/
    String serviceName;
    long id;

    TMessage message;

    try {
        protocol.readI16();
        protocol.readByte();
        serviceName = protocol.readString();
        id = protocol.readI64();
        message = protocol.readMessageBegin();
    } catch (TException e) {
        throw new IOException(e.getMessage(), e);
    }

    if (message.type == TMessageType.CALL) {

        RpcInvocation result = new RpcInvocation();
        result.setAttachment(Constants.INTERFACE_KEY, serviceName);
        result.setMethodName(message.name);

        String argsClassName = ExtensionLoader.getExtensionLoader(ClassNameGenerator.class)
                .getExtension(ThriftClassNameGenerator.NAME).generateArgsClassName(serviceName, message.name);

        if (StringUtils.isEmpty(argsClassName)) {
            throw new RpcException(RpcException.SERIALIZATION_EXCEPTION,
                    "The specified interface name incorrect.");
        }

        Class clazz = cachedClass.get(argsClassName);

        if (clazz == null) {
            try {

                clazz = ClassHelper.forNameWithThreadContextClassLoader(argsClassName);

                cachedClass.putIfAbsent(argsClassName, clazz);

            } catch (ClassNotFoundException e) {
                throw new RpcException(RpcException.SERIALIZATION_EXCEPTION, e.getMessage(), e);
            }
        }

        TBase args;

        try {
            args = (TBase) clazz.newInstance();
        } catch (InstantiationException e) {
            throw new RpcException(RpcException.SERIALIZATION_EXCEPTION, e.getMessage(), e);
        } catch (IllegalAccessException e) {
            throw new RpcException(RpcException.SERIALIZATION_EXCEPTION, e.getMessage(), e);
        }

        try {
            args.read(protocol);
            protocol.readMessageEnd();
        } catch (TException e) {
            throw new RpcException(RpcException.SERIALIZATION_EXCEPTION, e.getMessage(), e);
        }

        List<Object> parameters = new ArrayList<Object>();
        List<Class<?>> parameterTypes = new ArrayList<Class<?>>();
        int index = 1;

        while (true) {

            TFieldIdEnum fieldIdEnum = args.fieldForId(index++);

            if (fieldIdEnum == null) {
                break;
            }

            String fieldName = fieldIdEnum.getFieldName();

            String getMethodName = ThriftUtils.generateGetMethodName(fieldName);

            Method getMethod;

            try {
                getMethod = clazz.getMethod(getMethodName);
            } catch (NoSuchMethodException e) {
                throw new RpcException(RpcException.SERIALIZATION_EXCEPTION, e.getMessage(), e);
            }

            parameterTypes.add(getMethod.getReturnType());
            try {
                parameters.add(getMethod.invoke(args));
            } catch (IllegalAccessException e) {
                throw new RpcException(RpcException.SERIALIZATION_EXCEPTION, e.getMessage(), e);
            } catch (InvocationTargetException e) {
                throw new RpcException(RpcException.SERIALIZATION_EXCEPTION, e.getMessage(), e);
            }

        }

        result.setArguments(parameters.toArray());
        result.setParameterTypes(parameterTypes.toArray(new Class[parameterTypes.size()]));

        Request request = new Request(id);
        request.setData(result);

        cachedRequest.putIfAbsent(id, RequestData.create(message.seqid, serviceName, message.name));

        return request;

    } else if (message.type == TMessageType.EXCEPTION) {

        TApplicationException exception;

        try {
            exception = TApplicationException.read(protocol);
            protocol.readMessageEnd();
        } catch (TException e) {
            throw new IOException(e.getMessage(), e);
        }

        RpcResult result = new RpcResult();

        result.setException(new RpcException(exception.getMessage()));

        Response response = new Response();

        response.setResult(result);

        response.setId(id);

        return response;

    } else if (message.type == TMessageType.REPLY) {

        String resultClassName = ExtensionLoader.getExtensionLoader(ClassNameGenerator.class)
                .getExtension(ThriftClassNameGenerator.NAME).generateResultClassName(serviceName, message.name);

        if (StringUtils.isEmpty(resultClassName)) {
            throw new IllegalArgumentException(new StringBuilder(32)
                    .append("Could not infer service result class name from service name ").append(serviceName)
                    .append(", the service name you specified may not generated by thrift idl compiler")
                    .toString());
        }

        Class<?> clazz = cachedClass.get(resultClassName);

        if (clazz == null) {

            try {

                clazz = ClassHelper.forNameWithThreadContextClassLoader(resultClassName);

                cachedClass.putIfAbsent(resultClassName, clazz);

            } catch (ClassNotFoundException e) {
                throw new RpcException(RpcException.SERIALIZATION_EXCEPTION, e.getMessage(), e);
            }

        }

        TBase<?, ? extends TFieldIdEnum> result;
        try {
            result = (TBase<?, ?>) clazz.newInstance();
        } catch (InstantiationException e) {
            throw new RpcException(RpcException.SERIALIZATION_EXCEPTION, e.getMessage(), e);
        } catch (IllegalAccessException e) {
            throw new RpcException(RpcException.SERIALIZATION_EXCEPTION, e.getMessage(), e);
        }

        try {
            result.read(protocol);
            protocol.readMessageEnd();
        } catch (TException e) {
            throw new RpcException(RpcException.SERIALIZATION_EXCEPTION, e.getMessage(), e);
        }

        Object realResult = null;

        int index = 0;

        while (true) {

            TFieldIdEnum fieldIdEnum = result.fieldForId(index++);

            if (fieldIdEnum == null) {
                break;
            }

            Field field;

            try {
                field = clazz.getDeclaredField(fieldIdEnum.getFieldName());
                field.setAccessible(true);
            } catch (NoSuchFieldException e) {
                throw new RpcException(RpcException.SERIALIZATION_EXCEPTION, e.getMessage(), e);
            }

            try {
                realResult = field.get(result);
            } catch (IllegalAccessException e) {
                throw new RpcException(RpcException.SERIALIZATION_EXCEPTION, e.getMessage(), e);
            }

            if (realResult != null) {
                break;
            }

        }

        Response response = new Response();

        response.setId(id);

        RpcResult rpcResult = new RpcResult();

        if (realResult instanceof Throwable) {
            rpcResult.setException((Throwable) realResult);
        } else {
            rpcResult.setValue(realResult);
        }

        response.setResult(rpcResult);

        return response;

    } else {
        // Impossible
        throw new IOException();
    }

}

From source file:com.bigdata.dastor.thrift.Column.java

License:Apache License

public void read(TProtocol iprot) throws TException {
    TField field;/*  w ww . java 2  s.c  om*/
    iprot.readStructBegin();
    while (true) {
        field = iprot.readFieldBegin();
        if (field.type == TType.STOP) {
            break;
        }
        switch (field.id) {
        case 1: // NAME
            if (field.type == TType.STRING) {
                this.name = iprot.readBinary();
            } else {
                TProtocolUtil.skip(iprot, field.type);
            }
            break;
        case 2: // VALUE
            if (field.type == TType.STRING) {
                this.value = iprot.readBinary();
            } else {
                TProtocolUtil.skip(iprot, field.type);
            }
            break;
        case 3: // TIMESTAMP
            if (field.type == TType.I64) {
                this.timestamp = iprot.readI64();
                setTimestampIsSet(true);
            } else {
                TProtocolUtil.skip(iprot, field.type);
            }
            break;
        default:
            TProtocolUtil.skip(iprot, field.type);
        }
        iprot.readFieldEnd();
    }
    iprot.readStructEnd();

    // check for required fields of primitive type, which can't be checked in the validate method
    if (!isSetTimestamp()) {
        throw new TProtocolException(
                "Required field 'timestamp' was not found in serialized data! Struct: " + toString());
    }
    validate();
}

From source file:com.bigdata.dastor.thrift.Deletion.java

License:Apache License

public void read(TProtocol iprot) throws TException {
    TField field;/* www  .j av  a2  s.co m*/
    iprot.readStructBegin();
    while (true) {
        field = iprot.readFieldBegin();
        if (field.type == TType.STOP) {
            break;
        }
        switch (field.id) {
        case 1: // TIMESTAMP
            if (field.type == TType.I64) {
                this.timestamp = iprot.readI64();
                setTimestampIsSet(true);
            } else {
                TProtocolUtil.skip(iprot, field.type);
            }
            break;
        case 2: // SUPER_COLUMN
            if (field.type == TType.STRING) {
                this.super_column = iprot.readBinary();
            } else {
                TProtocolUtil.skip(iprot, field.type);
            }
            break;
        case 3: // PREDICATE
            if (field.type == TType.STRUCT) {
                this.predicate = new SlicePredicate();
                this.predicate.read(iprot);
            } else {
                TProtocolUtil.skip(iprot, field.type);
            }
            break;
        default:
            TProtocolUtil.skip(iprot, field.type);
        }
        iprot.readFieldEnd();
    }
    iprot.readStructEnd();

    // check for required fields of primitive type, which can't be checked in the validate method
    if (!isSetTimestamp()) {
        throw new TProtocolException(
                "Required field 'timestamp' was not found in serialized data! Struct: " + toString());
    }
    validate();
}

From source file:com.cloudera.flume.handlers.thrift.ThriftFlumeEvent.java

License:Apache License

public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
    org.apache.thrift.protocol.TField field;
    iprot.readStructBegin();//from w  ww.j av  a2  s.c  om
    while (true) {
        field = iprot.readFieldBegin();
        if (field.type == org.apache.thrift.protocol.TType.STOP) {
            break;
        }
        switch (field.id) {
        case 1: // TIMESTAMP
            if (field.type == org.apache.thrift.protocol.TType.I64) {
                this.timestamp = iprot.readI64();
                setTimestampIsSet(true);
            } else {
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
            }
            break;
        case 2: // PRIORITY
            if (field.type == org.apache.thrift.protocol.TType.I32) {
                this.priority = Priority.findByValue(iprot.readI32());
            } else {
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
            }
            break;
        case 3: // BODY
            if (field.type == org.apache.thrift.protocol.TType.STRING) {
                this.body = iprot.readBinary();
            } else {
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
            }
            break;
        case 4: // NANOS
            if (field.type == org.apache.thrift.protocol.TType.I64) {
                this.nanos = iprot.readI64();
                setNanosIsSet(true);
            } else {
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
            }
            break;
        case 5: // HOST
            if (field.type == org.apache.thrift.protocol.TType.STRING) {
                this.host = iprot.readString();
            } else {
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
            }
            break;
        case 6: // FIELDS
            if (field.type == org.apache.thrift.protocol.TType.MAP) {
                {
                    org.apache.thrift.protocol.TMap _map0 = iprot.readMapBegin();
                    this.fields = new HashMap<String, ByteBuffer>(2 * _map0.size);
                    for (int _i1 = 0; _i1 < _map0.size; ++_i1) {
                        String _key2;
                        ByteBuffer _val3;
                        _key2 = iprot.readString();
                        _val3 = iprot.readBinary();
                        this.fields.put(_key2, _val3);
                    }
                    iprot.readMapEnd();
                }
            } else {
                org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
            }
            break;
        default:
            org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);
        }
        iprot.readFieldEnd();
    }
    iprot.readStructEnd();

    // check for required fields of primitive type, which can't be checked in the validate method
    validate();
}

From source file:com.ebay.nest.io.sede.dynamic_type.DynamicSerDeTypei64.java

License:Apache License

@Override
public Object deserialize(Object reuse, TProtocol iprot)
        throws SerDeException, TException, IllegalAccessException {
    long val = iprot.readI64();
    if (val == 0 && iprot instanceof com.ebay.nest.io.sede.thrift.WriteNullsProtocol
            && ((com.ebay.nest.io.sede.thrift.WriteNullsProtocol) iprot).lastPrimitiveWasNull()) {
        return null;
    }//  w w w .  jav  a  2 s  . c  o  m
    return Long.valueOf(val);
}