Remove unused or unmaintainable internal classes
This commit is contained in:
parent
957c04e597
commit
dd2e36e5d9
@ -15,11 +15,17 @@
|
|||||||
*/
|
*/
|
||||||
package io.netty.util;
|
package io.netty.util;
|
||||||
|
|
||||||
|
import io.netty.logging.InternalLogger;
|
||||||
|
import io.netty.logging.InternalLoggerFactory;
|
||||||
|
import io.netty.util.internal.ReusableIterator;
|
||||||
|
import io.netty.util.internal.SharedResourceMisuseDetector;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.Executors;
|
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;
|
||||||
@ -28,12 +34,6 @@ 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;
|
||||||
|
|
||||||
import io.netty.logging.InternalLogger;
|
|
||||||
import io.netty.logging.InternalLoggerFactory;
|
|
||||||
import io.netty.util.internal.ConcurrentIdentityHashMap;
|
|
||||||
import io.netty.util.internal.ReusableIterator;
|
|
||||||
import io.netty.util.internal.SharedResourceMisuseDetector;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link Timer} optimized for approximated I/O timeout scheduling.
|
* A {@link Timer} optimized for approximated I/O timeout scheduling.
|
||||||
*
|
*
|
||||||
@ -221,8 +221,8 @@ public class HashedWheelTimer implements Timer {
|
|||||||
ticksPerWheel = normalizeTicksPerWheel(ticksPerWheel);
|
ticksPerWheel = normalizeTicksPerWheel(ticksPerWheel);
|
||||||
Set<HashedWheelTimeout>[] wheel = new Set[ticksPerWheel];
|
Set<HashedWheelTimeout>[] wheel = new Set[ticksPerWheel];
|
||||||
for (int i = 0; i < wheel.length; i ++) {
|
for (int i = 0; i < wheel.length; i ++) {
|
||||||
wheel[i] = new MapBackedSet<HashedWheelTimeout>(
|
wheel[i] = Collections.newSetFromMap(
|
||||||
new ConcurrentIdentityHashMap<HashedWheelTimeout, Boolean>(16, 0.95f, 4));
|
new ConcurrentHashMap<HashedWheelTimeout, Boolean>(16, 0.95f, 4));
|
||||||
}
|
}
|
||||||
return wheel;
|
return wheel;
|
||||||
}
|
}
|
||||||
@ -496,7 +496,7 @@ public class HashedWheelTimer implements Timer {
|
|||||||
// TODO return false
|
// TODO return false
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
wheel[stopIndex].remove(this);
|
wheel[stopIndex].remove(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,117 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2011 The Netty Project
|
|
||||||
*
|
|
||||||
* The Netty Project 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 io.netty.util.internal;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Conversion utility class to parse a property represented as a string or
|
|
||||||
* an object.
|
|
||||||
*/
|
|
||||||
public final class ConversionUtil {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts the specified object into an integer.
|
|
||||||
*/
|
|
||||||
public static int toInt(Object value) {
|
|
||||||
if (value instanceof Number) {
|
|
||||||
return ((Number) value).intValue();
|
|
||||||
} else {
|
|
||||||
return Integer.parseInt(String.valueOf(value));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts the specified object into a long integer.
|
|
||||||
*/
|
|
||||||
public static long toLong(Object value) {
|
|
||||||
if (value instanceof Number) {
|
|
||||||
return ((Number) value).longValue();
|
|
||||||
} else {
|
|
||||||
return Long.parseLong(String.valueOf(value));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts the specified object into a boolean.
|
|
||||||
*/
|
|
||||||
public static boolean toBoolean(Object value) {
|
|
||||||
if (value instanceof Boolean) {
|
|
||||||
return ((Boolean) value).booleanValue();
|
|
||||||
}
|
|
||||||
if (value instanceof Number) {
|
|
||||||
return ((Number) value).intValue() != 0;
|
|
||||||
} else {
|
|
||||||
String s = String.valueOf(value);
|
|
||||||
if (s.length() == 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
return Integer.parseInt(s) != 0;
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
// Proceed
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (Character.toUpperCase(s.charAt(0))) {
|
|
||||||
case 'T': case 'Y':
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts the specified object into an array of strings.
|
|
||||||
*/
|
|
||||||
public static String[] toStringArray(Object value) {
|
|
||||||
if (value instanceof String[]) {
|
|
||||||
return (String[]) value;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value instanceof Iterable<?>) {
|
|
||||||
List<String> answer = new ArrayList<String>();
|
|
||||||
for (Object v: (Iterable<?>) value) {
|
|
||||||
if (v == null) {
|
|
||||||
answer.add(null);
|
|
||||||
} else {
|
|
||||||
answer.add(String.valueOf(v));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return answer.toArray(new String[answer.size()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return String.valueOf(value).split("[, \\t\\n\\r\\f\\e\\a]");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String[] INTEGERS = {
|
|
||||||
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
|
|
||||||
"10", "11", "12", "13", "14", "15",
|
|
||||||
};
|
|
||||||
|
|
||||||
public static String toString(int value) {
|
|
||||||
if (value >= 0 && value < INTEGERS.length) {
|
|
||||||
return INTEGERS[value];
|
|
||||||
} else {
|
|
||||||
return Integer.toString(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private ConversionUtil() {
|
|
||||||
// Unused
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,69 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2011 The Netty Project
|
|
||||||
*
|
|
||||||
* The Netty Project 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 io.netty.util.internal;
|
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
public class ConversionUtilTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testNumberToInt() {
|
|
||||||
assertEquals(42, ConversionUtil.toInt(Long.valueOf(42)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testStringToInt() {
|
|
||||||
assertEquals(42, ConversionUtil.toInt("42"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testBooleanToBoolean() {
|
|
||||||
assertTrue(ConversionUtil.toBoolean(Boolean.TRUE));
|
|
||||||
assertFalse(ConversionUtil.toBoolean(Boolean.FALSE));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testNumberToBoolean() {
|
|
||||||
assertTrue(ConversionUtil.toBoolean(Integer.valueOf(42)));
|
|
||||||
assertFalse(ConversionUtil.toBoolean(Integer.valueOf(0)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testStringToBoolean() {
|
|
||||||
assertTrue(ConversionUtil.toBoolean("y"));
|
|
||||||
assertTrue(ConversionUtil.toBoolean("Y"));
|
|
||||||
assertTrue(ConversionUtil.toBoolean("yes"));
|
|
||||||
assertTrue(ConversionUtil.toBoolean("YES"));
|
|
||||||
assertTrue(ConversionUtil.toBoolean("yeah"));
|
|
||||||
assertTrue(ConversionUtil.toBoolean("YEAH"));
|
|
||||||
assertTrue(ConversionUtil.toBoolean("t"));
|
|
||||||
assertTrue(ConversionUtil.toBoolean("T"));
|
|
||||||
assertTrue(ConversionUtil.toBoolean("true"));
|
|
||||||
assertTrue(ConversionUtil.toBoolean("TRUE"));
|
|
||||||
assertTrue(ConversionUtil.toBoolean("42"));
|
|
||||||
|
|
||||||
assertFalse(ConversionUtil.toBoolean(""));
|
|
||||||
assertFalse(ConversionUtil.toBoolean("n"));
|
|
||||||
assertFalse(ConversionUtil.toBoolean("no"));
|
|
||||||
assertFalse(ConversionUtil.toBoolean("NO"));
|
|
||||||
assertFalse(ConversionUtil.toBoolean("f"));
|
|
||||||
assertFalse(ConversionUtil.toBoolean("false"));
|
|
||||||
assertFalse(ConversionUtil.toBoolean("FALSE"));
|
|
||||||
assertFalse(ConversionUtil.toBoolean("0"));
|
|
||||||
}
|
|
||||||
}
|
|
@ -15,6 +15,13 @@
|
|||||||
*/
|
*/
|
||||||
package io.netty.handler.execution;
|
package io.netty.handler.execution;
|
||||||
|
|
||||||
|
import io.netty.buffer.ChannelBuffer;
|
||||||
|
import io.netty.channel.Channel;
|
||||||
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
|
import io.netty.util.internal.QueueFactory;
|
||||||
|
import io.netty.util.internal.SharedResourceMisuseDetector;
|
||||||
|
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
@ -25,18 +32,6 @@ import java.util.concurrent.ThreadPoolExecutor;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
import io.netty.buffer.ChannelBuffer;
|
|
||||||
import io.netty.channel.Channel;
|
|
||||||
import io.netty.channel.ChannelEvent;
|
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
|
||||||
import io.netty.channel.ChannelState;
|
|
||||||
import io.netty.channel.ChannelStateEvent;
|
|
||||||
import io.netty.channel.MessageEvent;
|
|
||||||
import io.netty.channel.WriteCompletionEvent;
|
|
||||||
import io.netty.util.internal.ConcurrentIdentityHashMap;
|
|
||||||
import io.netty.util.internal.QueueFactory;
|
|
||||||
import io.netty.util.internal.SharedResourceMisuseDetector;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link ThreadPoolExecutor} which blocks the task submission when there's
|
* A {@link ThreadPoolExecutor} which blocks the task submission when there's
|
||||||
* too many tasks in the queue. Both per-{@link Channel} and per-{@link Executor}
|
* too many tasks in the queue. Both per-{@link Channel} and per-{@link Executor}
|
||||||
@ -132,7 +127,7 @@ public class MemoryAwareThreadPoolExecutor extends ThreadPoolExecutor {
|
|||||||
private volatile Settings settings;
|
private volatile Settings settings;
|
||||||
|
|
||||||
private final ConcurrentMap<Channel, AtomicLong> channelCounters =
|
private final ConcurrentMap<Channel, AtomicLong> channelCounters =
|
||||||
new ConcurrentIdentityHashMap<Channel, AtomicLong>();
|
new ConcurrentHashMap<Channel, AtomicLong>();
|
||||||
private final Limiter totalLimiter;
|
private final Limiter totalLimiter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -221,7 +216,7 @@ public class MemoryAwareThreadPoolExecutor extends ThreadPoolExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
allowCoreThreadTimeOut(true);
|
allowCoreThreadTimeOut(true);
|
||||||
|
|
||||||
settings = new Settings(
|
settings = new Settings(
|
||||||
objectSizeEstimator, maxChannelMemorySize);
|
objectSizeEstimator, maxChannelMemorySize);
|
||||||
|
|
||||||
@ -419,7 +414,7 @@ public class MemoryAwareThreadPoolExecutor extends ThreadPoolExecutor {
|
|||||||
//System.out.println("READABLE");
|
//System.out.println("READABLE");
|
||||||
ChannelHandlerContext ctx = eventTask.getContext();
|
ChannelHandlerContext ctx = eventTask.getContext();
|
||||||
if (ctx.getHandler() instanceof ExecutionHandler) {
|
if (ctx.getHandler() instanceof ExecutionHandler) {
|
||||||
// check if the attachment was set as this means that we suspend the channel from reads. This only works when
|
// check if the attachment was set as this means that we suspend the channel from reads. This only works when
|
||||||
// this pool is used with ExecutionHandler but I guess thats good enough for us.
|
// this pool is used with ExecutionHandler but I guess thats good enough for us.
|
||||||
//
|
//
|
||||||
// See #215
|
// See #215
|
||||||
|
@ -18,12 +18,12 @@ package io.netty.channel;
|
|||||||
import io.netty.logging.InternalLogger;
|
import io.netty.logging.InternalLogger;
|
||||||
import io.netty.logging.InternalLoggerFactory;
|
import io.netty.logging.InternalLoggerFactory;
|
||||||
import io.netty.util.DefaultAttributeMap;
|
import io.netty.util.DefaultAttributeMap;
|
||||||
import io.netty.util.internal.ConcurrentHashMap;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.ConnectException;
|
import java.net.ConnectException;
|
||||||
import java.net.SocketAddress;
|
import java.net.SocketAddress;
|
||||||
import java.nio.channels.ClosedChannelException;
|
import java.nio.channels.ClosedChannelException;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
@ -20,7 +20,6 @@ import io.netty.channel.Channel;
|
|||||||
import io.netty.channel.ChannelFuture;
|
import io.netty.channel.ChannelFuture;
|
||||||
import io.netty.channel.ChannelFutureListener;
|
import io.netty.channel.ChannelFutureListener;
|
||||||
import io.netty.channel.ServerChannel;
|
import io.netty.channel.ServerChannel;
|
||||||
import io.netty.util.internal.ConcurrentHashMap;
|
|
||||||
|
|
||||||
import java.util.AbstractSet;
|
import java.util.AbstractSet;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -28,6 +27,7 @@ import java.util.Collection;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
@ -15,10 +15,10 @@
|
|||||||
*/
|
*/
|
||||||
package io.netty.channel.local;
|
package io.netty.channel.local;
|
||||||
|
|
||||||
import java.util.concurrent.ConcurrentMap;
|
|
||||||
|
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import io.netty.util.internal.ConcurrentHashMap;
|
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.ConcurrentMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user