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

How to use
start
method
in
org.glassfish.grizzly.nio.transport.TCPNIOTransport

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

origin: apache/incubator-dubbo

@Override
protected void doOpen() throws Throwable {
  FilterChainBuilder filterChainBuilder = FilterChainBuilder.stateless();
  filterChainBuilder.add(new TransportFilter());
  filterChainBuilder.add(new GrizzlyCodecAdapter(getCodec(), getUrl(), this));
  filterChainBuilder.add(new GrizzlyHandler(getUrl(), this));
  TCPNIOTransportBuilder builder = TCPNIOTransportBuilder.newInstance();
  ThreadPoolConfig config = builder.getWorkerThreadPoolConfig();
  config.setPoolName(SERVER_THREAD_POOL_NAME).setQueueLimit(-1);
  String threadpool = getUrl().getParameter(Constants.THREADPOOL_KEY, Constants.DEFAULT_THREADPOOL);
  if (Constants.DEFAULT_THREADPOOL.equals(threadpool)) {
    int threads = getUrl().getPositiveParameter(Constants.THREADS_KEY, Constants.DEFAULT_THREADS);
    config.setCorePoolSize(threads).setMaxPoolSize(threads)
        .setKeepAliveTime(0L, TimeUnit.SECONDS);
  } else if ("cached".equals(threadpool)) {
    int threads = getUrl().getPositiveParameter(Constants.THREADS_KEY, Integer.MAX_VALUE);
    config.setCorePoolSize(0).setMaxPoolSize(threads)
        .setKeepAliveTime(60L, TimeUnit.SECONDS);
  } else {
    throw new IllegalArgumentException("Unsupported threadpool type " + threadpool);
  }
  builder.setKeepAlive(true).setReuseAddress(false)
      .setIOStrategy(SameThreadIOStrategy.getInstance());
  transport = builder.build();
  transport.setProcessor(filterChainBuilder.build());
  transport.bind(getBindAddress());
  transport.start();
}
origin: apache/incubator-dubbo

@Override
protected void doOpen() throws Throwable {
  FilterChainBuilder filterChainBuilder = FilterChainBuilder.stateless();
  filterChainBuilder.add(new TransportFilter());
  filterChainBuilder.add(new GrizzlyCodecAdapter(getCodec(), getUrl(), this));
  filterChainBuilder.add(new GrizzlyHandler(getUrl(), this));
  TCPNIOTransportBuilder builder = TCPNIOTransportBuilder.newInstance();
  ThreadPoolConfig config = builder.getWorkerThreadPoolConfig();
  config.setPoolName(SERVER_THREAD_POOL_NAME).setQueueLimit(-1);
  String threadpool = getUrl().getParameter(Constants.THREADPOOL_KEY, Constants.DEFAULT_THREADPOOL);
  if (Constants.DEFAULT_THREADPOOL.equals(threadpool)) {
    int threads = getUrl().getPositiveParameter(Constants.THREADS_KEY, Constants.DEFAULT_THREADS);
    config.setCorePoolSize(threads).setMaxPoolSize(threads)
        .setKeepAliveTime(0L, TimeUnit.SECONDS);
  } else if ("cached".equals(threadpool)) {
    int threads = getUrl().getPositiveParameter(Constants.THREADS_KEY, Integer.MAX_VALUE);
    config.setCorePoolSize(0).setMaxPoolSize(threads)
        .setKeepAliveTime(60L, TimeUnit.SECONDS);
  } else {
    throw new IllegalArgumentException("Unsupported threadpool type " + threadpool);
  }
  builder.setKeepAlive(true).setReuseAddress(false)
      .setIOStrategy(SameThreadIOStrategy.getInstance());
  transport = builder.build();
  transport.setProcessor(filterChainBuilder.build());
  transport.bind(getBindAddress());
  transport.start();
}
origin: apache/incubator-dubbo

