Rename getChildGroup() to childEventLoopGroup() / Minor cleanup

This commit is contained in:
Trustin Lee 2013-10-08 17:03:20 +09:00
parent e743a27e75
commit 1c15ba0c95
12 changed files with 31 additions and 44 deletions

View File

@ -17,7 +17,6 @@ package io.netty.channel.sctp.nio;
import com.sun.nio.sctp.SctpChannel;
import com.sun.nio.sctp.SctpServerChannel;
import io.netty.channel.ChannelException;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelMetadata;
@ -25,7 +24,6 @@ import io.netty.channel.ChannelOutboundBuffer;
import io.netty.channel.ChannelPromise;
import io.netty.channel.EventLoop;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.AbstractNioMessageChannel;
import io.netty.channel.nio.AbstractNioMessageServerChannel;
import io.netty.channel.sctp.DefaultSctpServerChannelConfig;
import io.netty.channel.sctp.SctpServerChannelConfig;
@ -145,7 +143,7 @@ public class NioSctpServerChannel extends AbstractNioMessageServerChannel
if (ch == null) {
return 0;
}
buf.add(new NioSctpChannel(this, getChildGroup().next(), ch));
buf.add(new NioSctpChannel(this, childEventLoopGroup().next(), ch));
return 1;
}

View File

@ -17,7 +17,6 @@ package io.netty.channel.sctp.oio;
import com.sun.nio.sctp.SctpChannel;
import com.sun.nio.sctp.SctpServerChannel;
import io.netty.channel.ChannelException;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelMetadata;
@ -25,7 +24,6 @@ import io.netty.channel.ChannelOutboundBuffer;
import io.netty.channel.ChannelPromise;
import io.netty.channel.EventLoop;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.oio.AbstractOioMessageChannel;
import io.netty.channel.oio.AbstractOioMessageServerChannel;
import io.netty.channel.sctp.DefaultSctpServerChannelConfig;
import io.netty.channel.sctp.SctpServerChannelConfig;
@ -200,7 +198,7 @@ public class OioSctpServerChannel extends AbstractOioMessageServerChannel
if (key.isAcceptable()) {
s = sch.accept();
if (s != null) {
buf.add(new OioSctpChannel(this, getChildGroup().next(), s));
buf.add(new OioSctpChannel(this, childEventLoopGroup().next(), s));
acceptedChannels ++;
}
}

View File

@ -17,7 +17,6 @@ package io.netty.channel.udt.nio;
import com.barchart.udt.TypeUDT;
import com.barchart.udt.nio.SocketChannelUDT;
import io.netty.channel.ChannelMetadata;
import io.netty.channel.EventLoop;
import io.netty.channel.EventLoopGroup;
@ -41,7 +40,7 @@ public class NioUdtByteAcceptorChannel extends NioUdtAcceptorChannel {
if (channelUDT == null) {
return 0;
} else {
buf.add(new NioUdtByteConnectorChannel(this, getChildGroup().next(), channelUDT));
buf.add(new NioUdtByteConnectorChannel(this, childEventLoopGroup().next(), channelUDT));
return 1;
}
}

View File

@ -17,7 +17,6 @@ package io.netty.channel.udt.nio;
import com.barchart.udt.TypeUDT;
import com.barchart.udt.nio.SocketChannelUDT;
import io.netty.channel.ChannelMetadata;
import io.netty.channel.EventLoop;
import io.netty.channel.EventLoopGroup;
@ -41,7 +40,7 @@ public class NioUdtMessageAcceptorChannel extends NioUdtAcceptorChannel {
if (channelUDT == null) {
return 0;
} else {
buf.add(new NioUdtMessageConnectorChannel(this, getChildGroup().next(), channelUDT));
buf.add(new NioUdtMessageConnectorChannel(this, childEventLoopGroup().next(), channelUDT));
return 1;
}
}

View File

