org.glassfish.grizzly.filterchain.FilterChainBuilder Java Examples

The following examples show how to use org.glassfish.grizzly.filterchain.FilterChainBuilder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GrizzlyClient.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@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();
}
 
Example #2
Source File: GrizzlyClient.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@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(getTimeout())
            .setIOStrategy(SameThreadIOStrategy.getInstance());
    transport = builder.build();
    transport.setProcessor(filterChainBuilder.build());
    transport.start();
}
 
Example #3
Source File: GrizzlyClient.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
@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(getTimeout())
            .setIOStrategy(SameThreadIOStrategy.getInstance());
    transport = builder.build();
    transport.setProcessor(filterChainBuilder.build());
    transport.start();
}
 
Example #4
Source File: GrizzlyClient.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@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(getTimeout())
            .setIOStrategy(SameThreadIOStrategy.getInstance());
    transport = builder.build();
    transport.setProcessor(filterChainBuilder.build());
    transport.start();
}
 
Example #5
Source File: GrizzlyClient.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@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(getTimeout())
            .setIOStrategy(SameThreadIOStrategy.getInstance());
    transport = builder.build();
    transport.setProcessor(filterChainBuilder.build());
    transport.start();
}
 
Example #6
Source File: Server.java    From FrameworkBenchmarks with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void setup(final NetworkListener networkListener, final FilterChainBuilder builder) {
	final int fcIdx = builder.indexOfType(FileCacheFilter.class);
	if (fcIdx != -1) {
		builder.remove(fcIdx);
	}

	final int itIdx = builder.indexOfType(IdleTimeoutFilter.class);
	if (itIdx != -1) {
		builder.remove(itIdx);
	}
}
 
Example #7
Source File: WebServer.java    From FrameworkBenchmarks with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void setup(final NetworkListener networkListener, final FilterChainBuilder builder) {
	final int fcIdx = builder.indexOfType(FileCacheFilter.class);
	if (fcIdx != -1) {
		builder.remove(fcIdx);
	}

	final int itIdx = builder.indexOfType(IdleTimeoutFilter.class);
	if (itIdx != -1) {
		builder.remove(itIdx);
	}
}
 
Example #8
Source File: FilterChainAgentIntercept.java    From java-specialagent with Apache License 2.0 4 votes vote down vote up
public static Object enter(final @Advice.This Object thiz) {
  if (AgentRuleUtil.callerEquals(1, 3, "io.opentracing.contrib.grizzly.http.server.TracedFilterChainBuilder.build"))
    return null;

  return new TracedFilterChainBuilder((FilterChainBuilder)thiz, GlobalTracer.get()).build();
}
 
Example #9
Source File: MuleFilterChainAgentIntercept.java    From java-specialagent with Apache License 2.0 4 votes vote down vote up
public static Object enter(final @Advice.This Object thiz) {
  if (AgentRuleUtil.callerEquals(1, 3, "io.opentracing.contrib.grizzly.http.server.TracedFilterChainBuilder.build"))
    return null;

  return new TracedMuleFilterChainBuilder((FilterChainBuilder)thiz, GlobalTracer.get()).build();
}
 
Example #10
Source File: TracedMuleFilterChainBuilder.java    From java-specialagent with Apache License 2.0 4 votes vote down vote up
public TracedMuleFilterChainBuilder(final FilterChainBuilder builder, final Tracer tracer) {
  super(builder, tracer);
}