Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to Netty 4.1 #4397

Merged
merged 14 commits into from
Jan 18, 2018
Prev Previous commit
Use locale metric registry for transport-specific metrics
  • Loading branch information
Jochen Schalanda committed Jan 11, 2018
commit 1df8385ad92ddcbd09da6c8905c23e9552106f96
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Bootstrap getBootstrap(MessageInput input) {
LOG.debug("Setting UDP receive buffer size to {} bytes", getRecvBufferSize());
final NettyTransportType transportType = nettyTransportConfiguration.getType();

eventLoopGroup = eventLoopGroupFactory.create(workerThreads, MetricRegistry.name(this.getClass(), "workers"));
eventLoopGroup = eventLoopGroupFactory.create(workerThreads, localRegistry, "workers");

return new Bootstrap()
.group(eventLoopGroup)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,14 @@
import java.util.concurrent.ThreadFactory;

public class EventLoopGroupFactory {
private final MetricRegistry metricRegistry;
private final NettyTransportConfiguration configuration;

@Inject
public EventLoopGroupFactory(MetricRegistry metricRegistry, NettyTransportConfiguration configuration) {
this.metricRegistry = metricRegistry;
public EventLoopGroupFactory(NettyTransportConfiguration configuration) {
this.configuration = configuration;
}

public EventLoopGroup create(int numThreads, String metricPrefix) {
public EventLoopGroup create(int numThreads, MetricRegistry metricRegistry, String metricPrefix) {
final ThreadFactory threadFactory = threadFactory(metricPrefix, metricRegistry);
final Executor executor = executor(metricPrefix, numThreads, threadFactory, metricRegistry);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.graylog2.inputs.transports.netty;

import com.codahale.metrics.MetricRegistry;
import io.netty.channel.EventLoopGroup;
import org.graylog2.inputs.transports.NettyTransportConfiguration;

Expand All @@ -25,17 +26,21 @@
public class EventLoopGroupProvider implements Provider<EventLoopGroup> {
private final EventLoopGroupFactory eventLoopGroupFactory;
private final NettyTransportConfiguration configuration;
private final MetricRegistry metricRegistry;

@Inject
public EventLoopGroupProvider(EventLoopGroupFactory eventLoopGroupFactory, NettyTransportConfiguration configuration) {
public EventLoopGroupProvider(EventLoopGroupFactory eventLoopGroupFactory,
NettyTransportConfiguration configuration,
MetricRegistry metricRegistry) {
this.eventLoopGroupFactory = eventLoopGroupFactory;
this.configuration = configuration;
this.metricRegistry = metricRegistry;
}

@Override
public EventLoopGroup get() {
final String name = "netty-transport";
final int numThreads = configuration.getNumThreads();
return eventLoopGroupFactory.create(numThreads, name);
return eventLoopGroupFactory.create(numThreads, metricRegistry, name);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ protected ServerBootstrap getBootstrap(MessageInput input) {
final LinkedHashMap<String, Callable<? extends ChannelHandler>> parentHandlers = getChannelHandlers(input);
final LinkedHashMap<String, Callable<? extends ChannelHandler>> childHandlers = getChildChannelHandlers(input);

childEventLoopGroup = eventLoopGroupFactory.create(workerThreads, MetricRegistry.name(this.getClass(), "workers"));
childEventLoopGroup = eventLoopGroupFactory.create(workerThreads, localRegistry, "workers");

return new ServerBootstrap()
.group(parentEventLoopGroup, childEventLoopGroup)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package org.graylog2.inputs.transports;

import com.codahale.metrics.Gauge;
import com.codahale.metrics.MetricRegistry;
import com.github.joschi.jadconfig.util.Size;
import com.google.common.collect.ImmutableMap;
import com.google.common.primitives.Ints;
Expand Down Expand Up @@ -85,10 +84,10 @@ public class UdpTransportTest {
@Before
@SuppressForbidden("Executors#newSingleThreadExecutor() is okay for tests")
public void setUp() throws Exception {
eventLoopGroupFactory = new EventLoopGroupFactory(new MetricRegistry(), nettyTransportConfiguration);
eventLoopGroup = eventLoopGroupFactory.create(1, "test");
throughputCounter = new ThroughputCounter(eventLoopGroup);
eventLoopGroupFactory = new EventLoopGroupFactory(nettyTransportConfiguration);
localMetricRegistry = new LocalMetricRegistry();
eventLoopGroup = eventLoopGroupFactory.create(1, localMetricRegistry,"test");
throughputCounter = new ThroughputCounter(eventLoopGroup);
udpTransport = new UdpTransport(CONFIGURATION, eventLoopGroupFactory, nettyTransportConfiguration, throughputCounter, localMetricRegistry);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package org.graylog2.plugin.inputs.transports;

import com.codahale.metrics.MetricRegistry;
import com.google.common.collect.ImmutableMap;
import io.netty.bootstrap.Bootstrap;
import io.netty.buffer.Unpooled;
Expand Down Expand Up @@ -78,7 +77,7 @@ public class AbstractTcpTransportTest {
@Before
public void setUp() {
eventLoopGroup = new NioEventLoopGroup();
eventLoopGroupFactory = new EventLoopGroupFactory(new MetricRegistry(), nettyTransportConfiguration);
eventLoopGroupFactory = new EventLoopGroupFactory(nettyTransportConfiguration);
throughputCounter = new ThroughputCounter(eventLoopGroup);
localRegistry = new LocalMetricRegistry();
}
Expand Down