Package org.apache.blur.thirdparty.thrift_0_9_0.protocol

Examples of org.apache.blur.thirdparty.thrift_0_9_0.protocol.TMap


    });
  }

  private Object execute(AsyncCall call) throws Exception {
    AsyncMethodCallback<?> realCallback = getRealAsyncMethodCallback(call._args);
    TAsyncClient client = newClient(call._clazz, call._connection);
    AsyncMethodCallback<?> retryingCallback = wrapCallback(realCallback, client, call._connection);
    resetArgs(call._args, retryingCallback);
    return call._method.invoke(client, call._args);
  }
View Full Code Here


    return (AsyncMethodCallback<?>) args[args.length - 1];
  }

  private TAsyncClient newClient(Class<?> c, Connection connection) throws InterruptedException {
    BlockingQueue<TAsyncClient> blockingQueue = getQueue(connection);
    TAsyncClient client = blockingQueue.poll();
    if (client != null) {
      return client;
    }

    AtomicInteger counter;
    synchronized (_numberOfConnections) {
      counter = _numberOfConnections.get(connection.getHost());
      if (counter == null) {
        counter = new AtomicInteger();
        _numberOfConnections.put(connection.getHost(), counter);
      }
    }

    synchronized (counter) {
      int numOfConnections = counter.get();
      while (numOfConnections >= _maxConnectionsPerHost) {
        client = blockingQueue.poll(_pollTime, TimeUnit.MILLISECONDS);
        if (client != null) {
          return client;
        }
        LOG.debug("Waiting for client number of connection [" + numOfConnections + "], max connection per host [" + _maxConnectionsPerHost + "]");
        numOfConnections = counter.get();
      }
      LOG.info("Creating a new client for [" + connection + "]");
      String name = c.getName();
      Constructor<?> constructor = _constructorCache.get(name);
      if (constructor == null) {
        String clientClassName = name.replace("$AsyncIface", "$AsyncClient");
        try {
          Class<?> clazz = Class.forName(clientClassName);
          constructor = clazz.getConstructor(new Class[] { TProtocolFactory.class, TAsyncClientManager.class, TNonblockingTransport.class });
          _constructorCache.put(name, constructor);
        } catch (Exception e) {
          throw new RuntimeException(e);
        }
      }
      try {
        TNonblockingSocket transport = newTransport(connection);
        client = (TAsyncClient) constructor.newInstance(new Object[] { _protocolFactory, _clientManager, transport });
        client.setTimeout(_timeout);
        counter.incrementAndGet();
        return client;
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
View Full Code Here

  public AsyncClientPool() throws IOException {
    this(DEFAULT_MAX_CONNECTIONS_PER_HOST, DEFAULT_CONNECTION_TIMEOUT);
  }

  public AsyncClientPool(int maxConnectionsPerHost, int connectionTimeout) throws IOException {
    _clientManager = new TAsyncClientManager();
    _protocolFactory = new TBinaryProtocol.Factory();
    _maxConnectionsPerHost = maxConnectionsPerHost;
    _timeout = connectionTimeout;
    try {
      _transportField = TAsyncClient.class.getDeclaredField("___transport");
View Full Code Here

    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

      struct.setField_ = null;
      struct.value_ = null;

      iprot.readStructBegin();

      TField field = iprot.readFieldBegin();

      struct.value_ = struct.standardSchemeReadValue(iprot, field);
      if (struct.value_ != null) {
        struct.setField_ = struct.enumForId(field.id);
      }
View Full Code Here

   * @param fieldIdPathRest The rest FieldId's that define a path to a TUnion
   * @throws TException
   */
  public Short partialDeserializeSetFieldIdInUnion(byte[] bytes, TFieldIdEnum fieldIdPathFirst, TFieldIdEnum ... fieldIdPathRestthrows TException {
    try {
      TField field = locateField(bytes, fieldIdPathFirst, fieldIdPathRest);
      if (field != null){
        protocol_.readStructBegin(); // The Union
        return protocol_.readFieldBegin().id; // The field set in the union
      }
      return null;
View Full Code Here

    }
  }

  private Object partialDeserializeField(byte ttype, byte[] bytes, TFieldIdEnum fieldIdPathFirst, TFieldIdEnum ... fieldIdPathRest) throws TException {
    try {
      TField field = locateField(bytes, fieldIdPathFirst, fieldIdPathRest);
      if (field != null) {
        // if this point is reached, iprot will be positioned at the start of the field.
        switch(ttype){
          case TType.BOOL:
            if (field.type == TType.BOOL){
View Full Code Here

    // index into field ID path being currently searched for
    int curPathIndex = 0;

    // this will be the located field, or null if it is not located
    TField field = null;

    protocol_.readStructBegin();

    while (curPathIndex < fieldIdPath.length) {
      field = protocol_.readFieldBegin();
View Full Code Here

  public int getType() {
    return type_;
  }

  public static TApplicationException read(TProtocol iprot) throws TException {
    TField field;
    iprot.readStructBegin();

    String message = null;
    int type = UNKNOWN;
View Full Code Here

    if (tableDesStr == null) {
      return null;
    }
    ByteArrayInputStream inputStream = new ByteArrayInputStream(tableDesStr.getBytes());
    TIOStreamTransport transport = new TIOStreamTransport(inputStream);
    TJSONProtocol protocol = new TJSONProtocol(transport);
    TableDescriptor descriptor = new TableDescriptor();
    try {
      descriptor.read(protocol);
    } catch (TException e) {
      throw new IOException(e);
View Full Code Here

TOP

Related Classes of org.apache.blur.thirdparty.thrift_0_9_0.protocol.TMap

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.