Example usage for org.apache.thrift.transport TMemoryInputTransport close

List of usage examples for org.apache.thrift.transport TMemoryInputTransport close

Introduction

In this page you can find the example usage for org.apache.thrift.transport TMemoryInputTransport close.

Prototype

@Override
    public void close() 

Source Link

Usage

From source file:com.nearinfinity.blur.analysis.BlurAnalyzer.java

License:Apache License

public static BlurAnalyzer create(InputStream inputStream) throws IOException {
    TMemoryInputTransport trans = new TMemoryInputTransport(getBytes(inputStream));
    TJSONProtocol protocol = new TJSONProtocol(trans);
    AnalyzerDefinition analyzerDefinition = new AnalyzerDefinition();
    try {/*w ww. j av  a2 s.c  om*/
        analyzerDefinition.read(protocol);
    } catch (TException e) {
        throw new RuntimeException(e);
    }
    trans.close();
    return new BlurAnalyzer(analyzerDefinition);
}

From source file:com.nearinfinity.blur.manager.clusterstatus.ZookeeperClusterStatus.java

License:Apache License

@SuppressWarnings("unchecked")
private <T extends TBase<?, ?>> T fromBytes(byte[] data, Class<T> clazz) {
    try {/*from  w ww  .  j a  v a2  s.  c  o  m*/
        if (data == null) {
            return null;
        }
        TBase<?, ?> base = clazz.newInstance();
        TMemoryInputTransport trans = new TMemoryInputTransport(data);
        TJSONProtocol protocol = new TJSONProtocol(trans);
        base.read(protocol);
        trans.close();
        return (T) base;
    } catch (InstantiationException e) {
        throw new RuntimeException(e);
    } catch (IllegalAccessException e) {
        throw new RuntimeException(e);
    } catch (TException e) {
        throw new RuntimeException(e);
    }
}