Java Code Examples for org.apache.thrift.transport.TFramedTransport

The following examples show how to use org.apache.thrift.transport.TFramedTransport. These examples are extracted from open source projects. 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 Project: das   Source File: DasServerManager.java    License: Apache License 2.0 6 votes vote down vote up
private boolean isAvailable(int port){
    try (TSocket transport = new TSocket("localhost", port, 5 * 1000)){
        TFramedTransport ft = new TFramedTransport(transport);
        TBinaryProtocol protocol = new TBinaryProtocol(ft);
        transport.open();

        DasCheckRequest request = new DasCheckRequest()
                .setAppId("server manager")
                .setClientAddress("")
                .setDasClientVersion("")
                .setPpdaiClientVersion("");

        DasServerStatus serverStatus =  new DasService.Client(protocol).check(request);
        return serverStatus.isOnline();
    } catch (Exception e) {
        dalLogger.error("isAvailable", e);
        logger.error(e.getMessage(), e);
        return false;
    }
}
 
Example 2
Source Project: singer   Source File: ThriftReader.java    License: Apache License 2.0 6 votes vote down vote up
public ThriftReader(
    String path,
    TBaseFactory<T> baseFactory,
    TProtocolFactory protocolFactory,
    int readBufferSize,
    int maxMessageSize) throws IOException {
  Preconditions.checkArgument(!Strings.isNullOrEmpty(path));
  Preconditions.checkNotNull(protocolFactory);

  this.byteOffsetInputStream = new ByteOffsetInputStream(
      new RandomAccessFile(path, "r"), readBufferSize);
  this.framedTransport = new TFramedTransport(new TIOStreamTransport(this
      .byteOffsetInputStream), maxMessageSize);
  this.baseFactory = Preconditions.checkNotNull(baseFactory);
  this.protocol = protocolFactory.get(this.framedTransport);
}
 
Example 3
Source Project: jigsaw-payment   Source File: AbstractTransportPool.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 根据rc的设置来确定创建什么类型的transport;
 *
 * @param instance
 * @return
 */
protected TTransport createNativeTransport(
        ServiceInstance<RpcPayload> instance) {
    TSocket socket = new TSocket(instance.getAddress(), instance.getPort());
    socket.setTimeout(socketTimeout);

    RpcPayload server = instance.getPayload();
    if ((server == null) || (server.getTransport() == null)
            || (server.getTransport().equals("socket"))) {
        return socket;
    } else if ("framed-transport".equals(server.getTransport())) {
        return new TFramedTransport(socket);
    }

    // for default, use TSocket;
    return socket;
}
 
Example 4
Source Project: drift   Source File: TestApacheThriftMethodInvoker.java    License: Apache License 2.0 6 votes vote down vote up
private static int logThrift(HostAndPort address, List<LogEntry> messages)
{
    try {
        TSocket socket = new TSocket(address.getHost(), address.getPort());
        socket.open();
        try {
            TBinaryProtocol tp = new TBinaryProtocol(new TFramedTransport(socket));
            assertEquals(new scribe.Client(tp).Log(messages), ResultCode.OK);
        }
        finally {
            socket.close();
        }
    }
    catch (TException e) {
        throw new RuntimeException(e);
    }
    return 1;
}
 
Example 5
Source Project: drift   Source File: TestDriftNettyMethodInvoker.java    License: Apache License 2.0 6 votes vote down vote up
private static List<DriftLogEntry> testMethodInvoker(ServerMethodInvoker methodInvoker)
{
    int invocationCount = testMethodInvoker(methodInvoker, ImmutableList.of(
            address -> logThrift(address, MESSAGES, new TTransportFactory(), new TBinaryProtocol.Factory()),
            address -> logThrift(address, MESSAGES, new TTransportFactory(), new TCompactProtocol.Factory()),
            address -> logThrift(address, MESSAGES, new TFramedTransport.Factory(), new TBinaryProtocol.Factory()),
            address -> logThrift(address, MESSAGES, new TFramedTransport.Factory(), new TCompactProtocol.Factory()),
            address -> logThriftAsync(address, MESSAGES),
            address -> logNiftyInvocationHandler(address, DRIFT_MESSAGES, Transport.UNFRAMED, BINARY),
            address -> logNiftyInvocationHandler(address, DRIFT_MESSAGES, Transport.UNFRAMED, Protocol.COMPACT),
            address -> logNiftyInvocationHandler(address, DRIFT_MESSAGES, Transport.UNFRAMED, Protocol.FB_COMPACT),
            address -> logNiftyInvocationHandler(address, DRIFT_MESSAGES, FRAMED, BINARY),
            address -> logNiftyInvocationHandler(address, DRIFT_MESSAGES, FRAMED, Protocol.COMPACT),
            address -> logNiftyInvocationHandler(address, DRIFT_MESSAGES, FRAMED, Protocol.FB_COMPACT),
            address -> logNiftyInvocationHandler(address, DRIFT_MESSAGES, Transport.HEADER, BINARY),
            address -> logNiftyInvocationHandler(address, DRIFT_MESSAGES, Transport.HEADER, Protocol.FB_COMPACT)));

    return newArrayList(concat(nCopies(invocationCount, DRIFT_MESSAGES)));
}
 
