congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
TCPNIOConnection
Code IndexAdd Tabnine to your IDE (free)

How to use
TCPNIOConnection
in
org.glassfish.grizzly.nio.transport

Best Java code snippets using org.glassfish.grizzly.nio.transport.TCPNIOConnection (Showing top 20 results out of 315)

origin: javaee/grizzly

private static int readSimpleByteBuffer(final TCPNIOConnection tcpConnection,
    final ByteBuffer byteBuffer) throws IOException {
  
  final SocketChannel socketChannel = (SocketChannel) tcpConnection.getChannel();
  return socketChannel.read(byteBuffer);
}
origin: org.glassfish.grizzly/grizzly-websockets-server

  @Override
  public void failed(final Throwable throwable) {
    connection.checkConnectFailed(throwable);
  }
}
origin: org.glassfish.grizzly/grizzly-websockets-server

/**
 * Method will be called, when some data was read on the connection
 */
protected final void onRead(Buffer data, int size) {
  if (size > 0) {
    notifyProbesRead(this, data, size);
  }
  checkEmptyRead(size);
}
origin: org.glassfish.grizzly/grizzly-websockets-server

protected static void onConnectedAsync(final TCPNIOConnection connection,
    final CompletionHandler<Connection> completionHandler)
    throws IOException {
  final TCPNIOTransport tcpTransport =
      (TCPNIOTransport) connection.getTransport();
  final SocketChannel channel = (SocketChannel) connection.getChannel();
  
  try {
    if (!channel.isConnected()) {
      channel.finishConnect();
    }
    connection.resetProperties();
    // Deregister OP_CONNECT interest
    connection.disableIOEvent(IOEvent.CLIENT_CONNECTED);
    // we can call configure for ready channel
    tcpTransport.getChannelConfigurator().postConfigure(tcpTransport, channel);
  } catch (Exception e) {
    abortConnection(connection, completionHandler, e);
    throw Exceptions.makeIOException(e);
  }
  
  if (connection.notifyReady()) {
    tcpTransport.fireIOEvent(IOEvent.CONNECTED, connection,
        new EnableReadHandler(completionHandler));
  }
}
origin: javaee/grizzly

@Override
public void onComplete(final Context context, final Object data)
    throws IOException {
  final TCPNIOConnection connection =
      (TCPNIOConnection) context.getConnection();
  if (completionHandler != null) {
    completionHandler.completed(connection);
  }
  if (!connection.isStandalone()) {
    connection.enableInitialOpRead();
  }
}
origin: org.glassfish.grizzly/grizzly-websockets-server

