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

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


    String tableDesStr = configuration.get(BLUR_TABLE_DESCRIPTOR);
    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);
    }
    transport.close();
    return descriptor;
  }
View Full Code Here


      trans_ = trans;
      selectionKey_ = selectionKey;
      selectThread_ = selectThread;
      buffer_ = ByteBuffer.allocate(4);

      frameTrans_ = new TMemoryInputTransport();
      response_ = new TByteArrayOutputStream();
      inTrans_ = inputTransportFactory_.getTransport(frameTrans_);
      outTrans_ = outputTransportFactory_.getTransport(new TIOStreamTransport(response_));
      inProt_ = inputProtocolFactory_.getProtocol(inTrans_);
      outProt_ = outputProtocolFactory_.getProtocol(outTrans_);
View Full Code Here

  public void start() throws TTransportException {
    _executorService = Executors.newThreadPool("thrift-processors", _threadCount);
    Blur.Processor<Blur.Iface> processor = new Blur.Processor<Blur.Iface>(_iface);

    TNonblockingServerSocket serverTransport = new TNonblockingServerSocket(getBindInetSocketAddress(_configuration));
    TThreadedSelectorServer.Args args = new TThreadedSelectorServer.Args(serverTransport);
    args.processor(processor);
    args.executorService(_executorService);
    args.transportFactory(new TFramedTransport.Factory());
    args.protocolFactory(new TBinaryProtocol.Factory(true, true));
View Full Code Here

        } 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) {
View Full Code Here

      }
    }
  }

  private TNonblockingSocket newTransport(Connection connection) throws IOException {
    return new TNonblockingSocket(connection.getHost(), connection.getPort());
  }
View Full Code Here

    /**
     * Accept a new connection.
     */
    private void handleAccept() {
      final TNonblockingTransport client = doAccept();
      if (client != null) {
        // Pass this connection to a selector thread
        final SelectorThread targetThread = threadChooser.nextThread();

        if (args.acceptPolicy == Args.AcceptPolicy.FAST_ACCEPT || invoker == null) {
          doAddAccept(targetThread, client);
        } else {
          // FAIR_ACCEPT
          try {
            invoker.submit(new Runnable() {
              public void run() {
                doAddAccept(targetThread, client);
              }
            });
          } catch (RejectedExecutionException rx) {
            LOGGER.warn("ExecutorService rejected accept registration!", rx);
            // close immediately
            client.close();
          }
        }
      }
    }
View Full Code Here

    }

    private void processAcceptedConnections() {
      // Register accepted connections
      while (!stopped_) {
        TNonblockingTransport accepted = acceptedQueue.poll();
        if (accepted == null) {
          break;
        }
        registerAccepted(accepted);
      }
View Full Code Here

    }
  }

  private void closeAndRemoveTransport(TAsyncClient client) {
    try {
      TNonblockingTransport transport = (TNonblockingTransport) _transportField.get(client);
      _transports.remove(transport);
      transport.close();
    } catch (IllegalArgumentException e) {
      throw new RuntimeException(e);
    } catch (IllegalAccessException e) {
      throw new RuntimeException(e);
    }
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));
    Client client = new Client(proto);
    return client;
  }
View Full Code Here

          }
          return result;
        } catch (RuntimeException e) {
          Throwable cause = e.getCause();
          if (cause instanceof TTransportException) {
            TTransportException t = (TTransportException) cause;
            if (handleError(connection, client, retries, command, t, maxRetries, backOffTime, maxBackOffTime)) {
              Throwable c = t.getCause();
              if (cause instanceof SocketTimeoutException) {
                throw new BlurException(c.getMessage(), BException.toString(c), ErrorType.REQUEST_TIMEOUT);
              }
              throw t;
            }
View Full Code Here

TOP

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

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.