Package org.apache.thrift.transport

Examples of org.apache.thrift.transport.TTransport


        }

        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


    {
        DocumentMetadata docMeta = new DocumentMetadata();

        byte[] decompressedData = CassandraUtils.decompress(ByteBufferUtil.getArray(data));

        TTransport trans = new TMemoryInputTransport(decompressedData);
        TProtocol deser = protocolFactory.getProtocol(trans);

        try
        {
            docMeta.read(deser);
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 = transportFactory.getTransport(socket);
        CassandraClient client = new CassandraClient(new TBinaryProtocol(transport));

        try
        {
            if (!transport.isOpen())
                transport.open();

            if (enable_cql)
                client.set_cql_version(cqlVersion);

            if (setKeyspace)
View Full Code Here

      String[] hostAddr = destination.split(":", 2);
      log.debug("Connecting to " + hostAddr[0] + ":" + hostAddr[1]);
      InetSocketAddress addr = new InetSocketAddress(hostAddr[0], Integer.parseInt(hostAddr[1]));
      Socket sock = new Socket();
      sock.connect(addr);
      TTransport transport = new TSocket(sock);
      TProtocol prot = new TBinaryProtocol(transport);
      return new Client(prot);
    } catch (Exception ex) {
      log.error(ex, ex);
      return null;
View Full Code Here

      public void run() {
        tserver.serve();
      }
    };
    t.start();
    TTransport clientTransport = new TSocket(new Socket("localhost", socket.getLocalPort()));
    TestService.Iface client = new TestService.Client(new TBinaryProtocol(clientTransport), new TBinaryProtocol(clientTransport));
    client = TraceWrap.client(client);
    assertFalse(client.checkTrace(null, "test"));
   
    Span start = Trace.on("start");
View Full Code Here

      for (String keeper : zookeepers) {
        int clients = 0;
        String mode = "unknown";
       
        String[] parts = keeper.split(":");
        TTransport transport = null;
        try {
          InetSocketAddress addr;
          if (parts.length > 1)
            addr = new InetSocketAddress(parts[0], Integer.parseInt(parts[1]));
          else
            addr = new InetSocketAddress(parts[0], 2181);
         
          transport = TTimeoutTransport.create(addr, 10 * 1000l);
          transport.write("stat\n".getBytes(), 0, 5);
          StringBuilder response = new StringBuilder();
          try {
            transport.flush();
            byte[] buffer = new byte[1024 * 100];
            int n = 0;
            while ((n = transport.read(buffer, 0, buffer.length)) > 0) {
              response.append(new String(buffer, 0, n));
            }
          } catch (TTransportException ex) {
            // happens at EOF
          }
          for (String line : response.toString().split("\n")) {
            if (line.startsWith(" "))
              clients++;
            if (line.startsWith("Mode"))
              mode = line.split(":")[1];
          }
          update.add(new ZooKeeperState(keeper, mode, clients));
        } catch (Exception ex) {
          log.info("Exception talking to zookeeper " + keeper, ex);
          update.add(new ZooKeeperState(keeper, "Down", -1));
        } finally {
          if (transport != null) {
            try {
              transport.close();
            } catch (Exception ex) {
              log.error(ex, ex);
            }
          }
        }
View Full Code Here

   *
   * @see org.apache.accumulo.core.client.admin.InstanceOperations#ping(java.lang.String)
   */
  @Override
  public void ping(String tserver) throws AccumuloException {
    TTransport transport = null;
    try {
      transport = ThriftUtil.createTransport(tserver, instance.getConfiguration().getPort(Property.TSERV_CLIENTPORT), instance.getConfiguration());
      TabletClientService.Client client = ThriftUtil.createClient(new TabletClientService.Client.Factory(), transport);
      client.getTabletServerStatus(Tracer.traceInfo(), credentials);
    } catch (TTransportException e) {
      throw new AccumuloException(e);
    } catch (ThriftSecurityException e) {
      throw new AccumuloException(e);
    } catch (TException e) {
      throw new AccumuloException(e);
    } finally {
      if (transport != null) {
        transport.close();
      }
    }
  }
View Full Code Here

    public TabletServerStatus getTableMap(boolean usePooledConnection) throws TException, ThriftSecurityException {
     
      if (usePooledConnection == true)
        throw new UnsupportedOperationException();
     
      TTransport transport = ThriftUtil.createTransport(address, conf);
     
      try {
        TabletClientService.Client client = ThriftUtil.createClient(new TabletClientService.Client.Factory(), transport);
        return client.getTabletServerStatus(Tracer.traceInfo(), SecurityConstants.getSystemCredentials());
      } finally {
        if (transport != null)
          transport.close();
      }
    }
View Full Code Here

    {
        Cassandra.Client client;

        try
        {
            TTransport transport = this.transport.getFactory().openTransport(host, port.thriftPort);

            client = new Cassandra.Client(new TBinaryProtocol(transport));

            if (mode.cqlVersion.isCql())
                client.set_cql_version(mode.cqlVersion.connectVersion);
View Full Code Here

    }
  }

  @Override
  public void ping(String tserver) throws AccumuloException {
    TTransport transport = null;
    try {
      transport = ThriftUtil.createTransport(AddressUtil.parseAddress(tserver, false), ServerConfigurationUtil.getConfiguration(instance));
      TabletClientService.Client client = ThriftUtil.createClient(new TabletClientService.Client.Factory(), transport);
      client.getTabletServerStatus(Tracer.traceInfo(), credentials.toThrift(instance));
    } catch (TTransportException e) {
      throw new AccumuloException(e);
    } catch (ThriftSecurityException e) {
      throw new AccumuloException(e);
    } catch (TException e) {
      throw new AccumuloException(e);
    } finally {
      if (transport != null) {
        transport.close();
      }
    }
  }
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.