Search in sources :

Example 1 with TMemoryInputTransport

use of org.apache.thrift.transport.TMemoryInputTransport in project jena by apache.

the class ThriftConverter method fromBytes.

public static void fromBytes(byte[] buffer, RDF_Quad quad) throws TException {
    TMemoryInputTransport transport = getInputTransport();
    transport.reset(buffer);
    TProtocol protocol = getInputProtocol();
    quad.read(protocol);
}
Also used : TProtocol(org.apache.thrift.protocol.TProtocol) TMemoryInputTransport(org.apache.thrift.transport.TMemoryInputTransport)

Example 2 with TMemoryInputTransport

use of org.apache.thrift.transport.TMemoryInputTransport in project jena by apache.

the class ThriftConverter method fromBytes.

public static void fromBytes(byte[] buffer, RDF_Triple triple) throws TException {
    TMemoryInputTransport transport = getInputTransport();
    transport.reset(buffer);
    TProtocol protocol = getInputProtocol();
    triple.read(protocol);
}
Also used : TProtocol(org.apache.thrift.protocol.TProtocol) TMemoryInputTransport(org.apache.thrift.transport.TMemoryInputTransport)

Example 3 with TMemoryInputTransport

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

the class BKDLConfig method deserialize.

@Override
public void deserialize(byte[] data) throws IOException {
    BKDLConfigFormat configFormat = new BKDLConfigFormat();
    TMemoryInputTransport transport = new TMemoryInputTransport(data);
    TJSONProtocol protocol = new TJSONProtocol(transport);
    try {
        configFormat.read(protocol);
    } catch (TException e) {
        throw new IOException("Failed to deserialize data '" + new String(data, UTF_8) + "' : ", e);
    }
    // bookkeeper cluster settings
    if (configFormat.isSetBkZkServers()) {
        bkZkServersForWriter = configFormat.getBkZkServers();
    }
    if (configFormat.isSetBkZkServersForReader()) {
        bkZkServersForReader = configFormat.getBkZkServersForReader();
    } else {
        bkZkServersForReader = bkZkServersForWriter;
    }
    if (configFormat.isSetBkLedgersPath()) {
        bkLedgersPath = configFormat.getBkLedgersPath();
    }
    // dl zookeeper cluster settings
    if (configFormat.isSetDlZkServersForWriter()) {
        dlZkServersForWriter = configFormat.getDlZkServersForWriter();
    }
    if (configFormat.isSetDlZkServersForReader()) {
        dlZkServersForReader = configFormat.getDlZkServersForReader();
    } else {
        dlZkServersForReader = dlZkServersForWriter;
    }
    // dl settings
    sanityCheckTxnID = !configFormat.isSetSanityCheckTxnID() || configFormat.isSanityCheckTxnID();
    encodeRegionID = configFormat.isSetEncodeRegionID() && configFormat.isEncodeRegionID();
    if (configFormat.isSetAclRootPath()) {
        aclRootPath = configFormat.getAclRootPath();
    }
    if (configFormat.isSetFirstLogSegmentSeqNo()) {
        firstLogSegmentSeqNo = configFormat.getFirstLogSegmentSeqNo();
    }
    isFederatedNamespace = configFormat.isSetFederatedNamespace() && configFormat.isFederatedNamespace();
    // Validate the settings
    if (null == bkZkServersForWriter || null == bkZkServersForReader || null == bkLedgersPath || null == dlZkServersForWriter || null == dlZkServersForReader) {
        throw new IOException("Missing zk/bk settings in BKDL Config : " + new String(data, UTF_8));
    }
}
Also used : TException(org.apache.thrift.TException) TJSONProtocol(org.apache.thrift.protocol.TJSONProtocol) BKDLConfigFormat(com.twitter.distributedlog.thrift.BKDLConfigFormat) IOException(java.io.IOException) TMemoryInputTransport(org.apache.thrift.transport.TMemoryInputTransport)

Example 4 with TMemoryInputTransport

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

the class ZKAccessControl method deserialize.

static AccessControlEntry deserialize(String zkPath, byte[] data) throws IOException {
    if (data.length == 0) {
        return DEFAULT_ACCESS_CONTROL_ENTRY;
    }
    AccessControlEntry ace = new AccessControlEntry();
    TMemoryInputTransport transport = new TMemoryInputTransport(data);
    TJSONProtocol protocol = new TJSONProtocol(transport);
    try {
        ace.read(protocol);
    } catch (TException e) {
        throw new CorruptedAccessControlException(zkPath, e);
    }
    return ace;
}
Also used : TException(org.apache.thrift.TException) TJSONProtocol(org.apache.thrift.protocol.TJSONProtocol) AccessControlEntry(com.twitter.distributedlog.thrift.AccessControlEntry) TMemoryInputTransport(org.apache.thrift.transport.TMemoryInputTransport)

Example 5 with TMemoryInputTransport

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

the class Utils method parseMessage.

public static Message parseMessage(byte[] data) throws TException {
    Message msg = new Message();
    TMemoryInputTransport transport = new TMemoryInputTransport(data);
    TBinaryProtocol protocol = new TBinaryProtocol(transport);
    msg.read(protocol);
    return msg;
}
Also used : Message(com.twitter.distributedlog.benchmark.thrift.Message) TBinaryProtocol(org.apache.thrift.protocol.TBinaryProtocol) TMemoryInputTransport(org.apache.thrift.transport.TMemoryInputTransport)

Aggregations

TMemoryInputTransport (org.apache.thrift.transport.TMemoryInputTransport)7 TProtocol (org.apache.thrift.protocol.TProtocol)3 TException (org.apache.thrift.TException)2 TJSONProtocol (org.apache.thrift.protocol.TJSONProtocol)2 Message (com.twitter.distributedlog.benchmark.thrift.Message)1 AccessControlEntry (com.twitter.distributedlog.thrift.AccessControlEntry)1 BKDLConfigFormat (com.twitter.distributedlog.thrift.BKDLConfigFormat)1 IOException (java.io.IOException)1 TBinaryProtocol (org.apache.thrift.protocol.TBinaryProtocol)1