• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java SocketChannelConfig类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中io.netty.channel.socket.SocketChannelConfig的典型用法代码示例。如果您正苦于以下问题:Java SocketChannelConfig类的具体用法?Java SocketChannelConfig怎么用?Java SocketChannelConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SocketChannelConfig类属于io.netty.channel.socket包,在下文中一共展示了SocketChannelConfig类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: setSoLingerChannelOption

import io.netty.channel.socket.SocketChannelConfig; //导入依赖的package包/类
@Test
public void setSoLingerChannelOption() throws IOException {
  startServer();
  Map<ChannelOption<?>, Object> channelOptions = new HashMap<ChannelOption<?>, Object>();
  // set SO_LINGER option
  int soLinger = 123;
  channelOptions.put(ChannelOption.SO_LINGER, soLinger);
  NettyClientTransport transport = new NettyClientTransport(
      address, NioSocketChannel.class, channelOptions, group, newNegotiator(),
      DEFAULT_WINDOW_SIZE, DEFAULT_MAX_MESSAGE_SIZE, GrpcUtil.DEFAULT_MAX_HEADER_LIST_SIZE,
      KEEPALIVE_TIME_NANOS_DISABLED, 1L, false, authority, null /* user agent */,
      tooManyPingsRunnable, new TransportTracer());
  transports.add(transport);
  callMeMaybe(transport.start(clientTransportListener));

  // verify SO_LINGER has been set
  ChannelConfig config = transport.channel().config();
  assertTrue(config instanceof SocketChannelConfig);
  assertEquals(soLinger, ((SocketChannelConfig) config).getSoLinger());
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:21,代码来源:NettyClientTransportTest.java


示例2: setBufferSizeIfConfigIsSocketChannelConfig

import io.netty.channel.socket.SocketChannelConfig; //导入依赖的package包/类
private void setBufferSizeIfConfigIsSocketChannelConfig(
		ChannelConfig config, long contentLength) {
	if (config instanceof SocketChannelConfig) {
		int sendBufferSize = contentLength < m_maxSendBufferSize ? (int) contentLength
				: m_maxSendBufferSize;
		((SocketChannelConfig) config).setSendBufferSize(sendBufferSize);
	}
}
 
开发者ID:eBay,项目名称:ServiceCOLDCache,代码行数:9,代码来源:NettyRequestProxyFilter.java


示例3: channelActive

import io.netty.channel.socket.SocketChannelConfig; //导入依赖的package包/类
@Override
public void channelActive(final ChannelHandlerContext ctx) throws Exception {
  final SocketChannelConfig config = (SocketChannelConfig) ctx.channel().config();

  // Disable Nagle's algorithm
  config.setTcpNoDelay(true);

  // Setup TCP keepalive
  config.setKeepAlive(true);

  super.channelActive(ctx);

  // Our work is done
  ctx.channel().pipeline().remove(this);
}
 
开发者ID:spotify,项目名称:folsom,代码行数:16,代码来源:TcpTuningHandler.java


示例4: testFilterRequest

import io.netty.channel.socket.SocketChannelConfig; //导入依赖的package包/类
@Test
public void testFilterRequest() throws IOException {
	AppConfiguration appConfig = new AppConfiguration(new ConfigLoader(),
			null);
	appConfig.init();

	PolicyManager policyManager = mock(PolicyManager.class);
	NettyRequestProxyFilter filter = new NettyRequestProxyFilter(
			policyManager, appConfig);

	ChannelHandlerContext ctx = mock(ChannelHandlerContext.class);
	when(ctx.attr(any(AttributeKey.class))).thenReturn(
			mock(Attribute.class));
	assertNull(filter.filterRequest(mock(HttpRequest.class), ctx));

	DefaultFullHttpRequest req = new DefaultFullHttpRequest(
			HttpVersion.HTTP_1_1, HttpMethod.GET, "http://test.ebay.com/s/");
	when(policyManager.cacheIsNeededFor(any(CacheDecisionObject.class)))
			.thenReturn(false);
	assertNull(filter.filterRequest(req, ctx));

	when(policyManager.cacheIsNeededFor(any(CacheDecisionObject.class)))
			.thenReturn(true);
	CacheManager cm = mock(CacheManager.class);
	when(policyManager.getCacheManager()).thenReturn(cm);
	assertNull(filter.filterRequest(req, ctx));

	FullHttpResponse resp = mock(FullHttpResponse.class);
	HttpHeaders respHeaders = mock(HttpHeaders.class);
	when(resp.headers()).thenReturn(respHeaders);
	when(respHeaders.get(any(CharSequence.class))).thenReturn("100");
	when(cm.get(anyString())).thenReturn(resp);
	Channel channel = mock(Channel.class);
	SocketChannelConfig config = mock(SocketChannelConfig.class);
	when(channel.config()).thenReturn(config);
	when(ctx.channel()).thenReturn(channel);
	req.headers().add("h1", "v1");

	when(resp.content()).thenReturn(
			new EmptyByteBuf(new PooledByteBufAllocator())).thenReturn(
			Unpooled.copiedBuffer("Hello".getBytes()));
	assertEquals(resp, filter.filterRequest(req, ctx));
	assertEquals(resp, filter.filterRequest(req, ctx));
}
 
开发者ID:eBay,项目名称:ServiceCOLDCache,代码行数:45,代码来源:NettyRequestProxyFilterTest.java


示例5: configureChannel

import io.netty.channel.socket.SocketChannelConfig; //导入依赖的package包/类
/**
 * Template method for changing properties on the given {@link SocketChannelConfig}.
 * <p>The default implementation sets the connect timeout based on the set property.
 * @param config the channel configuration
 */
protected void configureChannel(SocketChannelConfig config) {
	if (this.connectTimeout >= 0) {
		config.setConnectTimeoutMillis(this.connectTimeout);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:Netty4ClientHttpRequestFactory.java


示例6: configure

import io.netty.channel.socket.SocketChannelConfig; //导入依赖的package包/类
private void configure(SocketChannelConfig channelConfiguration) {
	channelConfiguration.setConnectTimeoutMillis(nettyHttpClientRequestConfiguration.connectionTimeout());
}
 
开发者ID:ljtfreitas,项目名称:java-restify,代码行数:4,代码来源:NettyBootstrapFactory.java


示例7: configureChannel

import io.netty.channel.socket.SocketChannelConfig; //导入依赖的package包/类
/**
 * Template method for changing properties on the given {@link SocketChannelConfig}.
 * <p>The default implementation sets the connect timeout based on the set property.
 * @param config the channel configuration
 */
protected void configureChannel(SocketChannelConfig config) {
    if (this.connectTimeout >= 0) {
        config.setConnectTimeoutMillis(this.connectTimeout);
    }
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:11,代码来源:NettyRequestFactory.java


示例8: config

import io.netty.channel.socket.SocketChannelConfig; //导入依赖的package包/类
@Override
public SocketChannelConfig config() {
    return config;
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:5,代码来源:NioSocketChannel.java


示例9: setTcpNoDelay

import io.netty.channel.socket.SocketChannelConfig; //导入依赖的package包/类
@Override
public SocketChannelConfig setTcpNoDelay(boolean tcpNoDelay) {
    channel.setOption(Options.TCP_NODELAY, tcpNoDelay);
    return this;
}
 
开发者ID:xnio,项目名称:netty-xnio-transport,代码行数:6,代码来源:XnioSocketChannelConfig.java


示例10: setSoLinger

import io.netty.channel.socket.SocketChannelConfig; //导入依赖的package包/类
@Override
public SocketChannelConfig setSoLinger(int soLinger) {
    throw new UnsupportedOperationException();
}
 
开发者ID:xnio,项目名称:netty-xnio-transport,代码行数:5,代码来源:XnioSocketChannelConfig.java


示例11: setSendBufferSize

import io.netty.channel.socket.SocketChannelConfig; //导入依赖的package包/类
@Override
public SocketChannelConfig setSendBufferSize(int sendBufferSize) {
    channel.setOption(Options.SEND_BUFFER, sendBufferSize);
    return this;
}
 
开发者ID:xnio,项目名称:netty-xnio-transport,代码行数:6,代码来源:XnioSocketChannelConfig.java


示例12: setReceiveBufferSize

import io.netty.channel.socket.SocketChannelConfig; //导入依赖的package包/类
@Override
public SocketChannelConfig setReceiveBufferSize(int receiveBufferSize) {
    channel.setOption(Options.RECEIVE_BUFFER, receiveBufferSize);
    return this;
}
 
开发者ID:xnio,项目名称:netty-xnio-transport,代码行数:6,代码来源:XnioSocketChannelConfig.java


示例13: setKeepAlive

import io.netty.channel.socket.SocketChannelConfig; //导入依赖的package包/类
@Override
public SocketChannelConfig setKeepAlive(boolean keepAlive) {
    channel.setOption(Options.KEEP_ALIVE, keepAlive);
    return this;
}
 
开发者ID:xnio,项目名称:netty-xnio-transport,代码行数:6,代码来源:XnioSocketChannelConfig.java


示例14: setTrafficClass

import io.netty.channel.socket.SocketChannelConfig; //导入依赖的package包/类
@Override
public SocketChannelConfig setTrafficClass(int trafficClass) {
    channel.setOption(Options.IP_TRAFFIC_CLASS, trafficClass);
    return this;
}
 
开发者ID:xnio,项目名称:netty-xnio-transport,代码行数:6,代码来源:XnioSocketChannelConfig.java


示例15: setReuseAddress

import io.netty.channel.socket.SocketChannelConfig; //导入依赖的package包/类
@Override
public SocketChannelConfig setReuseAddress(boolean reuseAddress) {
    channel.setOption(Options.REUSE_ADDRESSES, reuseAddress);
    return this;
}
 
开发者ID:xnio,项目名称:netty-xnio-transport,代码行数:6,代码来源:XnioSocketChannelConfig.java


示例16: setPerformancePreferences

import io.netty.channel.socket.SocketChannelConfig; //导入依赖的package包/类
@Override
public SocketChannelConfig setPerformancePreferences(int connectionTime, int latency, int bandwidth) {
    throw new UnsupportedOperationException();
}
 
开发者ID:xnio,项目名称:netty-xnio-transport,代码行数:5,代码来源:XnioSocketChannelConfig.java


示例17: setAllowHalfClosure

import io.netty.channel.socket.SocketChannelConfig; //导入依赖的package包/类
@Override
public SocketChannelConfig setAllowHalfClosure(boolean allowHalfClosure) {
    throw new UnsupportedOperationException();
}
 
开发者ID:xnio,项目名称:netty-xnio-transport,代码行数:5,代码来源:XnioSocketChannelConfig.java


示例18: setConnectTimeoutMillis

import io.netty.channel.socket.SocketChannelConfig; //导入依赖的package包/类
@Override
public SocketChannelConfig setConnectTimeoutMillis(int connectTimeoutMillis) {
    super.setConnectTimeoutMillis(connectTimeoutMillis);
    return this;
}
 
开发者ID:xnio,项目名称:netty-xnio-transport,代码行数:6,代码来源:XnioSocketChannelConfig.java


示例19: setMaxMessagesPerRead

import io.netty.channel.socket.SocketChannelConfig; //导入依赖的package包/类
@Override
public SocketChannelConfig setMaxMessagesPerRead(int maxMessagesPerRead) {
    super.setMaxMessagesPerRead(maxMessagesPerRead);
    return this;
}
 
开发者ID:xnio,项目名称:netty-xnio-transport,代码行数:6,代码来源:XnioSocketChannelConfig.java


示例20: setWriteSpinCount

import io.netty.channel.socket.SocketChannelConfig; //导入依赖的package包/类
@Override
public SocketChannelConfig setWriteSpinCount(int writeSpinCount) {
    super.setWriteSpinCount(writeSpinCount);
    return this;
}
 
开发者ID:xnio,项目名称:netty-xnio-transport,代码行数:6,代码来源:XnioSocketChannelConfig.java



注:本文中的io.netty.channel.socket.SocketChannelConfig类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AssumeRoleResult类代码示例发布时间:2022-05-22
下一篇:
Java VisibilityChecker类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap