Skip to content
This repository has been archived by the owner on Jun 19, 2019. It is now read-only.

Commit

Permalink
finatra/twitter-server/common/ostrich: Update to register TwitterServ…
Browse files Browse the repository at this point in the history
…er, AbstractApplication and Ostrich as libraries in /admin/registry.json

Problem

AbstractApplication, Ostrich and TwitterServer do not register themselves as
libraries in the /admin/registry.json.

Solution

Update com.twitter.server.AdminHttpServer in twitter-server,
com.twitter.ostrich.admin.AdminHttpService in ostrich, and the
com.twitter.common.application.modules.RegistryModule for AbstractApplication
to register themselves as libraries in the /admin/registry.json Registry.
Also update Finatra as necessary since its superclass from TwitterServer now
performs the library registration.

Result

TwitterServer, AbstractApplication (using the RegistryModule) and Ostrich
applications will be registered in the library section of the
/admin/registry.json.

RB_ID=825129
  • Loading branch information
cacoco authored and jenkins committed Apr 25, 2016
1 parent 4a842fe commit 0a3c719
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
2 changes: 2 additions & 0 deletions CHANGES
@@ -1,3 +1,5 @@
- Register Ostrich as a Library in the /admin/registry.json. ``RB_ID=825129``

9.17.0
-----
release: 10 March 2016
Expand Down
Expand Up @@ -23,7 +23,7 @@ import com.twitter.json.Json
import com.twitter.ostrich.stats.{StatsCollection, Stats}
import com.twitter.logging.Logger
import com.twitter.util.{Duration, NonFatal, Return, Throw}
import com.twitter.util.registry.{GlobalRegistry, Formatter, Registry}
import com.twitter.util.registry.{Library, GlobalRegistry, Formatter, Registry}
import java.io.{InputStream, OutputStream}
import java.net.{InetSocketAddress, Socket, URI}
import java.util.concurrent.Executors
Expand Down Expand Up @@ -507,6 +507,7 @@ class AdminHttpService private[ostrich](
ServiceTracker.register(this)
httpServer.start()
log.info("Admin HTTP interface started on port %d.", address.getPort)
Library.register("ostrich", Map.empty)
}

override def shutdown(): Unit = {
Expand Down
25 changes: 13 additions & 12 deletions src/test/scala/com/twitter/ostrich/admin/AdminHttpServiceTest.scala
Expand Up @@ -56,17 +56,18 @@ class AdminHttpServiceTest extends FunSuite with BeforeAndAfter
val registry = new SimpleRegistry

before {
service =
new AdminHttpService(
0,
20,
Stats,
new ServerInfoHandler(getClass),
30.seconds,
{ code => /* system-exit is a noop here */ },
registry
)
service.start()
GlobalRegistry.withRegistry(registry) {
service =
new AdminHttpService(
0,
20,
Stats,
new ServerInfoHandler(getClass),
30.seconds, { code => /* system-exit is a noop here */},
registry
)
service.start()
}
}

after {
Expand Down Expand Up @@ -443,7 +444,7 @@ class AdminHttpServiceTest extends FunSuite with BeforeAndAfter
registry.put(Seq("foo", "qux"), "quux")

val actual = get("/admin/registry")
val expected = """{"registry":{"foo":{"bar":"baz","qux":"quux"}}}"""
val expected = """{"registry":{"foo":{"bar":"baz","qux":"quux"},"library":{"ostrich":"__registered"}}}"""
assert(actual == expected)
}
}

0 comments on commit 0a3c719

Please sign in to comment.