Package

colossus

core

Permalink

package core

Visibility
  1. Public
  2. All

Type Members

  1. sealed trait AliveState extends ConnectionState

    Permalink
  2. trait BackoffMultiplier extends AnyRef

    Permalink

    A BackoffMultiplier is used by a BackoffPolicy determines how the amount of time changes in between retry attempts.

    A BackoffMultiplier is used by a BackoffPolicy determines how the amount of time changes in between retry attempts. For example, with a BackoffMultiplier.Linear multiplier (with a base backoff of 50 milliseconds), the amount of time in between retries will increase by 50 milliseconds each time.

  3. case class BackoffPolicy(baseBackoff: FiniteDuration, multiplier: BackoffMultiplier, maxTime: Option[FiniteDuration] = None, maxTries: Option[Int] = None, immediateFirstAttempt: Boolean = true) extends RetryPolicy with Product with Serializable

    Permalink

    A RetryPolicy used to gradually back-off from retries of an operation.

    A RetryPolicy used to gradually back-off from retries of an operation. This class is flexible enough to handle most common retry schemes, such as constantly retrying for a given amount of time or exponentially backing-off.

    Examples

    Retry every 30 seconds for up to 5 minutes

    BackoffPolicy(30.seconds, BackoffMultiplier.Constant, maxTime = Some(5.minutes), immediateFirstAttempt = false)

    Immediately retry once, then backoff exponentially starting at 100 milliseconds, doubling with every attempt until the interval in between attempts is 5 seconds

    BackoffPolicy(100.milliseconds, BackoffMultiplier.Exponential(5.seconds))
    baseBackoff

    The base value to use for backing off. This may be used by the multiplier

    multiplier

    The multiplier that will be applied to the baseBackoff

    maxTime

    The maximim amount of time to allow for retrying

    maxTries

    The maximum number of attempts to make

    immediateFirstAttempt

    Whether the first retry attempt should be immediate or use the given backoff and multiplier

  4. trait ChannelActions extends AnyRef

    Permalink

    This trait abstracts actions performed on a raw socket channel.

    This trait abstracts actions performed on a raw socket channel.

    This is essentially the only trait that should differ between live connections and fake connections in testing

  5. abstract class ClientConnection extends Connection

    Permalink
  6. trait ClientConnectionHandler extends ConnectionHandler

    Permalink

    ClientConnectionHandler is a trait meant to be used with outgoing connections.

  7. abstract class Connection extends WriteBuffer with WriteEndpoint

    Permalink
  8. trait ConnectionHandle extends ConnectionInfo

    Permalink

    This trait contains all connection-level functions that should be accessable to a top-level user.

    This trait contains all connection-level functions that should be accessable to a top-level user. It is primarily used by the Server DSL and subsequently the Service DSL, where we want to give users control over disconnecting/become, but not over lower-level tasks like requesting writes.

  9. trait ConnectionHandler extends WorkerItem

    Permalink

    This is the base trait for all connection handlers.

    This is the base trait for all connection handlers. When attached to a connection by a Delegator, these methods will be called in the worker's thread.

    A ConnectionHandler is what directly interfaces with a Connection and is the reactor for all of the Connection events that a Worker captures in its SelectLoop.

  10. trait ConnectionInfo extends AnyRef

    Permalink

    A trait encapsulating live information about a connection.

    A trait encapsulating live information about a connection. This should only contain read-only fields

  11. class ConnectionLimiter extends AnyRef

    Permalink

    Used to control slow start of servers, this will exponentially increase its limit over a period of time until max is reached.

    Used to control slow start of servers, this will exponentially increase its limit over a period of time until max is reached. Servers use this to gradually increase the number of allowable open connections during the first few seconds of startup, which can help alleviate thundering herd problems due to JVM warmup.

    Initializing a limiter with initial equal to max will essentially disable any slow ramp

  12. case class ConnectionLimiterConfig(enabled: Boolean, initial: Int, duration: FiniteDuration) extends Product with Serializable

    Permalink

    Configuration object for connection limiting, used as part of server settings.

    Configuration object for connection limiting, used as part of server settings. This does not contain the max value because that is already part of ServerSettings

  13. trait ConnectionManager extends AnyRef

    Permalink

    This is implemented by colossus.core.PipelineHandler and contains all the methods made available to all layers extending the core layer

  14. case class ConnectionSnapshot(domain: String, host: InetAddress, id: Long, timeOpen: Long = 0, readIdle: Long = 0, writeIdle: Long = 0, bytesSent: Long = 0, bytesReceived: Long = 0) extends Product with Serializable

    Permalink

    This class is used to report some basic stats about a Connection.

    This class is used to report some basic stats about a Connection. This is used in conjunction with the Metrics library and ConnectionPageRenderer.

    domain

    The domain of this Connection

    host

    The host of this Connection

    id

    The id of this Connection

    timeOpen

    The amount of time this Connection has been open

    readIdle

    milliseconds since the last read activity on the connection

    writeIdle

    milliseconds since the last write activity on the connection

    bytesSent

    The amount of bytes that this Connection has sent

    bytesReceived

    The amount of bytes that this Connection has received

  15. sealed trait ConnectionState extends AnyRef

    Permalink
  16. sealed trait ConnectionStatus extends AnyRef

    Permalink

    Represent the connection state.

    Represent the connection state. NotConnected, Connected or Connecting.

  17. class Context extends AnyRef

    Permalink

    Represents the binding of an item to a worker

  18. trait CoreDownstream extends HasUpstream[CoreUpstream] with DownstreamEvents

    Permalink

    These are the methods that the downstream neighbor of the CoreHandler must implement

  19. abstract class CoreHandler extends ConnectionHandler

    Permalink

    This is the connection handler on which the controller and service layers are built.

    This is the connection handler on which the controller and service layers are built. It contains some common functionality that is ultimately exposed to the users, such as methods to call for disconnecting and safely getting a reference to the ConnectionHandle. While there is no requirement to build handlers on top of this one, it is recommended instead of directly implementing the ConnectionHandler trait

  20. trait CoreUpstream extends ConnectionManager with UpstreamEvents

    Permalink

    These are the methods the Core layer directly exposes to its downstream neighbor which are generally not meant to be exposed further downstream

  21. case class DataBlock(data: Array[Byte]) extends Product with Serializable

    Permalink

    A low-overhead abstraction over a byte array.

    A low-overhead abstraction over a byte array. This offers much of the same functionally offered by Akka's ByteString, but without any additional overhead. While this makes DataBlock a bit less powerful and flexible, it also makes it considerably faster.

    TODO: This is possibly a contender for using in all places where Array[Byte] is used, but thorough benchmarking is needed. It is also possible that the performance of ByteString has improved in later versions of Akka, so that should also be tested before expanding on this any more.

  22. case class DataBuffer(data: ByteBuffer) extends Encoder with Product with Serializable

    Permalink

    A thin wrapper around a NIO ByteBuffer with data to read

    A thin wrapper around a NIO ByteBuffer with data to read

    DataBuffers are the primary way that data is read from and written to a connection. DataBuffers are mutable and not thread safe. They can only be read from once and cannot be reset.

  23. trait DataOutBuffer extends AnyRef

    Permalink

    The DataOutBuffer is a ConnectionHandler's interface for writing data out to the connection.

    The DataOutBuffer is a ConnectionHandler's interface for writing data out to the connection. DataOutBuffers support a "soft" overflow, which means it will dynamically allocate more space as needed, but is based off a fixed-length base size. The idea is that writing should stop as soon as the overflow is hit, but it is not a requirement.

  24. sealed trait DisconnectCause extends RootDisconnectCause

    Permalink

    Messages representing why a disconnect occurred.

    Messages representing why a disconnect occurred. These can be either normal disconnects or error cases

  25. sealed trait DisconnectError extends DisconnectCause

    Permalink

    Subset of DisconnectCause which represent errors which resulted in a disconnect.

  26. trait DownstreamEventHandler[T <: DownstreamEvents] extends DownstreamEvents with HasDownstream[T]

    Permalink

    This trait can be used for layers that are in the head or middle of a pipeline.

    This trait can be used for layers that are in the head or middle of a pipeline. It will automatically propagate events to the downstream neighbor. Notice that for each event, the onEvent method is called before propagating the event downstream.

  27. trait DownstreamEvents extends WorkerItemEvents

    Permalink

    These are events that propagate to each layer starting from the head and moving downstream

  28. class DynamicOutBuffer extends DataOutBuffer

    Permalink

    A ByteBuffer-backed growable buffer.

    A ByteBuffer-backed growable buffer. A fixed-size direct buffer is used for most of the time, but overflows are written to a eponentially growing non-direct buffer.

    Be aware, the DataBuffer returned from data merely wraps the underlying buffer to avoid copying

  29. trait Encoder extends AnyRef

    Permalink
  30. trait HandlerTail extends UpstreamEvents

    Permalink

    This trait must be implemented by the last stage of a pipeline

  31. trait HasDownstream[T] extends AnyRef

    Permalink

    This must be implemented by any non-tail member of a pipeline

  32. trait HasUpstream[T] extends AnyRef

    Permalink

    This trait must be implemented by any non-head member of a pipeline.

  33. trait IdleCheck extends WorkerItem

    Permalink

    A mixin trait for worker items that defines a method which is periodically called by the worker.

    A mixin trait for worker items that defines a method which is periodically called by the worker. This can be used to do periodic checks

  34. case class IncidentReport(totalTime: FiniteDuration, totalAttempts: Int) extends Product with Serializable

    Permalink
  35. case class InitContext(server: ServerRef, worker: WorkerRef) extends Product with Serializable

    Permalink

    An instance of this is handed to every new initializer for a server

  36. class InvalidConnectionStateException extends Exception

    Permalink
  37. trait KeyInterestManager extends ChannelActions

    Permalink
  38. trait ManualUnbindHandler extends ClientConnectionHandler

    Permalink

    A Simple mixin trait that will cause the worker to not automatically unbind this handler if the connection it's attached to is closed.

    A Simple mixin trait that will cause the worker to not automatically unbind this handler if the connection it's attached to is closed. This mixin is required if a connection handler wants to handle retry logic, since this trait will allow it to continue to receive messages during the reconnection process and bind to another connection

  39. sealed trait MoreDataResult extends AnyRef

    Permalink
  40. class PipelineHandler extends CoreHandler with CoreUpstream with ServerConnectionHandler with ClientConnectionHandler with IdleCheck

    Permalink

    The PipelineHandler forms the foundation of all pipeline-based connection handlers.

    The PipelineHandler forms the foundation of all pipeline-based connection handlers. It takes the head and tail of a pipeline and properly directs events to it.

  41. trait ProxyActor extends WorkerItemEvents

    Permalink

    This is a mixin for WorkerItemEvents that gives it actor-like capabilities.

    This is a mixin for WorkerItemEvents that gives it actor-like capabilities. A "proxy" Akka actor is spun up, such that any message sent to the proxy will be relayed to the WorkerItem.

    The proxy actors lifecycle will be linked to the lifecycle of the bound WorkerItem. workeritem, so if the actor is kill, the shutdownRequest method will be invoked, and likewise if this item is unbound the proxy actor will be killed.

    This is intended to be mixed in both to worker items as well as Pipeline Componenents.

  42. sealed trait RetryAttempt extends AnyRef

    Permalink

    A RetryAttempt represents the next action that should be taken when retring an operation.

  43. trait RetryIncident extends AnyRef

    Permalink

    A RetryIncident is a state machine for managing the retry logic of a single incident of a failed operation.

    A RetryIncident is a state machine for managing the retry logic of a single incident of a failed operation. It is generally unaware of what that operation is and takes no action itself, but instead is used by the performer of the operation as a control flow mechanism. For example, when a colossus.service.ServiceClient fails to connect to its target host, it will create a new RetryIncident from it's given RetryPolicy.

    On each successive failure of the operation, a call to nextAttempt() should be made that will return a RetryAttempt indicating what action should be taken. A single RetryIncident cannot be reused should be discarded when either the operation completes or gives up

  44. trait RetryPolicy extends AnyRef

    Permalink

    A RetryPolicy provides a scheme for managing controlled retries of some operation.

    A RetryPolicy provides a scheme for managing controlled retries of some operation. For example, colossus.service.ServiceClient uses a RetryPolicy to determine how it should try to reconnect if it's first attempt to connect fails.

    RetryPolicy acts as a factory for RetryIncident, which is a per-incident manager of retries. So everytime a user encounters a sitiation where an operation needs to be retried, it should use the RetryPolicy create a new incident, and use the incident until either the operation succeeds or the incident indicates to stop retrying.

  45. abstract class ServerConnection extends Connection

    Permalink
  46. trait ServerConnectionHandler extends ConnectionHandler

    Permalink

    Mixin containing events just for server connection handlers

  47. case class ServerContext(server: ServerRef, context: Context) extends Product with Serializable

    Permalink

    An instance of this is handed to every new server connection handler

  48. case class ServerRef extends Product with Serializable

    Permalink

    A ServerRef is a handle to a created server.

    A ServerRef is a handle to a created server. It can be used to get basic information about the state of the server as well as send operational commands to it.

  49. case class ServerSettings(port: Int, slowStart: ConnectionLimiterConfig = ConnectionLimiterConfig.NoLimiting, maxConnections: Int = 1000, maxIdleTime: Duration = Duration.Inf, lowWatermarkPercentage: Double = 0.75, highWatermarkPercentage: Double = 0.85, highWaterMaxIdleTime: FiniteDuration = 100.milliseconds, tcpBacklogSize: Option[Int] = None, bindingRetry: RetryPolicy = ..., delegatorCreationPolicy: WaitPolicy = ..., shutdownTimeout: FiniteDuration = 100.milliseconds) extends Product with Serializable

    Permalink

    Contains values for configuring how a Server operates

    Contains values for configuring how a Server operates

    These are all lower-level configuration settings that are for the most part not concerned with a server's application behavior

    The low/high watermark percentages are used to help mitigate connection overload. When a server hits the high watermark percentage of live connections, it will change the idle timeout from maxIdleTime to highWaterMaxIdleTime in an attempt to more aggressively close idle connections. This will continue until the percentage drops below lowWatermarkPercentage. This can be totally disabled by just setting both watermarks to 1.

    port

    Port on which this Server will accept connections

    maxConnections

    Max number of simultaneous live connections

    maxIdleTime

    Maximum idle time for connections when in non high water conditions

    lowWatermarkPercentage

    Percentage of live/max connections which represent a normal state

    highWatermarkPercentage

    Percentage of live/max connections which represent a high water state.

    highWaterMaxIdleTime

    Max idle time for connections when in high water conditions.

    tcpBacklogSize

    Set the max number of simultaneous connections awaiting accepting, or None for NIO default

    bindingRetry

    A colossus.core.RetryPolicy describing how to retry binding to the port if the first attempt fails. By default it will keep retrying forever.

    delegatorCreationPolicy

    A colossus.core.WaitPolicy describing how to handle delegator startup. Since a Server waits for a signal from the colossus.IOSystem that every worker has properly initialized a colossus.core.Initializer, this determines how long to wait before the initialization is considered a failure and whether to retry the initialization.

    shutdownTimeout

    Once a Server begins to shutdown, it will signal a request to every open connection. This determines how long it will wait for every connection to self-terminate before it forcibly closes them and completes the shutdown.

  50. sealed abstract class ShutdownAction extends AnyRef

    Permalink
  51. trait UpstreamEventHandler[T <: UpstreamEvents] extends UpstreamEvents with HasUpstream[T]

    Permalink

    An UpstreamEventHandler is generally implemented by members of a pipline that are neither the head nor tail.

    An UpstreamEventHandler is generally implemented by members of a pipline that are neither the head nor tail. This trait will ensure that events are propagated to upstream neighbors

  52. trait UpstreamEvents extends AnyRef

    Permalink

    These are events that propagate starting from the tail and move upstream

  53. case class WaitPolicy(waitTime: FiniteDuration, retryPolicy: RetryPolicy) extends Product with Serializable

    Permalink

    A WaitPolicy describes configuration for any process that needs to wait for some operation to complete, and if/how to retry the operation if it fails to complete within the waiting time.

    A WaitPolicy describes configuration for any process that needs to wait for some operation to complete, and if/how to retry the operation if it fails to complete within the waiting time.

    For example, a WaitPolicy is used by colossus.core.Server to determine how long to wait for it's delegators to start up and how to respond if they fail

    waitTime

    How long to wait before the operation should be considered timed out

    retryPolicy

    The policy that dictates how to retry the operation if it either fails or times out

  54. trait WatchedHandler extends ConnectionHandler

    Permalink

    A Watched handler allows an actor to be tied to a connection.

    A Watched handler allows an actor to be tied to a connection. The worker will watch the actor, and on termination will shutdown the connection associated with the actor

  55. sealed trait WorkerCommand extends AnyRef

    Permalink

    These are a different class of Commands to which a worker will respond.

    These are a different class of Commands to which a worker will respond. These are more relevant to the lifecycle of WorkerItems

  56. case class WorkerConfig(io: IOSystem, workerId: Int) extends Product with Serializable

    Permalink

    Contains the configuration for each Worker.

    Contains the configuration for each Worker. Created when Workers are spawned by the WorkerManager. Notice - currently the worker config cannot contain the MetricSystem, because workers are created as a part of creating the MetricSystem

    io

    The IOSystem to which this Worker belongs

    workerId

    This Worker's unique id amongst its peers.

  57. trait WorkerItem extends WorkerItemEvents

    Permalink

    A WorkerItem is anything that can be bound to worker to receive both events and external messages.

    A WorkerItem is anything that can be bound to worker to receive both events and external messages. WorkerItems are expected to be single-threaded and non-blocking. Once a WorkerItem is bound to a worker, all of its methods are executed in the event-loop thread of the bound worker.

    Note - WorkerItems currently do not automatically bind to a worker on construction. This is because a worker does the binding itself for server connections immediately on construction. Clients need to bind themselves, except when created through the BindAndCreateWorkerItem message. Maybe this should change.

    Note - WorkerItem cannot simply just always generate its own context, since in some cases we want one WorkerItem to replace another, in which case the context must be transferred

  58. trait WorkerItemEvents extends AnyRef

    Permalink

    This trait contains event handler methods for when a worker item is bound and unbound to/from a worker.

    This trait contains event handler methods for when a worker item is bound and unbound to/from a worker. This is used both by WorkerItem itself as well as components of connection handler pipelines like DownstreamEvents.

  59. class WorkerItemException extends Exception

    Permalink
  60. class WorkerItemManager extends AnyRef

    Permalink

    This keeps track of all the bound worker items, and properly handles added/removing them

  61. class WorkerItemProxy extends Actor with Stash

    Permalink
  62. case class WorkerRef extends Product with Serializable

    Permalink

    This is a Worker's public interface.

    This is a Worker's public interface. This is what can be used to communicate with a Worker, as it wraps the Worker's ActorRef, as well as providing some additional information which can be made public.

  63. trait WriteEndpoint extends ConnectionHandle

    Permalink

    This is passed to handlers to give them a way to synchronously write to the connection.

    This is passed to handlers to give them a way to synchronously write to the connection. Services wrap this

  64. sealed trait WriteStatus extends AnyRef

    Permalink

