Examples of TNonblockingTransport


Examples of org.apache.thrift.transport.TNonblockingTransport

  protected Runnable getRunnable(final FrameBuffer frameBuffer) {
    return new Runnable() {
      @Override
      public void run() {
        if (frameBuffer instanceof CustomNonblockingFrameBuffer) {
          TNonblockingTransport trans = ((CustomNonblockingFrameBuffer) frameBuffer).getTransport();
          if (trans instanceof TNonblockingSocket) {
            TNonblockingSocket tsock = (TNonblockingSocket) trans;
            Socket sock = tsock.getSocketChannel().socket();
            TServerUtils.clientAddress.set(sock.getInetAddress().getHostAddress() + ":" + sock.getPort());
          }
View Full Code Here

Examples of org.apache.thrift.transport.TNonblockingTransport

     * Accept a new connection.
     */
    @SuppressWarnings("unused")
    private void handleAccept() throws IOException {
      SelectionKey clientKey = null;
      TNonblockingTransport client = null;
      try {
        // accept the connection
        client = (TNonblockingTransport)serverTransport.accept();
        clientKey = client.registerSelector(selector, SelectionKey.OP_READ);

        // add this key to the map
          FrameBuffer frameBuffer = processorFactory_.isAsyncProcessor() ?
                  new CustomAsyncFrameBuffer(client, clientKey,SelectAcceptThread.this) :
                  new CustomFrameBuffer(client, clientKey,SelectAcceptThread.this);

          clientKey.attach(frameBuffer);
      } catch (TTransportException tte) {
        // something went wrong accepting.
        LOGGER.warn("Exception trying to accept!", tte);
        tte.printStackTrace();
        if (clientKey != null) cleanupSelectionKey(clientKey);
        if (client != null) client.close();
      }
    }
View Full Code Here

Examples of org.apache.thrift.transport.TNonblockingTransport

        }

        private void handleAccept()
        {
            SelectionKey clientKey = null;
            TNonblockingTransport client = null;
            try
            {
                // accept the connection
                client = (TNonblockingTransport) serverTransport.accept();
                clientKey = client.registerSelector(selector, SelectionKey.OP_READ);
                // add this key to the map
                FrameBuffer frameBuffer = new FrameBuffer(client, clientKey);
                clientKey.attach(frameBuffer);
            } catch (TTransportException ex)
            {
                // ignore this might have been handled by the other threads.
                // serverTransport.accept() as it returns null as nothing to accept.
                return;
            }
            catch (IOException tte)
            {
                // something went wrong accepting.
                LOGGER.warn("Exception trying to accept!", tte);
                tte.printStackTrace();
                if (clientKey != null)
                    cleanupSelectionkey(clientKey);
                if (client != null)
                    client.close();
            }
        }
View Full Code Here

Examples of org.apache.thrift.transport.TNonblockingTransport

        }

        @Override
        protected void selectorIterationComplete() throws IOException
        {
            TNonblockingTransport newClient;

            while ((newClient = newConnections.poll()) != null)
            {
                SelectionKey clientKey = newClient.registerSelector(selector, SelectionKey.OP_READ);
                clientKey.attach(new Message(newClient, clientKey, thriftFactories, useHeapBasedAllocation, alwaysReallocateBuffers));
            }
        }
View Full Code Here

Examples of org.apache.thrift.transport.TNonblockingTransport

    /**
     * Accept a new connection.
     */
    private void handleAccept() throws IOException {
      SelectionKey clientKey = null;
      TNonblockingTransport client = null;
      try {
        // accept the connection
        client = (TNonblockingTransport)serverTransport.accept();
        clientKey = client.registerSelector(selector, SelectionKey.OP_READ);

        // add this key to the map
        FrameBuffer frameBuffer = new FrameBuffer(client, clientKey);
        clientKey.attach(frameBuffer);
      } catch (TTransportException tte) {
        // something went wrong accepting.
        LOGGER.warn("Exception trying to accept!", tte);
        tte.printStackTrace();
        if (clientKey != null) cleanupSelectionkey(clientKey);
        if (client != null) client.close();
      }
    }
View Full Code Here

Examples of org.apache.thrift.transport.TNonblockingTransport

        }

        private void handleAccept()
        {
            SelectionKey clientKey = null;
            TNonblockingTransport client = null;
            try
            {
                // accept the connection
                client = (TNonblockingTransport) serverTransport.accept();
                clientKey = client.registerSelector(selector, SelectionKey.OP_READ);
                // add this key to the map
                FrameBuffer frameBuffer = new FrameBuffer(client, clientKey);
                clientKey.attach(frameBuffer);
            } catch (TTransportException ex)
            {
                // ignore this might have been handled by the other threads.
                // serverTransport.accept() as it returns null as nothing to accept.
                return;
            }
            catch (IOException tte)
            {
                // something went wrong accepting.
                LOGGER.warn("Exception trying to accept!", tte);
                tte.printStackTrace();
                if (clientKey != null)
                    cleanupSelectionkey(clientKey);
                if (client != null)
                    client.close();
            }
        }
View Full Code Here

Examples of org.apache.thrift.transport.TNonblockingTransport

        }

        private void handleAccept()
        {
            SelectionKey clientKey = null;
            TNonblockingTransport client = null;
            try
            {
                // accept the connection
                client = (TNonblockingTransport) serverTransport.accept();
                clientKey = client.registerSelector(selector, SelectionKey.OP_READ);
                // add this key to the map
                FrameBuffer frameBuffer = new FrameBuffer(client, clientKey);
                clientKey.attach(frameBuffer);
            } catch (TTransportException ex)
            {
                // ignore this might have been handled by the other threads.
                // serverTransport.accept() as it returns null as nothing to accept.
                return;
            }
            catch (IOException tte)
            {
                // something went wrong accepting.
                LOGGER.warn("Exception trying to accept!", tte);
                tte.printStackTrace();
                if (clientKey != null)
                    cleanupSelectionkey(clientKey);
                if (client != null)
                    client.close();
            }
        }
