io.netty.channel.kqueue.KQueueSocketChannel Java Examples
The following examples show how to use
io.netty.channel.kqueue.KQueueSocketChannel.
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: DefaultLoopKQueue.java From reactor-netty with Apache License 2.0 | 6 votes |
@Override @SuppressWarnings("unchecked") public <CHANNEL extends Channel> CHANNEL getChannel(Class<CHANNEL> channelClass) { if (channelClass.equals(SocketChannel.class)) { return (CHANNEL) new KQueueSocketChannel(); } if (channelClass.equals(ServerSocketChannel.class)) { return (CHANNEL) new KQueueServerSocketChannel(); } if (channelClass.equals(DatagramChannel.class)) { return (CHANNEL) new KQueueDatagramChannel(); } if (channelClass.equals(DomainSocketChannel.class)) { return (CHANNEL) new KQueueDomainSocketChannel(); } if (channelClass.equals(ServerDomainSocketChannel.class)) { return (CHANNEL) new KQueueServerDomainSocketChannel(); } throw new IllegalArgumentException("Unsupported channel type: " + channelClass.getSimpleName()); }
Example #2
Source File: Connector.java From serve with Apache License 2.0 | 5 votes |
public Class<? extends Channel> getClientChannel() { if (useNativeIo && Epoll.isAvailable()) { return uds ? EpollDomainSocketChannel.class : EpollSocketChannel.class; } else if (useNativeIo && KQueue.isAvailable()) { return uds ? KQueueDomainSocketChannel.class : KQueueSocketChannel.class; } return NioSocketChannel.class; }
Example #3
Source File: BuilderUtils.java From servicetalk with Apache License 2.0 | 5 votes |
/** * Returns the correct {@link Class} to use with the given {@link EventLoopGroup}. * * @param group the {@link EventLoopGroup} for which the class is needed * @param addressClass The class of the address that to connect to. * @return the class that should be used for bootstrapping */ public static Class<? extends Channel> socketChannel(EventLoopGroup group, Class<? extends SocketAddress> addressClass) { if (useEpoll(group)) { return DomainSocketAddress.class.isAssignableFrom(addressClass) ? EpollDomainSocketChannel.class : EpollSocketChannel.class; } else if (useKQueue(group)) { return DomainSocketAddress.class.isAssignableFrom(addressClass) ? KQueueDomainSocketChannel.class : KQueueSocketChannel.class; } else { return NioSocketChannel.class; } }
Example #4
Source File: BuilderUtils.java From servicetalk with Apache License 2.0 | 5 votes |
/** * Returns the correct Channel that wraps the given filedescriptor or {@code null} if not supported. * * @param group the {@link EventLoopGroup} for which the class is needed * @param address the filedescriptor to wrap. * @return the class that should be used for bootstrapping */ @Nullable public static Channel socketChannel(EventLoopGroup group, FileDescriptorSocketAddress address) { if (useEpoll(group)) { return new EpollSocketChannel(address.getValue()); } if (useKQueue(group)) { return new KQueueSocketChannel(address.getValue()); } return null; }
Example #5
Source File: Connector.java From multi-model-server with Apache License 2.0 | 5 votes |
public Class<? extends Channel> getClientChannel() { if (useNativeIo && Epoll.isAvailable()) { return uds ? EpollDomainSocketChannel.class : EpollSocketChannel.class; } else if (useNativeIo && KQueue.isAvailable()) { return uds ? KQueueDomainSocketChannel.class : KQueueSocketChannel.class; } return NioSocketChannel.class; }
Example #6
Source File: DefaultLoopKQueue.java From reactor-netty with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") public <CHANNEL extends Channel> Class<? extends CHANNEL> getChannelClass(Class<CHANNEL> channelClass) { if (channelClass.equals(SocketChannel.class)) { return (Class<? extends CHANNEL>) KQueueSocketChannel.class; } if (channelClass.equals(ServerSocketChannel.class)) { return (Class<? extends CHANNEL>) KQueueServerSocketChannel.class; } if (channelClass.equals(DatagramChannel.class)) { return (Class<? extends CHANNEL>) KQueueDatagramChannel.class; } throw new IllegalArgumentException("Unsupported channel type: " + channelClass.getSimpleName()); }
Example #7
Source File: SocketChannelProvider.java From Jupiter with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Override public T newChannel() { switch (channelType) { case ACCEPTOR: switch (socketType) { case JAVA_NIO: return (T) new NioServerSocketChannel(); case NATIVE_EPOLL: return (T) new EpollServerSocketChannel(); case NATIVE_KQUEUE: return (T) new KQueueServerSocketChannel(); case NATIVE_EPOLL_DOMAIN: return (T) new EpollServerDomainSocketChannel(); case NATIVE_KQUEUE_DOMAIN: return (T) new KQueueServerDomainSocketChannel(); default: throw new IllegalStateException("Invalid socket type: " + socketType); } case CONNECTOR: switch (socketType) { case JAVA_NIO: return (T) new NioSocketChannel(); case NATIVE_EPOLL: return (T) new EpollSocketChannel(); case NATIVE_KQUEUE: return (T) new KQueueSocketChannel(); case NATIVE_EPOLL_DOMAIN: return (T) new EpollDomainSocketChannel(); case NATIVE_KQUEUE_DOMAIN: return (T) new KQueueDomainSocketChannel(); default: throw new IllegalStateException("Invalid socket type: " + socketType); } default: throw new IllegalStateException("Invalid channel type: " + channelType); } }
Example #8
Source File: NetworkUtils.java From CloudNet with Apache License 2.0 | 4 votes |
public static Class<? extends SocketChannel> socketChannel() { return EPOLL ? EpollSocketChannel.class : KQueue.isAvailable() ? KQueueSocketChannel.class : NioSocketChannel.class; }
Example #9
Source File: MasterSlaveConnectionManager.java From redisson with Apache License 2.0 | 4 votes |
protected MasterSlaveConnectionManager(Config cfg, UUID id) { this.id = id.toString(); Version.logVersion(); if (cfg.getTransportMode() == TransportMode.EPOLL) { if (cfg.getEventLoopGroup() == null) { this.group = new EpollEventLoopGroup(cfg.getNettyThreads(), new DefaultThreadFactory("redisson-netty")); } else { this.group = cfg.getEventLoopGroup(); } this.socketChannelClass = EpollSocketChannel.class; if (PlatformDependent.isAndroid()) { this.resolverGroup = DefaultAddressResolverGroup.INSTANCE; } else { this.resolverGroup = cfg.getAddressResolverGroupFactory().create(EpollDatagramChannel.class, DnsServerAddressStreamProviders.platformDefault()); } } else if (cfg.getTransportMode() == TransportMode.KQUEUE) { if (cfg.getEventLoopGroup() == null) { this.group = new KQueueEventLoopGroup(cfg.getNettyThreads(), new DefaultThreadFactory("redisson-netty")); } else { this.group = cfg.getEventLoopGroup(); } this.socketChannelClass = KQueueSocketChannel.class; if (PlatformDependent.isAndroid()) { this.resolverGroup = DefaultAddressResolverGroup.INSTANCE; } else { this.resolverGroup = cfg.getAddressResolverGroupFactory().create(KQueueDatagramChannel.class, DnsServerAddressStreamProviders.platformDefault()); } } else { if (cfg.getEventLoopGroup() == null) { this.group = new NioEventLoopGroup(cfg.getNettyThreads(), new DefaultThreadFactory("redisson-netty")); } else { this.group = cfg.getEventLoopGroup(); } this.socketChannelClass = NioSocketChannel.class; if (PlatformDependent.isAndroid()) { this.resolverGroup = DefaultAddressResolverGroup.INSTANCE; } else { this.resolverGroup = cfg.getAddressResolverGroupFactory().create(NioDatagramChannel.class, DnsServerAddressStreamProviders.platformDefault()); } } if (cfg.getExecutor() == null) { int threads = Runtime.getRuntime().availableProcessors() * 2; if (cfg.getThreads() != 0) { threads = cfg.getThreads(); } executor = Executors.newFixedThreadPool(threads, new DefaultThreadFactory("redisson")); } else { executor = cfg.getExecutor(); } this.cfg = cfg; this.codec = cfg.getCodec(); this.commandExecutor = new CommandSyncService(this); }
Example #10
Source File: KQueueSupport.java From qpid-jms with Apache License 2.0 | 4 votes |
public static void createChannel(Bootstrap bootstrap) { bootstrap.channel(KQueueSocketChannel.class); }