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

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

Introduction

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

Prototype

public void writeI64(Long i64) throws TException 

Source Link

Usage

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

License:Apache License

public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
    validate();/*from w w w.  j  a v  a 2 s .co  m*/

    oprot.writeStructBegin(STRUCT_DESC);
    if (this.acked != null) {
        oprot.writeFieldBegin(ACKED_FIELD_DESC);
        {
            oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING,
                    org.apache.thrift.protocol.TType.MAP, this.acked.size()));
            for (Map.Entry<String, Map<GlobalStreamId, Long>> _iter85 : this.acked.entrySet()) {
                oprot.writeString(_iter85.getKey());
                {
                    oprot.writeMapBegin(
                            new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRUCT,
                                    org.apache.thrift.protocol.TType.I64, _iter85.getValue().size()));
                    for (Map.Entry<GlobalStreamId, Long> _iter86 : _iter85.getValue().entrySet()) {
                        _iter86.getKey().write(oprot);
                        oprot.writeI64(_iter86.getValue());
                    }
                    oprot.writeMapEnd();
                }
            }
            oprot.writeMapEnd();
        }
        oprot.writeFieldEnd();
    }
    if (this.failed != null) {
        oprot.writeFieldBegin(FAILED_FIELD_DESC);
        {
            oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING,
                    org.apache.thrift.protocol.TType.MAP, this.failed.size()));
            for (Map.Entry<String, Map<GlobalStreamId, Long>> _iter87 : this.failed.entrySet()) {
                oprot.writeString(_iter87.getKey());
                {
                    oprot.writeMapBegin(
                            new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRUCT,
                                    org.apache.thrift.protocol.TType.I64, _iter87.getValue().size()));
                    for (Map.Entry<GlobalStreamId, Long> _iter88 : _iter87.getValue().entrySet()) {
                        _iter88.getKey().write(oprot);
                        oprot.writeI64(_iter88.getValue());
                    }
                    oprot.writeMapEnd();
                }
            }
            oprot.writeMapEnd();
        }
        oprot.writeFieldEnd();
    }
    if (this.process_ms_avg != null) {
        oprot.writeFieldBegin(PROCESS_MS_AVG_FIELD_DESC);
        {
            oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING,
                    org.apache.thrift.protocol.TType.MAP, this.process_ms_avg.size()));
            for (Map.Entry<String, Map<GlobalStreamId, Double>> _iter89 : this.process_ms_avg.entrySet()) {
                oprot.writeString(_iter89.getKey());
                {
                    oprot.writeMapBegin(
                            new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRUCT,
                                    org.apache.thrift.protocol.TType.DOUBLE, _iter89.getValue().size()));
                    for (Map.Entry<GlobalStreamId, Double> _iter90 : _iter89.getValue().entrySet()) {
                        _iter90.getKey().write(oprot);
                        oprot.writeDouble(_iter90.getValue());
                    }
                    oprot.writeMapEnd();
                }
            }
            oprot.writeMapEnd();
        }
        oprot.writeFieldEnd();
    }
    if (this.executed != null) {
        oprot.writeFieldBegin(EXECUTED_FIELD_DESC);
        {
            oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING,
                    org.apache.thrift.protocol.TType.MAP, this.executed.size()));
            for (Map.Entry<String, Map<GlobalStreamId, Long>> _iter91 : this.executed.entrySet()) {
                oprot.writeString(_iter91.getKey());
                {
                    oprot.writeMapBegin(
                            new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRUCT,
                                    org.apache.thrift.protocol.TType.I64, _iter91.getValue().size()));
                    for (Map.Entry<GlobalStreamId, Long> _iter92 : _iter91.getValue().entrySet()) {
                        _iter92.getKey().write(oprot);
                        oprot.writeI64(_iter92.getValue());
                    }
                    oprot.writeMapEnd();
                }
            }
            oprot.writeMapEnd();
        }
        oprot.writeFieldEnd();
    }
    if (this.execute_ms_avg != null) {
        oprot.writeFieldBegin(EXECUTE_MS_AVG_FIELD_DESC);
        {
            oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING,
                    org.apache.thrift.protocol.TType.MAP, this.execute_ms_avg.size()));
            for (Map.Entry<String, Map<GlobalStreamId, Double>> _iter93 : this.execute_ms_avg.entrySet()) {
                oprot.writeString(_iter93.getKey());
                {
                    oprot.writeMapBegin(
                            new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRUCT,
                                    org.apache.thrift.protocol.TType.DOUBLE, _iter93.getValue().size()));
                    for (Map.Entry<GlobalStreamId, Double> _iter94 : _iter93.getValue().entrySet()) {
                        _iter94.getKey().write(oprot);
                        oprot.writeDouble(_iter94.getValue());
                    }
                    oprot.writeMapEnd();
                }
            }
            oprot.writeMapEnd();
        }
        oprot.writeFieldEnd();
    }
    oprot.writeFieldStop();
    oprot.writeStructEnd();
}

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