View Full Code Here

Examples of org.apache.thrift.transport.TNonblockingTransport

        }

        private void handleAccept()
        {
            SelectionKey clientKey = null;
            TNonblockingTransport client = null;
            try
            {
                // accept the connection
                client = (TNonblockingTransport) serverTransport.accept();
                clientKey = client.registerSelector(selector, SelectionKey.OP_READ);
                // add this key to the map
                FrameBuffer frameBuffer = new FrameBuffer(client, clientKey);
                clientKey.attach(frameBuffer);
            } catch (TTransportException ex)
            {
                // ignore this might have been handled by the other threads.
                // serverTransport.accept() as it returns null as nothing to accept.
                return;
            }
            catch (IOException tte)
            {
                // something went wrong accepting.
                LOGGER.warn("Exception trying to accept!", tte);
                tte.printStackTrace();
                if (clientKey != null)
                    cleanupSelectionkey(clientKey);
                if (client != null)
                    client.close();
            }
        }
View Full Code Here

Examples of org.apache.thrift.transport.TNonblockingTransport

        TSchedulingRequest req = new TSchedulingRequest();
        req.setApp("testApp");
        req.setTasks(tasks);
        req.setUser(user);

        TNonblockingTransport tr = new TNonblockingSocket(
            "localhost", schedulerPort);
        SchedulerService.AsyncClient client = new SchedulerService.AsyncClient(
            factory, manager, tr);
        //client.registerFrontend("testApp", new RegisterCallback());
        client.submitJob(req, new SubmitCallback(req, tr));
View Full Code Here

Examples of org.apache.thrift.transport.TNonblockingTransport

      transports.remove(client);
    }

    @Override
    public T makeObject(InetSocketAddress socket) throws Exception {
      TNonblockingTransport nbTr = new TNonblockingSocket(
          socket.getAddress().getHostAddress(), socket.getPort());
      TProtocolFactory factory = new TBinaryProtocol.Factory();
      T client = maker.create(nbTr, clientManager, factory);
      transports.put(client, nbTr);
      return client;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.