Fix various inspection warnings
This commit is contained in:
parent
3c9d912355
commit
eb337ff5a7
@ -42,7 +42,7 @@ public interface CompositeByteBuf extends ByteBuf, Iterable<ByteBuf> {
|
||||
* the {@link ByteBuf} to add
|
||||
* @return self
|
||||
* this instance
|
||||
* @thows {@link IndexOutOfBoundsException}
|
||||
* @throws {@link IndexOutOfBoundsException}
|
||||
* if the index is invalid
|
||||
*/
|
||||
CompositeByteBuf addComponent(int cIndex, ByteBuf buffer);
|
||||
@ -72,7 +72,7 @@ public interface CompositeByteBuf extends ByteBuf, Iterable<ByteBuf> {
|
||||
* the {@link ByteBuf}s to add
|
||||
* @return self
|
||||
* this instance
|
||||
* @thows {@link IndexOutOfBoundsException}
|
||||
* @throws {@link IndexOutOfBoundsException}
|
||||
* if the index is invalid
|
||||
*
|
||||
*/
|
||||
@ -87,7 +87,7 @@ public interface CompositeByteBuf extends ByteBuf, Iterable<ByteBuf> {
|
||||
* the {@link ByteBuf}s to add
|
||||
* @return self
|
||||
* this instance
|
||||
* @thows {@link IndexOutOfBoundsException}
|
||||
* @throws {@link IndexOutOfBoundsException}
|
||||
* if the index is invalid
|
||||
*/
|
||||
CompositeByteBuf addComponents(int cIndex, Iterable<ByteBuf> buffers);
|
||||
@ -99,7 +99,7 @@ public interface CompositeByteBuf extends ByteBuf, Iterable<ByteBuf> {
|
||||
* the index on from which the {@link ByteBuf} will be remove
|
||||
* @return self
|
||||
* this instance
|
||||
* @thows {@link IndexOutOfBoundsException}
|
||||
* @throws {@link IndexOutOfBoundsException}
|
||||
* if the index is invalid
|
||||
*/
|
||||
CompositeByteBuf removeComponent(int cIndex);
|
||||
@ -113,7 +113,7 @@ public interface CompositeByteBuf extends ByteBuf, Iterable<ByteBuf> {
|
||||
* the number of components to remove
|
||||
* @return self
|
||||
* this instance
|
||||
* @thows {@link IndexOutOfBoundsException}
|
||||
* @throws {@link IndexOutOfBoundsException}
|
||||
* if the index is invalid
|
||||
*/
|
||||
CompositeByteBuf removeComponents(int cIndex, int numComponents);
|
||||
@ -135,7 +135,7 @@ public interface CompositeByteBuf extends ByteBuf, Iterable<ByteBuf> {
|
||||
* the index for which the {@link ByteBuf} should be returned
|
||||
* @return buf
|
||||
* the {@link ByteBuf} on the specified index
|
||||
* @thows {@link IndexOutOfBoundsException}
|
||||
* @throws {@link IndexOutOfBoundsException}
|
||||
* if the index is invalid
|
||||
*/
|
||||
ByteBuf component(int cIndex);
|
||||
@ -147,7 +147,7 @@ public interface CompositeByteBuf extends ByteBuf, Iterable<ByteBuf> {
|
||||
* the offset for which the {@link ByteBuf} should be returned
|
||||
* @return buf
|
||||
* the {@link ByteBuf} on the specified index
|
||||
* @thows {@link IndexOutOfBoundsException}
|
||||
* @throws {@link IndexOutOfBoundsException}
|
||||
* if the offset is invalid
|
||||
*/
|
||||
ByteBuf componentAtOffset(int offset);
|
||||
@ -175,7 +175,7 @@ public interface CompositeByteBuf extends ByteBuf, Iterable<ByteBuf> {
|
||||
* the number of components to compose
|
||||
* @return self
|
||||
* this instance
|
||||
* @thows {@link IndexOutOfBoundsException}
|
||||
* @throws {@link IndexOutOfBoundsException}
|
||||
* if the offset is invalid
|
||||
*/
|
||||
CompositeByteBuf consolidate(int cIndex, int numComponents);
|
||||
|
@ -131,7 +131,7 @@ final class DefaultMessageBuf<T> extends ArrayDeque<T> implements MessageBuf<T>
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T1 extends Object> T1[] toArray(T1[] a) {
|
||||
public <T1> T1[] toArray(T1[] a) {
|
||||
ensureValid();
|
||||
return super.toArray(a);
|
||||
}
|
||||
|
@ -16,7 +16,6 @@
|
||||
package io.netty.handler.codec.http.websocketx;
|
||||
|
||||
import io.netty.buffer.MessageBuf;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundMessageHandlerAdapter;
|
||||
|
@ -27,12 +27,6 @@ public final class SocksAuthResponse extends SocksResponse {
|
||||
private static final SubnegotiationVersion SUBNEGOTIATION_VERSION = SubnegotiationVersion.AUTH_PASSWORD;
|
||||
private final AuthStatus authStatus;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param authStatus
|
||||
* @throws NullPointerException
|
||||
*/
|
||||
|
||||
public SocksAuthResponse(AuthStatus authStatus) {
|
||||
super(SocksResponseType.AUTH);
|
||||
if (authStatus == null) {
|
||||
|
@ -216,7 +216,7 @@ public abstract class SocksMessage {
|
||||
|
||||
private final byte b;
|
||||
|
||||
private SubnegotiationVersion(byte b) {
|
||||
SubnegotiationVersion(byte b) {
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
@ -245,9 +245,6 @@ public abstract class SocksMessage {
|
||||
|
||||
/**
|
||||
* Encode socks message into its byte representation and write it into byteBuf
|
||||
*
|
||||
* @param byteBuf
|
||||
* @see ByteBuf
|
||||
*/
|
||||
public abstract void encodeAsByteBuf(ByteBuf byteBuf);
|
||||
}
|
||||
|
@ -47,7 +47,8 @@ public final class MonitorRegistries implements Iterable<MonitorRegistry> {
|
||||
private static final int SUCCESSFUL_INITIALIZATION = 2;
|
||||
private static final int NOP_FALLBACK_INITIALIZATION = 3;
|
||||
|
||||
private static int INITIALIZATION_STATE = UNINITIALIZED;
|
||||
@SuppressWarnings("RedundantFieldInitialization")
|
||||
private static int initState = UNINITIALIZED;
|
||||
private static MonitorRegistry selectedRegistry;
|
||||
|
||||
/**
|
||||
@ -107,11 +108,11 @@ public final class MonitorRegistries implements Iterable<MonitorRegistry> {
|
||||
*/
|
||||
public MonitorRegistry unique() {
|
||||
//Implementation based on SLF4J's
|
||||
if (INITIALIZATION_STATE == UNINITIALIZED) {
|
||||
INITIALIZATION_STATE = ONGOING_INITIALIZATION;
|
||||
if (initState == UNINITIALIZED) {
|
||||
initState = ONGOING_INITIALIZATION;
|
||||
performInitialization();
|
||||
}
|
||||
switch (INITIALIZATION_STATE) {
|
||||
switch (initState) {
|
||||
case SUCCESSFUL_INITIALIZATION:
|
||||
return selectedRegistry;
|
||||
case NOP_FALLBACK_INITIALIZATION:
|
||||
@ -125,14 +126,14 @@ public final class MonitorRegistries implements Iterable<MonitorRegistry> {
|
||||
final Iterator<MonitorRegistry> registries = iterator();
|
||||
if (registries.hasNext()) {
|
||||
selectedRegistry = registries.next();
|
||||
INITIALIZATION_STATE = SUCCESSFUL_INITIALIZATION;
|
||||
initState = SUCCESSFUL_INITIALIZATION;
|
||||
}
|
||||
if (selectedRegistry != null && registries.hasNext()) {
|
||||
logger.warn(String.format("Multiple metrics implementations found. " +
|
||||
"Selected %s, ignoring other implementations", selectedRegistry.getClass().getName()));
|
||||
}
|
||||
if (selectedRegistry == null) {
|
||||
INITIALIZATION_STATE = NOP_FALLBACK_INITIALIZATION;
|
||||
initState = NOP_FALLBACK_INITIALIZATION;
|
||||
logger.debug("No metrics implementation found on the classpath.");
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
package io.netty.util.internal;
|
||||
|
||||
import sun.misc.Cleaner;
|
||||
import sun.misc.Unsafe;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.InetSocketAddress;
|
||||
@ -119,7 +120,7 @@ public final class DetectionUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return {@code true} if {@link sun.misc.Unsafe} was found on the classpath and can be used.
|
||||
* Return {@code true} if {@link Unsafe} was found on the classpath and can be used.
|
||||
*/
|
||||
public static boolean hasUnsafe() {
|
||||
return HAS_UNSAFE;
|
||||
|
@ -1,44 +1,58 @@
|
||||
/*
|
||||
* Copyright 2013 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.monitor;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import io.netty.monitor.support.SampleMonitorRegistryFactory;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class MonitorRegistriesTest {
|
||||
|
||||
@Test
|
||||
public final void instanceShouldNotReturnNull() {
|
||||
assertNotNull("instance() should NEVER return null",
|
||||
MonitorRegistries.instance());
|
||||
}
|
||||
@Test
|
||||
public final void instanceShouldNotReturnNull() {
|
||||
assertNotNull("instance() should NEVER return null",
|
||||
MonitorRegistries.instance());
|
||||
}
|
||||
|
||||
@Test
|
||||
public final void instanceShouldAlwaysReturnTheSameInstance() {
|
||||
final MonitorRegistries firstInstance = MonitorRegistries.instance();
|
||||
final MonitorRegistries secondInstance = MonitorRegistries.instance();
|
||||
assertSame("instance() should always return the same instance",
|
||||
firstInstance, secondInstance);
|
||||
}
|
||||
@Test
|
||||
public final void instanceShouldAlwaysReturnTheSameInstance() {
|
||||
final MonitorRegistries firstInstance = MonitorRegistries.instance();
|
||||
final MonitorRegistries secondInstance = MonitorRegistries.instance();
|
||||
assertSame("instance() should always return the same instance",
|
||||
firstInstance, secondInstance);
|
||||
}
|
||||
|
||||
@Test
|
||||
public final void forProviderShouldReturnMonitorRegistryMatchingTheSuppliedProvider() {
|
||||
final MonitorRegistries objectUnderTest = MonitorRegistries.instance();
|
||||
@Test
|
||||
public final void forProviderShouldReturnMonitorRegistryMatchingTheSuppliedProvider() {
|
||||
final MonitorRegistries objectUnderTest = MonitorRegistries.instance();
|
||||
|
||||
final MonitorRegistry registry = objectUnderTest
|
||||
.forProvider(SampleMonitorRegistryFactory.PROVIDER);
|
||||
final MonitorRegistry registry = MonitorRegistries.forProvider(SampleMonitorRegistryFactory.PROVIDER);
|
||||
|
||||
assertSame("forProvider(" + SampleMonitorRegistryFactory.PROVIDER
|
||||
+ ") should return a MonitorRegistry by the supplied provider",
|
||||
SampleMonitorRegistryFactory.SampleMonitorRegistry.class,
|
||||
registry.getClass());
|
||||
}
|
||||
assertSame("forProvider(" + SampleMonitorRegistryFactory.PROVIDER
|
||||
+ ") should return a MonitorRegistry by the supplied provider",
|
||||
SampleMonitorRegistryFactory.SampleMonitorRegistry.class,
|
||||
registry.getClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
public final void uniqueShouldThrowIllegalStateExceptionIfMoreThanOneProviderIsRegistered() {
|
||||
final MonitorRegistries objectUnderTest = MonitorRegistries.instance();
|
||||
@Test
|
||||
public final void uniqueShouldThrowIllegalStateExceptionIfMoreThanOneProviderIsRegistered() {
|
||||
final MonitorRegistries objectUnderTest = MonitorRegistries.instance();
|
||||
|
||||
objectUnderTest.unique();
|
||||
}
|
||||
objectUnderTest.unique();
|
||||
}
|
||||
}
|
||||
|
@ -15,17 +15,17 @@
|
||||
*/
|
||||
package io.netty.util;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class NetUtilTest {
|
||||
private final static Map<String, byte[]> validIpV4Hosts = new HashMap<String, byte[]>() {
|
||||
private static final long serialVersionUID = 2629792739366724032L;
|
||||
{
|
||||
put("192.168.1.0", new byte[]{
|
||||
(byte) 0xc0, (byte) 0xa8, 0x01, 0x00}
|
||||
@ -46,6 +46,7 @@ public class NetUtilTest {
|
||||
}
|
||||
};
|
||||
private final static Map<String, byte[]> invalidIpV4Hosts = new HashMap<String, byte[]>() {
|
||||
private static final long serialVersionUID = 1299215199895717282L;
|
||||
{
|
||||
put("1.256.3.4", null);
|
||||
put("256.0.0.1", null);
|
||||
@ -53,6 +54,7 @@ public class NetUtilTest {
|
||||
}
|
||||
};
|
||||
private final static Map<String, byte[]> validIpV6Hosts = new HashMap<String, byte[]>() {
|
||||
private static final long serialVersionUID = 3999763170377573184L;
|
||||
{
|
||||
put("::ffff:5.6.7.8", new byte[]{
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
@ -164,6 +166,7 @@ public class NetUtilTest {
|
||||
}
|
||||
};
|
||||
private final static Map<String, byte[]> invalidIpV6Hosts = new HashMap<String, byte[]>() {
|
||||
private static final long serialVersionUID = -5870810805409009696L;
|
||||
{
|
||||
// Test method with garbage.
|
||||
put("Obvious Garbage", null);
|
||||
@ -278,17 +281,17 @@ public class NetUtilTest {
|
||||
|
||||
@Test
|
||||
public void testCreateByteArrayFromIpAddressString() {
|
||||
for (String host : validIpV4Hosts.keySet()) {
|
||||
assertTrue(Arrays.equals(validIpV4Hosts.get(host), NetUtil.createByteArrayFromIpAddressString(host)));
|
||||
for (Entry<String, byte[]> stringEntry : validIpV4Hosts.entrySet()) {
|
||||
assertArrayEquals(stringEntry.getValue(), NetUtil.createByteArrayFromIpAddressString(stringEntry.getKey()));
|
||||
}
|
||||
for (String host : invalidIpV4Hosts.keySet()) {
|
||||
assertTrue(Arrays.equals(invalidIpV4Hosts.get(host), NetUtil.createByteArrayFromIpAddressString(host)));
|
||||
for (Entry<String, byte[]> stringEntry : invalidIpV4Hosts.entrySet()) {
|
||||
assertArrayEquals(stringEntry.getValue(), NetUtil.createByteArrayFromIpAddressString(stringEntry.getKey()));
|
||||
}
|
||||
for (String host : validIpV6Hosts.keySet()) {
|
||||
assertTrue(Arrays.equals(validIpV6Hosts.get(host), NetUtil.createByteArrayFromIpAddressString(host)));
|
||||
for (Entry<String, byte[]> stringEntry : validIpV6Hosts.entrySet()) {
|
||||
assertArrayEquals(stringEntry.getValue(), NetUtil.createByteArrayFromIpAddressString(stringEntry.getKey()));
|
||||
}
|
||||
for (String host : invalidIpV6Hosts.keySet()) {
|
||||
assertTrue(Arrays.equals(invalidIpV6Hosts.get(host), NetUtil.createByteArrayFromIpAddressString(host)));
|
||||
for (Entry<String, byte[]> stringEntry : invalidIpV6Hosts.entrySet()) {
|
||||
assertArrayEquals(stringEntry.getValue(), NetUtil.createByteArrayFromIpAddressString(stringEntry.getKey()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,13 +26,17 @@ import io.netty.channel.socket.nio.NioEventLoopGroup;
|
||||
import io.netty.channel.socket.nio.NioServerSocketChannel;
|
||||
import io.netty.util.CharsetUtil;
|
||||
|
||||
import javax.swing.JApplet;
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* {@link JApplet} which starts up a Server that receive data and discard it.
|
||||
*/
|
||||
public class AppletDiscardServer extends JApplet {
|
||||
|
||||
private static final long serialVersionUID = -7824894101960583175L;
|
||||
|
||||
private ServerBootstrap bootstrap;
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
try {
|
||||
|
@ -21,10 +21,10 @@ import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundMessageHandlerAdapter;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.channel.DefaultFileRegion;
|
||||
import io.netty.channel.socket.SocketChannel;
|
||||
import io.netty.channel.socket.nio.NioEventLoopGroup;
|
||||
import io.netty.channel.socket.nio.NioServerSocketChannel;
|
||||
import io.netty.channel.DefaultFileRegion;
|
||||
import io.netty.handler.codec.LineBasedFrameDecoder;
|
||||
import io.netty.handler.codec.string.StringDecoder;
|
||||
import io.netty.handler.codec.string.StringEncoder;
|
||||
@ -95,14 +95,14 @@ public class FileServer {
|
||||
File file = new File(msg);
|
||||
if (file.exists()) {
|
||||
if (!file.isFile()) {
|
||||
ctx.write("Not a file: " + file + "\n");
|
||||
ctx.write("Not a file: " + file + '\n');
|
||||
return;
|
||||
}
|
||||
ctx.write(file + " " + file.length() + "\n");
|
||||
ctx.write(file + " " + file.length() + '\n');
|
||||
ctx.sendFile(new DefaultFileRegion(new FileInputStream(file).getChannel(), 0, file.length()));
|
||||
ctx.write("\n");
|
||||
} else {
|
||||
ctx.write("File not found: " + file + "\n");
|
||||
ctx.write("File not found: " + file + '\n');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,14 +15,12 @@
|
||||
*/
|
||||
package io.netty.example.udt.echo.message;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.MessageBuf;
|
||||
import io.netty.channel.ChannelHandler.Sharable;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundMessageHandlerAdapter;
|
||||
import io.netty.transport.udt.UdtMessage;
|
||||
import io.netty.transport.udt.nio.NioUdtProvider;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -52,7 +50,6 @@ public class MsgEchoServerHandler extends
|
||||
@Override
|
||||
protected void messageReceived(final ChannelHandlerContext ctx,
|
||||
final UdtMessage message) throws Exception {
|
||||
final ByteBuf byteBuf = message.data();
|
||||
final MessageBuf<Object> out = ctx.nextOutboundMessageBuffer();
|
||||
out.add(message);
|
||||
ctx.flush();
|
||||
|
@ -24,13 +24,12 @@ import io.netty.handler.logging.LogLevel;
|
||||
import io.netty.handler.logging.LoggingHandler;
|
||||
import io.netty.transport.udt.UdtChannel;
|
||||
import io.netty.transport.udt.nio.NioUdtProvider;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* UDT Message Flow Peer
|
||||
* <p>
|
||||
@ -46,8 +45,7 @@ public abstract class MsgEchoPeerBase {
|
||||
protected final InetSocketAddress self;
|
||||
protected final InetSocketAddress peer;
|
||||
|
||||
public MsgEchoPeerBase(final InetSocketAddress self,
|
||||
final InetSocketAddress peer, final int messageSize) {
|
||||
protected MsgEchoPeerBase(final InetSocketAddress self, final InetSocketAddress peer, final int messageSize) {
|
||||
this.messageSize = messageSize;
|
||||
this.self = self;
|
||||
this.peer = peer;
|
||||
|
@ -16,15 +16,6 @@
|
||||
|
||||
package io.netty.example.udt.util;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.text.DateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TimeZone;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.yammer.metrics.Metrics;
|
||||
import com.yammer.metrics.core.Clock;
|
||||
import com.yammer.metrics.core.Counter;
|
||||
@ -40,6 +31,15 @@ import com.yammer.metrics.core.Timer;
|
||||
import com.yammer.metrics.reporting.AbstractPollingReporter;
|
||||
import com.yammer.metrics.stats.Snapshot;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.text.DateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TimeZone;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* A simple reporters which prints out application metrics to a
|
||||
* {@link PrintStream} periodically.
|
||||
@ -123,7 +123,7 @@ public class UtilConsoleReporter extends AbstractPollingReporter implements
|
||||
final String dateTime = format.format(new Date(clock.time()));
|
||||
out.print(dateTime);
|
||||
out.print(' ');
|
||||
for (int i = 0; i < (CONSOLE_WIDTH - dateTime.length() - 1); i++) {
|
||||
for (int i = 0; i < CONSOLE_WIDTH - dateTime.length() - 1; i++) {
|
||||
out.print('=');
|
||||
}
|
||||
out.println();
|
||||
@ -227,7 +227,7 @@ public class UtilConsoleReporter extends AbstractPollingReporter implements
|
||||
snapshot.get999thPercentile(), durationUnit);
|
||||
}
|
||||
|
||||
private String abbrev(final TimeUnit unit) {
|
||||
private static String abbrev(final TimeUnit unit) {
|
||||
switch (unit) {
|
||||
case NANOSECONDS:
|
||||
return "ns";
|
||||
|
@ -35,6 +35,5 @@ public class UtilThreadFactory implements ThreadFactory {
|
||||
@Override
|
||||
public Thread newThread(final Runnable runnable) {
|
||||
return new Thread(runnable, name + "-" + counter.getAndIncrement());
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ public final class IdleStateEvent {
|
||||
* Create a new instance
|
||||
*
|
||||
* @param state the detailed idle state.
|
||||
* @param count the count how often this kind of {@IdleStateEvent} was fired before
|
||||
* @param count the count how often this kind of {@link IdleStateEvent} was fired before
|
||||
* @param durationMillis the duration which caused the {@link IdleStateEvent} to get fired in milliseconds
|
||||
*/
|
||||
public IdleStateEvent(IdleState state, int count, long durationMillis) {
|
||||
@ -61,7 +61,7 @@ public final class IdleStateEvent {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the count how often this kind of {@IdleStateEvent} was fired before.
|
||||
* Return the count how often this kind of {@link IdleStateEvent} was fired before.
|
||||
*/
|
||||
public int count() {
|
||||
return count;
|
||||
|
@ -86,7 +86,7 @@ public class TrafficCounter {
|
||||
/**
|
||||
* Delay between two captures
|
||||
*/
|
||||
AtomicLong checkInterval = new AtomicLong(
|
||||
final AtomicLong checkInterval = new AtomicLong(
|
||||
AbstractTrafficShapingHandler.DEFAULT_CHECK_INTERVAL);
|
||||
|
||||
// default 1 s
|
||||
@ -117,7 +117,7 @@ public class TrafficCounter {
|
||||
/**
|
||||
* Is Monitor active
|
||||
*/
|
||||
AtomicBoolean monitorActive = new AtomicBoolean();
|
||||
final AtomicBoolean monitorActive = new AtomicBoolean();
|
||||
|
||||
/**
|
||||
* Class to implement monitoring at fix delay
|
||||
|
9
pom.xml
9
pom.xml
@ -69,7 +69,6 @@
|
||||
|
||||
<properties>
|
||||
<jboss.marshalling.version>1.3.14.GA</jboss.marshalling.version>
|
||||
<yammer.metrics.version>2.1.4</yammer.metrics.version>
|
||||
</properties>
|
||||
|
||||
<modules>
|
||||
@ -113,6 +112,12 @@
|
||||
<version>2.1.7</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.barchart.udt</groupId>
|
||||
<artifactId>barchart-udt-bundle</artifactId>
|
||||
<version>2.2.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
@ -174,7 +179,7 @@
|
||||
<dependency>
|
||||
<groupId>com.yammer.metrics</groupId>
|
||||
<artifactId>metrics-core</artifactId>
|
||||
<version>${yammer.metrics.version}</version>
|
||||
<version>2.2.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Test dependencies for jboss marshalling encoder/decoder -->
|
||||
|
@ -15,87 +15,77 @@
|
||||
~ under the License.
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-parent</artifactId>
|
||||
<version>4.0.0.Beta1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<parent>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-parent</artifactId>
|
||||
<version>4.0.0.Beta1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>netty-transport-udt</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<artifactId>netty-transport-udt</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Netty/Transport/UDT</name>
|
||||
<name>Netty/Transport/UDT</name>
|
||||
|
||||
<dependencies>
|
||||
<dependencies>
|
||||
|
||||
<!-- MAIN -->
|
||||
<!-- MAIN -->
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>netty-buffer</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>netty-buffer</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>netty-transport</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>netty-transport</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.barchart.udt</groupId>
|
||||
<artifactId>barchart-udt-bundle</artifactId>
|
||||
<version>2.2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.barchart.udt</groupId>
|
||||
<artifactId>barchart-udt-bundle</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- TEST -->
|
||||
<!-- TEST -->
|
||||
|
||||
<!-- see https://github.com/netty/netty/issues/874 -->
|
||||
<dependency>
|
||||
<groupId>com.yammer.metrics</groupId>
|
||||
<artifactId>metrics-core</artifactId>
|
||||
<version>2.2.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- see https://github.com/netty/netty/issues/874 -->
|
||||
<dependency>
|
||||
<groupId>com.yammer.metrics</groupId>
|
||||
<artifactId>metrics-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>1.0.9</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.caliper</groupId>
|
||||
<artifactId>caliper</artifactId>
|
||||
<version>0.5-rc1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.caliper</groupId>
|
||||
<artifactId>caliper</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<build>
|
||||
<plugins>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<forkMode>always</forkMode>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<forkMode>always</forkMode>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
@ -15,16 +15,16 @@
|
||||
*/
|
||||
package io.netty.transport.udt;
|
||||
|
||||
import static io.netty.channel.ChannelOption.*;
|
||||
import com.barchart.udt.OptionUDT;
|
||||
import com.barchart.udt.SocketUDT;
|
||||
import com.barchart.udt.nio.ChannelUDT;
|
||||
import io.netty.channel.ChannelOption;
|
||||
import io.netty.channel.DefaultChannelConfig;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import com.barchart.udt.OptionUDT;
|
||||
import com.barchart.udt.SocketUDT;
|
||||
import com.barchart.udt.nio.ChannelUDT;
|
||||
import static io.netty.channel.ChannelOption.*;
|
||||
|
||||
/**
|
||||
* The default {@link UdtChannelConfig} implementation.
|
||||
@ -38,8 +38,8 @@ public class DefaultUdtChannelConfig extends DefaultChannelConfig implements
|
||||
private volatile int protocolReceiveBuferSize = 10 * M;
|
||||
private volatile int protocolSendBuferSize = 10 * M;
|
||||
|
||||
private volatile int systemReceiveBufferSize = 1 * M;
|
||||
private volatile int systemSendBuferSize = 1 * M;
|
||||
private volatile int systemReceiveBufferSize = M;
|
||||
private volatile int systemSendBuferSize = M;
|
||||
|
||||
private volatile int allocatorReceiveBufferSize = 128 * K;
|
||||
private volatile int allocatorSendBufferSize = 128 * K;
|
||||
@ -149,8 +149,8 @@ public class DefaultUdtChannelConfig extends DefaultChannelConfig implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public UdtChannelConfig setProtocolReceiveBufferSize(final int allocator) {
|
||||
this.protocolReceiveBuferSize = allocator;
|
||||
public UdtChannelConfig setProtocolReceiveBufferSize(final int protocolReceiveBuferSize) {
|
||||
this.protocolReceiveBuferSize = protocolReceiveBuferSize;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -15,23 +15,13 @@
|
||||
*/
|
||||
package io.netty.transport.udt.nio;
|
||||
|
||||
import io.netty.logging.InternalLogger;
|
||||
import io.netty.logging.InternalLoggerFactory;
|
||||
import io.netty.transport.udt.UdtChannel;
|
||||
|
||||
import com.barchart.udt.TypeUDT;
|
||||
|
||||
/**
|
||||
* Byte Channel Rendezvous for UDT Streams.
|
||||
*/
|
||||
public class NioUdtByteRendezvousChannel extends NioUdtByteConnectorChannel
|
||||
implements UdtChannel {
|
||||
|
||||
private static final InternalLogger logger = InternalLoggerFactory
|
||||
.getInstance(NioUdtByteRendezvousChannel.class);
|
||||
|
||||
public class NioUdtByteRendezvousChannel extends NioUdtByteConnectorChannel {
|
||||
public NioUdtByteRendezvousChannel() {
|
||||
super(NioUdtProvider.newRendezvousChannelUDT(TypeUDT.STREAM));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,12 +15,8 @@
|
||||
*/
|
||||
package io.netty.transport.udt.nio;
|
||||
|
||||
import io.netty.logging.InternalLogger;
|
||||
import io.netty.logging.InternalLoggerFactory;
|
||||
import io.netty.transport.udt.UdtChannel;
|
||||
import io.netty.transport.udt.UdtMessage;
|
||||
|
||||
import com.barchart.udt.TypeUDT;
|
||||
import io.netty.transport.udt.UdtMessage;
|
||||
|
||||
/**
|
||||
* Message Rendezvous for UDT Datagrams.
|
||||
@ -28,10 +24,7 @@ import com.barchart.udt.TypeUDT;
|
||||
* Note: send/receive must use {@link UdtMessage} in the pipeline
|
||||
*/
|
||||
public class NioUdtMessageRendezvousChannel extends
|
||||
NioUdtMessageConnectorChannel implements UdtChannel {
|
||||
|
||||
private static final InternalLogger logger = InternalLoggerFactory
|
||||
.getInstance(NioUdtMessageConnectorChannel.class);
|
||||
NioUdtMessageConnectorChannel {
|
||||
|
||||
public NioUdtMessageRendezvousChannel() {
|
||||
super(NioUdtProvider.newRendezvousChannelUDT(TypeUDT.DATAGRAM));
|
||||
|
@ -16,7 +16,10 @@
|
||||
|
||||
package io.netty.transport.udt.bench.xfer;
|
||||
|
||||
import static io.netty.transport.udt.util.UnitHelp.*;
|
||||
import com.barchart.udt.SocketUDT;
|
||||
import com.barchart.udt.StatusUDT;
|
||||
import com.barchart.udt.TypeUDT;
|
||||
import com.google.caliper.Param;
|
||||
import io.netty.transport.udt.bench.BenchXfer;
|
||||
import io.netty.transport.udt.util.CaliperRunner;
|
||||
import io.netty.transport.udt.util.TrafficControl;
|
||||
@ -29,10 +32,7 @@ import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import com.barchart.udt.SocketUDT;
|
||||
import com.barchart.udt.StatusUDT;
|
||||
import com.barchart.udt.TypeUDT;
|
||||
import com.google.caliper.Param;
|
||||
import static io.netty.transport.udt.util.UnitHelp.*;
|
||||
|
||||
/**
|
||||
* perform two way native UDT socket send/recv
|
||||
@ -210,7 +210,7 @@ public class UdtNative extends BenchXfer {
|
||||
if (count != message) {
|
||||
throw new Exception("count");
|
||||
}
|
||||
if (this.sequence++ != buffer.getLong(0)) {
|
||||
if (sequence ++ != buffer.getLong(0)) {
|
||||
throw new Exception("sequence");
|
||||
}
|
||||
}
|
||||
@ -241,7 +241,7 @@ public class UdtNative extends BenchXfer {
|
||||
if (count != message) {
|
||||
throw new Exception("count");
|
||||
}
|
||||
if (this.sequence++ != buffer.getLong(0)) {
|
||||
if (sequence ++ != buffer.getLong(0)) {
|
||||
throw new Exception("sequence");
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,9 @@
|
||||
|
||||
package io.netty.transport.udt.bench.xfer;
|
||||
|
||||
import com.yammer.metrics.Metrics;
|
||||
import com.yammer.metrics.core.Counter;
|
||||
import com.yammer.metrics.core.Meter;
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
@ -26,18 +29,13 @@ import io.netty.transport.udt.util.CustomReporter;
|
||||
import io.netty.transport.udt.util.EchoMessageHandler;
|
||||
import io.netty.transport.udt.util.TrafficControl;
|
||||
import io.netty.transport.udt.util.UnitHelp;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.yammer.metrics.Metrics;
|
||||
import com.yammer.metrics.core.Counter;
|
||||
import com.yammer.metrics.core.Meter;
|
||||
|
||||
/**
|
||||
* perform two way netty send/recv
|
||||
*/
|
||||
@ -118,12 +116,12 @@ public final class UdtNetty {
|
||||
|
||||
isOn.set(false);
|
||||
|
||||
Thread.sleep(1 * 1000);
|
||||
Thread.sleep(1000);
|
||||
|
||||
peerFuture1.channel().close().sync();
|
||||
peerFuture2.channel().close().sync();
|
||||
|
||||
Thread.sleep(1 * 1000);
|
||||
Thread.sleep(1000);
|
||||
|
||||
peerBoot1.shutdown();
|
||||
peerBoot2.shutdown();
|
||||
|
@ -16,12 +16,12 @@
|
||||
|
||||
package io.netty.transport.udt.nio;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import io.netty.buffer.BufType;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestNioUdtByteAcceptorChannel extends TestAny {
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class NioUdtByteAcceptorChannelTest extends TestAny {
|
||||
|
||||
/**
|
||||
* verify channel meta data
|
||||
@ -33,5 +33,4 @@ public class TestNioUdtByteAcceptorChannel extends TestAny {
|
||||
.bufferType());
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -16,12 +16,12 @@
|
||||
|
||||
package io.netty.transport.udt.nio;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import io.netty.buffer.BufType;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestNioUdtByteConnectorChannel extends TestAny {
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class NioUdtByteConnectorChannelTest extends TestAny {
|
||||
|
||||
/**
|
||||
* verify channel meta data
|
@ -16,23 +16,22 @@
|
||||
|
||||
package io.netty.transport.udt.nio;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import com.yammer.metrics.Metrics;
|
||||
import com.yammer.metrics.core.Meter;
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.buffer.BufType;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.transport.udt.util.BootHelp;
|
||||
import io.netty.transport.udt.util.EchoByteHandler;
|
||||
import io.netty.transport.udt.util.UnitHelp;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import com.yammer.metrics.Metrics;
|
||||
import com.yammer.metrics.core.Meter;
|
||||
|
||||
public class TestNioUdtByteRendezvousChannel extends TestAny {
|
||||
public class NioUdtByteRendezvousChannelTest extends TestAny {
|
||||
|
||||
/**
|
||||
* verify channel meta data
|
||||
@ -55,11 +54,11 @@ public class TestNioUdtByteRendezvousChannel extends TestAny {
|
||||
final int transferLimit = messageSize * 16;
|
||||
|
||||
final Meter rate1 = Metrics.newMeter(
|
||||
TestNioUdtMessageRendezvousChannel.class, "send rate", "bytes",
|
||||
NioUdtMessageRendezvousChannelTest.class, "send rate", "bytes",
|
||||
TimeUnit.SECONDS);
|
||||
|
||||
final Meter rate2 = Metrics.newMeter(
|
||||
TestNioUdtMessageRendezvousChannel.class, "send rate", "bytes",
|
||||
NioUdtMessageRendezvousChannelTest.class, "send rate", "bytes",
|
||||
TimeUnit.SECONDS);
|
||||
|
||||
final InetSocketAddress addr1 = UnitHelp.localSocketAddress();
|
@ -16,12 +16,12 @@
|
||||
|
||||
package io.netty.transport.udt.nio;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import io.netty.buffer.BufType;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestNioUdtMessageAcceptorChannel extends TestAny {
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class NioUdtMessageAcceptorChannelTest extends TestAny {
|
||||
|
||||
/**
|
||||
* verify channel meta data
|
@ -16,12 +16,12 @@
|
||||
|
||||
package io.netty.transport.udt.nio;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import io.netty.buffer.BufType;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestNioUdtMessageConnectorChannel extends TestAny {
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class NioUdtMessageConnectorChannelTest extends TestAny {
|
||||
|
||||
/**
|
||||
* verify channel meta data
|
@ -16,23 +16,22 @@
|
||||
|
||||
package io.netty.transport.udt.nio;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import com.yammer.metrics.Metrics;
|
||||
import com.yammer.metrics.core.Meter;
|
||||
import io.netty.bootstrap.Bootstrap;
|
||||
import io.netty.buffer.BufType;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.transport.udt.util.BootHelp;
|
||||
import io.netty.transport.udt.util.EchoMessageHandler;
|
||||
import io.netty.transport.udt.util.UnitHelp;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import com.yammer.metrics.Metrics;
|
||||
import com.yammer.metrics.core.Meter;
|
||||
|
||||
public class TestNioUdtMessageRendezvousChannel extends TestAny {
|
||||
public class NioUdtMessageRendezvousChannelTest extends TestAny {
|
||||
|
||||
/**
|
||||
* verify channel meta data
|
||||
@ -55,11 +54,11 @@ public class TestNioUdtMessageRendezvousChannel extends TestAny {
|
||||
final int transferLimit = messageSize * 16;
|
||||
|
||||
final Meter rate1 = Metrics.newMeter(
|
||||
TestNioUdtMessageRendezvousChannel.class, "send rate", "bytes",
|
||||
NioUdtMessageRendezvousChannelTest.class, "send rate", "bytes",
|
||||
TimeUnit.SECONDS);
|
||||
|
||||
final Meter rate2 = Metrics.newMeter(
|
||||
TestNioUdtMessageRendezvousChannel.class, "send rate", "bytes",
|
||||
NioUdtMessageRendezvousChannelTest.class, "send rate", "bytes",
|
||||
TimeUnit.SECONDS);
|
||||
|
||||
final InetSocketAddress addr1 = UnitHelp.localSocketAddress();
|
@ -16,11 +16,11 @@
|
||||
|
||||
package io.netty.transport.udt.nio;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestNioUdtProvider extends TestAny {
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class NioUdtProviderTest extends TestAny {
|
||||
|
||||
/**
|
||||
* verify factory
|
@ -27,7 +27,7 @@ import java.util.concurrent.ThreadFactory;
|
||||
/**
|
||||
* Bootstrap utilities.
|
||||
*/
|
||||
public class BootHelp {
|
||||
public final class BootHelp {
|
||||
|
||||
/**
|
||||
* bootstrap for byte rendezvous peer
|
||||
@ -70,4 +70,5 @@ public class BootHelp {
|
||||
|
||||
}
|
||||
|
||||
private BootHelp() { }
|
||||
}
|
||||
|
@ -16,13 +16,6 @@
|
||||
|
||||
package io.netty.transport.udt.util;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.caliper.Measurement;
|
||||
import com.google.caliper.MeasurementSet;
|
||||
import com.google.caliper.Run;
|
||||
@ -33,6 +26,10 @@ import com.yammer.metrics.core.Meter;
|
||||
import com.yammer.metrics.core.MetricsRegistry;
|
||||
import com.yammer.metrics.core.Timer;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Caliper measure with Metrics provider.
|
||||
* <p>
|
||||
@ -40,9 +37,6 @@ import com.yammer.metrics.core.Timer;
|
||||
*/
|
||||
public class CaliperMeasure {
|
||||
|
||||
private final static Logger log = LoggerFactory
|
||||
.getLogger(CaliperMeasure.class);
|
||||
|
||||
/**
|
||||
* Gauge any double value
|
||||
*/
|
||||
@ -55,8 +49,8 @@ public class CaliperMeasure {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void value(final double number) {
|
||||
this.size = number;
|
||||
public void value(final double size) {
|
||||
this.size = size;
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,7 +128,7 @@ public class CaliperMeasure {
|
||||
/**
|
||||
* Workaround: zero breaks gwt web app.
|
||||
*/
|
||||
private double filter(final double value) {
|
||||
private static double filter(final double value) {
|
||||
if (value <= 0.0) {
|
||||
return 1.0;
|
||||
} else {
|
||||
@ -179,8 +173,8 @@ public class CaliperMeasure {
|
||||
return variables;
|
||||
}
|
||||
|
||||
private MeasurementSet measurementSet(final Map<Long, Measurement> map) {
|
||||
final Measurement[] array = map.values().toArray(new Measurement[0]);
|
||||
private static MeasurementSet measurementSet(final Map<Long, Measurement> map) {
|
||||
final Measurement[] array = map.values().toArray(new Measurement[map.size()]);
|
||||
final MeasurementSet set = new MeasurementSet(array);
|
||||
return set;
|
||||
}
|
||||
|
@ -17,6 +17,20 @@
|
||||
|
||||
package io.netty.transport.udt.util;
|
||||
|
||||
import com.google.caliper.ConfiguredBenchmark;
|
||||
import com.google.caliper.Environment;
|
||||
import com.google.caliper.EnvironmentGetter;
|
||||
import com.google.caliper.Json;
|
||||
import com.google.caliper.Result;
|
||||
import com.google.caliper.Run;
|
||||
import com.google.caliper.Runner;
|
||||
import com.google.caliper.Scenario;
|
||||
import com.google.caliper.ScenarioResult;
|
||||
import com.google.caliper.SimpleBenchmark;
|
||||
import com.yammer.metrics.core.TimerContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -31,21 +45,6 @@ import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.caliper.ConfiguredBenchmark;
|
||||
import com.google.caliper.Environment;
|
||||
import com.google.caliper.EnvironmentGetter;
|
||||
import com.google.caliper.Json;
|
||||
import com.google.caliper.Result;
|
||||
import com.google.caliper.Run;
|
||||
import com.google.caliper.Runner;
|
||||
import com.google.caliper.Scenario;
|
||||
import com.google.caliper.ScenarioResult;
|
||||
import com.google.caliper.SimpleBenchmark;
|
||||
import com.yammer.metrics.core.TimerContext;
|
||||
|
||||
/**
|
||||
* Custom caliper runner for {@link CaliperBench}.
|
||||
*/
|
||||
@ -69,9 +68,8 @@ public final class CaliperRunner {
|
||||
*/
|
||||
public static void execute(final Class<? extends CaliperBench> klaz)
|
||||
throws Exception {
|
||||
Run run;
|
||||
run = execute("WARMUP", klaz);
|
||||
run = execute("REPORT", klaz);
|
||||
execute("WARMUP", klaz);
|
||||
Run run = execute("REPORT", klaz);
|
||||
publish(newResult(run));
|
||||
}
|
||||
|
||||
@ -226,7 +224,7 @@ public final class CaliperRunner {
|
||||
final Run run = newRun("test-main");
|
||||
for (int param = 0; param < 5; param++) {
|
||||
final CaliperMeasure measure = new CaliperMeasure();
|
||||
measure.variables().put("param", "" + param);
|
||||
measure.variables().put("param", String.valueOf(param));
|
||||
for (int step = 0; step < 5; step++) {
|
||||
measure.rate().mark(50 + step);
|
||||
final TimerContext time = measure.time().time();
|
||||
|
@ -16,15 +16,6 @@
|
||||
|
||||
package io.netty.transport.udt.util;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.text.DateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TimeZone;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.yammer.metrics.Metrics;
|
||||
import com.yammer.metrics.core.Clock;
|
||||
import com.yammer.metrics.core.Counter;
|
||||
@ -40,6 +31,15 @@ import com.yammer.metrics.core.Timer;
|
||||
import com.yammer.metrics.reporting.AbstractPollingReporter;
|
||||
import com.yammer.metrics.stats.Snapshot;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.text.DateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TimeZone;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* A simple reporters which prints out application metrics to a
|
||||
* {@link PrintStream} periodically.
|
||||
@ -123,7 +123,7 @@ public class CustomReporter extends AbstractPollingReporter implements
|
||||
final String dateTime = format.format(new Date(clock.time()));
|
||||
out.print(dateTime);
|
||||
out.print(' ');
|
||||
for (int i = 0; i < (CONSOLE_WIDTH - dateTime.length() - 1); i++) {
|
||||
for (int i = 0; i < CONSOLE_WIDTH - dateTime.length() - 1; i++) {
|
||||
out.print('=');
|
||||
}
|
||||
out.println();
|
||||
@ -227,7 +227,7 @@ public class CustomReporter extends AbstractPollingReporter implements
|
||||
snapshot.get999thPercentile(), durationUnit);
|
||||
}
|
||||
|
||||
private String abbrev(final TimeUnit unit) {
|
||||
private static String abbrev(final TimeUnit unit) {
|
||||
switch (unit) {
|
||||
case NANOSECONDS:
|
||||
return "ns";
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
package io.netty.transport.udt.util;
|
||||
|
||||
import com.yammer.metrics.core.Meter;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.MessageBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
@ -23,12 +24,9 @@ import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundMessageHandlerAdapter;
|
||||
import io.netty.transport.udt.UdtMessage;
|
||||
import io.netty.transport.udt.nio.NioUdtProvider;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.yammer.metrics.core.Meter;
|
||||
|
||||
/**
|
||||
* Handler implementation for the echo peer. It initiates the ping-pong traffic
|
||||
* between the echo peers by sending the first message to the other peer on
|
||||
@ -59,7 +57,7 @@ public class EchoMessageHandler extends
|
||||
byteBuf.writeByte((byte) i);
|
||||
}
|
||||
|
||||
this.message = new UdtMessage(byteBuf);
|
||||
message = new UdtMessage(byteBuf);
|
||||
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,11 @@
|
||||
|
||||
package io.netty.transport.udt.util;
|
||||
|
||||
import com.barchart.udt.SocketUDT;
|
||||
import com.barchart.udt.StatusUDT;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
@ -25,12 +30,7 @@ import java.util.HashSet;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.barchart.udt.SocketUDT;
|
||||
import com.barchart.udt.StatusUDT;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Unit test helper.
|
||||
@ -38,6 +38,7 @@ import com.barchart.udt.StatusUDT;
|
||||
public final class UnitHelp {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(UnitHelp.class);
|
||||
private static final Pattern SPACES = Pattern.compile("\\s+");
|
||||
|
||||
/**
|
||||
* Zero out buffer.
|
||||
@ -80,7 +81,7 @@ public final class UnitHelp {
|
||||
* Invoke external process and wait for completion.
|
||||
*/
|
||||
public static void process(final String command) throws Exception {
|
||||
final ProcessBuilder builder = new ProcessBuilder(command.split("\\s+"));
|
||||
final ProcessBuilder builder = new ProcessBuilder(SPACES.split(command));
|
||||
final Process process = builder.start();
|
||||
process.waitFor();
|
||||
}
|
||||
@ -215,11 +216,11 @@ public final class UnitHelp {
|
||||
}
|
||||
|
||||
public static String randomString() {
|
||||
return "" + System.currentTimeMillis();
|
||||
return String.valueOf(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public static String randomSuffix(final String name) {
|
||||
return name + "-" + System.currentTimeMillis();
|
||||
return name + '-' + System.currentTimeMillis();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -34,7 +34,7 @@ public class UtilThreadFactory implements ThreadFactory {
|
||||
|
||||
@Override
|
||||
public Thread newThread(final Runnable runnable) {
|
||||
return new Thread(runnable, name + "-" + counter.getAndIncrement());
|
||||
return new Thread(runnable, name + '-' + counter.getAndIncrement());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,7 +16,6 @@
|
||||
package io.netty.channel;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufHolder;
|
||||
import io.netty.buffer.Freeable;
|
||||
import io.netty.buffer.MessageBuf;
|
||||
|
||||
|
@ -46,23 +46,19 @@ public final class ChannelPromiseAggregator implements ChannelFutureListener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void operationComplete(ChannelFuture future)
|
||||
throws Exception {
|
||||
|
||||
synchronized (this) {
|
||||
if (pendingPromises == null) {
|
||||
aggregatePromise.setSuccess();
|
||||
public synchronized void operationComplete(ChannelFuture future) throws Exception {
|
||||
if (pendingPromises == null) {
|
||||
aggregatePromise.setSuccess();
|
||||
} else {
|
||||
pendingPromises.remove(future);
|
||||
if (!future.isSuccess()) {
|
||||
aggregatePromise.setFailure(future.cause());
|
||||
for (ChannelPromise pendingFuture : pendingPromises) {
|
||||
pendingFuture.setFailure(future.cause());
|
||||
}
|
||||
} else {
|
||||
pendingPromises.remove(future);
|
||||
if (!future.isSuccess()) {
|
||||
aggregatePromise.setFailure(future.cause());
|
||||
for (ChannelPromise pendingFuture: pendingPromises) {
|
||||
pendingFuture.setFailure(future.cause());
|
||||
}
|
||||
} else {
|
||||
if (pendingPromises.isEmpty()) {
|
||||
aggregatePromise.setSuccess();
|
||||
}
|
||||
if (pendingPromises.isEmpty()) {
|
||||
aggregatePromise.setSuccess();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,13 +15,13 @@
|
||||
*/
|
||||
package io.netty.channel;
|
||||
|
||||
import io.netty.logging.InternalLogger;
|
||||
import io.netty.logging.InternalLoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.channels.WritableByteChannel;
|
||||
|
||||
import io.netty.logging.InternalLogger;
|
||||
import io.netty.logging.InternalLoggerFactory;
|
||||
|
||||
/**
|
||||
* Default {@link FileRegion} implementation which transfer data from a {@link FileChannel}.
|
||||
*/
|
||||
@ -71,7 +71,7 @@ public class DefaultFileRegion implements FileRegion {
|
||||
if (count < 0 || position < 0) {
|
||||
throw new IllegalArgumentException(
|
||||
"position out of range: " + position +
|
||||
" (expected: 0 - " + (this.count - 1) + ")");
|
||||
" (expected: 0 - " + (this.count - 1) + ')');
|
||||
}
|
||||
if (count == 0) {
|
||||
return 0L;
|
||||
|
@ -242,7 +242,6 @@ public abstract class SingleThreadEventExecutor extends AbstractExecutorService
|
||||
|
||||
/**
|
||||
* Poll all tasks from the task queue and run them via {@link Runnable#run()} method.
|
||||
* @return
|
||||
*/
|
||||
protected boolean runAllTasks() {
|
||||
boolean ran = false;
|
||||
|
@ -26,7 +26,7 @@ import java.util.concurrent.ThreadFactory;
|
||||
*
|
||||
*/
|
||||
public abstract class SingleThreadEventLoop extends SingleThreadEventExecutor implements EventLoop {
|
||||
protected CounterMonitor channelCounter = MonitorRegistries.instance()
|
||||
protected final CounterMonitor channelCounter = MonitorRegistries.instance()
|
||||
.unique().newCounterMonitor(new MonitorName(getClass(), "total-channels-registered"));
|
||||
|
||||
/**
|
||||
|
@ -65,7 +65,7 @@ public class AioSocketChannel extends AbstractAioChannel implements SocketChanne
|
||||
}
|
||||
}
|
||||
|
||||
private DefaultAioSocketChannelConfig config;
|
||||
private final DefaultAioSocketChannelConfig config;
|
||||
private volatile boolean inputShutdown;
|
||||
private volatile boolean outputShutdown;
|
||||
|
||||
|
@ -194,8 +194,8 @@ public abstract class AbstractNioChannel extends AbstractChannel {
|
||||
if (connectTimeoutException == null) {
|
||||
connectTimeoutException = new ConnectException("connection timed out");
|
||||
}
|
||||
ChannelPromise connectFuture = AbstractNioChannel.this.connectPromise;
|
||||
if (connectFuture != null && connectFuture.tryFailure(connectTimeoutException)) {
|
||||
ChannelPromise connectPromise = AbstractNioChannel.this.connectPromise;
|
||||
if (connectPromise != null && connectPromise.tryFailure(connectTimeoutException)) {
|
||||
close(voidFuture());
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
@ -62,7 +61,6 @@ public class SingleThreadEventLoopTest {
|
||||
|
||||
@Test
|
||||
public void shutdownAfterStart() throws Exception {
|
||||
final AtomicBoolean interrupted = new AtomicBoolean();
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
loop.execute(new Runnable() {
|
||||
@Override
|
||||
|
@ -18,8 +18,6 @@ package io.netty.channel.socket.nio;
|
||||
import io.netty.channel.AbstractEventLoopTest;
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
import io.netty.channel.socket.ServerSocketChannel;
|
||||
import io.netty.channel.socket.nio.NioEventLoopGroup;
|
||||
import io.netty.channel.socket.nio.NioServerSocketChannel;
|
||||
|
||||
public class NioEventLoopTest extends AbstractEventLoopTest {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user