Package org.apache.thrift.transport

Examples of org.apache.thrift.transport.TTransport


        }

        private static Cassandra.Client createThriftClient(String host, int port, String user, String passwd) throws Exception
        {
            TSocket socket = new TSocket(host, port);
            TTransport trans = new TFramedTransport(socket);
            trans.open();
            TProtocol protocol = new TBinaryProtocol(trans);
            Cassandra.Client client = new Cassandra.Client(protocol);
            if (user != null && passwd != null)
            {
                Map<String, String> credentials = new HashMap<String, String>();
View Full Code Here


        AccumuloSecurityException, AccumuloServerException {
      if (tabMuts.size() == 0) {
        return new MutationSet();
      }
      TInfo tinfo = Tracer.traceInfo();
      TTransport transport = null;
     
      timeoutTracker.startingWrite();
     
      try {
        TabletClientService.Iface client;
View Full Code Here

   
    return createNewTransport(cacheKey);
  }
 
  private TTransport createNewTransport(ThriftTransportKey cacheKey) throws TTransportException {
    TTransport transport;
    if (cacheKey.getTimeout() == 0) {
      transport = AddressUtil.createTSocket(cacheKey.getLocation(), cacheKey.getPort());
    } else {
      try {
        transport = TTimeoutTransport.create(AddressUtil.parseAddress(cacheKey.getLocation(), cacheKey.getPort()), cacheKey.getTimeout());
      } catch (IOException ex) {
        throw new TTransportException(ex);
      }
    }
    transport = ThriftUtil.transportFactory().getTransport(transport);
    transport.open();
   
    if (log.isTraceEnabled())
      log.trace("Creating new connection to connection to " + cacheKey.getLocation() + ":" + cacheKey.getPort());
   
    CachedTTransport tsc = new CachedTTransport(transport, cacheKey);
View Full Code Here

    }
  }
 
  @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

      }
      unscanned.put(new KeyExtent(entry.getKey()), ranges);
    }
   
    timeoutTracker.startingScan();
    TTransport transport = null;
    try {
      TabletClientService.Client client;
      if (timeoutTracker.getTimeOut() < conf.getTimeInMillis(Property.GENERAL_RPC_TIMEOUT))
        client = ThriftUtil.getTServerClient(server, conf, timeoutTracker.getTimeOut());
      else
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

      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(Constants.UTF8), 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, Constants.UTF8));
            }
          } 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

            if (!this.oneway) {
                ChannelBuffer responseBuffer;

                responseBuffer = SyncClientHelpers.sendSynchronousTwoWayMessage(channel, requestBuffer);

                TTransport inputTransport = new TChannelBufferInputTransport(responseBuffer);
                TProtocol inputProtocol = protocolFactory.getInputProtocolFactory().getProtocol(inputTransport);
                waitForResponse(inputProtocol, sequenceId);

                // read results
                results = readResponse(inputProtocol);
View Full Code Here

                public void onRequestSent() {}

                @Override
                public void onResponseReceived(ChannelBuffer message) {
                    try {
                        TTransport inputTransport = new TChannelBufferInputTransport(message);
                        TProtocol inputProtocol = protocolFactory.getInputProtocolFactory().getProtocol(inputTransport);
                        waitForResponse(inputProtocol, sequenceId);
                        Object results = readResponse(inputProtocol);
                        stats.addSuccessTime(nanosSince(start));
                        future.set(results);
View Full Code Here

    // or null, do not connect back.
    if (host != null && !"".equals(host)) {
      LOG.info("Assigning session id " + sessionId + " to connection to " + host + ":" + port);

      try {
        TTransport transport = new TFramedTransport(new TSocket(host, port));
        transport.open();
        TProtocol protocol = new TBinaryProtocol(transport);
        ClientConsole.Client client = new ClientConsole.Client(protocol);

        // Store the info about this RPC connection in the active sessions table.
        UserSession session = new UserSession(sessionId, transport, client);
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.