use of org.apache.thrift.transport.TTransport 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;
}
}
use of org.apache.thrift.transport.TTransport 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;
}
}
use of org.apache.thrift.transport.TTransport in project vcell by virtualcell.
the class BioformatsImageDatasetReader method getImageSizeInfo.
@Override
public ImageSizeInfo getImageSizeInfo(String fileName) throws Exception {
try (TTransport transport = new TSocket("localhost", port)) {
transport.open();
TProtocol protocol = new TBinaryProtocol(transport);
ImageDatasetService.Client client = new ImageDatasetService.Client(protocol);
org.vcell.imagedataset.ImageSizeInfo t_imageSizeInfo = client.getImageSizeInfo(fileName);
org.vcell.imagedataset.ISize t_size = t_imageSizeInfo.getISize();
double[] timePoints = new double[t_imageSizeInfo.getTimePoints().size()];
for (int i = 0; i < t_imageSizeInfo.getTimePointsSize(); i++) {
timePoints[i] = t_imageSizeInfo.getTimePoints().get(i);
}
ImageSizeInfo imageSizeInfo = new ImageSizeInfo(t_imageSizeInfo.imagePath, new ISize(t_size.getX(), t_size.getY(), t_size.getZ()), t_imageSizeInfo.numChannels, timePoints, t_imageSizeInfo.selectedTimeIndex);
return imageSizeInfo;
}
}
use of org.apache.thrift.transport.TTransport in project janusgraph by JanusGraph.
the class ThriftConnectionTest method testConnectionDropped.
@Test
public void testConnectionDropped() throws Exception {
CTConnectionFactory connectionFactory = spy(factoryConfig.build());
CTConnection mockConnection = spy(connectionFactory.makeObject("janusgraph"));
when(mockConnection.getConfig()).thenReturn(factoryConfig);
when(mockConnection.isOpen()).thenReturn(true);
TTransport mockClient = spy(mockConnection.getTransport());
assertTrue(connectionFactory.validateObject(null, mockConnection));
when(mockClient.readAll(new byte[0], 0, 0)).thenThrow(new TTransportException("Broken Pipe"));
assertTrue(mockClient.isOpen());
}
use of org.apache.thrift.transport.TTransport in project janusgraph by JanusGraph.
the class CTConnectionFactory method makeRawConnection.
/**
* Create a Cassandra-Thrift connection, but do not attempt to
* set a keyspace on the connection.
*
* @return A CTConnection ready to talk to a Cassandra cluster
* @throws TTransportException on any Thrift transport failure
*/
public CTConnection makeRawConnection() throws TTransportException {
final Config cfg = cfgRef.get();
String hostname = cfg.getRandomHost();
log.debug("Creating TSocket({}, {}, {}, {}, {})", hostname, cfg.port, cfg.username, cfg.password, cfg.timeoutMS);
TSocket socket;
if (null != cfg.sslTruststoreLocation && !cfg.sslTruststoreLocation.isEmpty()) {
TSSLTransportFactory.TSSLTransportParameters params = new TSSLTransportFactory.TSSLTransportParameters() {
{
setTrustStore(cfg.sslTruststoreLocation, cfg.sslTruststorePassword);
}
};
socket = TSSLTransportFactory.getClientSocket(hostname, cfg.port, cfg.timeoutMS, params);
} else {
socket = new TSocket(hostname, cfg.port, cfg.timeoutMS);
}
TTransport transport = new TFramedTransport(socket, cfg.frameSize);
log.trace("Created transport {}", transport);
TBinaryProtocol protocol = new TBinaryProtocol(transport);
Cassandra.Client client = new Cassandra.Client(protocol);
if (!transport.isOpen()) {
transport.open();
}
if (cfg.username != null) {
Map<String, String> credentials = new HashMap<String, String>() {
{
put(IAuthenticator.USERNAME_KEY, cfg.username);
put(IAuthenticator.PASSWORD_KEY, cfg.password);
}
};
try {
client.login(new AuthenticationRequest(credentials));
} catch (Exception e) {
// TTransportException will propagate authentication/authorization failure
throw new TTransportException(e);
}
}
return new CTConnection(transport, client, cfg);
}
Aggregations