License:Apache License

public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
    validate();/* ww  w  . ja  v  a  2s  .  c o m*/

    oprot.writeStructBegin(STRUCT_DESC);
    if (this.emitted != null) {
        oprot.writeFieldBegin(EMITTED_FIELD_DESC);
        {
            oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING,
                    org.apache.thrift.protocol.TType.MAP, this.emitted.size()));
            for (Map.Entry<String, Map<String, Long>> _iter141 : this.emitted.entrySet()) {
                oprot.writeString(_iter141.getKey());
                {
                    oprot.writeMapBegin(
                            new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING,
                                    org.apache.thrift.protocol.TType.I64, _iter141.getValue().size()));
                    for (Map.Entry<String, Long> _iter142 : _iter141.getValue().entrySet()) {
                        oprot.writeString(_iter142.getKey());
                        oprot.writeI64(_iter142.getValue());
                    }
                    oprot.writeMapEnd();
                }
            }
            oprot.writeMapEnd();
        }
        oprot.writeFieldEnd();
    }
    if (this.transferred != null) {
        oprot.writeFieldBegin(TRANSFERRED_FIELD_DESC);
        {
            oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING,
                    org.apache.thrift.protocol.TType.MAP, this.transferred.size()));
            for (Map.Entry<String, Map<String, Long>> _iter143 : this.transferred.entrySet()) {
                oprot.writeString(_iter143.getKey());
                {
                    oprot.writeMapBegin(
                            new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING,
                                    org.apache.thrift.protocol.TType.I64, _iter143.getValue().size()));
                    for (Map.Entry<String, Long> _iter144 : _iter143.getValue().entrySet()) {
                        oprot.writeString(_iter144.getKey());
                        oprot.writeI64(_iter144.getValue());
                    }
                    oprot.writeMapEnd();
                }
            }
            oprot.writeMapEnd();
        }
        oprot.writeFieldEnd();
    }
    if (this.specific != null) {
        oprot.writeFieldBegin(SPECIFIC_FIELD_DESC);
        this.specific.write(oprot);
        oprot.writeFieldEnd();
    }
    oprot.writeFieldStop();
    oprot.writeStructEnd();
}

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

License:Apache License

@Override
protected void writeValue(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
    switch (setField_) {
    case INT_ARG:
        Integer int_arg = (Integer) value_;
        oprot.writeI32(int_arg);
        return;/*w ww. j  av  a2s .  c  o m*/
    case LONG_ARG:
        Long long_arg = (Long) value_;
        oprot.writeI64(long_arg);
        return;
    case STRING_ARG:
        String string_arg = (String) value_;
        oprot.writeString(string_arg);
        return;
    case BOOL_ARG:
        Boolean bool_arg = (Boolean) value_;
        oprot.writeBool(bool_arg);
        return;
    case BINARY_ARG:
        ByteBuffer binary_arg = (ByteBuffer) value_;
        oprot.writeBinary(binary_arg);
        return;
    case DOUBLE_ARG:
        Double double_arg = (Double) value_;
        oprot.writeDouble(double_arg);
        return;
    default:
        throw new IllegalStateException("Cannot write union with unknown field " + setField_);
    }
}

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

License:Apache License

