Fixed compilation and removed unused fields

This commit is contained in:
Trustin Lee 2011-04-04 18:21:47 +09:00
parent 16750ffc28
commit b26f13d3b9
10 changed files with 12 additions and 55 deletions

View File

@ -57,9 +57,7 @@ class NioClientSocketPipelineSink extends AbstractChannelSink {
static final InternalLogger logger = static final InternalLogger logger =
InternalLoggerFactory.getInstance(NioClientSocketPipelineSink.class); InternalLoggerFactory.getInstance(NioClientSocketPipelineSink.class);
private static final AtomicInteger nextId = new AtomicInteger();
final int id = nextId.incrementAndGet();
final Executor bossExecutor; final Executor bossExecutor;
private final Boss boss = new Boss(); private final Boss boss = new Boss();
private final NioWorker[] workers; private final NioWorker[] workers;
@ -70,7 +68,7 @@ class NioClientSocketPipelineSink extends AbstractChannelSink {
this.bossExecutor = bossExecutor; this.bossExecutor = bossExecutor;
workers = new NioWorker[workerCount]; workers = new NioWorker[workerCount];
for (int i = 0; i < workers.length; i ++) { for (int i = 0; i < workers.length; i ++) {
workers[i] = new NioWorker(id, i + 1, workerExecutor); workers[i] = new NioWorker(workerExecutor);
} }
} }

View File