public static Buffer allocateAndReadBuffer(final TCPNIOConnection connection)
    throws IOException {
  final MemoryManager memoryManager = connection.getMemoryManager();
    final int receiveBufferSize =
        Math.min(TCPNIOTransport.MAX_RECEIVE_BUFFER_SIZE,
            connection.getReadBufferSize());
origin: javaee/grizzly

TCPNIOConnection obtainNIOConnection(final SocketChannel channel) {
  final TCPNIOConnection connection = new TCPNIOConnection(this, channel);
  configureNIOConnection(connection);
  
  return connection;
}
origin: javaee/grizzly

protected void addRecord(Connection connection,
    Buffer buffer,
    CompletionHandler completionHandler,
    Interceptor<ReadResult> interceptor) {
  final AsyncReadQueueRecord record = AsyncReadQueueRecord.create(
      connection, buffer,
      completionHandler, interceptor);
  ((TCPNIOConnection) connection).getAsyncReadQueue().offer(record);
}
origin: javaee/grizzly

private static void abortConnection(final TCPNIOConnection connection,
    final CompletionHandler<Connection> completionHandler,
    final Throwable failure) {
  connection.closeSilently();
  if (completionHandler != null) {
    completionHandler.failed(failure);
  }
}

origin: javaee/grizzly

protected static void onConnectedAsync(final TCPNIOConnection connection,
    final CompletionHandler<Connection> completionHandler)
    throws IOException {
  final TCPNIOTransport tcpTransport =
      (TCPNIOTransport) connection.getTransport();
  final SocketChannel channel = (SocketChannel) connection.getChannel();
  
  try {
    if (!channel.isConnected()) {
      channel.finishConnect();
    }
    connection.resetProperties();
    // Deregister OP_CONNECT interest
    connection.disableIOEvent(IOEvent.CLIENT_CONNECTED);
    // we can call configure for ready channel
    tcpTransport.getChannelConfigurator().postConfigure(tcpTransport, channel);
  } catch (Exception e) {
    abortConnection(connection, completionHandler, e);
    throw Exceptions.makeIOException(e);
  }
  
  if (connection.notifyReady()) {
    tcpTransport.fireIOEvent(IOEvent.CONNECTED, connection,
        new EnableReadHandler(completionHandler));
  }
}
origin: javaee/grizzly

@Override
public void onComplete(final Context context, final Object data)
    throws IOException {
  final TCPNIOConnection connection =
      (TCPNIOConnection) context.getConnection();
  if (completionHandler != null) {
    completionHandler.completed(connection);
  }
  if (!connection.isStandalone()) {
    connection.enableInitialOpRead();
  }
}
origin: javaee/grizzly

public static Buffer allocateAndReadBuffer(final TCPNIOConnection connection)
    throws IOException {
  final MemoryManager memoryManager = connection.getMemoryManager();
    final int receiveBufferSize =
        Math.min(TCPNIOTransport.MAX_RECEIVE_BUFFER_SIZE,
            connection.getReadBufferSize());
origin: org.glassfish.grizzly/grizzly-http-server-core

TCPNIOConnection obtainNIOConnection(final SocketChannel channel) {
  final TCPNIOConnection connection = new TCPNIOConnection(this, channel);
  configureNIOConnection(connection);
  
  return connection;
}
origin: javaee/grizzly

protected void addRecord(Connection connection,
    Buffer buffer,
    CompletionHandler completionHandler,
    Interceptor<ReadResult> interceptor) {
  final AsyncReadQueueRecord record = AsyncReadQueueRecord.create(
      connection, buffer,
      completionHandler, interceptor);
  ((TCPNIOConnection) connection).getAsyncReadQueue().offer(record);
}
origin: javaee/grizzly

private static void abortConnection(final TCPNIOConnection connection,
    final CompletionHandler<Connection> completionHandler,
    final Throwable failure) {
  connection.closeSilently();
  if (completionHandler != null) {
    completionHandler.failed(failure);
  }
}

origin: javaee/grizzly

protected static void onConnectedAsync(final TCPNIOConnection connection,
    final CompletionHandler<Connection> completionHandler)
    throws IOException {
  final TCPNIOTransport tcpTransport =
      (TCPNIOTransport) connection.getTransport();
  final SocketChannel channel = (SocketChannel) connection.getChannel();
  
  try {
    if (!channel.isConnected()) {
      channel.finishConnect();
    }
    connection.resetProperties();
    // Deregister OP_CONNECT interest
    connection.disableIOEvent(IOEvent.CLIENT_CONNECTED);
    // we can call configure for ready channel
    tcpTransport.getChannelConfigurator().postConfigure(tcpTransport, channel);
  } catch (Exception e) {
    abortConnection(connection, completionHandler, e);
    throw Exceptions.makeIOException(e);
  }
  
  if (connection.notifyReady()) {
    tcpTransport.fireIOEvent(IOEvent.CONNECTED, connection,
        new EnableReadHandler(completionHandler));
  }
}
origin: org.glassfish.grizzly/grizzly-core

@Override
public void onComplete(final Context context, final Object data)
    throws IOException {
  final TCPNIOConnection connection =
      (TCPNIOConnection) context.getConnection();
  if (completionHandler != null) {
    completionHandler.completed(connection);
  }
  if (!connection.isStandalone()) {
    connection.enableInitialOpRead();
  }
}
origin: javaee/grizzly

/**
 * Method will be called, when some data was read on the connection
 */
protected final void onRead(Buffer data, int size) {
  if (size > 0) {
    notifyProbesRead(this, data, size);
  }
  checkEmptyRead(size);
}
origin: javaee/grizzly

public static Buffer allocateAndReadBuffer(final TCPNIOConnection connection)
    throws IOException {
  final MemoryManager memoryManager = connection.getMemoryManager();
    final int receiveBufferSize =
        Math.min(TCPNIOTransport.MAX_RECEIVE_BUFFER_SIZE,
            connection.getReadBufferSize());
origin: javaee/grizzly

TCPNIOConnection obtainNIOConnection(final SocketChannel channel) {
  final TCPNIOConnection connection = new TCPNIOConnection(this, channel);
  configureNIOConnection(connection);
  
  return connection;
}
org.glassfish.grizzly.nio.transportTCPNIOConnection

Javadoc

org.glassfish.grizzly.Connection implementation for the TCPNIOTransport

Most used methods

  • <init>
  • getChannel
  • checkConnectFailed
    Method will be called in order to check if failure happened before Connection was reported as connec
  • checkEmptyRead
  • closeSilently
  • disableIOEvent
  • enableInitialOpRead
  • getAsyncReadQueue
  • getMemoryManager
  • getReadBufferSize
  • getTransport
  • getWriteBufferSize
  • getTransport,
  • getWriteBufferSize,
  • isStandalone,
  • notifyProbesConnect,
  • notifyProbesRead,
  • notifyProbesWrite,
  • notifyReady,
  • onConnect,
  • onRead,
  • onWrite

Popular in Java

  • Making http requests using okhttp
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • onCreateOptionsMenu (Activity)
  • getApplicationContext (Context)
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • Socket (java.net)
    Provides a client-side TCP socket.
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • SortedSet (java.util)
    SortedSet is a Set which iterates over its elements in a sorted order. The order is determined eithe
  • Servlet (javax.servlet)
    Defines methods that all servlets must implement. A servlet is a small Java program that runs within
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now