Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

privacy annotations for finagle-core

  • Loading branch information...
commit 6d8fc6ab2e9392e946e2069617083e1690812ae4 1 parent 5874ce1
Nick Kallen authored
Showing with 118 additions and 216 deletions.
  1. +28 −19 finagle-core/src/main/scala/com/twitter/finagle/builder/ClientBuilder.scala
  2. +0 −2  finagle-core/src/main/scala/com/twitter/finagle/builder/Common.scala
  3. +27 −19 finagle-core/src/main/scala/com/twitter/finagle/builder/ServerBuilder.scala
  4. +1 −1  finagle-core/src/main/scala/com/twitter/finagle/channel/ChannelClosingHandler.scala
  5. +1 −1  finagle-core/src/main/scala/com/twitter/finagle/channel/ChannelRequestStatsHandler.scala
  6. +2 −2 finagle-core/src/main/scala/com/twitter/finagle/channel/ChannelService.scala
  7. +2 −2 finagle-core/src/main/scala/com/twitter/finagle/channel/ConnectionLifecycleHandler.scala
  8. +6 −7 finagle-core/src/main/scala/com/twitter/finagle/channel/ServiceToChannelHandler.scala
  9. +7 −9 finagle-core/src/main/scala/com/twitter/finagle/channel/WriteCompletionTimeoutHandler.scala
  10. +8 −14 finagle-core/src/main/scala/com/twitter/finagle/http/AggregateHttpRequest.scala
  11. +1 −4 finagle-core/src/main/scala/com/twitter/finagle/http/ClientConnectionManager.scala
  12. +1 −1  finagle-core/src/main/scala/com/twitter/finagle/http/ConnectionManager.scala
  13. +1 −3 finagle-core/src/main/scala/com/twitter/finagle/http/ServerConnectionManager.scala
  14. +10 −10 finagle-core/src/main/scala/com/twitter/finagle/service/ExpiringService.scala
  15. +0 −4 finagle-core/src/main/scala/com/twitter/finagle/service/FailureAccrualFactory.scala
  16. +1 −1  finagle-core/src/main/scala/com/twitter/finagle/service/RefcountedService.scala
  17. +0 −1  finagle-core/src/main/scala/com/twitter/finagle/service/RetryingFilter.scala
  18. +1 −1  finagle-core/src/main/scala/com/twitter/finagle/service/SingletonFactory.scala
  19. +7 −7 finagle-core/src/main/scala/com/twitter/finagle/stats/CumulativeGauge.scala
  20. +0 −33 finagle-core/src/main/scala/com/twitter/finagle/test/HttpClient.scala
  21. +0 −35 finagle-core/src/main/scala/com/twitter/finagle/test/HttpServer.scala
  22. +0 −15 finagle-core/src/main/scala/com/twitter/finagle/tracing/Trace.scala
  23. +7 −7 finagle-core/src/main/scala/com/twitter/finagle/util/ChannelFuture.scala
  24. +0 −1  finagle-core/src/main/scala/com/twitter/finagle/util/ChannelSnooper.scala
  25. +1 −1  finagle-core/src/main/scala/com/twitter/finagle/util/Conversions.scala
  26. +1 −1  finagle-core/src/main/scala/com/twitter/finagle/util/InetSocketAddressUtil.scala
  27. +0 −4 finagle-core/src/main/scala/com/twitter/finagle/util/ReferenceCountedTimer.scala
  28. +1 −1  finagle-core/src/main/scala/com/twitter/finagle/util/RichFuture.scala
  29. +1 −1  finagle-core/src/main/scala/com/twitter/finagle/util/Timer.scala
  30. +3 −9 finagle-thrift/src/main/scala/com/twitter/finagle/thrift/ThriftServerFramedCodec.scala
