Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Make server address configurable #185

Closed
wants to merge 1 commit into from

2 participants

@franklinhu

Users may not want to bind to the default InetAddress.getLocalHost if they have multiple network interfaces.

@franklinhu franklinhu closed this pull request from a commit
@franklinhu franklinhu Make server address configurable
Users may not want to bind to the default `InetAddress.getLocalHost` if they
have multiple network interfaces.

Author: @franklinhu
Fixes #185
URL: #185
e0b732a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 22, 2012
  1. Expose server address as configurable

    Franklin Hu authored
This page is out of date. Refresh to see the latest.
View
2  zipkin-collector-core/src/main/scala/com/twitter/zipkin/config/ZipkinCollectorConfig.scala
@@ -116,8 +116,6 @@ trait ZipkinCollectorConfig extends ZipkinConfig[ZipkinCollector] {
def writeQueueConfig: WriteQueueConfig[T]
lazy val writeQueue: WriteQueue[T] = writeQueueConfig.apply(processor)
- lazy val serverAddr = new InetSocketAddress(InetAddress.getLocalHost, serverPort)
-
val serverConfig: CollectorServerConfig
def apply(runtime: RuntimeEnvironment): ZipkinCollector = {
View
6 ...collector-scribe/src/main/scala/com/twitter/zipkin/collector/ScribeCollectorService.scala
@@ -23,6 +23,7 @@ import com.twitter.util.{FuturePool, Future}
import com.twitter.zipkin.config.ScribeZipkinCollectorConfig
import com.twitter.zipkin.gen
import org.apache.zookeeper.KeeperException
+import java.net.InetSocketAddress
/**
* This class implements the log method from the Scribe Thrift interface.
@@ -40,15 +41,16 @@ class ScribeCollectorService(config: ScribeZipkinCollectorConfig, val writeQueue
override def start() {
/* Register a node in ZooKeeper for Scribe to pick up */
+ val serverAddress = new InetSocketAddress(config.serverAddress, config.serverPort)
val serverSet = new ServerSetImpl(config.zkClient, config.zkServerSetPath)
val cluster = new ZookeeperServerSetCluster(serverSet)
zkNodes = config.zkScribePaths.map {
path =>
- new ResilientZKNode(path, config.serverAddr.getHostName + ":" + config.serverAddr.getPort,
+ new ResilientZKNode(path, serverAddress.getHostName + ":" + serverAddress.getPort,
config.zkClient, config.timer, config.statsReceiver)
}.toSeq
zkNodes foreach (_.register())
- cluster.join(config.serverAddr)
+ cluster.join(serverAddress)
super.start()
}
View
7 ...llector-scribe/src/main/scala/com/twitter/zipkin/config/ScribeCollectorServerConfig.scala
@@ -23,13 +23,16 @@ import com.twitter.zipkin.collector.ScribeCollectorService
import com.twitter.zipkin.gen
import org.apache.thrift.protocol.TBinaryProtocol
import com.twitter.zipkin.config.collector.CollectorServerConfig
+import java.net.InetSocketAddress
class ScribeCollectorServerConfig(config: ScribeZipkinCollectorConfig) extends CollectorServerConfig {
val log = Logger.get(Logger.getClass)
def apply(): Server = {
- log.info("Starting collector service on addr " + config.serverAddr)
+ val serverAddress = new InetSocketAddress(config.serverAddress, config.serverPort)
+
+ log.info("Starting collector service on addr " + serverAddress)
/* Start the service */
val service = new ScribeCollectorService(config, config.writeQueue, config.categories)
@@ -39,7 +42,7 @@ class ScribeCollectorServerConfig(config: ScribeZipkinCollectorConfig) extends C
/* Start the server */
ServerBuilder()
.codec(ThriftServerFramedCodec())
- .bindTo(config.serverAddr)
+ .bindTo(serverAddress)
.name("ZipkinCollector")
.reportTo(config.statsReceiver)
.build(new gen.ZipkinCollector.FinagledService(service, new TBinaryProtocol.Factory()))
View
3  zipkin-common/src/main/scala/com/twitter/zipkin/config/ZipkinConfig.scala
@@ -23,9 +23,12 @@ import com.twitter.logging.{ConsoleHandler, LoggerFactory, Logger}
import com.twitter.util.{JavaTimer, Timer, Config}
import com.twitter.ostrich.admin._
import scala.util.matching.Regex
+import java.net.{InetAddress, InetSocketAddress}
trait ZipkinConfig[T <: Service] extends Config[RuntimeEnvironment => T] {
+ var serverAddress: InetAddress = InetAddress.getLocalHost
+
/* The port on which the server runs */
var serverPort: Int
View
6 zipkin-query-core/src/main/scala/com/twitter/zipkin/query/ZipkinQuery.scala
@@ -17,16 +17,16 @@ package com.twitter.zipkin.query
*
*/
import com.twitter.logging.Logger
-import org.apache.thrift.protocol.TBinaryProtocol
import com.twitter.zipkin.storage.{Aggregates, Index, Storage}
import com.twitter.zipkin.gen
import com.twitter.finagle.thrift.ThriftServerFramedCodec
import com.twitter.finagle.zookeeper.ZookeeperServerSetCluster
import com.twitter.finagle.builder.{ServerBuilder, Server}
-import java.net.{InetAddress, InetSocketAddress}
import com.twitter.ostrich.admin.{ServiceTracker, Service}
import com.twitter.zipkin.config.ZipkinQueryConfig
import com.twitter.common.zookeeper.ServerSet
+import java.net.InetSocketAddress
+import org.apache.thrift.protocol.TBinaryProtocol
class ZipkinQuery(
config: ZipkinQueryConfig, serverSet: ServerSet, storage: Storage, index: Index, aggregates: Aggregates
@@ -35,7 +35,7 @@ class ZipkinQuery(
val log = Logger.get(getClass.getName)
var thriftServer: Server = null
- val serverAddr = new InetSocketAddress(InetAddress.getLocalHost, config.serverPort)
+ val serverAddr = new InetSocketAddress(config.serverAddress, config.serverPort)
def start() {
log.info("Starting query thrift service on addr " + serverAddr)
Something went wrong with that request. Please try again.