Search in sources :

Example 26 with TSocket

use of org.apache.thrift.transport.TSocket in project metacat by Netflix.

the class CatalogThriftEventHandler method createContext.

/**
 * {@inheritDoc}
 */
@Override
public ServerContext createContext(final TProtocol input, final TProtocol output) {
    final String userName = "metacat-thrift-interface";
    // requestContext.getHeaderString("X-Forwarded-For");
    String clientHost = null;
    final long requestThreadId = Thread.currentThread().getId();
    final TTransport transport = input.getTransport();
    if (transport instanceof TSocket) {
        final TSocket thriftSocket = (TSocket) transport;
        clientHost = thriftSocket.getSocket().getInetAddress().getHostAddress();
    }
    final CatalogServerRequestContext context = new CatalogServerRequestContext(userName, null, clientHost, null, "hive", requestThreadId);
    MetacatContextManager.setContext(context);
    return context;
}
Also used : TTransport(org.apache.thrift.transport.TTransport) TSocket(org.apache.thrift.transport.TSocket)

Example 27 with TSocket

use of org.apache.thrift.transport.TSocket in project hive by apache.

the class SecurityUtils method getSSLSocket.

public static TTransport getSSLSocket(String host, int port, int loginTimeout, String trustStorePath, String trustStorePassWord) throws TTransportException {
    TSSLTransportFactory.TSSLTransportParameters params = new TSSLTransportFactory.TSSLTransportParameters();
    params.setTrustStore(trustStorePath, trustStorePassWord);
    params.requireClientAuth(true);
    // The underlying SSLSocket object is bound to host:port with the given SO_TIMEOUT and
    // SSLContext created with the given params
    TSocket tSSLSocket = TSSLTransportFactory.getClientSocket(host, port, loginTimeout, params);
    return getSSLSocketWithHttps(tSSLSocket);
}
Also used : TSSLTransportFactory(org.apache.thrift.transport.TSSLTransportFactory) TSocket(org.apache.thrift.transport.TSocket)

Example 28 with TSocket

use of org.apache.thrift.transport.TSocket in project vcell by virtualcell.

the class SimpleClient method main.

public static void main(String[] args) {
    try {
        TTransport transport;
        transport = new TSocket("localhost", 9091);
        transport.open();
        TProtocol protocol = new TBinaryProtocol(transport);
        SimulationService.Client client = new SimulationService.Client(protocol);
        perform(client);
        transport.close();
    } catch (TException x) {
        x.printStackTrace();
    }
}
Also used : TException(org.apache.thrift.TException) TBinaryProtocol(org.apache.thrift.protocol.TBinaryProtocol) TProtocol(org.apache.thrift.protocol.TProtocol) TTransport(org.apache.thrift.transport.TTransport) SimulationService(org.vcell.vcellij.api.SimulationService) TSocket(org.apache.thrift.transport.TSocket)

Example 29 with TSocket

use of org.apache.thrift.transport.TSocket in project vcell by virtualcell.

the class BioformatsImageDatasetReader method readImageDatasetChannels.

@Override
public ImageDataset[] readImageDatasetChannels(String imageID, ClientTaskStatusSupport status, boolean bMergeChannels, Integer timeIndex, ISize resize) throws Exception {
    try (TTransport transport = new TSocket("localhost", port)) {
        transport.open();
        TProtocol protocol = new TBinaryProtocol(transport);
        ImageDatasetService.Client client = new ImageDatasetService.Client(protocol);
        String fileName = imageID;
        org.vcell.imagedataset.ISize t_resize = null;
        if (resize != null) {
            t_resize = new org.vcell.imagedataset.ISize(resize.getX(), resize.getY(), resize.getZ());
        }
        List<org.vcell.imagedataset.ImageDataset> t_imageDatasetList = client.readImageDatasetChannels(fileName, bMergeChannels, timeIndex, t_resize);
        ImageDataset[] imageDatasets = new ImageDataset[t_imageDatasetList.size()];
        for (int i = 0; i < t_imageDatasetList.size(); i++) {
            imageDatasets[i] = getImageDataset(t_imageDatasetList.get(i));
        }
        return imageDatasets;
    }
}
Also used : ImageDataset(cbit.vcell.VirtualMicroscopy.ImageDataset) ImageDatasetService(org.vcell.imagedataset.ImageDatasetService) TBinaryProtocol(org.apache.thrift.protocol.TBinaryProtocol) TProtocol(org.apache.thrift.protocol.TProtocol) TTransport(org.apache.thrift.transport.TTransport) TSocket(org.apache.thrift.transport.TSocket)

Example 30 with TSocket

use of org.apache.thrift.transport.TSocket in project vcell by virtualcell.

the class BioformatsImageDatasetReader method readImageDataset.

@Override
public ImageDataset readImageDataset(String imageID, ClientTaskStatusSupport status) throws Exception {
    try (TTransport transport = new TSocket("localhost", port)) {
        transport.open();
        TProtocol protocol = new TBinaryProtocol(transport);
        ImageDatasetService.Client client = new ImageDatasetService.Client(protocol);
        String fileName = imageID;
        org.vcell.imagedataset.ImageDataset t_imageDataset = client.readImageDataset(fileName);
        ImageDataset imageDataset = getImageDataset(t_imageDataset);
        return imageDataset;
    }
}
Also used : ImageDatasetService(org.vcell.imagedataset.ImageDatasetService) TBinaryProtocol(org.apache.thrift.protocol.TBinaryProtocol) ImageDataset(cbit.vcell.VirtualMicroscopy.ImageDataset) TProtocol(org.apache.thrift.protocol.TProtocol) TTransport(org.apache.thrift.transport.TTransport) TSocket(org.apache.thrift.transport.TSocket)

Aggregations

TSocket (org.apache.thrift.transport.TSocket)66 TTransport (org.apache.thrift.transport.TTransport)43 TBinaryProtocol (org.apache.thrift.protocol.TBinaryProtocol)41 TProtocol (org.apache.thrift.protocol.TProtocol)36 TFramedTransport (org.apache.thrift.transport.TFramedTransport)33 IOException (java.io.IOException)16 TException (org.apache.thrift.TException)16 TTransportException (org.apache.thrift.transport.TTransportException)15 TCompactProtocol (org.apache.thrift.protocol.TCompactProtocol)9 Cassandra (org.apache.cassandra.thrift.Cassandra)5 ImageDatasetService (org.vcell.imagedataset.ImageDatasetService)5 Socket (java.net.Socket)4 SocketException (java.net.SocketException)4 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 Hello (org.tech.model.Hello)4 ImageDataset (cbit.vcell.VirtualMicroscopy.ImageDataset)3 ByteBuffer (java.nio.ByteBuffer)3 SSLSocket (javax.net.ssl.SSLSocket)3 TBinaryProtocol (org.apache.cassandra.thrift.TBinaryProtocol)3