Example 6
Source Project: rpcx-benchmark   Source File: AppClient.java    License: Apache License 2.0 6 votes vote down vote up
public static Greeter.Client[] createClients(String host, int n, BenchmarkMessage msg) throws TException {
    TTransport[] transport = new TTransport[n];
    Greeter.Client[] clients = new Greeter.Client[n];

    //warmup
    for (int i = 0; i < n; i++) {
        transport[i] = new TFramedTransport(new TSocket(host, 8972));
        transport[i].open();

        TProtocol protocol = new TBinaryProtocol(transport[i]);
        clients[i] =  new Greeter.Client(protocol);
        clients[i].say(msg);
    }

    return clients;
}
 
Example 7
Source Project: ThriftJ   Source File: ThriftServerTest2.java    License: Apache License 2.0 6 votes vote down vote up
public static void main(String[] args){
	ExecutorService es = Executors.newFixedThreadPool(2);
	for(int i=0; i<ports.length; i++){
		final int index = i;
		es.execute(new Runnable() {
			@Override
			public void run() {
				try{
					TNonblockingServerSocket socket = new TNonblockingServerSocket(ports[index]);
					TestThriftJ.Processor processor = new TestThriftJ.Processor(new QueryImp());
					TNonblockingServer.Args arg = new TNonblockingServer.Args(socket);
					arg.protocolFactory(new TBinaryProtocol.Factory());
					arg.transportFactory(new TFramedTransport.Factory());
					arg.processorFactory(new TProcessorFactory(processor));
					TServer server = new TNonblockingServer (arg);
					
					logger.info("127.0.0.1:" + ports[index] + " start");
					server.serve();
				}catch(Exception e){
					logger.error("127.0.0.1:" + ports[index] + " error");
				}
			}
		});
	}
}
 
Example 8
Source Project: ThriftJ   Source File: ThriftServerTest.java    License: Apache License 2.0 6 votes vote down vote up
public static void main(String[] args){
	ExecutorService es = Executors.newFixedThreadPool(2);
	for(int i=0; i<ports.length; i++){
		final int index = i;
		es.execute(new Runnable() {
			@Override
			public void run() {
				try{
					TNonblockingServerSocket socket = new TNonblockingServerSocket(ports[index]);
					TestThriftJ.Processor processor = new TestThriftJ.Processor(new QueryImp());
					TNonblockingServer.Args arg = new TNonblockingServer.Args(socket);
					arg.protocolFactory(new TBinaryProtocol.Factory());
					arg.transportFactory(new TFramedTransport.Factory());
					arg.processorFactory(new TProcessorFactory(processor));
					TServer server = new TNonblockingServer(arg);
					
					logger.info("127.0.0.1:" + ports[index] + " start");
					server.serve();
				}catch(Exception e){
					logger.error("127.0.0.1:" + ports[index] + " error");
				}
			}
		});
	}
}
 
Example 9
Source Project: leaf-snowflake   Source File: rpcClient.java    License: Apache License 2.0 6 votes vote down vote up
public static void startClient2(String ip ,int port ,int timeout) throws Exception
{
	TTransport transport = new TFramedTransport(new TSocket(ip,port,timeout));
	TProtocol protocol = new TBinaryProtocol(transport);
	leafrpc.Client client = new leafrpc.Client(protocol);
	transport.open();

	for(int i = 0; i< 1000000; i++)
	{
		client.getID("");
		if (i % 100000 == 0)
		{
			System.out.println(Thread.currentThread().getName() + " " + client.getID(""));
		}
		//ai.incrementAndGet();
	}
	transport.close();
}
 
