Java Code Examples for org.apache.thrift.transport.TMemoryBuffer#flush()

The following examples show how to use org.apache.thrift.transport.TMemoryBuffer#flush() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ServerLoad.java    From distributedlog with Apache License 2.0 5 votes vote down vote up
public byte[] serialize() throws IOException {
    TMemoryBuffer transport = new TMemoryBuffer(BUFFER_SIZE);
    TJSONProtocol protocol = new TJSONProtocol(transport);
    try {
        toThrift().write(protocol);
        transport.flush();
        return transport.toString(UTF_8.name()).getBytes(UTF_8);
    } catch (TException e) {
        throw new IOException("Failed to serialize server load : ", e);
    } catch (UnsupportedEncodingException uee) {
        throw new IOException("Failed to serialize server load : ", uee);
    }
}
 
Example 2
Source File: StreamLoad.java    From distributedlog with Apache License 2.0 5 votes vote down vote up
public byte[] serialize() throws IOException {
    TMemoryBuffer transport = new TMemoryBuffer(BUFFER_SIZE);
    TJSONProtocol protocol = new TJSONProtocol(transport);
    try {
        toThrift().write(protocol);
        transport.flush();
        return transport.toString(UTF_8.name()).getBytes(UTF_8);
    } catch (TException e) {
        throw new IOException("Failed to serialize stream load : ", e);
    } catch (UnsupportedEncodingException uee) {
        throw new IOException("Failed to serialize stream load : ", uee);
    }
}
 
Example 3
Source File: ZKAccessControl.java    From distributedlog with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example 4
Source File: ZKAccessControl.java    From distributedlog with Apache License 2.0 5 votes vote down vote up
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);
    }
}