@Override
protected void doOpen() throws Throwable {
  FilterChainBuilder filterChainBuilder = FilterChainBuilder.stateless();
  filterChainBuilder.add(new TransportFilter());
  filterChainBuilder.add(new GrizzlyCodecAdapter(getCodec(), getUrl(), this));
  filterChainBuilder.add(new GrizzlyHandler(getUrl(), this));
  TCPNIOTransportBuilder builder = TCPNIOTransportBuilder.newInstance();
  ThreadPoolConfig config = builder.getWorkerThreadPoolConfig();
  config.setPoolName(CLIENT_THREAD_POOL_NAME)
      .setQueueLimit(-1)
      .setCorePoolSize(0)
      .setMaxPoolSize(Integer.MAX_VALUE)
      .setKeepAliveTime(60L, TimeUnit.SECONDS);
  builder.setTcpNoDelay(true).setKeepAlive(true)
      .setConnectionTimeout(getConnectTimeout())
      .setIOStrategy(SameThreadIOStrategy.getInstance());
  transport = builder.build();
  transport.setProcessor(filterChainBuilder.build());
  transport.start();
}
origin: apache/incubator-dubbo

@Override
protected void doOpen() throws Throwable {
  FilterChainBuilder filterChainBuilder = FilterChainBuilder.stateless();
  filterChainBuilder.add(new TransportFilter());
  filterChainBuilder.add(new GrizzlyCodecAdapter(getCodec(), getUrl(), this));
  filterChainBuilder.add(new GrizzlyHandler(getUrl(), this));
  TCPNIOTransportBuilder builder = TCPNIOTransportBuilder.newInstance();
  ThreadPoolConfig config = builder.getWorkerThreadPoolConfig();
  config.setPoolName(CLIENT_THREAD_POOL_NAME)
      .setQueueLimit(-1)
      .setCorePoolSize(0)
      .setMaxPoolSize(Integer.MAX_VALUE)
      .setKeepAliveTime(60L, TimeUnit.SECONDS);
  builder.setTcpNoDelay(true).setKeepAlive(true)
      .setConnectionTimeout(getConnectTimeout())
      .setIOStrategy(SameThreadIOStrategy.getInstance());
  transport = builder.build();
  transport.setProcessor(filterChainBuilder.build());
  transport.start();
}
origin: com.ning/async-http-client

public GrizzlyAsyncHttpProvider(final AsyncHttpClientConfig clientConfig) {
  this.clientConfig = clientConfig;
  this.providerConfig =
      clientConfig.getAsyncHttpProviderConfig() instanceof GrizzlyAsyncHttpProviderConfig ?
      (GrizzlyAsyncHttpProviderConfig) clientConfig.getAsyncHttpProviderConfig()
      : new GrizzlyAsyncHttpProviderConfig();
  final TCPNIOTransportBuilder builder = TCPNIOTransportBuilder.newInstance();
  clientTransport = builder.build();
  initializeTransport(clientConfig);
  connectionManager = new ConnectionManager(this, clientTransport, providerConfig);
  try {
    clientTransport.start();
  } catch (IOException ioe) {
    throw new RuntimeException(ioe);
  }
}
origin: org.glassfish.tyrus/tyrus-container-grizzly-client

private static TCPNIOTransport getOrCreateSharedTransport(
    ThreadPoolConfig workerThreadPoolConfig, ThreadPoolConfig selectorThreadPoolConfig) throws IOException {
  synchronized (TRANSPORT_LOCK) {
    if (transport == null) {
      Logger.getLogger(GrizzlyClientSocket.class.getName()).log(Level.FINE, "Starting shared container.");
      transport = createTransport(workerThreadPoolConfig, selectorThreadPoolConfig, true);
      transport.start();
    }
  }
  return transport;
}
origin: eclipse-ee4j/tyrus

