Package org.apache.thrift.transport

Examples of org.apache.thrift.transport.TTransport


    }

    private static Cassandra.Client createConnection(String host, Integer port, boolean framed) throws IOException
    {
        TSocket socket = new TSocket(host, port);
        TTransport trans = framed ? new TFramedTransport(socket) : socket;
        try
        {
            trans.open();
        }
        catch (TTransportException e)
        {
            throw new IOException("unable to connect to server", e);
        }
View Full Code Here


    {
        // random node selection for fake load balancing
        String currentNode = nodes[Stress.randomizer.nextInt(nodes.length)];

        TSocket socket = new TSocket(currentNode, port);
        TTransport transport = (isUnframed()) ? socket : new TFramedTransport(socket);
        Cassandra.Client client = new Cassandra.Client(new TBinaryProtocol(transport));

        try
        {
            transport.open();

            if (setKeyspace)
            {
                client.set_keyspace("Keyspace1");
            }
View Full Code Here

    }

    private static Cassandra.Client createConnection(String host, Integer port, boolean framed) throws TTransportException
    {
        TSocket socket = new TSocket(host, port);
        TTransport trans = framed ? new TFramedTransport(socket) : socket;
        trans.open();
        TProtocol protocol = new TBinaryProtocol(trans);

        return new Cassandra.Client(protocol);
    }
View Full Code Here

        }

        private static Cassandra.Client createThriftClient(String host, int port) throws TTransportException
        {
            TSocket socket = new TSocket(host, port);
            TTransport trans = new TFramedTransport(socket);
            trans.open();
            TProtocol protocol = new TBinaryProtocol(trans);
            return new Cassandra.Client(protocol);
        }
View Full Code Here

        }

        private static Cassandra.Client createThriftClient(String host, int port) throws TTransportException
        {
            TSocket socket = new TSocket(host, port);
            TTransport trans = new TFramedTransport(socket);
            trans.open();
            TProtocol protocol = new org.apache.thrift.protocol.TBinaryProtocol(trans);
            return new Cassandra.Client(protocol);
        }
View Full Code Here

    public static Cassandra.Client createConnection(String host, Integer port, boolean framed)
            throws IOException
    {
        TSocket socket = new TSocket(host, port);
        TTransport trans = framed ? new TFramedTransport(socket) : socket;
        try
        {
            trans.open();
        }
        catch (TTransportException e)
        {
            throw new IOException("unable to connect to server", e);
        }
View Full Code Here

          }
        });

    stopped = false;
    while (!stopped && !Thread.interrupted()) {
      TTransport client = null;
      try {
        client = serverTransport_.accept();
      } catch (TTransportException ttx) {
        if (!stopped) {
          LOG.warn("Transport error when accepting message", ttx);
          continue;
        } else {
          // The server has been stopped
          break;
        }
      }

      ClientConnnection command = new ClientConnnection(client);
      try {
        executorService.execute(command);
      } catch (RejectedExecutionException rex) {
        if (client.getClass() == TSocket.class) {
          // We expect the client to be TSocket.
          LOG.warn(QUEUE_FULL_MSG + " from " +
              ((TSocket) client).getSocket().getRemoteSocketAddress());
        } else {
          LOG.warn(QUEUE_FULL_MSG, rex);
        }
        client.close();
      }
    }

    shutdownServer();
  }
View Full Code Here

    /**
     * Loops on processing a client forever
     */
    public void run() {
      TProcessor processor = null;
      TTransport inputTransport = null;
      TTransport outputTransport = null;
      TProtocol inputProtocol = null;
      TProtocol outputProtocol = null;
      try {
        processor = processorFactory_.getProcessor(client);
        inputTransport = inputTransportFactory_.getTransport(client);
        outputTransport = outputTransportFactory_.getTransport(client);
        inputProtocol = inputProtocolFactory_.getProtocol(inputTransport);
        outputProtocol = outputProtocolFactory_.getProtocol(outputTransport);
        // we check stopped_ first to make sure we're not supposed to be shutting
        // down. this is necessary for graceful shutdown.
        while (!stopped && processor.process(inputProtocol, outputProtocol)) {
           // message limit is reset for every request
           // see THRIFT-601, working on thrift 0.8.0
           // NOTE that THRIFT-820 breaks this again in thrift 0.9.0
           // and TFramedTransport needs to be used from this version onwards
           // to avoid the buffer overflow
           inputProtocol = inputProtocolFactory_.getProtocol(inputTransport);
           outputProtocol = outputProtocolFactory_.getProtocol(outputTransport);
        }
      } catch (TTransportException ttx) {
        // Assume the client died and continue silently
      } catch (TException tx) {
        LOG.error("Thrift error occurred during processing of message.", tx);
      } catch (Exception x) {
        LOG.error("Error occurred during processing of message.", x);
      }

      if (inputTransport != null) {
        inputTransport.close();
      }

      if (outputTransport != null) {
        outputTransport.close();
      }
    }
View Full Code Here

            throws IOException
    {
        try
        {
            TSocket socket = new TSocket(host, port);
            TTransport transport = getInputTransportFactory(conf).openTransport(socket);
            return new Cassandra.Client(new TBinaryProtocol(transport));
        }
        catch (LoginException e)
        {
            throw new IOException("Unable to login to server " + host + ":" + port, e);
View Full Code Here

                return;

            // create connection using thrift
            String location = getLocation();
            socket = new TSocket(location, ConfigHelper.getInputRpcPort(conf));
            TTransport transport = ConfigHelper.getInputTransportFactory(conf).openTransport(socket);
            TBinaryProtocol binaryProtocol = new TBinaryProtocol(transport);
            client = new Cassandra.Client(binaryProtocol);

            // log in
            client.set_keyspace(keyspace);
View Full Code Here

TOP

Related Classes of org.apache.thrift.transport.TTransport

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.