public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
    validate();/*  ww w  .ja v  a  2s.c om*/

    oprot.writeStructBegin(STRUCT_DESC);
    if (this.acked != null) {
        oprot.writeFieldBegin(ACKED_FIELD_DESC);
        {
            oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING,
                    org.apache.thrift.protocol.TType.MAP, this.acked.size()));
            for (Map.Entry<String, Map<String, Long>> _iter119 : this.acked.entrySet()) {
                oprot.writeString(_iter119.getKey());
                {
                    oprot.writeMapBegin(
                            new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING,
                                    org.apache.thrift.protocol.TType.I64, _iter119.getValue().size()));
                    for (Map.Entry<String, Long> _iter120 : _iter119.getValue().entrySet()) {
                        oprot.writeString(_iter120.getKey());
                        oprot.writeI64(_iter120.getValue());
                    }
                    oprot.writeMapEnd();
                }
            }
            oprot.writeMapEnd();
        }
        oprot.writeFieldEnd();
    }
    if (this.failed != null) {
        oprot.writeFieldBegin(FAILED_FIELD_DESC);
        {
            oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING,
                    org.apache.thrift.protocol.TType.MAP, this.failed.size()));
            for (Map.Entry<String, Map<String, Long>> _iter121 : this.failed.entrySet()) {
                oprot.writeString(_iter121.getKey());
                {
                    oprot.writeMapBegin(
                            new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING,
                                    org.apache.thrift.protocol.TType.I64, _iter121.getValue().size()));
                    for (Map.Entry<String, Long> _iter122 : _iter121.getValue().entrySet()) {
                        oprot.writeString(_iter122.getKey());
                        oprot.writeI64(_iter122.getValue());
                    }
                    oprot.writeMapEnd();
                }
            }
            oprot.writeMapEnd();
        }
        oprot.writeFieldEnd();
    }
    if (this.complete_ms_avg != null) {
        oprot.writeFieldBegin(COMPLETE_MS_AVG_FIELD_DESC);
        {
            oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING,
                    org.apache.thrift.protocol.TType.MAP, this.complete_ms_avg.size()));
            for (Map.Entry<String, Map<String, Double>> _iter123 : this.complete_ms_avg.entrySet()) {
                oprot.writeString(_iter123.getKey());
                {
                    oprot.writeMapBegin(
                            new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING,
                                    org.apache.thrift.protocol.TType.DOUBLE, _iter123.getValue().size()));
                    for (Map.Entry<String, Double> _iter124 : _iter123.getValue().entrySet()) {
                        oprot.writeString(_iter124.getKey());
                        oprot.writeDouble(_iter124.getValue());
                    }
                    oprot.writeMapEnd();
                }
            }
            oprot.writeMapEnd();
        }
        oprot.writeFieldEnd();
    }
    oprot.writeFieldStop();
    oprot.writeStructEnd();
}

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;
    }/*  w w w .  ja v a  2 s  .c o 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.baidu.oped.apm.common.util.ByteSizeTest.java

License:Apache License

@Test
public void test() throws TException {
    TCompactProtocol.Factory factory = new TCompactProtocol.Factory();

    ByteArrayOutputStream baos = new ByteArrayOutputStream(16);
    TIOStreamTransport transport = new TIOStreamTransport(baos);
    TProtocol protocol = factory.getProtocol(transport);

    long l = TimeUnit.DAYS.toMillis(1);
    logger.debug("day:{}", l);
    long currentTime = System.currentTimeMillis();
    logger.debug("currentTime:{}" + currentTime);
    protocol.writeI64(l);
    byte[] buffer = baos.toByteArray();
    logger.debug("{}", buffer.length);

}

From source file:com.baidu.oped.apm.plugin.thrift.ThriftRequestProperty.java

License:Apache License

public void writeTraceHeader(ThriftHeader headerKey, TProtocol oprot) throws TException {
    Object headerValue = this.thriftHeaders.get(headerKey);
    if (headerValue == null) {
        return;//from  w  w w  .j  av a 2  s. co  m
    }
    byte headerType = headerKey.getType();
    TField traceField = new TField(headerKey.name(), headerKey.getType(), headerKey.getId());
    oprot.writeFieldBegin(traceField);
    try {
        if (headerType == TType.STRING) {
            // these will be read as byte buffer although it's probably safe to just use writeString here.
            // see org.apache.thrift.protocol.TProtocolUtil.skip(TProtocol, byte, int)
            oprot.writeBinary(stringToByteBuffer((String) headerValue));
        } else if (headerType == TType.I64) {
            oprot.writeI64((Long) headerValue);
        } else if (headerType == TType.I16) {
            oprot.writeI16((Short) headerValue);
        } else if (headerType == TType.BOOL) {
            oprot.writeBool((Boolean) headerValue);
        } else {
            throw new TProtocolException("Invalid apm header type - " + headerType);
        }
    } finally {
        oprot.writeFieldEnd();
    }
}

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

License:Apache License

public void write(TProtocol oprot) throws TException {
    validate();// w  ww. java  2s .c  o m

    oprot.writeStructBegin(STRUCT_DESC);
    if (this.name != null) {
        oprot.writeFieldBegin(NAME_FIELD_DESC);
        oprot.writeBinary(this.name);
        oprot.writeFieldEnd();
    }
    if (this.value != null) {
        oprot.writeFieldBegin(VALUE_FIELD_DESC);
        oprot.writeBinary(this.value);
        oprot.writeFieldEnd();
    }
    oprot.writeFieldBegin(TIMESTAMP_FIELD_DESC);
    oprot.writeI64(this.timestamp);
    oprot.writeFieldEnd();
    oprot.writeFieldStop();
    oprot.writeStructEnd();
}

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

License:Apache License

public void write(TProtocol oprot) throws TException {
    validate();/*from   w  w  w.  j a v a 2 s.  com*/

    oprot.writeStructBegin(STRUCT_DESC);
    oprot.writeFieldBegin(TIMESTAMP_FIELD_DESC);
    oprot.writeI64(this.timestamp);
    oprot.writeFieldEnd();
    if (this.super_column != null) {
        if (isSetSuper_column()) {
            oprot.writeFieldBegin(SUPER_COLUMN_FIELD_DESC);
            oprot.writeBinary(this.super_column);
            oprot.writeFieldEnd();
        }
    }
    if (this.predicate != null) {
        if (isSetPredicate()) {
            oprot.writeFieldBegin(PREDICATE_FIELD_DESC);
            this.predicate.write(oprot);
            oprot.writeFieldEnd();
        }
    }
    oprot.writeFieldStop();
    oprot.writeStructEnd();
}

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