View
47 finagle-core/src/main/scala/com/twitter/finagle/builder/ClientBuilder.scala
@@ -34,30 +34,32 @@ object ClientBuilder {
}
/**
- * A word about the default values:
+ * A handy way to construct an RPC Client.
+ *
+ * ''Note'': A word about the default values:
*
* o connectionTimeout: optimized for within a datanceter
* o by default, no request timeout
*/
case class ClientBuilder[Req, Rep](
- _cluster: Option[Cluster],
- _protocol: Option[Protocol[Req, Rep]],
- _connectionTimeout: Duration,
- _requestTimeout: Duration,
- _statsReceiver: Option[StatsReceiver],
- _loadStatistics: (Int, Duration),
- _name: Option[String],
- _hostConnectionCoresize: Option[Int],
- _hostConnectionLimit: Option[Int],
- _hostConnectionIdleTime: Option[Duration],
- _hostConnectionMaxIdleTime: Option[Duration],
- _sendBufferSize: Option[Int],
- _recvBufferSize: Option[Int],
- _retries: Option[Int],
- _logger: Option[Logger],
- _channelFactory: Option[ReferenceCountedChannelFactory],
- _tls: Option[SSLContext],
- _startTls: Boolean)
+ private val _cluster: Option[Cluster],
+ private val _protocol: Option[Protocol[Req, Rep]],
+ private val _connectionTimeout: Duration,
+ private val _requestTimeout: Duration,
+ private val _statsReceiver: Option[StatsReceiver],
+ private val _loadStatistics: (Int, Duration),
+ private val _name: Option[String],
+ private val _hostConnectionCoresize: Option[Int],
+ private val _hostConnectionLimit: Option[Int],
+ private val _hostConnectionIdleTime: Option[Duration],
+ private val _hostConnectionMaxIdleTime: Option[Duration],
+ private val _sendBufferSize: Option[Int],
+ private val _recvBufferSize: Option[Int],
+ private val _retries: Option[Int],
+ private val _logger: Option[Logger],
+ private val _channelFactory: Option[ReferenceCountedChannelFactory],
+ private val _tls: Option[SSLContext],
+ private val _startTls: Boolean)
{
def this() = this(
None, // cluster
@@ -251,6 +253,10 @@ case class ClientBuilder[Req, Rep](
future
}
+ /**
+ * Construct a ServiceFactory. This is useful for stateful protocols (e.g.,
+ * those that support transactions or authentication).
+ */
def buildFactory(): ServiceFactory[Req, Rep] = {
if (!_cluster.isDefined)
throw new IncompleteSpecification("No hosts were specified")
@@ -308,6 +314,9 @@ case class ClientBuilder[Req, Rep](
}
}
+ /**
+ * Construct a Service.
+ */
def build(): Service[Req, Rep] = {
var service: Service[Req, Rep] = new FactoryToService[Req, Rep](buildFactory())
View
2  finagle-core/src/main/scala/com/twitter/finagle/builder/Common.scala
@@ -1,5 +1,3 @@
package com.twitter.finagle.builder
-import org.jboss.netty.channel.ChannelPipelineFactory
-
class IncompleteSpecification(message: String) extends Exception(message)
View
46 finagle-core/src/main/scala/com/twitter/finagle/builder/ServerBuilder.scala
@@ -53,26 +53,26 @@ object ServerBuilder {
Executors.newCachedThreadPool())))
}
-// TODO: common superclass between client & server builders for common
-// concerns.
-
+/**
+ * A handy Builder for constructing Servers (i.e., binding Services to a port).
+ */
case class ServerBuilder[Req, Rep](
- _codec: Option[Codec[Req, Rep]],
- _statsReceiver: Option[StatsReceiver],
- _name: Option[String],
- _sendBufferSize: Option[Int],
- _recvBufferSize: Option[Int],
- _bindTo: Option[SocketAddress],
- _logger: Option[Logger],
- _tls: Option[(String, String)],
- _startTls: Boolean,
- _channelFactory: Option[ReferenceCountedChannelFactory],
- _maxConcurrentRequests: Option[Int],
- _hostConnectionMaxIdleTime: Option[Duration],
- _requestTimeout: Option[Duration],
- _readTimeout: Option[Duration],
- _writeCompletionTimeout: Option[Duration],
- _traceReceiver: TraceReceiver)
+ private val _codec: Option[Codec[Req, Rep]],
+ private val _statsReceiver: Option[StatsReceiver],
+ private val _name: Option[String],
+ private val _sendBufferSize: Option[Int],
+ private val _recvBufferSize: Option[Int],
+ private val _bindTo: Option[SocketAddress],
+ private val _logger: Option[Logger],
+ private val _tls: Option[(String, String)],
+ private val _startTls: Boolean,
+ private val _channelFactory: Option[ReferenceCountedChannelFactory],
+ private val _maxConcurrentRequests: Option[Int],
+ private val _hostConnectionMaxIdleTime: Option[Duration],
+ private val _requestTimeout: Option[Duration],
+ private val _readTimeout: Option[Duration],
+ private val _writeCompletionTimeout: Option[Duration],
+ private val _traceReceiver: TraceReceiver)
{
import ServerBuilder._
@@ -168,8 +168,16 @@ case class ServerBuilder[Req, Rep](
private[this] def scopedStatsReceiver =
_statsReceiver map { sr => _name map (sr.scope(_)) getOrElse sr }
+ /**
+ * Construct the Server, given the provided Service.
+ */
def build(service: Service[Req, Rep]): Server = build(() => service)
+ /**
+ * Construct the Server, given the provided ServiceFactory. This
+ * is useful if the protocol is stateful (e.g., requires authentication
+ * or supports transactions).
+ */
def build(serviceFactory: () => Service[Req, Rep]): Server = {
val codec = _codec.getOrElse {
throw new IncompleteSpecification("No codec was specified")
View
2  finagle-core/src/main/scala/com/twitter/finagle/channel/ChannelClosingHandler.scala
@@ -12,7 +12,7 @@ import org.jboss.netty.channel.{
import com.twitter.finagle.util.Conversions._
import com.twitter.finagle.util.LatentChannelFuture
-class ChannelClosingHandler
+private[finagle] class ChannelClosingHandler
extends SimpleChannelUpstreamHandler
with LifeCycleAwareChannelHandler
{
View
2  finagle-core/src/main/scala/com/twitter/finagle/channel/ChannelRequestStatsHandler.scala
@@ -14,7 +14,7 @@ import org.jboss.netty.channel.{
import com.twitter.util.Future
import com.twitter.finagle.stats.StatsReceiver
-class ChannelRequestStatsHandler(statsReceiver: StatsReceiver)
+private[finagle] class ChannelRequestStatsHandler(statsReceiver: StatsReceiver)
extends SimpleChannelHandler
with ConnectionLifecycleHandler
{
View
4 finagle-core/src/main/scala/com/twitter/finagle/channel/ChannelService.scala
@@ -19,7 +19,7 @@ import com.twitter.finagle.util.{Ok, Error, Cancelled, AsyncLatch}
* channel. It is responsible for requests dispatched to a given
* (connected) channel during its lifetime.
*/
-class ChannelService[Req, Rep](channel: Channel, factory: ChannelServiceFactory[Req, Rep])
+private[finagle] class ChannelService[Req, Rep](channel: Channel, factory: ChannelServiceFactory[Req, Rep])
extends Service[Req, Rep]
{
private[this] val currentReplyFuture = new AtomicReference[Promise[Rep]]
@@ -88,7 +88,7 @@ class ChannelService[Req, Rep](channel: Channel, factory: ChannelServiceFactory[
/**
* A factory for ChannelService instances, given a bootstrap.
*/
-class ChannelServiceFactory[Req, Rep](
+private[finagle] class ChannelServiceFactory[Req, Rep](
bootstrap: ClientBootstrap,
prepareChannel: Service[Req, Rep] => Future[Service[Req, Rep]],
statsReceiver: StatsReceiver = NullStatsReceiver)
View
4 finagle-core/src/main/scala/com/twitter/finagle/channel/ConnectionLifecycleHandler.scala
@@ -2,13 +2,13 @@ package com.twitter.finagle.channel
import org.jboss.netty.channel.{
SimpleChannelHandler, LifeCycleAwareChannelHandler,
- Channel, ChannelHandlerContext, ChannelStateEvent}
+ ChannelHandlerContext, ChannelStateEvent}
import com.twitter.util.{Future, Promise, Return}
import com.twitter.finagle.util.Conversions._
-trait ConnectionLifecycleHandler
+private[finagle] trait ConnectionLifecycleHandler
extends SimpleChannelHandler
with LifeCycleAwareChannelHandler
{
View
13 finagle-core/src/main/scala/com/twitter/finagle/channel/ServiceToChannelHandler.scala
@@ -10,11 +10,10 @@ import org.jboss.netty.handler.timeout.ReadTimeoutException
import com.twitter.util.{Future, Promise, Return, Throw}
import com.twitter.finagle.util.Conversions._
-import com.twitter.finagle.util.AsyncLatch
import com.twitter.finagle.stats.{StatsReceiver, NullStatsReceiver}
import com.twitter.finagle.{CodecException, Service, WriteTimedOutException}
-class ServiceToChannelHandler[Req, Rep](
+private[finagle] class ServiceToChannelHandler[Req, Rep](
service: Service[Req, Rep],
statsReceiver: StatsReceiver,
log: Logger)
@@ -25,7 +24,7 @@ class ServiceToChannelHandler[Req, Rep](
def this(service: Service[Req, Rep]) =
this(service, NullStatsReceiver)
- private[this] sealed trait State
+ private[this] sealed abstract class State
// valid transitions are:
//
@@ -46,15 +45,15 @@ class ServiceToChannelHandler[Req, Rep](
service.release()
}
- /**
+ /**
* onShutdown: this Future is satisfied when the channel has been
* closed.
- */
+ */
val onShutdown: Future[Unit] = onShutdownPromise
- /**
+ /**
* drain(): admit no new requests.
- */
+ */
def drain() = {
var continue = false
do {
View
16 finagle-core/src/main/scala/com/twitter/finagle/channel/WriteCompletionTimeoutHandler.scala
@@ -1,23 +1,21 @@
package com.twitter.finagle.channel
-/**
- * A simple handler that times out a write if it fails to complete
- * within the given time. This can be used to ensure that clients
- * complete reception within a certain time, preventing a resource DoS
- * on a server.
- */
-
import org.jboss.netty.channel.{
SimpleChannelDownstreamHandler, Channels,
ChannelHandlerContext, MessageEvent}
import com.twitter.util.{Time, Duration, Timer}
-import com.twitter.conversions.time._
import com.twitter.finagle.util.Conversions._
import com.twitter.finagle.WriteTimedOutException
-class WriteCompletionTimeoutHandler(timer: Timer, timeout: Duration)
+/**
+ * A simple handler that times out a write if it fails to complete
+ * within the given time. This can be used to ensure that clients
+ * complete reception within a certain time, preventing a resource DoS
+ * on a server.
+ */
+private[finagle] class WriteCompletionTimeoutHandler(timer: Timer, timeout: Duration)
extends SimpleChannelDownstreamHandler
{
override def writeRequested(ctx: ChannelHandlerContext, e: MessageEvent) {
View
22 finagle-core/src/main/scala/com/twitter/finagle/http/AggregateHttpRequest.scala
@@ -6,36 +6,30 @@ package com.twitter.finagle.http
import scala.collection.JavaConversions._
-import java.nio.ByteOrder
-
import org.jboss.netty.channel.{
- MessageEvent, Channels,
- SimpleChannelUpstreamHandler,
- ChannelHandlerContext}
+ MessageEvent, Channels, ChannelHandlerContext}
import org.jboss.netty.handler.codec.http.{
HttpHeaders, HttpRequest,
- HttpResponse, HttpChunk,
- DefaultHttpResponse,
+ HttpChunk, DefaultHttpResponse,
HttpVersion, HttpResponseStatus}
import org.jboss.netty.buffer.{
- ChannelBuffer, ChannelBuffers,
- CompositeChannelBuffer}
+ ChannelBuffer, ChannelBuffers}
import com.twitter.finagle.util.Conversions._
import com.twitter.finagle.channel.LeftFoldUpstreamHandler
-object OneHundredContinueResponse
+private[finagle] object OneHundredContinueResponse
extends DefaultHttpResponse(
HttpVersion.HTTP_1_1,
HttpResponseStatus.CONTINUE)
-class HttpFailure(ctx: ChannelHandlerContext, status: HttpResponseStatus)
+private[finagle] class HttpFailure(ctx: ChannelHandlerContext, status: HttpResponseStatus)
extends LeftFoldUpstreamHandler
{
{
val response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, status)
val future = Channels.future(ctx.getChannel)
- Channels.write(ctx, future, response, ctx.getChannel.getRemoteAddress)
+ Channels.write(ctx, future, response, ctx.getChannel.getRemoteAddress)
future onSuccessOrFailure { ctx.getChannel.close() }
}
@@ -43,7 +37,7 @@ class HttpFailure(ctx: ChannelHandlerContext, status: HttpResponseStatus)
this // (swallow the message)
}
-case class AggregateHttpChunks(
+private[finagle] case class AggregateHttpChunks(
whenDone: LeftFoldUpstreamHandler,
request: HttpRequest,
bufferBudget: Int,
@@ -85,7 +79,7 @@ case class AggregateHttpChunks(
}
}
-class AggregateHttpRequest(maxBufferSize: Int)
+private[finagle] class AggregateHttpRequest(maxBufferSize: Int)
extends LeftFoldUpstreamHandler
{
override def messageReceived(ctx: ChannelHandlerContext, e: MessageEvent) =
View
5 finagle-core/src/main/scala/com/twitter/finagle/http/ClientConnectionManager.scala
@@ -1,11 +1,8 @@
package com.twitter.finagle.http
import org.jboss.netty.channel._
-import org.jboss.netty.handler.codec.http._
-import com.twitter.finagle.util.Conversions._
-
-class ClientConnectionManager extends SimpleChannelHandler {
+private[finagle] class ClientConnectionManager extends SimpleChannelHandler {
private[this] val manager = new ConnectionManager
// Note that for HTTP requests without a content length, the
View
2  finagle-core/src/main/scala/com/twitter/finagle/http/ConnectionManager.scala
@@ -8,7 +8,7 @@ package com.twitter.finagle.http
import org.jboss.netty.handler.codec.http._
-class ConnectionManager {
+private[finagle] class ConnectionManager {
private[this] var isKeepAlive = false
private[this] var isIdle = true
View
4 finagle-core/src/main/scala/com/twitter/finagle/http/ServerConnectionManager.scala
@@ -1,8 +1,6 @@
package com.twitter.finagle.http
import org.jboss.netty.channel._
-import org.jboss.netty.handler.codec.http._
-
import com.twitter.finagle.util.Conversions._
/**
@@ -20,7 +18,7 @@ import com.twitter.finagle.util.Conversions._
// the Connection header, that request becomes the last one for the
// connection."
-class ServerConnectionManager extends SimpleChannelHandler {
+private[finagle] class ServerConnectionManager extends SimpleChannelHandler {
private[this] val manager = new ConnectionManager
override def messageReceived(ctx: ChannelHandlerContext, e: MessageEvent) {
View
20 finagle-core/src/main/scala/com/twitter/finagle/service/ExpiringService.scala
@@ -1,22 +1,22 @@
package com.twitter.finagle.service
-/**
- * A service wrapper that expires the underlying service after a
- * certain amount of idle time. By default, expiring calls
- * ``.release()'' on the underlying channel, but this action is
- * customizable.
- */
-
import com.twitter.util
import com.twitter.util.{Duration, Future}
import com.twitter.finagle.util.Timer
import com.twitter.finagle.{Service, WriteException, ChannelClosedException}
+
+/**
+ * A service wrapper that expires the underlying service after a
+ * certain amount of idle time. By default, expiring calls
+ * ``.release()'' on the underlying channel, but this action is
+ * customizable.
+ */
class ExpiringService[Req, Rep](
- underlying: Service[Req, Rep],
- maxIdleTime: Duration,
- timer: util.Timer = Timer.default)
+ underlying: Service[Req, Rep],
+ maxIdleTime: Duration,
+ timer: util.Timer = Timer.default)
extends Service[Req, Rep]
{
private[this] var requestCount = 0
View
4 finagle-core/src/main/scala/com/twitter/finagle/service/FailureAccrualFactory.scala
@@ -1,10 +1,6 @@
package com.twitter.finagle.service
-import java.util.concurrent.atomic.AtomicInteger
-
import com.twitter.util.{Time, Duration, Throw, Return}
-import com.twitter.conversions.time._
-
import com.twitter.finagle.{Service, ServiceFactory}
/**
View
2  finagle-core/src/main/scala/com/twitter/finagle/service/RefcountedService.scala
@@ -3,7 +3,7 @@ package com.twitter.finagle.service
import com.twitter.finagle.Service
import com.twitter.finagle.util.AsyncLatch
-class RefcountedService[Req, Rep](underlying: Service[Req, Rep])
+private[finagle] class RefcountedService[Req, Rep](underlying: Service[Req, Rep])
extends Service[Req, Rep]
{
protected[this] val replyLatch = new AsyncLatch
View
1  finagle-core/src/main/scala/com/twitter/finagle/service/RetryingFilter.scala
@@ -1,6 +1,5 @@
package com.twitter.finagle.service
-import com.twitter.finagle.util.Conversions._
import com.twitter.util._
import com.twitter.finagle.WriteException
import com.twitter.finagle.{SimpleFilter, Service}
View
2  finagle-core/src/main/scala/com/twitter/finagle/service/SingletonFactory.scala
@@ -5,7 +5,7 @@ import com.twitter.util.Future
import com.twitter.finagle.{Service, ServiceFactory}
import com.twitter.finagle.util.AsyncLatch
-class SingletonFactory[Req, Rep](service: Service[Req, Rep])
+private[finagle] class SingletonFactory[Req, Rep](service: Service[Req, Rep])
extends ServiceFactory[Req, Rep]
{
private[this] var latch = new AsyncLatch
View
14 finagle-core/src/main/scala/com/twitter/finagle/stats/CumulativeGauge.scala
@@ -1,15 +1,15 @@
package com.twitter.finagle.stats
+import ref.WeakReference
+import collection.mutable.WeakHashMap
+
+
/**
* CumulativeGauge provides a gauge that is composed of the (addition)
* of several underlying gauges. It follows the weak reference
* semantics of Gauges as outlined in StatsReceiver.
*/
-
-import ref.WeakReference
-import collection.mutable.WeakHashMap
-
-trait CumulativeGauge {
+private[finagle] trait CumulativeGauge {
private[this] case class UnderlyingGauge(f: () => Float) extends Gauge {
def remove() { removeGauge(this) }
}
@@ -51,7 +51,7 @@ trait CumulativeGauge {
def deregister(): Unit
}
-trait StatsReceiverWithCumulativeGauges extends StatsReceiver {
+private[finagle] trait StatsReceiverWithCumulativeGauges extends StatsReceiver {
private[this] val gaugeMap = new WeakHashMap[Seq[String], CumulativeGauge]
/**
@@ -60,7 +60,7 @@ trait StatsReceiverWithCumulativeGauges extends StatsReceiver {
*/
protected[this] def registerGauge(name: Seq[String], f: => Float)
protected[this] def deregisterGauge(name: Seq[String])
-
+
def addGauge(name: String*)(f: => Float) = synchronized {
val cumulativeGauge = gaugeMap getOrElseUpdate(name, {
new CumulativeGauge {
View
33 finagle-core/src/main/scala/com/twitter/finagle/test/HttpClient.scala
@@ -1,33 +0,0 @@
-package com.twitter.finagle.test
-
-import java.util.logging.Logger
-import org.jboss.netty.handler.codec.http._
-
-import com.twitter.finagle.builder.{ClientBuilder, Http}
-import com.twitter.finagle.Service
-
-object HttpClient {
- def main(args: Array[String]) {
- val client =
- ClientBuilder()
- .name("http")
- .hosts("localhost:10000,localhost:10001,localhost:10003")
- .codec(Http)
- .retries(2)
- .logger(Logger.getLogger("http"))
- .build()
-
- for (_ <- 0 until 100)
- makeRequest(client)
- }
-
- def makeRequest(client: Service[HttpRequest, HttpResponse]) {
- client(new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/")) respond {
- case _ =>
- makeRequest(client)
- }
- }
-
- def quiesce() = ()
- def shutdown() = ()
-}
View
35 finagle-core/src/main/scala/com/twitter/finagle/test/HttpServer.scala
@@ -1,35 +0,0 @@
-package com.twitter.finagle.test
-
-import java.net.InetSocketAddress
-import java.util.Date
-
-import org.jboss.netty.buffer._
-import org.jboss.netty.handler.codec.http._
-
-import com.twitter.finagle.builder._
-import com.twitter.finagle._
-
-import com.twitter.util.Future
-
-object HttpServer {
- def main(args: Array[String]) {
- val server = new Service[HttpRequest, HttpResponse] {
- def apply(request: HttpRequest) = Future {
- val response = new DefaultHttpResponse(
- HttpVersion.HTTP_1_1, HttpResponseStatus.OK)
- response.setContent(ChannelBuffers.wrappedBuffer(("Hello from Finagle HTTP server at " + new Date().toString()).getBytes))
- response
- }
- }
-
- val logger = java.util.logging.Logger.getLogger(getClass.getName)
- ServerBuilder()
- .codec(Http)
- .bindTo(new InetSocketAddress(10000))
- .logger(logger)
- .build(server)
- }
-
- def quiesce() = ()
- def shutdown() = ()
-}
View
15 finagle-core/src/main/scala/com/twitter/finagle/tracing/Trace.scala
@@ -1,20 +1,5 @@
package com.twitter.finagle.tracing
-/**
- * Support for tracing in finagle. The main abstraction herein is the
- * "Trace", which is a local that contains various metadata required
- * for distributed tracing as well as references to the local traced
- * events. We mimic Dapper in many ways, including borrowing its
- * nomenclature.
- *
- * “Dapper, a Large-Scale Distributed Systems Tracing Infrastructure”,
- * Benjamin H. Sigelman, Luiz André Barroso, Mike Burrows, Pat
- * Stephenson, Manoj Plakal, Donald Beaver, Saul Jaspan, Chandan
- * Shanbhag, 2010.
- *
- * http://research.google.com/pubs/archive/36356.pdf
- */
-
import scala.util.Random
import com.twitter.util.{Local, Time, TimeFormat, RichU64Long}
View
14 finagle-core/src/main/scala/com/twitter/finagle/util/ChannelFuture.scala
@@ -7,22 +7,22 @@ import org.jboss.netty.channel._
/**
* A ChannelFuture that doesn't need to have a channel on creation.
*/
-class LatentChannelFuture extends DefaultChannelFuture(null, false) {
+private[finagle] class LatentChannelFuture extends DefaultChannelFuture(null, false) {
@volatile private var channel: Channel = _
def setChannel(c: Channel) { channel = c }
override def getChannel() = channel
}
-sealed abstract class State
-case object Cancelled extends State
-case class Ok(channel: Channel) extends State
-case class Error(cause: Throwable) extends State
+private[finagle] sealed abstract class State
+private[finagle] case object Cancelled extends State
+private[finagle] case class Ok(channel: Channel) extends State
+private[finagle] case class Error(cause: Throwable) extends State
-class CancelledException extends Exception
+private[finagle] class CancelledException extends Exception
// TODO: decide what to do about cancellation here.
-class RichChannelFuture(val self: ChannelFuture) {
+private[finagle] class RichChannelFuture(val self: ChannelFuture) {
def apply(f: State => Unit) {
self.addListener(new ChannelFutureListener {
def operationComplete(future: ChannelFuture) {
View
1  finagle-core/src/main/scala/com/twitter/finagle/util/ChannelSnooper.scala
@@ -2,7 +2,6 @@ package com.twitter.finagle.util
import java.io.PrintStream
import java.nio.charset.Charset
-import java.util.logging.Logger
import org.jboss.netty.channel._
import org.jboss.netty.buffer.ChannelBuffer
View
2  finagle-core/src/main/scala/com/twitter/finagle/util/Conversions.scala
@@ -4,7 +4,7 @@ import org.jboss.netty.channel.ChannelFuture
import com.twitter.util.Future
-object Conversions {
+private[finagle] object Conversions {
implicit def channelFutureToRichChannelFuture(f: ChannelFuture) = new RichChannelFuture(f)
implicit def futureToRichFuture[A](f: Future[A]) = new RichFuture(f)
}
View
2  finagle-core/src/main/scala/com/twitter/finagle/util/InetSocketAddressUtil.scala
@@ -2,7 +2,7 @@ package com.twitter.finagle.util
import java.net.InetSocketAddress
-object InetSocketAddressUtil {
+private[finagle] object InetSocketAddressUtil {
/**
* Parses a comma or space-delimited string of hostname and port pairs. For example,
*
View
4 finagle-core/src/main/scala/com/twitter/finagle/util/ReferenceCountedTimer.scala
@@ -1,4 +0,0 @@
-package com.twitter.finagle.util
-
-import org.jboss.netty.util.{Timer => NettyTimer}
-
View
2  finagle-core/src/main/scala/com/twitter/finagle/util/RichFuture.scala
@@ -5,7 +5,7 @@ import com.twitter.util.{Duration, Future, Promise, Try}
import Conversions._
-class RichFuture[A](self: Future[A]) {
+private[finagle] class RichFuture[A](self: Future[A]) {
def timeout(timer: util.Timer, howlong: Duration)(orElse: => Try[A]) = {
val promise = new Promise[A]
val timeout = timer.schedule(howlong.fromNow) { promise.updateIfEmpty(orElse) }
View
2  finagle-core/src/main/scala/com/twitter/finagle/util/Timer.scala
@@ -6,7 +6,7 @@ import java.util.concurrent.TimeUnit
import com.twitter.util.{Time, Duration, TimerTask, ReferenceCountedTimer}
import org.jboss.netty.util.{HashedWheelTimer, Timeout}
-object Timer {
+private[finagle] object Timer {
// This timer should only be used inside the context of finagle,
// since it requires explicit reference count management. (Via the
// builder routines.)
View
12 finagle-thrift/src/main/scala/com/twitter/finagle/thrift/ThriftServerFramedCodec.scala
@@ -1,20 +1,14 @@
package com.twitter.finagle.thrift
import org.apache.thrift.protocol.{TBinaryProtocol, TMessage, TMessageType}
-import org.apache.thrift.transport.{TMemoryBuffer, TMemoryInputTransport}
-
import org.jboss.netty.channel.{
- SimpleChannelHandler, Channel, ChannelEvent, ChannelHandlerContext,
+ ChannelHandlerContext,
SimpleChannelDownstreamHandler, MessageEvent, Channels,
ChannelPipelineFactory}
-import org.jboss.netty.buffer.{ChannelBuffer, ChannelBuffers}
-import org.jboss.netty.handler.codec.oneone.OneToOneDecoder
-import org.jboss.netty.channel.SimpleChannelUpstreamHandler
-
+import org.jboss.netty.buffer.ChannelBuffers
import com.twitter.util.Future
import com.twitter.finagle._
-import com.twitter.finagle.util.TracingHeader
-import com.twitter.finagle.tracing.{BufferingTranscript, Trace}
+import com.twitter.finagle.tracing.Trace
class ThriftServerChannelBufferEncoder extends SimpleChannelDownstreamHandler {
override def writeRequested(ctx: ChannelHandlerContext, e: MessageEvent) = {
Please sign in to comment.
Something went wrong with that request. Please try again.