private static TCPNIOTransport getOrCreateSharedTransport(
    ThreadPoolConfig workerThreadPoolConfig, ThreadPoolConfig selectorThreadPoolConfig) throws IOException {
  synchronized (TRANSPORT_LOCK) {
    if (transport == null) {
      Logger.getLogger(GrizzlyClientSocket.class.getName()).log(Level.FINE, "Starting shared container.");
      transport = createTransport(workerThreadPoolConfig, selectorThreadPoolConfig, true);
      transport.start();
    }
  }
  return transport;
}
origin: org.mule.modules/mule-module-http

/**
 * Starts the transport and the {@code idleTimeoutExecutorService} if not started. This is because
 * they should be started lazily when the first server is registered (otherwise there will be Grizzly
 * threads even if there is no listener-config in the app).
 */
private void startTransportIfNotStarted() throws IOException
{
  if (!transportStarted)
  {
    transportStarted = true;
    transport.start();
    idleTimeoutDelayedExecutor.start();
  }
}
origin: org.mule.services/mule-service-http

/**
 * Starts the transport if not started. This is because it should be started lazily when the first server is registered
 * (otherwise there will be Grizzly threads even if there is no HTTP usage in any app).
 */
private void startTransportIfNotStarted() throws ServerCreationException {
 withContextClassLoader(this.getClass().getClassLoader(), () -> {
  if (!transportStarted) {
   transportStarted = true;
   transport.start();
  }
  return null;
 }, ServerCreationException.class, e -> {
  throw new ServerCreationException("Transport failed at startup.", e);
 });
}
origin: org.apache.apex/apex-shaded-ning19

public GrizzlyAsyncHttpProvider(final AsyncHttpClientConfig clientConfig) {
  this.clientConfig = clientConfig;
  this.providerConfig =
      clientConfig.getAsyncHttpProviderConfig() instanceof GrizzlyAsyncHttpProviderConfig ?
      (GrizzlyAsyncHttpProviderConfig) clientConfig.getAsyncHttpProviderConfig()
      : new GrizzlyAsyncHttpProviderConfig();
  final TCPNIOTransportBuilder builder = TCPNIOTransportBuilder.newInstance();
  clientTransport = builder.build();
  initializeTransport(clientConfig);
  connectionManager = new ConnectionManager(this, clientTransport, providerConfig);
  try {
    clientTransport.start();
  } catch (IOException ioe) {
    throw new RuntimeException(ioe);
  }
}
origin: io.gatling/async-http-client

public GrizzlyAsyncHttpProvider(final AsyncHttpClientConfig clientConfig) {
  this.clientConfig = clientConfig;
  this.providerConfig =
      clientConfig.getAsyncHttpProviderConfig() instanceof GrizzlyAsyncHttpProviderConfig ?
      (GrizzlyAsyncHttpProviderConfig) clientConfig.getAsyncHttpProviderConfig()
      : new GrizzlyAsyncHttpProviderConfig();
  final TCPNIOTransportBuilder builder = TCPNIOTransportBuilder.newInstance();
  clientTransport = builder.build();
  initializeTransport(clientConfig);
  connectionManager = new ConnectionManager(this, clientTransport, providerConfig);
  try {
    clientTransport.start();
  } catch (IOException ioe) {
    throw new RuntimeException(ioe);
  }
}
origin: org.glassfish.grizzly/grizzly-http-client

public GrizzlyAsyncHttpProvider(final AsyncHttpClientConfig clientConfig) {
  this.clientConfig = clientConfig;
  this.providerConfig =
      clientConfig.getAsyncHttpProviderConfig() instanceof GrizzlyAsyncHttpProviderConfig ?
      (GrizzlyAsyncHttpProviderConfig) clientConfig.getAsyncHttpProviderConfig()
      : new GrizzlyAsyncHttpProviderConfig();
  final TCPNIOTransportBuilder builder = TCPNIOTransportBuilder.newInstance();
  clientTransport = builder.build();
  initializeTransport(clientConfig);
  connectionManager = new ConnectionManager(this, clientTransport, providerConfig);
  try {
    clientTransport.start();
  } catch (IOException ioe) {
    throw new RuntimeException(ioe);
  }
}
origin: javaee/grizzly-ahc

