Fit to 120 column (Done)

This commit is contained in:
Trustin Lee 2012-06-08 21:02:11 +09:00
parent 9479636bd6
commit 3fb5b9e105
26 changed files with 181 additions and 136 deletions

View File

@ -231,12 +231,13 @@ public class ClientBootstrap extends Bootstrap {
}
/**
* Attempts to bind a channel with the specified {@code localAddress}. later the channel can be connected
* to a remoteAddress by calling {@link Channel#connect(SocketAddress)}.This method is useful where bind and connect
* need to be done in separate steps.
* Attempts to bind a channel with the specified {@code localAddress}. later the channel can
* be connected to a remoteAddress by calling {@link Channel#connect(SocketAddress)}.This method
* is useful where bind and connect need to be done in separate steps.
*
* This can also be useful if you want to set an attachment to the {@link Channel} via
* {@link Channel#setAttachment(Object)} so you can use it after the {@link #bind(SocketAddress)} was done.
* {@link Channel#setAttachment(Object)} so you can use it after the {@link #bind(SocketAddress)}
* was done.
* <br>
* For example:
*

View File

@ -1723,13 +1723,15 @@ public interface ChannelBuffer extends Comparable<ChannelBuffer> {
String charsetName, ChannelBufferIndexFinder terminatorFinder);
/**
* @deprecated Use {@link #bytesBefore(int, int, ChannelBufferIndexFinder)} and {@link #toString(int, int, Charset)} instead.
* @deprecated Use {@link #bytesBefore(int, int, ChannelBufferIndexFinder)} and
* {@link #toString(int, int, Charset)} instead.
*/
@Deprecated
String toString(int index, int length, String charsetName);
/**
* @deprecated Use {@link #bytesBefore(int, int, ChannelBufferIndexFinder)} and {@link #toString(int, int, Charset)} instead.
* @deprecated Use {@link #bytesBefore(int, int, ChannelBufferIndexFinder)} and
* {@link #toString(int, int, Charset)} instead.
*/
@Deprecated
String toString(

View File

@ -227,7 +227,8 @@ public final class ChannelBuffers {
* More accurate estimation yields less unexpected reallocation overhead.
* The new buffer's {@code readerIndex} and {@code writerIndex} are {@code 0}.
*/
public static ChannelBuffer dynamicBuffer(ByteOrder endianness, int estimatedLength, ChannelBufferFactory factory) {
public static ChannelBuffer dynamicBuffer(
ByteOrder endianness, int estimatedLength, ChannelBufferFactory factory) {
return new DynamicChannelBuffer(endianness, estimatedLength, factory);
}
@ -308,7 +309,8 @@ public final class ChannelBuffers {
return EMPTY_BUFFER;
}
if (buffer.hasArray()) {
return wrappedBuffer(buffer.order(), buffer.array(), buffer.arrayOffset() + buffer.position(), buffer.remaining());
return wrappedBuffer(
buffer.order(), buffer.array(), buffer.arrayOffset() + buffer.position(), buffer.remaining());
} else {
return new ByteBufferBackedChannelBuffer(buffer);
}
@ -1050,7 +1052,8 @@ public final class ChannelBuffers {
* The default implementation of {@link ChannelBuffer#indexOf(int, int, ChannelBufferIndexFinder)}.
* This method is useful when implementing a new buffer type.
*/
public static int indexOf(ChannelBuffer buffer, int fromIndex, int toIndex, ChannelBufferIndexFinder indexFinder) {
public static int indexOf(
ChannelBuffer buffer, int fromIndex, int toIndex, ChannelBufferIndexFinder indexFinder) {
if (fromIndex <= toIndex) {
return firstIndexOf(buffer, fromIndex, toIndex, indexFinder);
} else {
@ -1118,7 +1121,8 @@ public final class ChannelBuffers {
return -1;
}
private static int firstIndexOf(ChannelBuffer buffer, int fromIndex, int toIndex, ChannelBufferIndexFinder indexFinder) {
private static int firstIndexOf(
ChannelBuffer buffer, int fromIndex, int toIndex, ChannelBufferIndexFinder indexFinder) {
fromIndex = Math.max(fromIndex, 0);
if (fromIndex >= toIndex || buffer.capacity() == 0) {
return -1;
@ -1133,7 +1137,8 @@ public final class ChannelBuffers {
return -1;
}
private static int lastIndexOf(ChannelBuffer buffer, int fromIndex, int toIndex, ChannelBufferIndexFinder indexFinder) {
private static int lastIndexOf(
ChannelBuffer buffer, int fromIndex, int toIndex, ChannelBufferIndexFinder indexFinder) {
fromIndex = Math.min(fromIndex, buffer.capacity());
if (fromIndex < 0 || buffer.capacity() == 0) {
return -1;

View File

@ -56,11 +56,11 @@ public class DirectChannelBufferFactory extends AbstractChannelBufferFactory {
private final Object bigEndianLock = new Object();
private final Object littleEndianLock = new Object();
private final int preallocatedBufferCapacity;
private ChannelBuffer preallocatedBigEndianBuffer;
private int preallocatedBigEndianBufferPosition;
private ChannelBuffer preallocatedLittleEndianBuffer;
private int preallocatedLittleEndianBufferPosition;
private final int preallocatedBufCapacity;
private ChannelBuffer preallocatedBEBuf;
private int preallocatedBEBufPos;
private ChannelBuffer preallocatedLEBuf;
private int preallocatedLEBufPos;
/**
* Creates a new factory whose default {@link ByteOrder} is
@ -96,10 +96,10 @@ public class DirectChannelBufferFactory extends AbstractChannelBufferFactory {
super(defaultOrder);
if (preallocatedBufferCapacity <= 0) {
throw new IllegalArgumentException(
"preallocatedBufferCapacity must be greater than 0: " + preallocatedBufferCapacity);
"preallocatedBufCapacity must be greater than 0: " + preallocatedBufferCapacity);
}
this.preallocatedBufferCapacity = preallocatedBufferCapacity;
this.preallocatedBufCapacity = preallocatedBufferCapacity;
}
public ChannelBuffer getBuffer(ByteOrder order, int capacity) {
@ -112,7 +112,7 @@ public class DirectChannelBufferFactory extends AbstractChannelBufferFactory {
if (capacity == 0) {
return ChannelBuffers.EMPTY_BUFFER;
}
if (capacity >= preallocatedBufferCapacity) {
if (capacity >= preallocatedBufCapacity) {
return ChannelBuffers.directBuffer(order, capacity);
}
@ -160,17 +160,17 @@ public class DirectChannelBufferFactory extends AbstractChannelBufferFactory {
private ChannelBuffer allocateBigEndianBuffer(int capacity) {
ChannelBuffer slice;
synchronized (bigEndianLock) {
if (preallocatedBigEndianBuffer == null) {
preallocatedBigEndianBuffer = ChannelBuffers.directBuffer(ByteOrder.BIG_ENDIAN, preallocatedBufferCapacity);
slice = preallocatedBigEndianBuffer.slice(0, capacity);
preallocatedBigEndianBufferPosition = capacity;
} else if (preallocatedBigEndianBuffer.capacity() - preallocatedBigEndianBufferPosition >= capacity) {
slice = preallocatedBigEndianBuffer.slice(preallocatedBigEndianBufferPosition, capacity);
preallocatedBigEndianBufferPosition += capacity;
if (preallocatedBEBuf == null) {
preallocatedBEBuf = ChannelBuffers.directBuffer(ByteOrder.BIG_ENDIAN, preallocatedBufCapacity);
slice = preallocatedBEBuf.slice(0, capacity);
preallocatedBEBufPos = capacity;
} else if (preallocatedBEBuf.capacity() - preallocatedBEBufPos >= capacity) {
slice = preallocatedBEBuf.slice(preallocatedBEBufPos, capacity);
preallocatedBEBufPos += capacity;
} else {
preallocatedBigEndianBuffer = ChannelBuffers.directBuffer(ByteOrder.BIG_ENDIAN, preallocatedBufferCapacity);
slice = preallocatedBigEndianBuffer.slice(0, capacity);
preallocatedBigEndianBufferPosition = capacity;
preallocatedBEBuf = ChannelBuffers.directBuffer(ByteOrder.BIG_ENDIAN, preallocatedBufCapacity);
slice = preallocatedBEBuf.slice(0, capacity);
preallocatedBEBufPos = capacity;
}
}
return slice;
@ -179,17 +179,17 @@ public class DirectChannelBufferFactory extends AbstractChannelBufferFactory {
private ChannelBuffer allocateLittleEndianBuffer(int capacity) {
ChannelBuffer slice;
synchronized (littleEndianLock) {
if (preallocatedLittleEndianBuffer == null) {
preallocatedLittleEndianBuffer = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, preallocatedBufferCapacity);
slice = preallocatedLittleEndianBuffer.slice(0, capacity);
preallocatedLittleEndianBufferPosition = capacity;
} else if (preallocatedLittleEndianBuffer.capacity() - preallocatedLittleEndianBufferPosition >= capacity) {
slice = preallocatedLittleEndianBuffer.slice(preallocatedLittleEndianBufferPosition, capacity);
preallocatedLittleEndianBufferPosition += capacity;
if (preallocatedLEBuf == null) {
preallocatedLEBuf = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, preallocatedBufCapacity);
slice = preallocatedLEBuf.slice(0, capacity);
preallocatedLEBufPos = capacity;
} else if (preallocatedLEBuf.capacity() - preallocatedLEBufPos >= capacity) {
slice = preallocatedLEBuf.slice(preallocatedLEBufPos, capacity);
preallocatedLEBufPos += capacity;
} else {
preallocatedLittleEndianBuffer = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, preallocatedBufferCapacity);
slice = preallocatedLittleEndianBuffer.slice(0, capacity);
preallocatedLittleEndianBufferPosition = capacity;
preallocatedLEBuf = ChannelBuffers.directBuffer(ByteOrder.LITTLE_ENDIAN, preallocatedBufCapacity);
slice = preallocatedLEBuf.slice(0, capacity);
preallocatedLEBufPos = capacity;
}
}
return slice;

View File

@ -29,46 +29,60 @@ import java.net.SocketAddress;
* <th>Direction</th><th>State</th><th>Value</th><th>Meaning</th>
* </tr>
* <tr>
* <td>Upstream</td><td>{@link #OPEN}</td><td>{@code true}</td><td>The channel is open.</td>
* <td>Upstream</td><td>{@link #OPEN}</td>
* <td>{@code true}</td><td>The channel is open.</td>
* </tr>
* <tr>
* <td>Upstream</td><td>{@link #OPEN}</td><td>{@code false}</td><td>The channel is closed.</td>
* <td>Upstream</td><td>{@link #OPEN}</td>
* <td>{@code false}</td><td>The channel is closed.</td>
* </tr>
* <tr>
* <td>Upstream</td><td>{@link #BOUND}</td><td>{@link SocketAddress}</td><td>The channel is bound to a local address.</td>
* <td>Upstream</td><td>{@link #BOUND}</td>
* <td>{@link SocketAddress}</td><td>The channel is bound to a local address.</td>
* </tr>
* <tr>
* <td>Upstream</td><td>{@link #BOUND}</td><td>{@code null}</td><td>The channel is unbound to a local address.</td>
* <td>Upstream</td><td>{@link #BOUND}</td>
* <td>{@code null}</td><td>The channel is unbound to a local address.</td>
* </tr>
* <tr>
* <td>Upstream</td><td>{@link #CONNECTED}</td><td>{@link SocketAddress}</td><td>The channel is connected to a remote address.</td>
* <td>Upstream</td><td>{@link #CONNECTED}</td>
* <td>{@link SocketAddress}</td><td>The channel is connected to a remote address.</td>
* </tr>
* <tr>
* <td>Upstream</td><td>{@link #CONNECTED}</td><td>{@code null}</td><td>The channel is disconnected from a remote address.</td>
* <td>Upstream</td><td>{@link #CONNECTED}</td>
* <td>{@code null}</td><td>The channel is disconnected from a remote address.</td>
* </tr>
* <tr>
* <td>Upstream</td><td>{@link #INTEREST_OPS}</td><td>an integer</td><td>The channel interestOps has been changed.</td>
* <td>Upstream</td><td>{@link #INTEREST_OPS}</td>
* <td>an integer</td><td>The channel interestOps has been changed.</td>
* </tr>
* <tr>
* <td>Downstream</td><td>{@link #OPEN}</td><td>{@code true}</td><td>N/A</td>
* <td>Downstream</td><td>{@link #OPEN}</td>
* <td>{@code true}</td><td>N/A</td>
* </tr>
* <tr>
* <td>Downstream</td><td>{@link #OPEN}</td><td>{@code false}</td><td>Close the channel.</td>
* <td>Downstream</td><td>{@link #OPEN}</td>
* <td>{@code false}</td><td>Close the channel.</td>
* </tr>
* <tr>
* <td>Downstream</td><td>{@link #BOUND}</td><td>{@link SocketAddress}</td><td>Bind the channel to the specified local address.</td>
* <td>Downstream</td><td>{@link #BOUND}</td>
* <td>{@link SocketAddress}</td><td>Bind the channel to the specified local address.</td>
* </tr>
* <tr>
* <td>Downstream</td><td>{@link #BOUND}</td><td>{@code null}</td><td>Unbind the channel from the current local address.</td>
* <td>Downstream</td><td>{@link #BOUND}</td>
* <td>{@code null}</td><td>Unbind the channel from the current local address.</td>
* </tr>
* <tr>
* <td>Downstream</td><td>{@link #CONNECTED}</td><td>{@link SocketAddress}</td><td>Connect the channel to the specified remote address.</td>
* <td>Downstream</td><td>{@link #CONNECTED}</td>
* <td>{@link SocketAddress}</td><td>Connect the channel to the specified remote address.</td>
* </tr>
* <tr>
* <td>Downstream</td><td>{@link #CONNECTED}</td><td>{@code null}</td><td>Disconnect the channel from the current remote address.</td>
* <td>Downstream</td><td>{@link #CONNECTED}</td>
* <td>{@code null}</td><td>Disconnect the channel from the current remote address.</td>
* </tr>
* <tr>
* <td>Downstream</td><td>{@link #INTEREST_OPS}</td><td>an integer</td><td>Change the interestOps of the channel.</td>
* <td>Downstream</td><td>{@link #INTEREST_OPS}</td>
* <td>an integer</td><td>Change the interestOps of the channel.</td>
* </tr>
* </table>
* <p>

View File

@ -55,7 +55,9 @@ final class DefaultLocalChannel extends AbstractChannel implements LocalChannel
volatile LocalAddress localAddress;
volatile LocalAddress remoteAddress;
DefaultLocalChannel(LocalServerChannel parent, ChannelFactory factory, ChannelPipeline pipeline, ChannelSink sink, DefaultLocalChannel pairedChannel) {
DefaultLocalChannel(
LocalServerChannel parent, ChannelFactory factory, ChannelPipeline pipeline,
ChannelSink sink, DefaultLocalChannel pairedChannel) {
super(parent, factory, pipeline, sink);
this.pairedChannel = pairedChannel;
config = new DefaultChannelConfig();

View File

@ -43,8 +43,8 @@ public class DefaultLocalServerChannelFactory implements LocalServerChannelFacto
/**
* Release all the previous created channels. This takes care of calling {@link LocalChannelRegistry#unregister(LocalAddress)}
* for each if them.
* Release all the previous created channels.
* This takes care of calling {@link LocalChannelRegistry#unregister(LocalAddress)} for each of them.
*/
public void releaseExternalResources() {
group.close().awaitUninterruptibly();

View File

@ -15,9 +15,9 @@
*/
package org.jboss.netty.channel.socket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.StandardSocketOptions;
import org.jboss.netty.channel.ChannelConfig;
import org.jboss.netty.channel.FixedReceiveBufferSizePredictor;
@ -49,9 +49,11 @@ import org.jboss.netty.channel.ReceiveBufferSizePredictorFactory;
* </tr><tr>
* <td>{@code "receiveBufferSize"}</td><td>{@link #setReceiveBufferSize(int)}</td>
* </tr><tr>
* <td>{@code "receiveBufferSizePredictor"}</td><td>{@link #setReceiveBufferSizePredictor(ReceiveBufferSizePredictor)}</td>
* <td>{@code "receiveBufferSizePredictor"}</td>
* <td>{@link #setReceiveBufferSizePredictor(ReceiveBufferSizePredictor)}</td>
* </tr><tr>
* <td>{@code "receiveBufferSizePredictorFactory"}</td><td>{@link #setReceiveBufferSizePredictorFactory(ReceiveBufferSizePredictorFactory)}</td>
* <td>{@code "receiveBufferSizePredictorFactory"}</td>
* <td>{@link #setReceiveBufferSizePredictorFactory(ReceiveBufferSizePredictorFactory)}</td>
* </tr><tr>
* <td>{@code "sendBufferSize"}</td><td>{@link #setSendBufferSize(int)}</td>
* </tr><tr>
@ -64,64 +66,62 @@ import org.jboss.netty.channel.ReceiveBufferSizePredictorFactory;
public interface DatagramChannelConfig extends ChannelConfig {
/**
* Gets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_SNDBUF}</a> option.
* Gets the {@link StandardSocketOptions#SO_SNDBUF} option.
*/
int getSendBufferSize();
/**
* Sets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_SNDBUF}</a> option.
* Sets the {@link StandardSocketOptions#SO_SNDBUF} option.
*/
void setSendBufferSize(int sendBufferSize);
/**
* Gets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_RCVBUF}</a> option.
* Gets the {@link StandardSocketOptions#SO_RCVBUF} option.
*/
int getReceiveBufferSize();
/**
* Gets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_RCVBUF}</a> option.
* Sets the {@link StandardSocketOptions#SO_RCVBUF} option.
*/
void setReceiveBufferSize(int receiveBufferSize);
/**
* Gets the traffic class.
* Gets the {@link StandardSocketOptions#IP_TOS} option.
*/
int getTrafficClass();
/**
* Sets the traffic class as specified in {@link DatagramSocket#setTrafficClass(int)}.
* Gets the {@link StandardSocketOptions#IP_TOS} option.
*/
void setTrafficClass(int trafficClass);
/**
* Gets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_REUSEADDR}</a> option.
* Gets the {@link StandardSocketOptions#SO_REUSEADDR} option.
*/
boolean isReuseAddress();
/**
* Sets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_REUSEADDR}</a> option.
* Sets the {@link StandardSocketOptions#SO_REUSEADDR} option.
*/
void setReuseAddress(boolean reuseAddress);
/**
* Gets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_BROADCAST}</a> option.
* Gets the {@link StandardSocketOptions#SO_BROADCAST} option.
*/
boolean isBroadcast();
/**
* Sets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_BROADCAST}</a> option.
* Sets the {@link StandardSocketOptions#SO_BROADCAST} option.
*/
void setBroadcast(boolean broadcast);
/**
* Gets the setting for local loopback of multicast datagrams.
*
* @return {@code true} if and only if the loopback mode has been disabled
* Gets the {@link StandardSocketOptions#IP_MULTICAST_LOOP} option.
*/
boolean isLoopbackModeDisabled();
/**
* Sets the setting for local loopback of multicast datagrams.
* Sets the {@link StandardSocketOptions#IP_MULTICAST_LOOP} option.
*
* @param loopbackModeDisabled
* {@code true} if and only if the loopback mode has been disabled
@ -129,14 +129,12 @@ public interface DatagramChannelConfig extends ChannelConfig {
void setLoopbackModeDisabled(boolean loopbackModeDisabled);
/**
* Gets the default time-to-live for multicast packets sent out on the
* socket.
* Gets the {@link StandardSocketOptions#IP_MULTICAST_TTL} option.
*/
int getTimeToLive();
/**
* Sets the default time-to-live for multicast packets sent out on the
* {@link DatagramChannel} in order to control the scope of the multicasts.
* Sets the {@link StandardSocketOptions#IP_MULTICAST_TTL} option.
*/
void setTimeToLive(int ttl);
@ -151,14 +149,12 @@ public interface DatagramChannelConfig extends ChannelConfig {
void setInterface(InetAddress interfaceAddress);
/**
* Gets the network interface for outgoing multicast datagrams sent on
* the {@link DatagramChannel}.
* Gets the {@link StandardSocketOptions#IP_MULTICAST_IF} option.
*/
NetworkInterface getNetworkInterface();
/**
* Sets the network interface for outgoing multicast datagrams sent on
* the {@link DatagramChannel}.
* Sets the {@link StandardSocketOptions#IP_MULTICAST_IF} option.
*/
void setNetworkInterface(NetworkInterface networkInterface);

View File

@ -16,6 +16,7 @@
package org.jboss.netty.channel.socket;
import java.net.ServerSocket;
import java.net.StandardSocketOptions;
import org.jboss.netty.channel.ChannelConfig;
@ -55,22 +56,22 @@ public interface ServerSocketChannelConfig extends ChannelConfig {
void setBacklog(int backlog);
/**
* Gets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_REUSEADDR}</a> option.
* Gets the {@link StandardSocketOptions#SO_REUSEADDR} option.
*/
boolean isReuseAddress();
/**
* Sets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_REUSEADDR}</a> option.
* Sets the {@link StandardSocketOptions#SO_REUSEADDR} option.
*/
void setReuseAddress(boolean reuseAddress);
/**
* Gets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_RCVBUF}</a> option.
* Gets the {@link StandardSocketOptions#SO_RCVBUF} option.
*/
int getReceiveBufferSize();
/**
* Sets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_RCVBUF}</a> option.
* Sets the {@link StandardSocketOptions#SO_RCVBUF} option.
*/
void setReceiveBufferSize(int receiveBufferSize);

View File

@ -16,6 +16,7 @@
package org.jboss.netty.channel.socket;
import java.net.Socket;
import java.net.StandardSocketOptions;
import org.jboss.netty.channel.ChannelConfig;
@ -50,72 +51,72 @@ import org.jboss.netty.channel.ChannelConfig;
public interface SocketChannelConfig extends ChannelConfig {
/**
* Gets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_TCPNODELAY}</a> option.
* Gets the {@link StandardSocketOptions#TCP_NODELAY} option.
*/
boolean isTcpNoDelay();
/**
* Sets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_TCPNODELAY}</a> option.
* Sets the {@link StandardSocketOptions#TCP_NODELAY} option.
*/
void setTcpNoDelay(boolean tcpNoDelay);
/**
* Gets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_LINGER}</a> option.
* Gets the {@link StandardSocketOptions#SO_LINGER} option.
*/
int getSoLinger();
/**
* Sets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_LINGER}</a> option.
* Sets the {@link StandardSocketOptions#SO_LINGER} option.
*/
void setSoLinger(int soLinger);
/**
* Gets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_SNDBUF}</a> option.
* Gets the {@link StandardSocketOptions#SO_SNDBUF} option.
*/
int getSendBufferSize();
/**
* Sets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_SNDBUF}</a> option.
* Sets the {@link StandardSocketOptions#SO_SNDBUF} option.
*/
void setSendBufferSize(int sendBufferSize);
/**
* Gets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_RCVBUF}</a> option.
* Gets the {@link StandardSocketOptions#SO_RCVBUF} option.
*/
int getReceiveBufferSize();
/**
* Gets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_RCVBUF}</a> option.
* Sets the {@link StandardSocketOptions#SO_RCVBUF} option.
*/
void setReceiveBufferSize(int receiveBufferSize);
/**
* Gets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_KEEPALIVE}</a> option.
* Gets the {@link StandardSocketOptions#SO_KEEPALIVE} option.
*/
boolean isKeepAlive();
/**
* Sets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_KEEPALIVE}</a> option.
* Sets the {@link StandardSocketOptions#SO_KEEPALIVE} option.
*/
void setKeepAlive(boolean keepAlive);
/**
* Gets the traffic class.
* Gets the {@link StandardSocketOptions#IP_TOS} option.
*/
int getTrafficClass();
/**
* Sets the traffic class as specified in {@link Socket#setTrafficClass(int)}.
* Sets the {@link StandardSocketOptions#IP_TOS} option.
*/
void setTrafficClass(int trafficClass);
/**
* Gets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_REUSEADDR}</a> option.
* Gets the {@link StandardSocketOptions#SO_REUSEADDR} option.
*/
boolean isReuseAddress();
/**
* Sets the <a href="http://java.sun.com/javase/6/docs/technotes/guides/net/socketOpt.html">{@code SO_REUSEADDR}</a> option.
* Sets the {@link StandardSocketOptions#SO_REUSEADDR} option.
*/
void setReuseAddress(boolean reuseAddress);

View File

@ -100,7 +100,9 @@ abstract class AbstractNioChannel<C extends SelectableChannel & WritableByteChan
final C channel;
protected AbstractNioChannel(Integer id, Channel parent, ChannelFactory factory, ChannelPipeline pipeline, ChannelSink sink, AbstractNioWorker worker, C ch) {
protected AbstractNioChannel(
Integer id, Channel parent, ChannelFactory factory, ChannelPipeline pipeline,
ChannelSink sink, AbstractNioWorker worker, C ch) {
super(id, parent, factory, pipeline, sink);
this.worker = worker;
this.channel = ch;

View File

@ -148,7 +148,8 @@ abstract class AbstractNioWorker implements Worker {
}
/**
* Start the {@link AbstractNioWorker} and return the {@link Selector} that will be used for the {@link AbstractNioChannel}'s when they get registered
* Start the {@link AbstractNioWorker} and return the {@link Selector} that will be used for
* the {@link AbstractNioChannel}'s when they get registered
*
* @return selector
*/

View File

@ -25,11 +25,11 @@ import org.jboss.netty.util.ExternalResourceReleasable;
import org.jboss.netty.util.internal.ExecutorUtil;
/**
* Abstract base class for {@link WorkerPool} implementations that create the {@link Worker}'s up-front and return them in a "fair" fashion when calling
* {@link #nextWorker()}
*
* Abstract base class for {@link WorkerPool} implementations that create the {@link Worker}'s
* up-front and return them in a "fair" fashion when calling {@link #nextWorker()}
*/
public abstract class AbstractNioWorkerPool<E extends AbstractNioWorker> implements WorkerPool<E> , ExternalResourceReleasable {
public abstract class AbstractNioWorkerPool<E extends AbstractNioWorker>
implements WorkerPool<E>, ExternalResourceReleasable {
private final AbstractNioWorker[] workers;
private final AtomicInteger workerIndex = new AtomicInteger();
@ -39,7 +39,8 @@ public abstract class AbstractNioWorkerPool<E extends AbstractNioWorker> impleme
* Create a new instance
*
* @param workerExecutor the {@link Executor} to use for the {@link Worker}'s
* @param allowShutdownOnIdle allow the {@link Worker}'s to shutdown when there is not {@link Channel} is registered with it
* @param allowShutdownOnIdle allow the {@link Worker}'s to shutdown when there is not
* {@link Channel} is registered with it
* @param workerCount the count of {@link Worker}'s to create
*/
AbstractNioWorkerPool(Executor workerExecutor, int workerCount, boolean allowShutDownOnIdle) {
@ -65,7 +66,8 @@ public abstract class AbstractNioWorkerPool<E extends AbstractNioWorker> impleme
*
*
* @param executor the {@link Executor} to use
* @param allowShutdownOnIdle allow the {@link Worker} to shutdown when there is not {@link Channel} is registered with it
* @param allowShutdownOnIdle allow the {@link Worker} to shutdown when there is not
* {@link Channel} is registered with it
* @return worker the new {@link Worker}
*/
protected abstract E createWorker(Executor executor, boolean allowShutdownOnIdle);

View File

@ -88,7 +88,8 @@ public class NioClientSocketChannelFactory implements ClientSocketChannelFactory
private final NioClientSocketPipelineSink sink;
/**
* Creates a new {@link NioClientSocketChannelFactory} which uses {@link Executors#newCachedThreadPool()} for the worker and boss executors.
* Creates a new {@link NioClientSocketChannelFactory} which uses {@link Executors#newCachedThreadPool()}
* for the worker and boss executors.
*
* See {@link #NioClientSocketChannelFactory(Executor, Executor)}
*/

View File

@ -130,7 +130,8 @@ public final class NioDatagramChannel extends AbstractNioChannel<DatagramChannel
public ChannelFuture joinGroup(InetAddress multicastAddress) {
try {
return joinGroup(multicastAddress, NetworkInterface.getByInetAddress(getLocalAddress().getAddress()), null);
return joinGroup(
multicastAddress, NetworkInterface.getByInetAddress(getLocalAddress().getAddress()), null);
} catch (SocketException e) {
return Channels.failedFuture(this, e);
}
@ -144,7 +145,8 @@ public final class NioDatagramChannel extends AbstractNioChannel<DatagramChannel
/**
* Joins the specified multicast group at the specified interface using the specified source.
*/
public ChannelFuture joinGroup(InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source) {
public ChannelFuture joinGroup(
InetAddress multicastAddress, NetworkInterface networkInterface, InetAddress source) {
if (DetectionUtil.javaVersion() < 7) {
throw new UnsupportedOperationException();
} else {
@ -185,7 +187,8 @@ public final class NioDatagramChannel extends AbstractNioChannel<DatagramChannel
public ChannelFuture leaveGroup(InetAddress multicastAddress) {
try {
return leaveGroup(multicastAddress, NetworkInterface.getByInetAddress(getLocalAddress().getAddress()), null);
return leaveGroup(
multicastAddress, NetworkInterface.getByInetAddress(getLocalAddress().getAddress()), null);
} catch (SocketException e) {
return Channels.failedFuture(this, e);
}
@ -222,7 +225,8 @@ public final class NioDatagramChannel extends AbstractNioChannel<DatagramChannel
while (keyIt.hasNext()) {
MembershipKey key = keyIt.next();
if (networkInterface.equals(key.networkInterface())) {
if (source == null && key.sourceAddress() == null || source != null && source.equals(key.sourceAddress())) {
if (source == null && key.sourceAddress() == null ||
source != null && source.equals(key.sourceAddress())) {
key.drop();
keyIt.remove();
}

View File

@ -144,7 +144,8 @@ public class NioDatagramChannelFactory implements DatagramChannelFactory {
* Use {@link #NioDatagramChannelFactory(WorkerPool, InternetProtocolFamily)} if unsure.
*
* @param workerPool
* the {@link WorkerPool} which will be used to obtain the {@link NioDatagramWorker} that execute the I/O worker threads
* the {@link WorkerPool} which will be used to obtain the {@link NioDatagramWorker} that execute
* the I/O worker threads
*/
public NioDatagramChannelFactory(WorkerPool<NioDatagramWorker> workerPool) {
this(workerPool, null);
@ -186,7 +187,8 @@ public class NioDatagramChannelFactory implements DatagramChannelFactory {
* Creates a new instance.
*
* @param workerPool
* the {@link WorkerPool} which will be used to obtain the {@link Worker} that execute the I/O worker threads
* the {@link WorkerPool} which will be used to obtain the {@link Worker} that execute
* the I/O worker threads
* @param family
* the {@link InternetProtocolFamily} to use. This should be used for UDP multicast.
* <strong>Be aware that this option is only considered when running on java7+</strong>

View File

@ -38,8 +38,9 @@ class NioDatagramPipelineSink extends AbstractNioChannelSink {
private final WorkerPool<NioDatagramWorker> workerPool;
/**
* Creates a new {@link NioDatagramPipelineSink} with a the number of {@link NioDatagramWorker}s specified in workerCount.
* The {@link NioDatagramWorker}s take care of reading and writing for the {@link NioDatagramChannel}.
* Creates a new {@link NioDatagramPipelineSink} with a the number of {@link NioDatagramWorker}s
* specified in workerCount. The {@link NioDatagramWorker}s take care of reading and writing
* for the {@link NioDatagramChannel}.
*
* @param workerExecutor
* the {@link Executor} that will run the {@link NioDatagramWorker}s

View File

@ -90,7 +90,8 @@ public class NioServerSocketChannelFactory implements ServerSocketChannelFactory
private final ChannelSink sink;
/**
* Create a new {@link NioServerSocketChannelFactory} using {@link Executors#newCachedThreadPool()} for the boss and worker.
* Create a new {@link NioServerSocketChannelFactory} using {@link Executors#newCachedThreadPool()}
* for the boss and worker.
*
* See {@link #NioServerSocketChannelFactory(Executor, Executor)}
*/
@ -136,7 +137,8 @@ public class NioServerSocketChannelFactory implements ServerSocketChannelFactory
* @param bossExecutor
* the {@link Executor} which will execute the boss threads
* @param workerPool
* the {@link WorkerPool} which will be used to obtain the {@link NioWorker} that execute the I/O worker threads
* the {@link WorkerPool} which will be used to obtain the {@link NioWorker} that execute
* the I/O worker threads
*/
public NioServerSocketChannelFactory(
Executor bossExecutor, WorkerPool<NioWorker> workerPool) {

View File

@ -42,9 +42,11 @@ import org.jboss.netty.channel.socket.SocketChannelConfig;
* </tr><tr>
* <td>{@code "writeSpinCount"}</td><td>{@link #setWriteSpinCount(int)}</td>
* </tr><tr>
* <td>{@code "receiveBufferSizePredictor"}</td><td>{@link #setReceiveBufferSizePredictor(ReceiveBufferSizePredictor)}</td>
* <td>{@code "receiveBufferSizePredictor"}</td>
* <td>{@link #setReceiveBufferSizePredictor(ReceiveBufferSizePredictor)}</td>
* </tr><tr>
* <td>{@code "receiveBufferSizePredictorFactory"}</td><td>{@link #setReceiveBufferSizePredictorFactory(ReceiveBufferSizePredictorFactory)}</td>
* <td>{@code "receiveBufferSizePredictorFactory"}</td>
* <td>{@link #setReceiveBufferSizePredictorFactory(ReceiveBufferSizePredictorFactory)}</td>
* </tr>
* </table>
*/

View File

@ -19,8 +19,9 @@ import org.jboss.netty.channel.socket.Worker;
import org.jboss.netty.util.ExternalResourceReleasable;
/**
* This implementation of a {@link WorkerPool} should be used if you plan to share a {@link WorkerPool} between different Factories. You will need to call {@link #destroy()} by your own once
* you want to release any resources of it.
* This implementation of a {@link WorkerPool} should be used if you plan to share a
* {@link WorkerPool} between different Factories. You will need to call {@link #destroy()} by your
* own once you want to release any resources of it.
*
*
*/

View File

@ -27,7 +27,6 @@ import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.CompositeChannelBuffer;
import org.jboss.netty.channel.DefaultFileRegion;
import org.jboss.netty.channel.FileRegion;
import org.jboss.netty.util.internal.DetectionUtil;
final class SocketSendBufferPool {
@ -368,7 +367,8 @@ final class SocketSendBufferPool {
public void release() {
if (file instanceof DefaultFileRegion) {
if (((DefaultFileRegion) file).releaseAfterTransfer()) {
// Make sure the FileRegion resource are released otherwise it may cause a FD leak or something similar
// Make sure the FileRegion resource are released otherwise it may cause a FD
// leak or something similar
file.releaseExternalResources();
}
}

View File

@ -134,10 +134,12 @@ abstract class AbstractOioWorker<C extends AbstractOioChannel> implements Worker
/**
* Process the incoming messages and also is responsible for call {@link Channels#fireMessageReceived(Channel, Object)} once a message
* was processed without errors.
* Process the incoming messages and also is responsible for call
* {@link Channels#fireMessageReceived(Channel, Object)} once a message was processed without
* errors.
*
* @return continue returns <code>true</code> as long as this worker should continue to try processing incoming messages
* @return continue returns <code>true</code> as long as this worker should continue to try
* processing incoming messages
* @throws IOException
*/
abstract boolean process() throws IOException;

View File

@ -91,7 +91,8 @@ public class OioServerSocketChannelFactory implements ServerSocketChannelFactory
private final ChannelSink sink;
/**
* Create a new {@link OioServerSocketChannelFactory} with a {@link Executors#newCachedThreadPool()} for the boss and worker executor.
* Create a new {@link OioServerSocketChannelFactory} with a {@link Executors#newCachedThreadPool()}
* for the boss and worker executor.
*
* See {@link #OioServerSocketChannelFactory(Executor, Executor)}
*/

View File

@ -94,8 +94,8 @@ class OioWorker extends AbstractOioWorker<OioSocketChannel> {
try {
int length = 0;
// Add support to write a FileRegion. This in fact will not give any performance gain but at least it not fail and
// we did the best to emulate it
// Add support to write a FileRegion. This in fact will not give any performance gain
// but at least it not fail and we did the best to emulate it
if (message instanceof FileRegion) {
FileRegion fr = (FileRegion) message;
try {

View File

@ -415,8 +415,8 @@ public class MemoryAwareThreadPoolExecutor extends ThreadPoolExecutor {
}
/**
* Returns if the {@link ChannelFuture}'s of the {@link ChannelEventRunnable}'s should be notified about the shutdown of this {@link MemoryAwareThreadPoolExecutor}.
*
* Returns if the {@link ChannelFuture}'s of the {@link ChannelEventRunnable}'s should be
* notified about the shutdown of this {@link MemoryAwareThreadPoolExecutor}.
*/
public boolean getNotifyChannelFuturesOnShutdown() {
return notifyOnShutdown;

View File

@ -55,8 +55,9 @@ public final class QueueFactory {
} catch (Throwable t) {
// For whatever reason an exception was thrown while loading the LinkedTransferQueue
//
// This mostly happens because of a custom classloader or security policy that did not allow us to access the
// com.sun.Unmisc class. So just log it and fallback to the old LegacyLinkedTransferQueue that works in all cases
// This mostly happens because of a custom classloader or security policy that did not
// allow us to access the com.sun.Unmisc class. So just log it and fallback to the old
// LegacyLinkedTransferQueue that works in all cases
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Unable to instance LinkedTransferQueue, fallback to LegacyLinkedTransferQueue", t);
}
@ -87,8 +88,9 @@ public final class QueueFactory {
} catch (Throwable t) {
// For whatever reason an exception was thrown while loading the LinkedTransferQueue
//
// This mostly happens because of a custom classloader or security policy that did not allow us to access the
// com.sun.Unmisc class. So just log it and fallback to the old LegacyLinkedTransferQueue that works in all cases
// This mostly happens because of a custom classloader or security policy that did not
// allow us to access the com.sun.Unmisc class. So just log it and fallback to the old
// LegacyLinkedTransferQueue that works in all cases
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Unable to instance LinkedTransferQueue, fallback to LegacyLinkedTransferQueue", t);
}