@ -43,9 +43,6 @@ import org.jboss.netty.channel.MessageEvent;
*/ */
class NioDatagramPipelineSink extends AbstractChannelSink { class NioDatagramPipelineSink extends AbstractChannelSink {
private static final AtomicInteger nextId = new AtomicInteger();
private final int id = nextId.incrementAndGet();
private final NioDatagramWorker[] workers; private final NioDatagramWorker[] workers;
private final AtomicInteger workerIndex = new AtomicInteger(); private final AtomicInteger workerIndex = new AtomicInteger();
@ -62,7 +59,7 @@ class NioDatagramPipelineSink extends AbstractChannelSink {
NioDatagramPipelineSink(final Executor workerExecutor, final int workerCount) { NioDatagramPipelineSink(final Executor workerExecutor, final int workerCount) {
workers = new NioDatagramWorker[workerCount]; workers = new NioDatagramWorker[workerCount];
for (int i = 0; i < workers.length; i ++) { for (int i = 0; i < workers.length; i ++) {
workers[i] = new NioDatagramWorker(id, i + 1, workerExecutor); workers[i] = new NioDatagramWorker(workerExecutor);
} }
} }

View File

@ -64,16 +64,6 @@ class NioDatagramWorker implements Runnable {
private static final InternalLogger logger = InternalLoggerFactory private static final InternalLogger logger = InternalLoggerFactory
.getInstance(NioDatagramWorker.class); .getInstance(NioDatagramWorker.class);
/**
* This id of this worker.
*/
private final int id;
/**
* This id of the NioDatagramPipelineSink.
*/
private final int bossId;
/** /**
* Executor used to execute {@link Runnable}s such as * Executor used to execute {@link Runnable}s such as
* {@link ChannelRegistionTask}. * {@link ChannelRegistionTask}.
@ -131,14 +121,10 @@ class NioDatagramWorker implements Runnable {
/** /**
* Sole constructor. * Sole constructor.
* *
* @param bossId This id of the NioDatagramPipelineSink
* @param id The id of this worker
* @param executor the {@link Executor} used to execute {@link Runnable}s * @param executor the {@link Executor} used to execute {@link Runnable}s
* such as {@link ChannelRegistionTask} * such as {@link ChannelRegistionTask}
*/ */
NioDatagramWorker(final int bossId, final int id, final Executor executor) { NioDatagramWorker(final Executor executor) {
this.bossId = bossId;
this.id = id;
this.executor = executor; this.executor = executor;
} }

View File

@ -53,16 +53,14 @@ class NioServerSocketPipelineSink extends AbstractChannelSink {
static final InternalLogger logger = static final InternalLogger logger =
InternalLoggerFactory.getInstance(NioServerSocketPipelineSink.class); InternalLoggerFactory.getInstance(NioServerSocketPipelineSink.class);
private static final AtomicInteger nextId = new AtomicInteger();
private final int id = nextId.incrementAndGet();
private final NioWorker[] workers; private final NioWorker[] workers;
private final AtomicInteger workerIndex = new AtomicInteger(); private final AtomicInteger workerIndex = new AtomicInteger();
NioServerSocketPipelineSink(Executor workerExecutor, int workerCount) { NioServerSocketPipelineSink(Executor workerExecutor, int workerCount) {
workers = new NioWorker[workerCount]; workers = new NioWorker[workerCount];
for (int i = 0; i < workers.length; i ++) { for (int i = 0; i < workers.length; i ++) {
workers[i] = new NioWorker(id, i + 1, workerExecutor); workers[i] = new NioWorker(workerExecutor);
} }
} }

View File

@ -66,8 +66,6 @@ class NioWorker implements Runnable {
static final int CLEANUP_INTERVAL = 256; // XXX Hard-coded value, but won't need customization. static final int CLEANUP_INTERVAL = 256; // XXX Hard-coded value, but won't need customization.
private final int bossId;
private final int id;
private final Executor executor; private final Executor executor;
private boolean started; private boolean started;
private volatile Thread thread; private volatile Thread thread;
@ -82,9 +80,7 @@ class NioWorker implements Runnable {
private final SocketReceiveBufferPool recvBufferPool = new SocketReceiveBufferPool(); private final SocketReceiveBufferPool recvBufferPool = new SocketReceiveBufferPool();
private final SocketSendBufferPool sendBufferPool = new SocketSendBufferPool(); private final SocketSendBufferPool sendBufferPool = new SocketSendBufferPool();
NioWorker(int bossId, int id, Executor executor) { NioWorker(Executor executor) {
this.bossId = bossId;
this.id = id;
this.executor = executor; this.executor = executor;
} }

View File

@ -20,7 +20,6 @@ import static org.jboss.netty.channel.Channels.*;
import java.io.PushbackInputStream; import java.io.PushbackInputStream;
import java.net.SocketAddress; import java.net.SocketAddress;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicInteger;
import org.jboss.netty.channel.AbstractChannelSink; import org.jboss.netty.channel.AbstractChannelSink;
import org.jboss.netty.channel.ChannelEvent; import org.jboss.netty.channel.ChannelEvent;
@ -42,9 +41,6 @@ import org.jboss.netty.util.internal.DeadLockProofWorker;
*/ */
class OioClientSocketPipelineSink extends AbstractChannelSink { class OioClientSocketPipelineSink extends AbstractChannelSink {
private static final AtomicInteger nextId = new AtomicInteger();
private final int id = nextId.incrementAndGet();
private final Executor workerExecutor; private final Executor workerExecutor;
OioClientSocketPipelineSink(Executor workerExecutor) { OioClientSocketPipelineSink(Executor workerExecutor) {

View File

@ -17,7 +17,6 @@ package org.jboss.netty.channel.socket.oio;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.atomic.AtomicInteger;
import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelPipeline; import org.jboss.netty.channel.ChannelPipeline;
@ -78,11 +77,8 @@ import org.jboss.netty.util.internal.ExecutorUtil;
*/ */
public class OioDatagramChannelFactory implements DatagramChannelFactory { public class OioDatagramChannelFactory implements DatagramChannelFactory {
private static final AtomicInteger nextId = new AtomicInteger();
private final Executor workerExecutor; private final Executor workerExecutor;
final OioDatagramPipelineSink sink; final OioDatagramPipelineSink sink;
final int id = nextId.incrementAndGet();
/** /**
* Creates a new instance. * Creates a new instance.
@ -95,7 +91,7 @@ public class OioDatagramChannelFactory implements DatagramChannelFactory {
throw new NullPointerException("workerExecutor"); throw new NullPointerException("workerExecutor");
} }
this.workerExecutor = workerExecutor; this.workerExecutor = workerExecutor;
sink = new OioDatagramPipelineSink(id, workerExecutor); sink = new OioDatagramPipelineSink(workerExecutor);
} }
@Override @Override

View File

@ -40,11 +40,9 @@ import org.jboss.netty.util.internal.DeadLockProofWorker;
*/ */
class OioDatagramPipelineSink extends AbstractChannelSink { class OioDatagramPipelineSink extends AbstractChannelSink {
private final int id;
private final Executor workerExecutor; private final Executor workerExecutor;
OioDatagramPipelineSink(int id, Executor workerExecutor) { OioDatagramPipelineSink(Executor workerExecutor) {
this.id = id;
this.workerExecutor = workerExecutor; this.workerExecutor = workerExecutor;
} }
@ -141,10 +139,6 @@ class OioDatagramPipelineSink extends AbstractChannelSink {
} }
fireChannelConnected(channel, channel.getRemoteAddress()); fireChannelConnected(channel, channel.getRemoteAddress());
final String service = "OldIO";
final String category = "DatagramWorker";
final String comment = channel.toString();
if (!bound) { if (!bound) {
// Start the business. // Start the business.
DeadLockProofWorker.start( DeadLockProofWorker.start(

View File

@ -24,7 +24,6 @@ import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock;
@ -86,7 +85,6 @@ public class HashedWheelTimer implements Timer {
static final InternalLogger logger = static final InternalLogger logger =
InternalLoggerFactory.getInstance(HashedWheelTimer.class); InternalLoggerFactory.getInstance(HashedWheelTimer.class);
private static final AtomicInteger id = new AtomicInteger();
private static final SharedResourceMisuseDetector misuseDetector = private static final SharedResourceMisuseDetector misuseDetector =
new SharedResourceMisuseDetector(HashedWheelTimer.class); new SharedResourceMisuseDetector(HashedWheelTimer.class);
@ -209,10 +207,7 @@ public class HashedWheelTimer implements Timer {
roundDuration = tickDuration * wheel.length; roundDuration = tickDuration * wheel.length;
workerThread = threadFactory.newThread(new ThreadRenamingRunnable( workerThread = threadFactory.newThread(worker);
worker,
"HashedWheelTimer", null, null,
String.valueOf(id.incrementAndGet()), null));
// Misuse check // Misuse check
misuseDetector.increase(); misuseDetector.increase();

View File

@ -15,13 +15,13 @@
*/ */
package org.jboss.netty.util; package org.jboss.netty.util;
import org.jboss.netty.channel.ChannelFactory;
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import org.jboss.netty.channel.ChannelFactory;
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
/** /**
* A {@link ThreadFactory} that creates a new {@link Thread} with the specified name and thread ID. * A {@link ThreadFactory} that creates a new {@link Thread} with the specified name and thread ID.
* This class is useful when you want to customize the name of the I/O threads: * This class is useful when you want to customize the name of the I/O threads:
@ -84,6 +84,7 @@ public class NamedThreadFactory implements ThreadFactory {
* {@inheritDoc} The name of the thread is {@code "prefix + threadId"}. (e.g. {@code "ioThread-1"} if * {@inheritDoc} The name of the thread is {@code "prefix + threadId"}. (e.g. {@code "ioThread-1"} if
* {@code prefix} is {@code "ioThread-"}. * {@code prefix} is {@code "ioThread-"}.
*/ */
@Override
public Thread newThread(Runnable r) { public Thread newThread(Runnable r) {
Thread t = new Thread(group, r, prefix + threadId.getAndIncrement()); Thread t = new Thread(group, r, prefix + threadId.getAndIncrement());
t.setDaemon(daemon); t.setDaemon(daemon);