public GrizzlyAsyncHttpProvider(final AsyncHttpClientConfig clientConfig) {
  this.clientConfig = clientConfig;
  this.providerConfig =
      clientConfig.getAsyncHttpProviderConfig() instanceof GrizzlyAsyncHttpProviderConfig ?
      (GrizzlyAsyncHttpProviderConfig) clientConfig.getAsyncHttpProviderConfig()
      : new GrizzlyAsyncHttpProviderConfig();
  final TCPNIOTransportBuilder builder = TCPNIOTransportBuilder.newInstance();
  clientTransport = builder.build();
  initializeTransport(clientConfig);
  connectionManager = new ConnectionManager(this, clientTransport, providerConfig);
  try {
    clientTransport.start();
  } catch (IOException ioe) {
    throw new RuntimeException(ioe);
  }
}
origin: javaee/grizzly

public void setupServer() {
  servertransport = TCPNIOTransportBuilder.newInstance().build();
  // no use for default memorymanager
  servertransport.configureStandalone(true);
  try {
    final TCPNIOServerConnection serverConnection = servertransport.bind(PORT);
    servertransport.start();
    // Start echo server thread
    startEchoServerThread(servertransport, serverConnection);
  } catch (Exception ex) {
    LOGGER.log(Level.SEVERE, "Server start error", ex);
  }
}
origin: javaee/grizzly

public void setupClient() {
  clienttransport = TCPNIOTransportBuilder.newInstance().build();
  try {
    clienttransport.start();
    clienttransport.configureBlocking(false);
    clienttransport.configureStandalone(true);
    
    Future<Connection> future =
        clienttransport.connect("localhost", PORT);
    clientconnection = future.get(10, TimeUnit.SECONDS);
    assertTrue(clientconnection != null);
    clientconnection.configureStandalone(true);
    clientWriter =
        ((StandaloneProcessor) clientconnection.getProcessor()).
        getStreamWriter(clientconnection);
    
  } catch (Exception ex) {
    LOGGER.log(Level.SEVERE, "Client start error", ex);
  }
}
origin: javaee/grizzly

@Test
public void testCustomThreadPoolSameThreadStrategy() throws Exception {
  final int poolSize = Math.max(Runtime.getRuntime().availableProcessors()/2, 1);
  final ThreadPoolConfig poolCfg = ThreadPoolConfig.defaultConfig();
  poolCfg.setCorePoolSize(poolSize).setMaxPoolSize(poolSize);
  final TCPNIOTransport tcpTransport = TCPNIOTransportBuilder.newInstance()
      .setReuseAddress(true)
      .setIOStrategy(SameThreadIOStrategy.getInstance())
      .setSelectorThreadPoolConfig(poolCfg)
      .setWorkerThreadPoolConfig(null)
      .build();
  try {
    tcpTransport.start();
  } finally {
    tcpTransport.shutdownNow();
  }
}
origin: javaee/grizzly

private void initializeClientTransport() throws IOException {
  final TCPNIOTransport tcpTransport =
      TCPNIOTransportBuilder.newInstance().build();
  tcpTransport.start();
  clientTransport = tcpTransport;
  
  final FilterChain clientFilterChain = FilterChainBuilder.stateless()
      .add(new TransportFilter())
      .add(new StringFilter(Charsets.UTF8_CHARSET))
      .add(new ClientFilter(this))
      .build();
  
  connectorHandler = TCPNIOConnectorHandler.builder(tcpTransport)
      .processor(clientFilterChain)
      .build();
}

origin: javaee/grizzly

@Before
public void init() throws IOException {
  final FilterChain filterChain = FilterChainBuilder.stateless()
      .add(new TransportFilter())
      .add(new BaseFilter() {
    @Override
    public NextAction handleAccept(FilterChainContext ctx) throws IOException {
      serverSideConnections.add(ctx.getConnection());
      return ctx.getStopAction();
    }
    @Override
    public NextAction handleClose(FilterChainContext ctx) throws IOException {
      serverSideConnections.remove(ctx.getConnection());
      return ctx.getStopAction();
    }
  }).build();
  
  transport = TCPNIOTransportBuilder.newInstance().build();
  transport.setProcessor(filterChain);
  
  transport.bind(PORT);
  transport.start();
}