License:Apache License

public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
    validate();/* ww w .j  ava2 s.c  o  m*/

    oprot.writeStructBegin(STRUCT_DESC);
    oprot.writeFieldBegin(TIMESTAMP_FIELD_DESC);
    oprot.writeI64(this.timestamp);
    oprot.writeFieldEnd();
    if (this.priority != null) {
        oprot.writeFieldBegin(PRIORITY_FIELD_DESC);
        oprot.writeI32(this.priority.getValue());
        oprot.writeFieldEnd();
    }
    if (this.body != null) {
        oprot.writeFieldBegin(BODY_FIELD_DESC);
        oprot.writeBinary(this.body);
        oprot.writeFieldEnd();
    }
    oprot.writeFieldBegin(NANOS_FIELD_DESC);
    oprot.writeI64(this.nanos);
    oprot.writeFieldEnd();
    if (this.host != null) {
        oprot.writeFieldBegin(HOST_FIELD_DESC);
        oprot.writeString(this.host);
        oprot.writeFieldEnd();
    }
    if (this.fields != null) {
        oprot.writeFieldBegin(FIELDS_FIELD_DESC);
        {
            oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING,
                    org.apache.thrift.protocol.TType.STRING, this.fields.size()));
            for (Map.Entry<String, ByteBuffer> _iter4 : this.fields.entrySet()) {
                oprot.writeString(_iter4.getKey());
                oprot.writeBinary(_iter4.getValue());
            }
            oprot.writeMapEnd();
        }
        oprot.writeFieldEnd();
    }
    oprot.writeFieldStop();
    oprot.writeStructEnd();
}