diff --git a/akka-actor/src/main/java/org/jboss/netty/akka/logging/AbstractInternalLogger.java b/akka-actor/src/main/java/org/jboss/netty/akka/logging/AbstractInternalLogger.java deleted file mode 100644 index 555ea86f09..0000000000 --- a/akka-actor/src/main/java/org/jboss/netty/akka/logging/AbstractInternalLogger.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2009 Red Hat, Inc. - * - * Red Hat licenses this file to you under the Apache License, version 2.0 - * (the "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package org.jboss.netty.akka.logging; - -/** - * A skeletal implementation of {@link InternalLogger}. This class implements - * all methods that have a {@link InternalLogLevel} parameter by default to call - * specific logger methods such as {@link #info(String)} or {@link #isInfoEnabled()}. - * - * @author The Netty Project - * @author Trustin Lee - * @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $ - */ -public abstract class AbstractInternalLogger implements InternalLogger { - - /** - * Creates a new instance. - */ - protected AbstractInternalLogger() { - super(); - } - - public boolean isEnabled(InternalLogLevel level) { - switch (level) { - case DEBUG: - return isDebugEnabled(); - case INFO: - return isInfoEnabled(); - case WARN: - return isWarnEnabled(); - case ERROR: - return isErrorEnabled(); - default: - throw new Error(); - } - } - - public void log(InternalLogLevel level, String msg, Throwable cause) { - switch (level) { - case DEBUG: - debug(msg, cause); - break; - case INFO: - info(msg, cause); - break; - case WARN: - warn(msg, cause); - break; - case ERROR: - error(msg, cause); - break; - default: - throw new Error(); - } - } - - public void log(InternalLogLevel level, String msg) { - switch (level) { - case DEBUG: - debug(msg); - break; - case INFO: - info(msg); - break; - case WARN: - warn(msg); - break; - case ERROR: - error(msg); - break; - default: - throw new Error(); - } - } -} diff --git a/akka-actor/src/main/java/org/jboss/netty/akka/logging/InternalLogLevel.java b/akka-actor/src/main/java/org/jboss/netty/akka/logging/InternalLogLevel.java deleted file mode 100644 index c9963d26d6..0000000000 --- a/akka-actor/src/main/java/org/jboss/netty/akka/logging/InternalLogLevel.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2009 Red Hat, Inc. - * - * Red Hat licenses this file to you under the Apache License, version 2.0 - * (the "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package org.jboss.netty.akka.logging; - -/** - * The log level that {@link InternalLogger} can log at. - * - * @author The Netty Project - * @author Trustin Lee - * @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $ - */ -public enum InternalLogLevel { - /** - * 'DEBUG' log level. - */ - DEBUG, - /** - * 'INFO' log level. - */ - INFO, - /** - * 'WARN' log level. - */ - WARN, - /** - * 'ERROR' log level. - */ - ERROR; -} diff --git a/akka-actor/src/main/java/org/jboss/netty/akka/logging/InternalLogger.java b/akka-actor/src/main/java/org/jboss/netty/akka/logging/InternalLogger.java deleted file mode 100644 index 19d3373e6c..0000000000 --- a/akka-actor/src/main/java/org/jboss/netty/akka/logging/InternalLogger.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright 2009 Red Hat, Inc. - * - * Red Hat licenses this file to you under the Apache License, version 2.0 - * (the "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package org.jboss.netty.akka.logging; - -/** - * Internal-use-only logger used by Netty. DO NOT - * access this class outside of Netty. - * - * @author The Netty Project - * @author Trustin Lee - * - * @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $ - */ -public interface InternalLogger { - /** - * Returns {@code true} if a DEBUG level message is logged. - */ - boolean isDebugEnabled(); - - /** - * Returns {@code true} if an INFO level message is logged. - */ - boolean isInfoEnabled(); - - /** - * Returns {@code true} if a WARN level message is logged. - */ - boolean isWarnEnabled(); - - /** - * Returns {@code true} if an ERROR level message is logged. - */ - boolean isErrorEnabled(); - - /** - * Returns {@code true} if the specified log level message is logged. - */ - boolean isEnabled(InternalLogLevel level); - - /** - * Logs a DEBUG level message. - */ - void debug(String msg); - - /** - * Logs a DEBUG level message. - */ - void debug(String msg, Throwable cause); - - /** - * Logs an INFO level message. - */ - void info(String msg); - - /** - * Logs an INFO level message. - */ - void info(String msg, Throwable cause); - - /** - * Logs a WARN level message. - */ - void warn(String msg); - - /** - * Logs a WARN level message. - */ - void warn(String msg, Throwable cause); - - /** - * Logs an ERROR level message. - */ - void error(String msg); - - /** - * Logs an ERROR level message. - */ - void error(String msg, Throwable cause); - - /** - * Logs a message. - */ - void log(InternalLogLevel level, String msg); - - /** - * Logs a message. - */ - void log(InternalLogLevel level, String msg, Throwable cause); -} diff --git a/akka-actor/src/main/java/org/jboss/netty/akka/logging/InternalLoggerFactory.java b/akka-actor/src/main/java/org/jboss/netty/akka/logging/InternalLoggerFactory.java deleted file mode 100644 index bda537b35b..0000000000 --- a/akka-actor/src/main/java/org/jboss/netty/akka/logging/InternalLoggerFactory.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright 2009 Red Hat, Inc. - * - * Red Hat licenses this file to you under the Apache License, version 2.0 - * (the "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package org.jboss.netty.akka.logging; - -import org.jboss.netty.akka.util.internal.StackTraceSimplifier; - -/** - * Creates an {@link InternalLogger} or changes the default factory - * implementation. This factory allows you to choose what logging framework - * Netty should use. The default factory is {@link JdkLoggerFactory}. - * You can change it to your preferred logging framework before other Netty - * classes are loaded: - *
- * {@link org.jboss.netty.akka.logging.InternalLoggerFactory}.setDefaultFactory(new {@link Log4JLoggerFactory}());
- *
- * Please note that the new default factory is effective only for the classes
- * which were loaded after the default factory is changed. Therefore,
- * {@link #setDefaultFactory(org.jboss.netty.akka.logging.InternalLoggerFactory)} should be called as early
- * as possible and shouldn't be called more than once.
- *
- * @author The Netty Project
- * @author Trustin Lee
- *
- * @version $Rev: 2122 $, $Date: 2010-02-02 11:00:04 +0900 (Tue, 02 Feb 2010) $
- *
- * @apiviz.landmark
- * @apiviz.has org.jboss.netty.logging.InternalLogger oneway - - creates
- */
-public abstract class InternalLoggerFactory {
- private static volatile InternalLoggerFactory defaultFactory = new JdkLoggerFactory();
-
- static {
- // Load the dependent classes in advance to avoid the case where
- // the VM fails to load the required classes because of too many open
- // files.
- StackTraceSimplifier.simplify(new Exception());
- }
-
- /**
- * Returns the default factory. The initial default factory is
- * {@link JdkLoggerFactory}.
- */
- public static InternalLoggerFactory getDefaultFactory() {
- return defaultFactory;
- }
-
- /**
- * Changes the default factory.
- */
- public static void setDefaultFactory(InternalLoggerFactory defaultFactory) {
- if (defaultFactory == null) {
- throw new NullPointerException("defaultFactory");
- }
- InternalLoggerFactory.defaultFactory = defaultFactory;
- }
-
- /**
- * Creates a new logger instance with the name of the specified class.
- */
- public static InternalLogger getInstance(Class> clazz) {
- return getInstance(clazz.getName());
- }
-
- /**
- * Creates a new logger instance with the specified name.
- */
- public static InternalLogger getInstance(String name) {
- final InternalLogger logger = getDefaultFactory().newInstance(name);
- return new InternalLogger() {
-
- public void debug(String msg) {
- logger.debug(msg);
- }
-
- public void debug(String msg, Throwable cause) {
- StackTraceSimplifier.simplify(cause);
- logger.debug(msg, cause);
- }
-
- public void error(String msg) {
- logger.error(msg);
- }
-
- public void error(String msg, Throwable cause) {
- StackTraceSimplifier.simplify(cause);
- logger.error(msg, cause);
- }
-
- public void info(String msg) {
- logger.info(msg);
- }
-
- public void info(String msg, Throwable cause) {
- StackTraceSimplifier.simplify(cause);
- logger.info(msg, cause);
- }
-
- public boolean isDebugEnabled() {
- return logger.isDebugEnabled();
- }
-
- public boolean isErrorEnabled() {
- return logger.isErrorEnabled();
- }
-
- public boolean isInfoEnabled() {
- return logger.isInfoEnabled();
- }
-
- public boolean isWarnEnabled() {
- return logger.isWarnEnabled();
- }
-
- public void warn(String msg) {
- logger.warn(msg);
- }
-
- public void warn(String msg, Throwable cause) {
- StackTraceSimplifier.simplify(cause);
- logger.warn(msg, cause);
- }
-
- public boolean isEnabled(InternalLogLevel level) {
- return logger.isEnabled(level);
- }
-
- public void log(InternalLogLevel level, String msg) {
- logger.log(level, msg);
- }
-
- public void log(InternalLogLevel level, String msg, Throwable cause) {
- StackTraceSimplifier.simplify(cause);
- logger.log(level, msg, cause);
- }
- };
- }
-
- /**
- * Creates a new logger instance with the specified name.
- */
- public abstract InternalLogger newInstance(String name);
-}
diff --git a/akka-actor/src/main/java/org/jboss/netty/akka/logging/JdkLogger.java b/akka-actor/src/main/java/org/jboss/netty/akka/logging/JdkLogger.java
deleted file mode 100644
index 56d68e74a0..0000000000
--- a/akka-actor/src/main/java/org/jboss/netty/akka/logging/JdkLogger.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- *
- * Red Hat licenses this file to you under the Apache License, version 2.0
- * (the "License"); you may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-package org.jboss.netty.akka.logging;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * java.util.logging
- * logger.
- *
- * @author The Netty Project
- * @author Trustin Lee
- *
- * @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
- *
- */
-class JdkLogger extends AbstractInternalLogger {
-
- private final Logger logger;
- private final String loggerName;
-
- JdkLogger(Logger logger, String loggerName) {
- this.logger = logger;
- this.loggerName = loggerName;
- }
-
- public void debug(String msg) {
- logger.logp(Level.FINE, loggerName, null, msg);
- }
-
- public void debug(String msg, Throwable cause) {
- logger.logp(Level.FINE, loggerName, null, msg, cause);
- }
-
- public void error(String msg) {
- logger.logp(Level.SEVERE, loggerName, null, msg);
- }
-
- public void error(String msg, Throwable cause) {
- logger.logp(Level.SEVERE, loggerName, null, msg, cause);
- }
-
- public void info(String msg) {
- logger.logp(Level.INFO, loggerName, null, msg);
- }
-
- public void info(String msg, Throwable cause) {
- logger.logp(Level.INFO, loggerName, null, msg, cause);
- }
-
- public boolean isDebugEnabled() {
- return logger.isLoggable(Level.FINE);
- }
-
- public boolean isErrorEnabled() {
- return logger.isLoggable(Level.SEVERE);
- }
-
- public boolean isInfoEnabled() {
- return logger.isLoggable(Level.INFO);
- }
-
- public boolean isWarnEnabled() {
- return logger.isLoggable(Level.WARNING);
- }
-
- public void warn(String msg) {
- logger.logp(Level.WARNING, loggerName, null, msg);
- }
-
- public void warn(String msg, Throwable cause) {
- logger.logp(Level.WARNING, loggerName, null, msg, cause);
- }
-
- @Override
- public String toString() {
- return loggerName;
- }
-}
diff --git a/akka-actor/src/main/java/org/jboss/netty/akka/logging/JdkLoggerFactory.java b/akka-actor/src/main/java/org/jboss/netty/akka/logging/JdkLoggerFactory.java
deleted file mode 100644
index d4be45bf9d..0000000000
--- a/akka-actor/src/main/java/org/jboss/netty/akka/logging/JdkLoggerFactory.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- *
- * Red Hat licenses this file to you under the Apache License, version 2.0
- * (the "License"); you may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-package org.jboss.netty.akka.logging;
-
-
-/**
- * Logger factory which creates a
- * java.util.logging
- * logger.
- *
- * @author The Netty Project
- * @author Trustin Lee
- *
- * @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
- *
- */
-public class JdkLoggerFactory extends InternalLoggerFactory {
-
- @Override
- public InternalLogger newInstance(String name) {
- final java.util.logging.Logger logger =
- java.util.logging.Logger.getLogger(name);
- return new JdkLogger(logger, name);
- }
-}
diff --git a/akka-actor/src/main/java/org/jboss/netty/akka/util/DebugUtil.java b/akka-actor/src/main/java/org/jboss/netty/akka/util/DebugUtil.java
deleted file mode 100644
index 6038c8decd..0000000000
--- a/akka-actor/src/main/java/org/jboss/netty/akka/util/DebugUtil.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- *
- * Red Hat licenses this file to you under the Apache License, version 2.0
- * (the "License"); you may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
- * under the License.
- */
-package org.jboss.netty.akka.util;
-
-import org.jboss.netty.akka.util.internal.SystemPropertyUtil;
-
-/**
- * Determines if Netty is running in a debug mode or not. Please note that
- * this is not a Java debug mode. You can enable Netty debug mode by
- * specifying the {@code "org.jboss.netty.debug"} system property (e.g.
- * {@code java -Dorg.jboss.netty.debug ...})
- * - * If debug mode is disabled (default), the stack trace of the exceptions are - * compressed to help debugging a user application. - *
- * If debug mode is enabled, the stack trace of the exceptions raised in
- * {@link ChannelPipeline} or {@link ChannelSink} are retained as it is to help
- * debugging Netty.
- *
- * @author The Netty Project
- * @author Trustin Lee
- *
- * @version $Rev: 2080 $, $Date: 2010-01-26 18:04:19 +0900 (Tue, 26 Jan 2010) $
- */
-public class DebugUtil {
-
- /**
- * Returns {@code true} if and only if Netty debug mode is enabled.
- */
- public static boolean isDebugEnabled() {
- String value;
- try {
- value = SystemPropertyUtil.get("org.jboss.netty.debug");
- } catch (Exception e) {
- value = null;
- }
-
- if (value == null) {
- return false;
- }
-
- value = value.trim().toUpperCase();
- return !value.startsWith("N") &&
- !value.startsWith("F") &&
- !value.equals("0");
- }
-
- private DebugUtil() {
- // Unused
- }
-}
diff --git a/akka-actor/src/main/java/org/jboss/netty/akka/util/HashedWheelTimer.java b/akka-actor/src/main/java/org/jboss/netty/akka/util/HashedWheelTimer.java
index bc6e6d9829..328d2dc39f 100644
--- a/akka-actor/src/main/java/org/jboss/netty/akka/util/HashedWheelTimer.java
+++ b/akka-actor/src/main/java/org/jboss/netty/akka/util/HashedWheelTimer.java
@@ -15,12 +15,11 @@
*/
package org.jboss.netty.akka.util;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.Executors;
+import akka.event.LoggingAdapter;
+import org.jboss.netty.akka.util.internal.ConcurrentIdentityHashMap;
+import org.jboss.netty.akka.util.internal.ReusableIterator;
+
+import java.util.*;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -28,12 +27,6 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
-import org.jboss.netty.akka.logging.InternalLogger;
-import org.jboss.netty.akka.logging.InternalLoggerFactory;
-import org.jboss.netty.akka.util.internal.ConcurrentIdentityHashMap;
-import org.jboss.netty.akka.util.internal.ReusableIterator;
-import org.jboss.netty.akka.util.internal.SharedResourceMisuseDetector;
-
/**
* A {@link Timer} optimized for approximated I/O timeout scheduling.
*
@@ -82,14 +75,8 @@ import org.jboss.netty.akka.util.internal.SharedResourceMisuseDetector;
* @version $Rev: 2297 $, $Date: 2010-06-07 10:50:02 +0900 (Mon, 07 Jun 2010) $
*/
public class HashedWheelTimer implements Timer {
-
- static final InternalLogger logger =
- InternalLoggerFactory.getInstance(HashedWheelTimer.class);
private static final AtomicInteger id = new AtomicInteger();
- private static final SharedResourceMisuseDetector misuseDetector =
- new SharedResourceMisuseDetector(HashedWheelTimer.class);
-
private final Worker worker = new Worker();
final Thread workerThread;
final AtomicBoolean shutdown = new AtomicBoolean();
@@ -101,65 +88,7 @@ public class HashedWheelTimer implements Timer {
final int mask;
final ReadWriteLock lock = new ReentrantReadWriteLock();
volatile int wheelCursor;
-
- /**
- * Creates a new timer with the default thread factory
- * ({@link java.util.concurrent.Executors#defaultThreadFactory()}), default tick duration, and
- * default number of ticks per wheel.
- */
- public HashedWheelTimer() {
- this(Executors.defaultThreadFactory());
- }
-
- /**
- * Creates a new timer with the default thread factory
- * ({@link java.util.concurrent.Executors#defaultThreadFactory()}) and default number of ticks
- * per wheel.
- *
- * @param tickDuration the duration between tick
- * @param unit the time unit of the {@code tickDuration}
- */
- public HashedWheelTimer(long tickDuration, TimeUnit unit) {
- this(Executors.defaultThreadFactory(), tickDuration, unit);
- }
-
- /**
- * Creates a new timer with the default thread factory
- * ({@link java.util.concurrent.Executors#defaultThreadFactory()}).
- *
- * @param tickDuration the duration between tick
- * @param unit the time unit of the {@code tickDuration}
- * @param ticksPerWheel the size of the wheel
- */
- public HashedWheelTimer(long tickDuration, TimeUnit unit, int ticksPerWheel) {
- this(Executors.defaultThreadFactory(), tickDuration, unit, ticksPerWheel);
- }
-
- /**
- * Creates a new timer with the default tick duration and default number of
- * ticks per wheel.
- *
- * @param threadFactory a {@link java.util.concurrent.ThreadFactory} that creates a
- * background {@link Thread} which is dedicated to
- * {@link TimerTask} execution.
- */
- public HashedWheelTimer(ThreadFactory threadFactory) {
- this(threadFactory, 100, TimeUnit.MILLISECONDS);
- }
-
- /**
- * Creates a new timer with the default number of ticks per wheel.
- *
- * @param threadFactory a {@link java.util.concurrent.ThreadFactory} that creates a
- * background {@link Thread} which is dedicated to
- * {@link TimerTask} execution.
- * @param tickDuration the duration between tick
- * @param unit the time unit of the {@code tickDuration}
- */
- public HashedWheelTimer(
- ThreadFactory threadFactory, long tickDuration, TimeUnit unit) {
- this(threadFactory, tickDuration, unit, 512);
- }
+ private LoggingAdapter logger;
/**
* Creates a new timer.
@@ -172,6 +101,7 @@ public class HashedWheelTimer implements Timer {
* @param ticksPerWheel the size of the wheel
*/
public HashedWheelTimer(
+ LoggingAdapter logger,
ThreadFactory threadFactory,
long tickDuration, TimeUnit unit, int ticksPerWheel) {
@@ -190,6 +120,8 @@ public class HashedWheelTimer implements Timer {
"ticksPerWheel must be greater than 0: " + ticksPerWheel);
}
+ this.logger = logger;
+
// Normalize ticksPerWheel to power of two and initialize the wheel.
wheel = createWheel(ticksPerWheel);
iterators = createIterators(wheel);
@@ -207,12 +139,7 @@ public class HashedWheelTimer implements Timer {
}
roundDuration = tickDuration * wheel.length;
-
- workerThread = threadFactory.newThread(new ThreadRenamingRunnable(
- worker, "Hashed wheel timer #" + id.incrementAndGet()));
-
- // Misuse check
- misuseDetector.increase();
+ workerThread = threadFactory.newThread(worker);
}
@SuppressWarnings("unchecked")
@@ -295,8 +222,6 @@ public class HashedWheelTimer implements Timer {
Thread.currentThread().interrupt();
}
- misuseDetector.decrease();
-
Set