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. class BasicCoreHandler extends CoreHandler with ServerConnectionHandler

    Permalink
  5. abstract class BasicSyncHandler extends WorkerItem with ConnectionHandler

    Permalink

    Convenience implementation of ConnectionHandler which provides implementations for all of the necessary functions.

    Convenience implementation of ConnectionHandler which provides implementations for all of the necessary functions. This allows for a devloper to extend this trait and only provide definitions for the functions they require.

  6. 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

  7. abstract class ClientConnection extends Connection

    Permalink
  8. trait ClientConnectionHandler extends WorkerItem with ConnectionHandler

    Permalink

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

  9. abstract class Connection extends WriteBuffer with WriteEndpoint

    Permalink
  10. 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.

  11. 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.

  12. 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

  13. 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

  14. 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

  15. 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

  16. sealed trait ConnectionState extends AnyRef

    Permalink
  17. sealed trait ConnectionStatus extends AnyRef

    Permalink

    Represent the connection state.

    Represent the connection state. NotConnected, Connected or Connecting.

  18. sealed trait ConnectionVolumeState extends AnyRef

    Permalink

    ConnectionVolumeState indicates whether or not if the Server is operating with a normal workload, which is represented by the current ratio of used / available connections being beneath the ServerSettings.highWatermarkPercentage amount.

    ConnectionVolumeState indicates whether or not if the Server is operating with a normal workload, which is represented by the current ratio of used / available connections being beneath the ServerSettings.highWatermarkPercentage amount. Once this ratio is breached, the state will be changed to the HighWater state.

    In this state, the server will more aggressively timeout and close idle connections. Effectively what this means is that when the Server polls its connections in the Highwater state, any connection that is seen as idle for longer than ServerSettings.highWaterMaxIdleTime will be reaped. It does this in an effort to free up space.

    The Server will return back to its normal state when the connection ratio recedes past the lowWater mark.

  19. class Context extends AnyRef

    Permalink

    Represents the binding of an item to a worker

  20. abstract class CoreHandler extends WorkerItem with 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

  21. class DSLDelegator extends Delegator

    Permalink
  22. 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.

  23. 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.

  24. 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.

  25. sealed trait DataReader extends AnyRef

    Permalink

    A DataReader is the result of codec's encode operation.

    A DataReader is the result of codec's encode operation. It can either return a DataBuffer, which contains the entire encoded object at once, or it can return a DataStream, which has a Sink for streaming the encoded object.

  26. case class DataStream(source: Source[DataBuffer]) extends DataReader with Product with Serializable

    Permalink
  27. abstract class Delegator extends AnyRef

    Permalink

    A Delegator is in charge of creating new ConnectionHandler’s for each new connection.

    A Delegator is in charge of creating new ConnectionHandler’s for each new connection. Delegators live inside workers and run as part of the worker’s event loop

    Delegators are the liaison between the outside world and your application's connection handling logic.

    They can hold state, and pass that state to newly created ConnectionHandlers.

    They can receive messages from the outside world, and thus be notified of changes in their environment by way of the handleMessage.

    This is triggered by utilizing the ServerRef's delegatorBroadcast function.

  28. 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

  29. sealed trait DisconnectError extends DisconnectCause

    Permalink

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

  30. 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

  31. trait Encoder extends DataReader

    Permalink
  32. 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

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

    Permalink
  34. abstract class Initializer extends AnyRef

    Permalink

    An Initializer is used to perform any setup/coordination logic for a Server! inside a Worker.

    An Initializer is used to perform any setup/coordination logic for a Server! inside a Worker. Initializers are also used to provide new connections from the server with connection handlers. An initializer is created per worker, so all actions on a single Initializer are single-threaded. See colossus.core.Server! to see how Initializer is used when starting servers.

  35. class InvalidConnectionStateException extends Exception

    Permalink
  36. trait KeyInterestManager extends ChannelActions

    Permalink
  37. trait ManualUnbindHandler extends WorkerItem with 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

  38. sealed trait MoreDataResult extends AnyRef

    Permalink
  39. trait ProxyActor extends WorkerItem

    Permalink

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

    This is a mixin for WorkerItem 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 this 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.

  40. sealed trait RetryAttempt extends AnyRef

    Permalink

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

  41. 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

  42. 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.

  43. case class ServerConfig(name: MetricAddress, delegatorFactory: Factory, settings: ServerSettings) extends Product with Serializable

    Permalink

    Configuration used to specify a Server's application-level behavior

    Configuration used to specify a Server's application-level behavior

    As opposed to ServerSettings which contains just lower-level config, ServiceConfig contains higher-level settings. Ideally, abstraction layers on top of the core layer should provide an API that allows users to create a specialized server, where the delegator factory is provided by the API and the name and settings by the user.

    name

    Name of the Server, all reported metrics are prefixed using this name

    delegatorFactory

    Factory to generate colossus.core.Delegators for each Worker

    settings

    lower-level server configuration settings

  44. abstract class ServerConnection extends Connection

    Permalink
  45. trait ServerConnectionHandler extends WorkerItem with ConnectionHandler

    Permalink

    Mixin containing events just for server connection handlers

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

    Permalink

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

  47. trait ServerDSL extends AnyRef

    Permalink
  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.Delegator, 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. case class ServerState(connectionVolumeState: ConnectionVolumeState, serverStatus: ServerStatus) extends Product with Serializable

    Permalink

    Represents the current state of a Server.

    Represents the current state of a Server.

    connectionVolumeState

    Represents if the a Server's connections are normal or in highwater

    serverStatus

    Represents the Server's current status

  51. sealed trait ServerStatus extends AnyRef

    Permalink

    Represents the startup status of the server.

    Represents the startup status of the server.

    • Initializing : The server was just started and is registering with the IOSystem
    • Binding : The server is registered and in the process of binding to its port
    • Bound : The server is actively listening on the port and accepting connections
    • ShuttingDown : The server is shutting down. It is no longer accepting new connections and waiting for existing connections to close
    • Dead : The server is fully shutdown
  52. sealed abstract class ShutdownAction extends AnyRef

    Permalink
  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 WorkerItem with 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. abstract class WorkerItem extends AnyRef

    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. class WorkerItemException extends Exception

    Permalink
  59. class WorkerItemManager extends AnyRef

    Permalink

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

  60. class WorkerItemProxy extends Actor with Stash

    Permalink
  61. 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.

  62. 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

  63. 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 ConnectionVolumeState

    Permalink
  7. object DataBlock extends Serializable

    Permalink
  8. object DataBuffer extends Serializable

    Permalink
  9. object Delegator

    Permalink
  10. object DisconnectCause

    Permalink
  11. object MoreDataResult

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

    Permalink

    A RetryPolicy that will never retry

  13. object ProxyActor

    Permalink
  14. object RetryAttempt

    Permalink
  15. object RetryPolicy

    Permalink
  16. object Server extends ServerDSL

    Permalink

    The entry point for starting a Server

  17. object ServerDSL

    Permalink
  18. object ServerSettings extends Serializable

    Permalink
  19. object ServerStatus

    Permalink
  20. object ShutdownAction

    Permalink
  21. object WaitPolicy extends Serializable

    Permalink
  22. 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.

  23. object WorkerCommand

    Permalink
  24. object WorkerItemProxy

    Permalink
  25. object WriteStatus

    Permalink

Ungrouped