Skip to content

Commit

Permalink
Extract building connections metric name into a method
Browse files Browse the repository at this point in the history
Reduce duplicate code across all HTTP connection factories.
  • Loading branch information
Artem Prigoda committed Dec 28, 2014
1 parent a1d751f commit 2380624
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
Expand Up @@ -434,13 +434,16 @@ public Connector build(Server server,

final ByteBufferPool bufferPool = buildBufferPool();

final String timerName = name(HttpConnectionFactory.class,
bindHost,
Integer.toString(port),
"connections");
return buildConnector(server, scheduler, bufferPool, name, threadPool,
new InstrumentedConnectionFactory(httpConnectionFactory,
metrics.timer(timerName)));
metrics.timer(httpConnections())));
}

/**
* Get name of the timer that tracks incoming HTTP connections
*/
protected String httpConnections() {
return name(HttpConnectionFactory.class, bindHost, Integer.toString(port), "connections");
}

protected ServerConnector buildConnector(Server server,
Expand Down
Expand Up @@ -545,14 +545,9 @@ public Connector build(Server server, MetricRegistry metrics, String name, Threa

final ByteBufferPool bufferPool = buildBufferPool();

final String timerName = name(HttpConnectionFactory.class,
getBindHost(),
Integer.toString(getPort()),
"connections");

return buildConnector(server, scheduler, bufferPool, name, threadPool,
new InstrumentedConnectionFactory(sslConnectionFactory,
metrics.timer(timerName)),
metrics.timer(httpConnections())),
httpConnectionFactory);
}

Expand Down
Expand Up @@ -9,7 +9,6 @@
import org.eclipse.jetty.io.ByteBufferPool;
import org.eclipse.jetty.server.*;
import org.eclipse.jetty.spdy.api.SPDY;
import org.eclipse.jetty.spdy.server.NPNServerConnectionFactory;
import org.eclipse.jetty.spdy.server.http.HTTPSPDYServerConnectionFactory;
import org.eclipse.jetty.spdy.server.http.PushStrategy;
import org.eclipse.jetty.util.ssl.SslContextFactory;
Expand Down Expand Up @@ -93,11 +92,8 @@ public Connector build(Server server, MetricRegistry metrics, String name, Threa

final ByteBufferPool bufferPool = buildBufferPool();

final String timerName = name(HttpConnectionFactory.class, getBindHost(), Integer.toString(getPort()),
"connections");

return buildConnector(server, scheduler, bufferPool, name, threadPool,
new InstrumentedConnectionFactory(sslConnectionFactory, metrics.timer(timerName)),
new InstrumentedConnectionFactory(sslConnectionFactory, metrics.timer(httpConnections())),
negotiatingFactory,
spdyFactory,
httpConnectionFactory);
Expand Down

0 comments on commit 2380624

Please sign in to comment.