本文整理汇总了Java中io.netty.channel.udt.UdtChannel类的典型用法代码示例。如果您正苦于以下问题:Java UdtChannel类的具体用法?Java UdtChannel怎么用?Java UdtChannel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UdtChannel类属于io.netty.channel.udt包,在下文中一共展示了UdtChannel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: run
import io.netty.channel.udt.UdtChannel; //导入依赖的package包/类
public void run() throws Exception {
final ThreadFactory connectFactory = new DefaultThreadFactory("rendezvous");
final NioEventLoopGroup connectGroup = new NioEventLoopGroup(1,
connectFactory, NioUdtProvider.BYTE_PROVIDER);
try {
final Bootstrap bootstrap = new Bootstrap();
bootstrap.group(connectGroup)
.channelFactory(NioUdtProvider.BYTE_RENDEZVOUS)
.handler(new ChannelInitializer<UdtChannel>() {
@Override
protected void initChannel(UdtChannel ch) throws Exception {
ch.pipeline().addLast(
new LoggingHandler(LogLevel.INFO),
new ByteEchoPeerHandler(messageSize));
}
});
final ChannelFuture future = bootstrap.connect(peerAddress, myAddress).sync();
future.channel().closeFuture().sync();
} finally {
connectGroup.shutdownGracefully();
}
}
开发者ID:cowthan,项目名称:JavaAyo,代码行数:23,代码来源:ByteEchoPeerBase.java
示例2: run
import io.netty.channel.udt.UdtChannel; //导入依赖的package包/类
public void run() throws Exception {
final ThreadFactory connectFactory = new UtilThreadFactory("rendezvous");
final NioEventLoopGroup connectGroup = new NioEventLoopGroup(1,
connectFactory, NioUdtProvider.BYTE_PROVIDER);
try {
final Bootstrap bootstrap = new Bootstrap();
bootstrap.group(connectGroup)
.channelFactory(NioUdtProvider.BYTE_RENDEZVOUS)
.handler(new ChannelInitializer<UdtChannel>() {
@Override
protected void initChannel(UdtChannel ch) throws Exception {
ch.pipeline().addLast(
new LoggingHandler(LogLevel.INFO),
new ByteEchoPeerHandler(messageSize));
}
});
final ChannelFuture future = bootstrap.connect(peerAddress, myAddress).sync();
future.channel().closeFuture().sync();
} finally {
connectGroup.shutdownGracefully();
}
}
开发者ID:kyle-liu,项目名称:netty4study,代码行数:23,代码来源:ByteEchoPeerBase.java
示例3: main
import io.netty.channel.udt.UdtChannel; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
// Configure the client.
final ThreadFactory connectFactory = new DefaultThreadFactory("connect");
final NioEventLoopGroup connectGroup = new NioEventLoopGroup(1,
connectFactory, NioUdtProvider.MESSAGE_PROVIDER);
try {
final Bootstrap boot = new Bootstrap();
boot.group(connectGroup)
.channelFactory(NioUdtProvider.MESSAGE_CONNECTOR)
.handler(new ChannelInitializer<UdtChannel>() {
@Override
public void initChannel(final UdtChannel ch)
throws Exception {
ch.pipeline().addLast(
new LoggingHandler(LogLevel.INFO),
new MsgEchoClientHandler());
}
});
// Start the client.
final ChannelFuture f = boot.connect(HOST, PORT).sync();
// Wait until the connection is closed.
f.channel().closeFuture().sync();
} finally {
// Shut down the event loop to terminate all threads.
connectGroup.shutdownGracefully();
}
}
开发者ID:cowthan,项目名称:JavaAyo,代码行数:29,代码来源:MsgEchoClient.java
示例4: main
import io.netty.channel.udt.UdtChannel; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
final ThreadFactory acceptFactory = new DefaultThreadFactory("accept");
final ThreadFactory connectFactory = new DefaultThreadFactory("connect");
final NioEventLoopGroup acceptGroup =
new NioEventLoopGroup(1, acceptFactory, NioUdtProvider.MESSAGE_PROVIDER);
final NioEventLoopGroup connectGroup =
new NioEventLoopGroup(1, connectFactory, NioUdtProvider.MESSAGE_PROVIDER);
// Configure the server.
try {
final ServerBootstrap boot = new ServerBootstrap();
boot.group(acceptGroup, connectGroup)
.channelFactory(NioUdtProvider.MESSAGE_ACCEPTOR)
.option(ChannelOption.SO_BACKLOG, 10)
.handler(new LoggingHandler(LogLevel.INFO))
.childHandler(new ChannelInitializer<UdtChannel>() {
@Override
public void initChannel(final UdtChannel ch)
throws Exception {
ch.pipeline().addLast(
new LoggingHandler(LogLevel.INFO),
new MsgEchoServerHandler());
}
});
// Start the server.
final ChannelFuture future = boot.bind(PORT).sync();
// Wait until the server socket is closed.
future.channel().closeFuture().sync();
} finally {
// Shut down all event loops to terminate all threads.
acceptGroup.shutdownGracefully();
connectGroup.shutdownGracefully();
}
}
开发者ID:cowthan,项目名称:JavaAyo,代码行数:35,代码来源:MsgEchoServer.java
示例5: main
import io.netty.channel.udt.UdtChannel; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
// Configure the client.
final ThreadFactory connectFactory = new DefaultThreadFactory("connect");
final NioEventLoopGroup connectGroup = new NioEventLoopGroup(1,
connectFactory, NioUdtProvider.BYTE_PROVIDER);
try {
final Bootstrap boot = new Bootstrap();
boot.group(connectGroup)
.channelFactory(NioUdtProvider.BYTE_CONNECTOR)
.handler(new ChannelInitializer<UdtChannel>() {
@Override
public void initChannel(final UdtChannel ch)
throws Exception {
ch.pipeline().addLast(
new LoggingHandler(LogLevel.INFO),
new ByteEchoClientHandler());
}
});
// Start the client.
final ChannelFuture f = boot.connect(HOST, PORT).sync();
// Wait until the connection is closed.
f.channel().closeFuture().sync();
} finally {
// Shut down the event loop to terminate all threads.
connectGroup.shutdownGracefully();
}
}
开发者ID:cowthan,项目名称:JavaAyo,代码行数:28,代码来源:ByteEchoClient.java
示例6: main
import io.netty.channel.udt.UdtChannel; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
final ThreadFactory acceptFactory = new DefaultThreadFactory("accept");
final ThreadFactory connectFactory = new DefaultThreadFactory("connect");
final NioEventLoopGroup acceptGroup = new NioEventLoopGroup(1, acceptFactory, NioUdtProvider.BYTE_PROVIDER);
final NioEventLoopGroup connectGroup = new NioEventLoopGroup(1, connectFactory, NioUdtProvider.BYTE_PROVIDER);
// Configure the server.
try {
final ServerBootstrap boot = new ServerBootstrap();
boot.group(acceptGroup, connectGroup)
.channelFactory(NioUdtProvider.BYTE_ACCEPTOR)
.option(ChannelOption.SO_BACKLOG, 10)
.handler(new LoggingHandler(LogLevel.INFO))
.childHandler(new ChannelInitializer<UdtChannel>() {
@Override
public void initChannel(final UdtChannel ch)
throws Exception {
ch.pipeline().addLast(
new LoggingHandler(LogLevel.INFO),
new ByteEchoServerHandler());
}
});
// Start the server.
final ChannelFuture future = boot.bind(PORT).sync();
// Wait until the server socket is closed.
future.channel().closeFuture().sync();
} finally {
// Shut down all event loops to terminate all threads.
acceptGroup.shutdownGracefully();
connectGroup.shutdownGracefully();
}
}
开发者ID:cowthan,项目名称:JavaAyo,代码行数:33,代码来源:ByteEchoServer.java
示例7: run
import io.netty.channel.udt.UdtChannel; //导入依赖的package包/类
public void run() throws Exception {
// Configure the peer.
final ThreadFactory connectFactory = new DefaultThreadFactory("rendezvous");
final NioEventLoopGroup connectGroup = new NioEventLoopGroup(1,
connectFactory, NioUdtProvider.MESSAGE_PROVIDER);
try {
final Bootstrap boot = new Bootstrap();
boot.group(connectGroup)
.channelFactory(NioUdtProvider.MESSAGE_RENDEZVOUS)
.handler(new ChannelInitializer<UdtChannel>() {
@Override
public void initChannel(final UdtChannel ch)
throws Exception {
ch.pipeline().addLast(
new LoggingHandler(LogLevel.INFO),
new MsgEchoPeerHandler(messageSize));
}
});
// Start the peer.
final ChannelFuture f = boot.connect(peer, self).sync();
// Wait until the connection is closed.
f.channel().closeFuture().sync();
} finally {
// Shut down the event loop to terminate all threads.
connectGroup.shutdownGracefully();
}
}
开发者ID:cowthan,项目名称:JavaAyo,代码行数:28,代码来源:MsgEchoPeerBase.java
示例8: run
import io.netty.channel.udt.UdtChannel; //导入依赖的package包/类
@Override
public void run() {
final Bootstrap boot = new Bootstrap();
final ThreadFactory clientFactory = new DefaultThreadFactory("client");
final NioEventLoopGroup connectGroup = new NioEventLoopGroup(1,
clientFactory, NioUdtProvider.BYTE_PROVIDER);
try {
boot.group(connectGroup)
.channelFactory(NioUdtProvider.BYTE_CONNECTOR)
.handler(new ChannelInitializer<UdtChannel>() {
@Override
protected void initChannel(final UdtChannel ch)
throws Exception {
final ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast("framer",
new DelimiterBasedFrameDecoder(8192,
Delimiters.lineDelimiter()));
pipeline.addLast("decoder", new StringDecoder(
CharsetUtil.UTF_8));
pipeline.addLast("encoder", new StringEncoder(
CharsetUtil.UTF_8));
pipeline.addLast("handler", new ClientHandler());
}
});
channel = boot.connect(host, port).sync().channel();
isRunning = true;
log.info("Client ready.");
waitForRunning(false);
log.info("Client closing...");
channel.close().sync();
isShutdown = true;
log.info("Client is done.");
} catch (final Throwable e) {
log.error("Client failed.", e);
} finally {
connectGroup.shutdownGracefully().syncUninterruptibly();
}
}
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:40,代码来源:UDTClientServerConnectionTest.java
示例9: run
import io.netty.channel.udt.UdtChannel; //导入依赖的package包/类
public void run() throws Exception {
// Configure the client.
final ThreadFactory connectFactory = new UtilThreadFactory("connect");
final NioEventLoopGroup connectGroup = new NioEventLoopGroup(1,
connectFactory, NioUdtProvider.MESSAGE_PROVIDER);
try {
final Bootstrap boot = new Bootstrap();
boot.group(connectGroup)
.channelFactory(NioUdtProvider.MESSAGE_CONNECTOR)
.handler(new ChannelInitializer<UdtChannel>() {
@Override
public void initChannel(final UdtChannel ch)
throws Exception {
ch.pipeline().addLast(
new LoggingHandler(LogLevel.INFO),
new MsgEchoClientHandler(messageSize));
}
});
// Start the client.
final ChannelFuture f = boot.connect(host, port).sync();
// Wait until the connection is closed.
f.channel().closeFuture().sync();
} finally {
// Shut down the event loop to terminate all threads.
connectGroup.shutdownGracefully();
}
}
开发者ID:kyle-liu,项目名称:netty4study,代码行数:28,代码来源:MsgEchoClient.java
示例10: run
import io.netty.channel.udt.UdtChannel; //导入依赖的package包/类
public void run() throws Exception {
final ThreadFactory acceptFactory = new UtilThreadFactory("accept");
final ThreadFactory connectFactory = new UtilThreadFactory("connect");
final NioEventLoopGroup acceptGroup = new NioEventLoopGroup(1,
acceptFactory, NioUdtProvider.MESSAGE_PROVIDER);
final NioEventLoopGroup connectGroup = new NioEventLoopGroup(1,
connectFactory, NioUdtProvider.MESSAGE_PROVIDER);
// Configure the server.
try {
final ServerBootstrap boot = new ServerBootstrap();
boot.group(acceptGroup, connectGroup)
.channelFactory(NioUdtProvider.MESSAGE_ACCEPTOR)
.option(ChannelOption.SO_BACKLOG, 10)
.handler(new LoggingHandler(LogLevel.INFO))
.childHandler(new ChannelInitializer<UdtChannel>() {
@Override
public void initChannel(final UdtChannel ch)
throws Exception {
ch.pipeline().addLast(
new LoggingHandler(LogLevel.INFO),
new MsgEchoServerHandler());
}
});
// Start the server.
final ChannelFuture future = boot.bind(port).sync();
// Wait until the server socket is closed.
future.channel().closeFuture().sync();
} finally {
// Shut down all event loops to terminate all threads.
acceptGroup.shutdownGracefully();
connectGroup.shutdownGracefully();
}
}
开发者ID:kyle-liu,项目名称:netty4study,代码行数:34,代码来源:MsgEchoServer.java
示例11: run
import io.netty.channel.udt.UdtChannel; //导入依赖的package包/类
public void run() throws Exception {
// Configure the client.
final ThreadFactory connectFactory = new UtilThreadFactory("connect");
final NioEventLoopGroup connectGroup = new NioEventLoopGroup(1,
connectFactory, NioUdtProvider.BYTE_PROVIDER);
try {
final Bootstrap boot = new Bootstrap();
boot.group(connectGroup)
.channelFactory(NioUdtProvider.BYTE_CONNECTOR)
.handler(new ChannelInitializer<UdtChannel>() {
@Override
public void initChannel(final UdtChannel ch)
throws Exception {
ch.pipeline().addLast(
new LoggingHandler(LogLevel.INFO),
new ByteEchoClientHandler(messageSize));
}
});
// Start the client.
final ChannelFuture f = boot.connect(host, port).sync();
// Wait until the connection is closed.
f.channel().closeFuture().sync();
} finally {
// Shut down the event loop to terminate all threads.
connectGroup.shutdownGracefully();
}
}
开发者ID:kyle-liu,项目名称:netty4study,代码行数:28,代码来源:ByteEchoClient.java
示例12: run
import io.netty.channel.udt.UdtChannel; //导入依赖的package包/类
public void run() throws Exception {
final ThreadFactory acceptFactory = new UtilThreadFactory("accept");
final ThreadFactory connectFactory = new UtilThreadFactory("connect");
final NioEventLoopGroup acceptGroup = new NioEventLoopGroup(1,
acceptFactory, NioUdtProvider.BYTE_PROVIDER);
final NioEventLoopGroup connectGroup = new NioEventLoopGroup(1,
connectFactory, NioUdtProvider.BYTE_PROVIDER);
// Configure the server.
try {
final ServerBootstrap boot = new ServerBootstrap();
boot.group(acceptGroup, connectGroup)
.channelFactory(NioUdtProvider.BYTE_ACCEPTOR)
.option(ChannelOption.SO_BACKLOG, 10)
.handler(new LoggingHandler(LogLevel.INFO))
.childHandler(new ChannelInitializer<UdtChannel>() {
@Override
public void initChannel(final UdtChannel ch)
throws Exception {
ch.pipeline().addLast(
new LoggingHandler(LogLevel.INFO),
new ByteEchoServerHandler());
}
});
// Start the server.
final ChannelFuture future = boot.bind(port).sync();
// Wait until the server socket is closed.
future.channel().closeFuture().sync();
} finally {
// Shut down all event loops to terminate all threads.
acceptGroup.shutdownGracefully();
connectGroup.shutdownGracefully();
}
}
开发者ID:kyle-liu,项目名称:netty4study,代码行数:34,代码来源:ByteEchoServer.java
示例13: run
import io.netty.channel.udt.UdtChannel; //导入依赖的package包/类
public void run() throws Exception {
// Configure the peer.
final ThreadFactory connectFactory = new UtilThreadFactory("rendezvous");
final NioEventLoopGroup connectGroup = new NioEventLoopGroup(1,
connectFactory, NioUdtProvider.MESSAGE_PROVIDER);
try {
final Bootstrap boot = new Bootstrap();
boot.group(connectGroup)
.channelFactory(NioUdtProvider.MESSAGE_RENDEZVOUS)
.handler(new ChannelInitializer<UdtChannel>() {
@Override
public void initChannel(final UdtChannel ch)
throws Exception {
ch.pipeline().addLast(
new LoggingHandler(LogLevel.INFO),
new MsgEchoPeerHandler(messageSize));
}
});
// Start the peer.
final ChannelFuture f = boot.connect(peer, self).sync();
// Wait until the connection is closed.
f.channel().closeFuture().sync();
} finally {
// Shut down the event loop to terminate all threads.
connectGroup.shutdownGracefully();
}
}
开发者ID:kyle-liu,项目名称:netty4study,代码行数:28,代码来源:MsgEchoPeerBase.java
示例14: bindUdtPort
import io.netty.channel.udt.UdtChannel; //导入依赖的package包/类
/**
* Start listening as a server at the given address..
*
* @param addr the address to listen at
* @param port the port number to listen at
* @param bindAllNetworkIfs whether to bind on all network interfaces
* @return true if listening was started
* @throws ChannelException in case binding failed
*/
private boolean bindUdtPort(InetAddress addr, int port, boolean bindAllNetworkIfs) {
if (udtPortsToSockets.containsKey(port)) {
return true;
}
ThreadFactory bossFactory = new UtilThreadFactory("boss");
ThreadFactory workerFactory = new UtilThreadFactory("worker");
NioEventLoopGroup bossGroup = new NioEventLoopGroup(1, bossFactory,
NioUdtProvider.BYTE_PROVIDER);
NioEventLoopGroup workerGroup = new NioEventLoopGroup(1, workerFactory,
NioUdtProvider.BYTE_PROVIDER);
NettyUdtServerHandler handler = new NettyUdtServerHandler(component);
ServerBootstrap bootstrap = new ServerBootstrap();
bootstrap.group(bossGroup, workerGroup).channelFactory(NioUdtProvider.BYTE_ACCEPTOR)
.childHandler(new NettyInitializer<UdtChannel>(handler, msgDecoderClass))
.option(ChannelOption.SO_REUSEADDR, true);
try {
if (bindAllNetworkIfs) {
bootstrap.bind(new InetSocketAddress(port)).sync();
} else {
bootstrap.bind(new InetSocketAddress(addr, port)).sync();
}
logger.debug("Successfully bound to ip:port {}:{}", addr, port);
} catch (InterruptedException e) {
logger.warn("Problem when trying to bind to {}:{}", addr.getHostAddress(), port);
trigger(new Fault(e.getCause()), control);
return false;
}
InetSocketAddress iAddr = new InetSocketAddress(addr, port);
udtPortsToSockets.put(port, iAddr);
udtSocketsToServerBootstraps.put(iAddr, bootstrap);
return true;
}
开发者ID:jimdowling,项目名称:nat-traverser,代码行数:48,代码来源:NettyNetwork.java
示例15: connectUdt
import io.netty.channel.udt.UdtChannel; //导入依赖的package包/类
/**
* Connect to a UDT server.
*
* @param remoteAddress the remote address
* @param localAddress the local address to bind to
* @return true if connection succeeded
* @throws ChannelException if connecting failed
*/
private boolean connectUdt(Address remoteAddress, Address localAddress) {
InetSocketAddress remote = address2SocketAddress(remoteAddress);
InetSocketAddress local = address2SocketAddress(localAddress);
if (udtSocketsToBootstraps.containsKey(remote)) {
return true;
}
ThreadFactory workerFactory = new UtilThreadFactory("clientWorker");
NioEventLoopGroup workerGroup = new NioEventLoopGroup(1, workerFactory,
NioUdtProvider.BYTE_PROVIDER);
NettyStreamHandler handler = new NettyStreamHandler(component, Transport.UDT);
Bootstrap bootstrap = new Bootstrap();
bootstrap.group(workerGroup).channelFactory(NioUdtProvider.BYTE_CONNECTOR)
.handler(new NettyInitializer<UdtChannel>(handler, msgDecoderClass))
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, CONNECT_TIMEOUT_MS)
.option(ChannelOption.SO_REUSEADDR, true);
try {
UdtChannel c = (UdtChannel) bootstrap.connect(remote, local).sync().channel();
addLocalSocket(remote, c);
logger.debug("Successfully connected to ip:port {}", remote.toString());
} catch (InterruptedException e) {
logger.warn("Problem when trying to connect to {}", remote.toString());
trigger(new Fault(e.getCause()), control);
return false;
}
udtSocketsToBootstraps.put(remote, bootstrap);
return true;
}
开发者ID:jimdowling,项目名称:nat-traverser,代码行数:40,代码来源:NettyNetwork.java
示例16: sendUdt
import io.netty.channel.udt.UdtChannel; //导入依赖的package包/类
/**
* Send a message to using UDT. Connects to a server on demand.
*
* @param msg the message to be sent
* @throws ChannelException in case of connection problems
*/
private void sendUdt(RewriteableMsg msg) {
InetSocketAddress dst = address2SocketAddress(msg.getDestination());
UdtChannel channel = udtSocketsToChannels.get(dst);
if (channel == null) {
if (connectUdt(msg.getDestination(), msg.getSource()) == false) {
logger.warn("Channel was null when trying to write msg of type: "
+ msg.getClass().getCanonicalName() + " with dst address: "
+ dst.toString());
trigger(new Fault(new IllegalStateException(
"Could not send messge because connection could not be established to "
+ dst.toString())), control);
return;
}
channel = udtSocketsToChannels.get(dst);
}
try {
logger.trace("Sending " + msg.getClass().getCanonicalName() + " from {} to {} ",
msg.getSource().getId(), msg.getDestination().getId());
channel.writeAndFlush(msg);
totalWrittenBytes += msg.getSize();
} catch (Exception ex) {
ex.printStackTrace();
logger.warn("Problem trying to write msg of type: "
+ msg.getClass().getCanonicalName() + " with dst address: "
+ dst.toString());
throw new RuntimeException(ex.getMessage());
}
}
开发者ID:jimdowling,项目名称:nat-traverser,代码行数:37,代码来源:NettyNetwork.java
示例17: channelActive
import io.netty.channel.udt.UdtChannel; //导入依赖的package包/类
@Override
public void channelActive(ChannelHandlerContext ctx) {
super.channelActive(ctx);
UdtChannel channel = (UdtChannel) ctx.channel();
component.channels.addLocalSocket(channel);
InetSocketAddress other = channel.remoteAddress();
channel.writeAndFlush(new DisambiguateConnection(component.self, new NettyAddress(other), protocol, component.boundUDTPort, true));
}
开发者ID:kompics,项目名称:kompics,代码行数:9,代码来源:UDTServerHandler.java
示例18: disambiguate
import io.netty.channel.udt.UdtChannel; //导入依赖的package包/类
void disambiguate(DisambiguateConnection msg, Channel c) {
synchronized (this) {
if (c.isActive()) { // might have been closed by the time we get the lock?
component.setCustomMDC();
try {
component.extLog.debug("Handling Disamb: {} on {}", msg, c);
if (c instanceof SocketChannel) {
SocketChannel sc = (SocketChannel) c;
address4Remote.put(sc.remoteAddress(), msg.getSource().asSocket());
tcpChannels.put(msg.getSource().asSocket(), sc);
component.networkStatus(ConnectionStatus.established(msg.getSource(), Transport.TCP));
if (!tcpChannels.get(msg.getSource().asSocket()).isEmpty()) { // don't add if we don't have a TCP channel since host is most likely dead
udtBoundPorts.put(msg.getSource().asSocket(), new InetSocketAddress(msg.getSource().getIp(), msg.udtPort));
}
component.trigger(new SendDelayed(msg.getSource(), Transport.TCP));
if (waitingForCreationUDT.remove(msg.getSource().asSocket())) {
component.extLog.debug("Requesting creation of outstanding UDT channel to {}", msg.getSource());
createUDTChannel(msg.getSource(), component.bootstrapUDTClient);
}
} else if (c instanceof UdtChannel) {
UdtChannel uc = (UdtChannel) c;
address4Remote.put(uc.remoteAddress(), msg.getSource().asSocket());
udtChannels.put(msg.getSource().asSocket(), uc);
component.networkStatus(ConnectionStatus.established(msg.getSource(), Transport.UDT));
if (!tcpChannels.get(msg.getSource().asSocket()).isEmpty()) { // don't add if we don't have a TCP channel since host is most likely dead
udtBoundPorts.put(msg.getSource().asSocket(), new InetSocketAddress(msg.getSource().getIp(), msg.udtPort));
}
component.trigger(new SendDelayed(msg.getSource(), Transport.UDT));
}
} finally {
MDC.clear();
}
}
}
}
开发者ID:kompics,项目名称:kompics,代码行数:40,代码来源:ChannelManager.java
示例19: checkUDTChannel
import io.netty.channel.udt.UdtChannel; //导入依赖的package包/类
void checkUDTChannel(Msg msg, UdtChannel c) {
// Ignore some messages
if (msg instanceof CheckChannelActive) {
return;
}
if (msg instanceof CloseChannel) {
return;
}
if (msg instanceof ChannelClosed) {
return;
}
if (!c.equals(udtActiveChannels.get(msg.getSource().asSocket()))) {
synchronized (this) {
component.setCustomMDC();
try {
UdtChannel activeC = udtActiveChannels.get(msg.getSource().asSocket());
udtActiveChannels.put(msg.getSource().asSocket(), c);
udtChannels.put(msg.getSource().asSocket(), c);
if (activeC != null && !activeC.equals(c)) {
component.extLog.warn("Duplicate TCP channel between {} and {}: local {}, remote {}",
new Object[]{msg.getSource(), msg.getDestination(), c.localAddress(), c.remoteAddress()});
UdtChannel minsc = minChannel(udtChannels.get(msg.getSource().asSocket()));
minsc.writeAndFlush(new MessageNotify.Req(new CheckChannelActive(component.self, msg.getSource(), Transport.UDT)));
}
} finally {
MDC.clear();
}
}
component.trigger(new SendDelayed(msg.getSource(), Transport.UDT));
}
}
开发者ID:kompics,项目名称:kompics,代码行数:36,代码来源:ChannelManager.java
示例20: channel2Id
import io.netty.channel.udt.UdtChannel; //导入依赖的package包/类
private int channel2Id(Channel c) {
if (c instanceof SocketChannel) {
return channel2Id((SocketChannel) c);
}
if (c instanceof UdtChannel) {
return channel2Id((UdtChannel) c);
}
throw new NotImplementedException();
}
开发者ID:kompics,项目名称:kompics,代码行数:10,代码来源:ChannelManager.java
注:本文中的io.netty.channel.udt.UdtChannel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论