Example 10
Source Project: learning-hadoop   Source File: CassandraConnection.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Construct an CassandaraConnection with optional authentication.
 * 
 * @param host the host to connect to
 * @param port the port to use
 * @param username the username to authenticate with (may be null
 * for no authentication)
 * @param password the password to authenticate with (may be null
 * for no authentication)
 * @throws Exception if the connection fails
 */
public CassandraConnection(String host, int port,
    String username, String password, int timeout) throws Exception {
  TSocket socket = new TSocket(host, port);
  if (timeout > 0) {
    socket.setTimeout(timeout);
  }
  
  m_transport = new TFramedTransport(socket);
  TProtocol protocol = new TBinaryProtocol(m_transport);
  m_client = new Cassandra.Client(protocol);      
  m_transport.open();
  
  if (!Const.isEmpty(username) && !Const.isEmpty(password)) {
    Map<String, String> creds = new HashMap<String, String>();
    creds.put("username", username);
    creds.put("password", password);
    m_client.login(new AuthenticationRequest(creds));
  }
}
 
Example 11
Source Project: ThriftBook   Source File: MultiServiceClient.java    License: Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws TException {
    TTransport trans = new TFramedTransport(new TSocket("localhost", 9090));
    TProtocol proto = new TJSONProtocol(trans);

    TMultiplexedProtocol proto_msg = new TMultiplexedProtocol(proto, "Message");
    Message.Client client_msg = new Message.Client(proto_msg);
    TMultiplexedProtocol proto_time = new TMultiplexedProtocol(proto, "ServerTime");
    ServerTime.Client client_time = new ServerTime.Client(proto_time);

    trans.open();
    String line;
    do {
        System.out.println("Message from server: " + client_msg.motd());
        System.out.println("Time at server: " + client_time.time_at_server((short)-1));
        System.out.println("Enter to continue, 'q' to quit: ");
        line = System.console().readLine();
    } while (0 != line.compareToIgnoreCase("q"));   
}
 
Example 12
Source Project: stratio-cassandra   Source File: TestRingCache.java    License: Apache License 2.0 6 votes vote down vote up
private void setup(String server, int port) throws Exception
{
    /* Establish a thrift connection to the cassandra instance */
    TSocket socket = new TSocket(server, port);
    System.out.println(" connected to " + server + ":" + port + ".");
    TBinaryProtocol binaryProtocol = new TBinaryProtocol(new TFramedTransport(socket));
    Cassandra.Client cassandraClient = new Cassandra.Client(binaryProtocol);
    socket.open();
    thriftClient = cassandraClient;
    String seed = DatabaseDescriptor.getSeeds().iterator().next().getHostAddress();
    conf = new Configuration();
    ConfigHelper.setOutputPartitioner(conf, DatabaseDescriptor.getPartitioner().getClass().getName());
    ConfigHelper.setOutputInitialAddress(conf, seed);
    ConfigHelper.setOutputRpcPort(conf, Integer.toString(DatabaseDescriptor.getRpcPort()));

}
 
Example 13
public static void main(String[] args) {
    int port = 9090;

    try {
        TServerTransport serverTransport = new TServerSocket(port);

        Args processor = new TThreadPoolServer.Args(serverTransport)
                .inputTransportFactory(new TFramedTransport.Factory())
                .outputTransportFactory(new TFramedTransport.Factory())
                .processor(new Processor<>(new TestThriftServiceHandler()));
        //            processor.maxWorkerThreads = 20;
        TThreadPoolServer server = new TThreadPoolServer(processor);

        System.out.println("Starting the server...");
        server.serve();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 14
@BeforeClass
public static void setUp() {
    int port = 9090;

    try {
        TServerTransport serverTransport = new TServerSocket(port);

        Args processor = new TThreadPoolServer.Args(serverTransport)
                .inputTransportFactory(new TFramedTransport.Factory())
                .outputTransportFactory(new TFramedTransport.Factory())
                .processor(new Processor<>(new TestThriftServiceHandler()));
        //            processor.maxWorkerThreads = 20;
        TThreadPoolServer server = new TThreadPoolServer(processor);

        logger.info("Starting test server...");
        new Thread(server::serve).start();
        Thread.sleep(1000); // waiting server init
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 15
@Test
public void testReusingIFace() throws TException {
    List<ServiceInfo> serverList = Collections
            .singletonList(new ServiceInfo("127.0.0.1", 9090));
    PoolConfig config = new PoolConfig();
    config.setFailover(true);
    config.setTimeout(1000);
    ThriftClientPool<TestThriftService.Client> pool = new ThriftClientPool<>(serverList,
            transport -> new Client(new TBinaryProtocol(new TFramedTransport(transport))),
            config);

    Iface iface = pool.iface();
    iface.echo("Hello!");
    boolean exceptionThrow = false;
    try {
        iface.echo("Hello again!");
    } catch (IllegalStateException e) {
        logger.info("exception thrown expected!", e);
        exceptionThrow = true;
    }
    Assert.assertTrue("exception must thrown", exceptionThrow);
}
 
Example 16
Source Project: plow   Source File: ThriftServer.java    License: Apache License 2.0 6 votes vote down vote up
@PostConstruct
public void start() {
    logger.info("Starting thift server " + name + " on port " + port);

    try {
        transport = new TNonblockingServerSocket(port);
        server = new TThreadedSelectorServer(
                new TThreadedSelectorServer.Args(transport)
            .processor(processor)
            .workerThreads(threads)
            .selectorThreads((threads / 16) + 1)
            .protocolFactory(protocolFactory)
            .transportFactory(new TFramedTransport.Factory()));
        thread.start();

    } catch (TTransportException e) {
        throw new RuntimeException("Unable to start thrift server " + e, e);
    }
}
 
Example 17
Source Project: mt-flume   Source File: ScribeSource.java    License: Apache License 2.0 6 votes vote down vote up
public void run() {
  try {
    Scribe.Processor processor = new Scribe.Processor(new Receiver());
    TNonblockingServerTransport transport = new TNonblockingServerSocket(port);
    THsHaServer.Args args = new THsHaServer.Args(transport);
    
    args.workerThreads(workers);
    args.processor(processor);
    args.transportFactory(new TFramedTransport.Factory());
    args.protocolFactory(new TBinaryProtocol.Factory(false, false));

    server = new THsHaServer(args);

    LOG.info("Starting Scribe Source on port " + port);

    server.serve();
  } catch (Exception e) {
    LOG.warn("Scribe failed", e);
  }
}
 
Example 18
Source Project: RDFS   Source File: CoronaAdmin.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Turns on the Safe Mode if safeMode is true. Turns off the Safe Mode if
 * safeMode is false.
 * @param safeMode Is true if we want the Safe Mode to be on. false
 *                 otherwise.
 * @return 0 if successful.
 * @throws IOException
 */
private int setSafeMode(boolean safeMode) throws IOException {
  // Get the current configuration
  CoronaConf conf = new CoronaConf(getConf());

  InetSocketAddress address = NetUtils.createSocketAddr(conf
    .getClusterManagerAddress());
  TFramedTransport transport = new TFramedTransport(
    new TSocket(address.getHostName(), address.getPort()));
  ClusterManagerService.Client client = new ClusterManagerService.Client(
    new TBinaryProtocol(transport));

  try {
    transport.open();
    if (client.setSafeMode(safeMode)) {
      System.out.println("The safeMode is: " +
                          (safeMode ? "ON" : "OFF"));
    } else {
      System.err.println("Could not set the safeMode flag");
    }
  } catch (TException e) {
    throw new IOException(e);
  }

  return 0;
}
 
Example 19
Source Project: RDFS   Source File: CoronaTaskTracker.java    License: Apache License 2.0 6 votes vote down vote up
private synchronized void initializeClusterManagerClient()
    throws IOException {
  // Connect to cluster manager thrift service
  String target = CoronaConf.getClusterManagerAddress(fConf);
  LOG.info("Connecting to Cluster Manager at " + target);
  InetSocketAddress address = NetUtils.createSocketAddr(target);
  transport = new TFramedTransport(
    new TSocket(address.getHostName(), address.getPort()));
  TProtocol protocol = new TBinaryProtocol(transport);
  client = new ClusterManagerService.Client(protocol);
  try {
    transport.open();
  } catch (TTransportException e) {
    throw new IOException(e);
  }
}
 
Example 20
Source Project: luxun   Source File: ThriftServer.java    License: Apache License 2.0 6 votes vote down vote up
public ThriftServer(QueueService.Iface queueService, ServerConfig serverConfig, ThriftServerStats stats) throws TTransportException {
		this.queueService = queueService;
		this.serverConfig = serverConfig;
        this.stats = stats;
        
        // assemble thrift server
        TProcessor tprocessor = new QueueService.Processor(this.queueService);
        TNonblockingServerSocket tnbSocketTransport = new TNonblockingServerSocket(serverConfig.getPort());
        TNonblockingServer.Args tnbArgs = new TNonblockingServer.Args(tnbSocketTransport);
        tnbArgs.processor(tprocessor);
        // Nonblocking server mode must use TFramedTransport
        tnbArgs.transportFactory(new TFramedTransport.Factory());
        tnbArgs.protocolFactory(new TBinaryProtocol.Factory());
        
        this.server = new TNonblockingServer(tnbArgs);
        
//        THsHaServer.Args thhArgs = new THsHaServer.Args(tnbSocketTransport);
//        thhArgs.processor(tprocessor);
//        // Nonblocking server mode must use TFramedTransport
//        thhArgs.transportFactory(new TFramedTransport.Factory());
//        thhArgs.protocolFactory(new TBinaryProtocol.Factory());
//
//        this.server = new THsHaServer(thhArgs);
    
        this.serverThread = new ServerThread(this.server);
	}
 
Example 21
Source Project: suro   Source File: ConnectionPool.java    License: Apache License 2.0 6 votes vote down vote up
public void connect() throws Exception {
    TSocket socket = new TSocket(server.getHost(), server.getPort(), config.getConnectionTimeout());
    socket.getSocket().setTcpNoDelay(true);
    socket.getSocket().setKeepAlive(true);
    socket.getSocket().setSoLinger(true, 0);
    transport = new TFramedTransport(socket);
    transport.open();

    TProtocol protocol = new TBinaryProtocol(transport);

    client = new SuroServer.Client(protocol);
    ServiceStatus status = client.getStatus();
    if (status != ServiceStatus.ALIVE) {
        transport.close();
        throw new RuntimeException(server + " IS NOT ALIVE!!!");
    }
}
 
Example 22
Source Project: das   Source File: ServerSelector.java    License: Apache License 2.0 5 votes vote down vote up
static ClientObject getClientObject(String host, int port) throws TTransportException {
    TSocket transport = new TSocket(host, port);
    TFramedTransport ft = new TFramedTransport(transport);
    TBinaryProtocol protocol = new TBinaryProtocol(ft);
    transport.open();
    return new ClientObject(new DasService.Client(protocol), transport);
}
 
Example 23
Source Project: octo-rpc   Source File: OriginThriftTest.java    License: Apache License 2.0 5 votes vote down vote up
private static Twitter.Iface getOriginThriftClient() throws TTransportException {
    transport = new TFramedTransport(new TSocket("localhost", serverPort));
    transport.open();
    TProtocol protocol = new TBinaryProtocol(transport);
    Twitter.Iface client = new Twitter.Client(protocol);
    return client;
}
 
Example 24
Source Project: drift   Source File: TestApacheThriftMethodInvoker.java    License: Apache License 2.0 5 votes vote down vote up
private static int testProcessor(TProcessor processor, List<ToIntFunction<HostAndPort>> clients)
        throws Exception
{
    try (TServerSocket serverTransport = new TServerSocket(0)) {
        TProtocolFactory protocolFactory = new Factory();
        TTransportFactory transportFactory = new TFramedTransport.Factory();
        TServer server = new TSimpleServer(new Args(serverTransport)
                .protocolFactory(protocolFactory)
                .transportFactory(transportFactory)
                .processor(processor));

        Thread serverThread = new Thread(server::serve);
        try {
            serverThread.start();

            int localPort = serverTransport.getServerSocket().getLocalPort();
            HostAndPort address = HostAndPort.fromParts("localhost", localPort);

            int sum = 0;
            for (ToIntFunction<HostAndPort> client : clients) {
                sum += client.applyAsInt(address);
            }
            return sum;
        }
        finally {
            server.stop();
            serverThread.interrupt();
        }
    }
}
 
Example 25
Source Project: drift   Source File: TestDriftNettyMethodInvoker.java    License: Apache License 2.0 5 votes vote down vote up
private static List<LogEntry> testProcessor(TProcessor processor)
        throws Exception
{
    int invocationCount = testProcessor(processor, ImmutableList.of(
            address -> logThrift(address, MESSAGES, new TFramedTransport.Factory(), new TBinaryProtocol.Factory()),
            address -> logThriftAsync(address, MESSAGES),
            address -> logNiftyInvocationHandlerOptional(address, DRIFT_MESSAGES),
            address -> logNiftyInvocationHandler(address, DRIFT_MESSAGES, FRAMED, BINARY)));

    return newArrayList(concat(nCopies(invocationCount, MESSAGES)));
}
 
Example 26
Source Project: drift   Source File: TestDriftNettyMethodInvoker.java    License: Apache License 2.0 5 votes vote down vote up
private static int testProcessor(TProcessor processor, List<ToIntFunction<HostAndPort>> clients)
        throws Exception
{
    try (TServerSocket serverTransport = new TServerSocket(0)) {
        TProtocolFactory protocolFactory = new TBinaryProtocol.Factory();
        TTransportFactory transportFactory = new TFramedTransport.Factory();
        TServer server = new TSimpleServer(new Args(serverTransport)
                .protocolFactory(protocolFactory)
                .transportFactory(transportFactory)
                .processor(processor));

        Thread serverThread = new Thread(server::serve);
        try {
            serverThread.start();

            int localPort = serverTransport.getServerSocket().getLocalPort();
            HostAndPort address = HostAndPort.fromParts("localhost", localPort);

            int sum = 0;
            for (ToIntFunction<HostAndPort> client : clients) {
                sum += client.applyAsInt(address);
            }
            return sum;
        }
        finally {
            server.stop();
            serverThread.interrupt();
        }
    }
}
 
Example 27
Source Project: drift   Source File: TestDriftNettyServerTransport.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testOutOfOrderNot()
{
    TestingServerMethodInvoker methodInvoker = new TestingServerMethodInvoker();
    int invocationCount = testServerMethodInvoker(methodInvoker, true, ImmutableList.of(
            address -> testOutOfOrder(address, MESSAGES, new TTransportFactory(), new TBinaryProtocol.Factory(), methodInvoker.getFutureResults()),
            address -> testOutOfOrder(address, MESSAGES, new TTransportFactory(), new TCompactProtocol.Factory(), methodInvoker.getFutureResults()),
            address -> testOutOfOrder(address, MESSAGES, new TFramedTransport.Factory(), new TBinaryProtocol.Factory(), methodInvoker.getFutureResults()),
            address -> testOutOfOrder(address, MESSAGES, new TFramedTransport.Factory(), new TCompactProtocol.Factory(), methodInvoker.getFutureResults())));

    List<DriftLogEntry> expectedMessages = newArrayList(concat(nCopies(invocationCount, DRIFT_MESSAGES)));
    assertEquals(ImmutableList.copyOf(methodInvoker.getMessages()), expectedMessages);
}
 
Example 28
Source Project: drift   Source File: TestDriftNettyServerTransport.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testOutOfOrderNotSupported()
{
    TestingServerMethodInvoker methodInvoker = new TestingServerMethodInvoker();
    int invocationCount = testServerMethodInvoker(methodInvoker, false, ImmutableList.of(
            address -> testOutOfOrderNotSupported(address, MESSAGES, new TTransportFactory(), new TBinaryProtocol.Factory(), methodInvoker.getFutureResults()),
            address -> testOutOfOrderNotSupported(address, MESSAGES, new TTransportFactory(), new TCompactProtocol.Factory(), methodInvoker.getFutureResults()),
            address -> testOutOfOrderNotSupported(address, MESSAGES, new TFramedTransport.Factory(), new TBinaryProtocol.Factory(), methodInvoker.getFutureResults()),
            address -> testOutOfOrderNotSupported(address, MESSAGES, new TFramedTransport.Factory(), new TCompactProtocol.Factory(), methodInvoker.getFutureResults())));

    List<DriftLogEntry> expectedMessages = newArrayList(concat(nCopies(invocationCount, DRIFT_MESSAGES)));
    assertEquals(ImmutableList.copyOf(methodInvoker.getMessages()), expectedMessages);
}
 
Example 29
Source Project: janusgraph_tutorial   Source File: Schema.java    License: Apache License 2.0 5 votes vote down vote up
private void dropOldKeyspace() throws InvalidRequestException, SchemaDisagreementException, TException {
  TTransport tr = new TFramedTransport(new TSocket("localhost", 9160));
  TProtocol proto = new TBinaryProtocol(tr);
  Cassandra.Client client = new Cassandra.Client(proto);
  tr.open();

  client.system_drop_keyspace(JANUSGRAPH);
  LOGGER.info("DROPPED keyspace janusgraph");
  tr.close();
}
 
Example 30
Source Project: rpc-benchmark   Source File: ThriftUserServiceClient.java    License: Apache License 2.0 5 votes vote down vote up
public ThriftUserServiceClient(String host, int port) {
	transport = new TFramedTransport(new TSocket(host, port));
	protocol = new TBinaryProtocol(transport);
	client = new UserService.Client(protocol);

	try {
		transport.open();
	} catch (TTransportException e) {
		throw new Error(e);
	}
}