Search in sources :

Example 11 with TMemoryBuffer

use of org.apache.thrift.transport.TMemoryBuffer in project pinpoint by naver.

the class BytesUtilsTest method compactProtocolVint.

@Test
public void compactProtocolVint() throws TException {
    TMemoryBuffer tMemoryBuffer = writeVInt32(BytesUtils.zigzagToInt(64));
    logger.trace("length:{}", tMemoryBuffer.length());
    TMemoryBuffer tMemoryBuffer2 = writeVInt32(64);
    logger.trace("length:{}", tMemoryBuffer2.length());
}
Also used : TMemoryBuffer(org.apache.thrift.transport.TMemoryBuffer) Test(org.junit.Test)

Example 12 with TMemoryBuffer

use of org.apache.thrift.transport.TMemoryBuffer in project distributedlog by twitter.

the class ZKAccessControl method serialize.

static byte[] serialize(AccessControlEntry ace) throws IOException {
    TMemoryBuffer transport = new TMemoryBuffer(BUFFER_SIZE);
    TJSONProtocol protocol = new TJSONProtocol(transport);
    try {
        ace.write(protocol);
        transport.flush();
        return transport.toString(UTF_8.name()).getBytes(UTF_8);
    } catch (TException e) {
        throw new IOException("Failed to serialize access control entry : ", e);
    } catch (UnsupportedEncodingException uee) {
        throw new IOException("Failed to serialize acesss control entry : ", uee);
    }
}
Also used : TException(org.apache.thrift.TException) TJSONProtocol(org.apache.thrift.protocol.TJSONProtocol) TMemoryBuffer(org.apache.thrift.transport.TMemoryBuffer) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IOException(java.io.IOException)

Aggregations

TMemoryBuffer (org.apache.thrift.transport.TMemoryBuffer)12 Properties (java.util.Properties)5 Configuration (org.apache.hadoop.conf.Configuration)5 TCTLSeparatedProtocol (org.apache.hadoop.hive.serde2.thrift.TCTLSeparatedProtocol)5 TException (org.apache.thrift.TException)4 TField (org.apache.thrift.protocol.TField)3 TJSONProtocol (org.apache.thrift.protocol.TJSONProtocol)3 TMap (org.apache.thrift.protocol.TMap)3 TStruct (org.apache.thrift.protocol.TStruct)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 TList (org.apache.thrift.protocol.TList)2 IOException (java.io.IOException)1 TBinaryProtocol (org.apache.thrift.protocol.TBinaryProtocol)1 TCompactProtocol (org.apache.thrift.protocol.TCompactProtocol)1 TProtocol (org.apache.thrift.protocol.TProtocol)1 TSimpleJSONProtocol (org.apache.thrift.protocol.TSimpleJSONProtocol)1 Test (org.junit.Test)1