Package org.apache.thrift7.transport

Examples of org.apache.thrift7.transport.TSocket


  }

  public Client newClient(Connection connection) throws TTransportException, IOException {
    String host = connection.getHost();
    int port = connection.getPort();
    TSocket trans;
    Socket socket;
    if (connection.isProxy()) {
      Proxy proxy = new Proxy(Type.SOCKS, new InetSocketAddress(connection.getProxyHost(), connection.getProxyPort()));
      socket = new Socket(proxy);
    } else {
      socket = new Socket();
    }
    int timeout = connection.getTimeout();
    socket.setTcpNoDelay(true);
    socket.setSoTimeout(timeout);
    socket.connect(new InetSocketAddress(host, port), timeout);
    trans = new TSocket(socket);

    TProtocol proto = new TBinaryProtocol(new TFramedTransport(trans));
    Client client = new Client(proto);
    return client;
  }
View Full Code Here


  }

  public Client newClient(Connection connection) throws TTransportException, IOException {
    String host = connection.getHost();
    int port = connection.getPort();
    TSocket trans;
    Socket socket;
    if (connection.isProxy()) {
      Proxy proxy = new Proxy(Type.SOCKS, new InetSocketAddress(connection.getProxyHost(), connection.getProxyPort()));
      socket = new Socket(proxy);
    } else {
      socket = new Socket();
    }
    int timeout = connection.getTimeout();
    socket.setTcpNoDelay(true);
    socket.setSoTimeout(timeout);
    socket.connect(new InetSocketAddress(host, port), timeout);
    trans = new TSocket(socket);

    TProtocol proto = new TBinaryProtocol(new TFramedTransport(trans, _maxFrameSize));
    return new WeightedClient(proto);
  }
View Full Code Here

    if (transport instanceof TFramedTransport) {
      TFramedTransport framedTransport = (TFramedTransport) transport;
      transport = framedTransport.getTransport();
    }
    if (transport instanceof TSocket) {
      TSocket tsocket = (TSocket) transport;
      Socket socket = tsocket.getSocket();
      SocketAddress localSocketAddress = socket.getLocalSocketAddress();
      SocketAddress remoteSocketAddress = socket.getRemoteSocketAddress();
      return localSocketAddress.toString() + ":" + remoteSocketAddress.toString();
    }
    return "unknown";
View Full Code Here

            if (transport instanceof TFramedTransport) {
              TFramedTransport framedTransport = (TFramedTransport) transport;
              transport = framedTransport.getTransport();
            }
            if (transport instanceof TSocket) {
              TSocket tsocket = (TSocket) transport;
              Socket socket = tsocket.getSocket();
              SocketAddress remoteSocketAddress = socket.getRemoteSocketAddress();
              return remoteSocketAddress.toString();
            }
            return "unknown";
          }
View Full Code Here

              }
            });
           
            // Read objects
            assert thriftIn.hasNext();
            TBase base = thriftIn.read();
            assert base != null;
            StormTopology topology = (StormTopology) base;
            assert topology != null;
           
            return topology;
View Full Code Here

  /**
    * Reads the next object from the file.
    */
  public TBase read() throws IOException {
    TBase t = creator.create();
    try {
      t.read(binaryIn);
    } catch (TException e) {
      throw new IOException(e);
    }
    return t;
  }
View Full Code Here

    }

    public static <T> T thriftDeserialize(Class c, byte[] b) {
        try {
            T ret = (T) c.newInstance();
            TDeserializer des = threadDes.get();
            if (des == null) {
                des = new TDeserializer();
                threadDes.set(des);
            }
            des.deserialize((TBase) ret, b);
            return ret;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
       
View Full Code Here

    } catch (AlreadyAliveException e) {
      LOG.info(topologyname + " is already exist ");
      throw e;
    } catch (Throwable e) {
      LOG.info("Failed to check whether topology is alive or not", e);
      throw new TException(e);
    }
   
    int counter = data.getSubmittedCount().incrementAndGet();
    String topologyId = topologyname + "-" + counter + "-"
        + TimeUtils.current_time_secs();
View Full Code Here

    } catch (AlreadyAliveException e) {
      LOG.info("Fail to kill " + topologyname + " before restarting");
      return;
    } catch (Throwable e) {
      LOG.info("Failed to check whether topology is alive or not", e);
      throw new TException(e);
    }
   
    int counter = data.getSubmittedCount().incrementAndGet();
    String topologyId = topologyname + "-" + counter + "-"
        + TimeUtils.current_time_secs();
View Full Code Here

      LOG.error(errMsg, e);
      throw new NotAliveException(errMsg);
    } catch (Exception e) {
      String errMsg = "Failed to kill topology " + topologyName;
      LOG.error(errMsg, e);
      throw new TException(errMsg);
    }

  }
View Full Code Here

TOP

Related Classes of org.apache.thrift7.transport.TSocket

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.