@ -23,15 +23,14 @@ import com.barchart.udt.nio.RendezvousChannelUDT;
import com.barchart.udt.nio.SelectorProviderUDT;
import com.barchart.udt.nio.ServerSocketChannelUDT;
import com.barchart.udt.nio.SocketChannelUDT;
import io.netty.bootstrap.ChannelFactory;
import io.netty.bootstrap.ServerChannelFactory;
import io.netty.channel.Channel;
import io.netty.channel.ChannelException;
import io.netty.channel.EventLoop;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.udt.UdtServerChannel;
import io.netty.channel.udt.UdtChannel;
import io.netty.channel.udt.UdtServerChannel;
import java.io.IOException;
import java.nio.channels.spi.SelectorProvider;
@ -43,7 +42,7 @@ import java.nio.channels.spi.SelectorProvider;
* <p>
* Provides {@link SelectorProvider} for UDT channels.
*/
public abstract class NioUdtProvider<T extends UdtChannel> {
public abstract class NioUdtProvider {
/**
* {@link ChannelFactory} for UDT Byte Acceptor. See {@link TypeUDT#STREAM}
@ -132,8 +131,7 @@ public abstract class NioUdtProvider<T extends UdtChannel> {
/**
* Convenience factory for {@link KindUDT#ACCEPTOR} channels.
*/
protected static ServerSocketChannelUDT newAcceptorChannelUDT(
final TypeUDT type) {
protected static ServerSocketChannelUDT newAcceptorChannelUDT(final TypeUDT type) {
try {
return SelectorProviderUDT.from(type).openServerSocketChannel();
} catch (final IOException e) {
@ -155,8 +153,7 @@ public abstract class NioUdtProvider<T extends UdtChannel> {
/**
* Convenience factory for {@link KindUDT#RENDEZVOUS} channels.
*/
protected static RendezvousChannelUDT newRendezvousChannelUDT(
final TypeUDT type) {
protected static RendezvousChannelUDT newRendezvousChannelUDT(final TypeUDT type) {
try {
return SelectorProviderUDT.from(type).openRendezvousChannel();
} catch (final IOException e) {
@ -197,8 +194,11 @@ public abstract class NioUdtProvider<T extends UdtChannel> {
return kind;
}
private static final class NioUdtChannelFactory<T extends UdtChannel> extends NioUdtProvider<T>
implements ChannelFactory<T> {
/**
* Produce new {@link UdtChannel} based on factory {@link #kind()} and {@link #type()}
*/
private static final class NioUdtChannelFactory<T extends UdtChannel>
extends NioUdtProvider implements ChannelFactory<T> {
private NioUdtChannelFactory(final TypeUDT type, final KindUDT kind) {
super(type, kind);
@ -209,7 +209,7 @@ public abstract class NioUdtProvider<T extends UdtChannel> {
public T newChannel(EventLoop eventLoop) {
switch (kind()) {
case ACCEPTOR:
throw new IllegalStateException("wrong kind=" + kind());
throw new IllegalStateException("wrong kind: " + kind());
case CONNECTOR:
switch (type()) {
case DATAGRAM:
@ -217,7 +217,7 @@ public abstract class NioUdtProvider<T extends UdtChannel> {
case STREAM:
return (T) new NioUdtByteConnectorChannel(eventLoop);
default:
throw new IllegalStateException("wrong type=" + type());
throw new IllegalStateException("wrong type: " + type());
}
case RENDEZVOUS:
switch (type()) {
@ -226,15 +226,15 @@ public abstract class NioUdtProvider<T extends UdtChannel> {
case STREAM:
return (T) new NioUdtByteRendezvousChannel(eventLoop);
default:
throw new IllegalStateException("wrong type=" + type());
throw new IllegalStateException("wrong type: " + type());
}
default:
throw new IllegalStateException("wrong kind=" + kind());
throw new IllegalStateException("wrong kind: " + kind());
}
}
}
private static final class NioUdtServerChannelFactory<T extends UdtServerChannel> extends NioUdtProvider<T>
private static final class NioUdtServerChannelFactory<T extends UdtServerChannel> extends NioUdtProvider
implements ServerChannelFactory<T> {
private NioUdtServerChannelFactory(final TypeUDT type, final KindUDT kind) {
@ -252,27 +252,20 @@ public abstract class NioUdtProvider<T extends UdtChannel> {
case STREAM:
return (T) new NioUdtByteAcceptorChannel(eventLoop, childGroup);
default:
throw new IllegalStateException("wrong type=" + type());
throw new IllegalStateException("wrong type: " + type());
}
case CONNECTOR:
case RENDEZVOUS:
default:
throw new IllegalStateException("wrong kind=" + kind());
throw new IllegalStateException("wrong kind: " + kind());
}
}
}
/**
* Produce new {@link UdtChannel} based on factory {@link #kind()} and {@link #type()}
*/
/*
*/
/**
* UDT Socket Type. See {@link TypeUDT}
*/
public TypeUDT type() {
return type;
}
}

View File

@ -74,7 +74,8 @@ public abstract class AbstractServerChannel extends AbstractChannel implements S
throw new UnsupportedOperationException();
}
public EventLoopGroup getChildGroup() {
@Override
public EventLoopGroup childEventLoopGroup() {
return childGroup;
}

View File

@ -23,5 +23,5 @@ import io.netty.channel.socket.ServerSocketChannel;
*/
public interface ServerChannel extends Channel {
EventLoopGroup getChildGroup();
EventLoopGroup childEventLoopGroup();
}

View File

@ -136,7 +136,7 @@ public class LocalServerChannel extends AbstractServerChannel {
}
LocalChannel serve(final LocalChannel peer) {
final LocalChannel child = new LocalChannel(this, getChildGroup().next(), peer);
final LocalChannel child = new LocalChannel(this, childEventLoopGroup().next(), peer);
if (eventLoop().inEventLoop()) {
serve0(child);
} else {

View File

@ -15,13 +15,13 @@
*/
package io.netty.channel.nio;
import java.nio.channels.SelectableChannel;
import io.netty.channel.Channel;
import io.netty.channel.EventLoop;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.ServerChannel;
import java.nio.channels.SelectableChannel;
public abstract class AbstractNioMessageServerChannel extends AbstractNioMessageChannel implements ServerChannel {
private final EventLoopGroup childGroup;
@ -33,8 +33,8 @@ public abstract class AbstractNioMessageServerChannel extends AbstractNioMessage
}
@Override
public EventLoopGroup getChildGroup() {
return this.childGroup;
public EventLoopGroup childEventLoopGroup() {
return childGroup;
}
}

View File

@ -30,7 +30,7 @@ public abstract class AbstractOioMessageServerChannel extends AbstractOioMessage
}
@Override
public EventLoopGroup getChildGroup() {
public EventLoopGroup childEventLoopGroup() {
return childGroup;
}

View File

@ -20,7 +20,6 @@ import io.netty.channel.ChannelMetadata;
import io.netty.channel.ChannelOutboundBuffer;
import io.netty.channel.EventLoop;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.AbstractNioMessageChannel;
import io.netty.channel.nio.AbstractNioMessageServerChannel;
import io.netty.channel.socket.DefaultServerSocketChannelConfig;
import io.netty.channel.socket.ServerSocketChannelConfig;
@ -116,7 +115,7 @@ public class NioServerSocketChannel extends AbstractNioMessageServerChannel
try {
if (ch != null) {
buf.add(new NioSocketChannel(this, getChildGroup().next(), ch));
buf.add(new NioSocketChannel(this, childEventLoopGroup().next(), ch));
return 1;
}
} catch (Throwable t) {

View File

@ -155,7 +155,7 @@ public class OioServerSocketChannel extends AbstractOioMessageServerChannel impl
Socket s = socket.accept();
try {
if (s != null) {
buf.add(new OioSocketChannel(this, getChildGroup().next(), s));
buf.add(new OioSocketChannel(this, childEventLoopGroup().next(), s));
return 1;
}
} catch (Throwable t) {