Value Members

  1. object BackoffMultiplier

    Permalink
  2. object ConnectionLimiter

    Permalink
  3. object ConnectionLimiterConfig extends Serializable

    Permalink
  4. object ConnectionState

    Permalink
  5. object ConnectionStatus

    Permalink
  6. object DataBlock extends Serializable

    Permalink
  7. object DataBuffer extends Serializable

    Permalink
  8. object DisconnectCause

    Permalink
  9. object MoreDataResult

    Permalink
  10. object NoRetry extends RetryPolicy with RetryIncident with Product with Serializable

    Permalink

    A RetryPolicy that will never retry

  11. object PipelineHandler

    Permalink
  12. object ProxyActor

    Permalink
  13. object RetryAttempt

    Permalink
  14. object RetryPolicy

    Permalink
  15. object ServerSettings extends Serializable

    Permalink
  16. object ShutdownAction

    Permalink
  17. object WaitPolicy extends Serializable

    Permalink
  18. object Worker

    Permalink

    Like the server actor, it is critical that instances of this actor get their own thread, since they block when waiting for events.

    Like the server actor, it is critical that instances of this actor get their own thread, since they block when waiting for events.

    Workers are the "engine" of Colossus. They are the components which receive and operate on Connections, respond to java NIO select loop events and execute the corresponding reactors in the Delegator and ConnectionHandlers.

    These are the messages to which a Worker will respond.

  19. object WorkerCommand

    Permalink
  20. object WorkerItemProxy

    Permalink
  21. object WriteStatus

    Permalink
  22. package server

    Permalink

Ungrouped