origin: org.apache.dubbo/dubbo-remoting-grizzly

@Override
protected void doOpen() throws Throwable {
  FilterChainBuilder filterChainBuilder = FilterChainBuilder.stateless();
  filterChainBuilder.add(new TransportFilter());
  filterChainBuilder.add(new GrizzlyCodecAdapter(getCodec(), getUrl(), this));
  filterChainBuilder.add(new GrizzlyHandler(getUrl(), this));
  TCPNIOTransportBuilder builder = TCPNIOTransportBuilder.newInstance();
  ThreadPoolConfig config = builder.getWorkerThreadPoolConfig();
  config.setPoolName(CLIENT_THREAD_POOL_NAME)
      .setQueueLimit(-1)
      .setCorePoolSize(0)
      .setMaxPoolSize(Integer.MAX_VALUE)
      .setKeepAliveTime(60L, TimeUnit.SECONDS);
  builder.setTcpNoDelay(true).setKeepAlive(true)
      .setConnectionTimeout(getConnectTimeout())
      .setIOStrategy(SameThreadIOStrategy.getInstance());
  transport = builder.build();
  transport.setProcessor(filterChainBuilder.build());
  transport.start();
}
origin: org.apache.dubbo/dubbo

@Override
protected void doOpen() throws Throwable {
  FilterChainBuilder filterChainBuilder = FilterChainBuilder.stateless();
  filterChainBuilder.add(new TransportFilter());
  filterChainBuilder.add(new GrizzlyCodecAdapter(getCodec(), getUrl(), this));
  filterChainBuilder.add(new GrizzlyHandler(getUrl(), this));
  TCPNIOTransportBuilder builder = TCPNIOTransportBuilder.newInstance();
  ThreadPoolConfig config = builder.getWorkerThreadPoolConfig();
  config.setPoolName(CLIENT_THREAD_POOL_NAME)
      .setQueueLimit(-1)
      .setCorePoolSize(0)
      .setMaxPoolSize(Integer.MAX_VALUE)
      .setKeepAliveTime(60L, TimeUnit.SECONDS);
  builder.setTcpNoDelay(true).setKeepAlive(true)
      .setConnectionTimeout(getConnectTimeout())
      .setIOStrategy(SameThreadIOStrategy.getInstance());
  transport = builder.build();
  transport.setProcessor(filterChainBuilder.build());
  transport.start();
}
org.glassfish.grizzly.nio.transportTCPNIOTransportstart

Popular methods of TCPNIOTransport

  • bind
  • setProcessor
  • shutdownNow
  • isStopped
  • getAsyncQueueIO
  • setTcpNoDelay
  • setLinger
  • unbind
  • getProcessor
  • getServerConnectionBackLog
    Get the default server connection backlog size.
  • setIOStrategy
  • setKeepAlive
  • setIOStrategy,
  • setKeepAlive,
  • setSelectorRunnersCount,
  • setServerConnectionBackLog,
  • shutdown,
  • connect,
  • getLinger,
  • isKeepAlive,
  • isTcpNoDelay

Popular in Java

  • Running tasks concurrently on multiple threads
  • compareTo (BigDecimal)
  • addToBackStack (FragmentTransaction)
  • getApplicationContext (Context)
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • OutputStream (java.io)
    A writable sink for bytes.Most clients will use output streams that write data to the file system (
  • ServerSocket (java.net)
    This class represents a server-side socket that waits for incoming client connections. A ServerSocke
  • Time (java.sql)
    Java representation of an SQL TIME value. Provides utilities to format and parse the time's represen
  • SortedSet (java.util)
    SortedSet is a Set which iterates over its elements in a sorted order. The order is determined eithe
  • Reference (javax.naming)
  • Best IntelliJ plugins
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