public final class EConfigure extends Object
EConfigure.Service and
EConfigure.RemoteConnection instances and passing
these objects to
EServer.configure(EConfigure) and
ERemoteApp.configure(EConfigure), respectively.
EConfigure.Dispatcher has a private constructor
and cannot be instantiated by the application.
Also provides methods for storing this configuration to
properties or
preferences.
Please note that eBus configuration requires no service or connections to be specified. If this is the case, remote connections are neither accepted nor established.
eBus release 4.7.0 supports secure TCP connections based on
SSL/TLS using SSLContext. This connection type is
not supported using properties/preferences
configuration as this would require placing sensitive
information in an insecure manner. Therefore, creating
secure TCP services and connections can only be done
using the API.
Dispatcher threads are instantiated on JVM start-up, the
dispatcher configuration is taken from the properties file
specified by the command line parameter
-Dnet.sf.eBus.config.file=<property file path>
or
-Dnet.sf.eBus.config.jsonFile=<typesafe json file path>.
eBus loads the EClientDispatcher configuration from
this properties file and creates the dispatcher threads
according to this configuration. If no configuration file is
specified or is incorrectly configured, eBus defaults to a
single, blocking run queue. The run queue thread count equals
Runtime.availableProcessors().
The eBus configuration uses the following keys for both properties and preferences. JSON configuration keys are similar and shown here. As of eBus v. 5.1.0, eBus connections may be paused which is described in detail here.
eBus.servers: a comma-separated list of
eBus local server names. This key is optional or may
be an empty string. The names must be unique (no
duplicates). The server name is used to retrieve the
following keys:
eBus.service.name.port:
the service is opened on this TCP port.
This property is required.
eBus.service.name.addressFilter:
the AddressFilter limiting which clients may
connect to this eBus application. This is a positive
filter meaning that is specifies which clients may
connect to this application and not a negative filter
which allows all connections except those specified.
This property is a string which must satisfy
AddressFilter.parse(String).
This property is optional and may be set to an empty string.
eBus.service.name.inputBufferSize:
the socket input buffer size in bytes per connection.
Must be an integer value > zero.
The default setting is
ERemoteApp.DEFAULT_BUFFER_SIZE.
eBus.service.name.outputBufferSize:
the socket output buffer size in bytes per connection.
Must be an integer value > zero.
The default setting is
ERemoteApp.DEFAULT_BUFFER_SIZE.
eBus.service.name.byteOrder:
the socket input and output
ByteBuffers are set to this byte
order.
The default setting is
ByteOrder.LITTLE_ENDIAN.
eBus.service.name.messageQueueSize:
when the output buffer is full, outgoing messages are
queued until the output buffer is no longer full.
This value specifies the maximum number of messages
which may enqueued at any one time. Must be an integer
≥ zero where zero means the message queue size is
unlimited.
The default setting is an unlimited message queue.
eBus.server.name.serviceSelector:
the named selector thread used to monitor the server
socket channel.
The default setting is
net.sf.eBus.net.AsyncChannel.defaultSelector
eBus.server.name.connectionSelector:
the named selector thread used to monitor the accepted
client socket channels.
The default setting is
net.sf.eBus.net.AsyncChannel.defaultSelector
eBus.service.name.heartbeatDelay:
the accepted connection sends heartbeat messages this
many milliseconds after the last received message.
Every time a message is received, this timer is reset.
Must be an integer ≥ zero where zero means that
no heartbeat message is sent.
The default is not to send heartbeat message.
eBus.service.name.heartbeatReplyDelay:
wait this many milliseconds for a reply to a heartbeat
message. If a reply is not received in this
time limit, close the connection. Must be an integer
value ≥ zero where zero means no time limit.
The default is no time limit because heart beating is off by default.
eBus.service.name.canPause:
this boolean value specifies whether accepted
connections may be paused by the remote connection
initiator. If true, then the following two
properties are used to limit how long the connection
may be paused and the number of messages that may
be queued up waiting for transmission when the
connection is resumed.
The default is false, accepted connections
may not be paused.
eBus.service.name.pause.pauseTime:
the maximum allowed pause time for accepted
connections. The value is in milliseconds.
This value is required if canPause is
true.
eBus.service.name.pause.maxBacklogSize:
when a connection is paused, at most this many
messages are queued up for transmit when the
connection is resumed. When the limit is reached,
messages are discarded based on the client-specified
EConfigure.DiscardPolicy.
The default value is zero which means there is no limit to the message backlog queue.
eBus.connections: a comma-separated list of
eBus remote connection names. This key is optional or may
be an empty string. The names must be unique (no
duplicates). The connection name is used to retrieve the
following keys:
eBus.connection.name.host:
the connection is made to this host. May be either a
host name or dotted notation IP address.
This setting is required.
eBus.connection.name.port:
the connection is made to this TCP port.
This setting is required.
eBus.connection.name.bindPort:
the connection's local end is bound to this TCP port.
The default setting is to bind the local port is OS-dependent. The OS will bind the local port to what is considered the next available TCP port.
eBus.connection.name.inputBufferSize:
the socket input buffer size in bytes. Must be an
integer value > zero.
The default setting is
ERemoteApp.DEFAULT_BUFFER_SIZE.
eBus.connection.name.outputBufferSize:
the socket output buffer size in bytes. Must be an
integer value > zero.
The default setting is
ERemoteApp.DEFAULT_BUFFER_SIZE.
eBus.connection.name.byteOrder:
the socket input and output
ByteBuffers are set to this byte
order.
The default setting is
ByteOrder.LITTLE_ENDIAN.
eBus.connection.name.messageQueueSize:
when the output buffer is full, outgoing messages are
queued until the output buffer is no longer full.
This value specifies the maximum number of messages
which may enqueued at any one time. Must be an integer
≥ zero where zero means the queue size is
unlimited.
The default setting is an unlimited message queue size.
eBus.connection.name.selector:
the named selector thread used to monitor this socket
channel.
The default setting is
net.sf.eBus.net.AsyncChannel.defaultSelector
eBus.connection.name.reconnect:
boolean value which specifies whether the connection
is automatically reconnected if lost if true. Should
be true or false.
The default setting is false. This default
value is used if the key is either missing, has no
value, or the value cannot be decoded.
eBus.connection.name.reconnectTime:
the number of milliseconds between reconnect attempts.
This is an 8-byte, signed integer value and must be
> zero.
The default setting is
ERemoteApp.DEFAULT_RECONNECT_TIME. This value
is ignored if reconnect is false.
eBus.connection.name.heartbeatDelay:
send a heartbeat message after this many milliseconds
after the last received message. Every time a message
is received, this timer is reset. This integer value
must be ≥ zero where zero means that heartbeat
messages are not sent.
The default setting is not to send a heartbeat message.
eBus.connection.name.heartbeatReplyDelay:
wait this many milliseconds for a reply to a heartbeat
message. If a reply is not received in this
time limit, close the connection. This integer value
must be ≥ zero where zero means there is no
heartbeat reply time limit.
The default setting is no time limit because heart beating is off by default.
eBus.connection.name.canPause:
this boolean value specifies whether the connection
will pause or not based on the pause properties. If
true, then the following properties are used
to decide when the connection is paused and when the
connection is resumed.
The default is false, the connection will not
pause.
eBus.connection.name.pause.pauseTime:
the connection will pause for at most this much time.
If the remote end has a shorter maximum pause time,
then that shorted time period is used. The value is
in milliseconds.
This value is required if canPause is
true.
eBus.connection.name.pause.maxBacklogSize:
when a connection is paused, at most this many
messages are queued up for transmit when the
connection is resumed. When the limit is reached,
messages are discarded based on the client-specified
EConfigure.DiscardPolicy.
If the remote end supports a lesser value, then that
lesser value is used.
The default value is zero which means there is no limit to the message backlog queue.
eBus.connection.name.pause.discardPolicy:
when the pending message queue reaches the
maxBacklogSize, messages are discard based on
either
EConfigure.DiscardPolicy.YOUNGEST_FIRST
or
EConfigure.DiscardPolicy.OLDEST_FIRST
The default value is OLDEST_FIRST.
eBus.connection.name.pause.idleTime:
pause the connection if no messages are sent or
received on this connection for this duration. The
value is in milliseconds. If specified this value
should be < maxConnectTime. This
rule is not enforced.
This property is optional and defaults to zero milliseconds which means idle time is turned off.
eBus.connection.name.pause.maxConnectTime:
a connection may remain up for at most this many
milliseconds regardless of connection being busy.
When this limit is reached the connection is
immediately paused.
This property is required if canPause is
true.
eBus.connection.name.pause.resumeOnBacklogSize:
when the message backlog reaches this limit,
automatically resume the connection. If specified,
this value should be <
maxBacklogSize to allow time for the
connection to be resumed and the pending messages sent
before the maximum backlog limit is reached and
messages are discarded. This rule is not enforced.
This property is optional and defaults to zero which means this capability is disabled.
eBus.dispatchers: a comma-separated list of eBus
dispatcher groups. This key is optional and may be set to
an empty string. The names must be unique with no
duplicates. The dispatcher name is used to retrieve the
following keys:
java command line
parameter
-Dnet.sf.eBus.config.file=<properties file path>
must be set because dispatchers are started by the
EClient class initializer block.)
eBus.dispatcher.name.isDefault:
Set to "true" if this is the default dispatcher. The
default dispatcher is used for all client classes not
explicitly assigned to a dispatcher. If multiple
dispatchers are designated as the default, then it
cannot be determined which selector will be used as
default.
The default value for this setting is false.
eBus.dispatcher.name.runQueueType:
Defines how the dispatcher thread removes clients from
the run queue: blocking, spinning,
spin+park, spin+yield. Blocking is the
most fair since it allows other threads to use the
core while waiting a client to be offered to the run
queue; but blocking is also the slowest. Spinning
means that the dispatcher is repeatedly calling
Queue.poll() until a client is
returned. Spinning is the fastest extraction technique
but monopolizes the core, preventing other threads
from using it. The spin+park and spin+yield types are
a compromise between blocking and spinning. The
dispatcher calls Queue.poll a configured
number of times, trying to extract a client. If no
client is returned after that configured spin limit is
reached, the dispatcher either parks for a specified
nanosecond time or yields the core. When the
dispatcher returns from the park or yield, the spin
limit is reset to the configured limit and the poll
spin begins again.
The default value for this setting is blocking.
eBus.dispatcher.name.spinLimit:
If runQueueType is set to spin+park or
spin+yield, then this is the
Queue.poll spin limit.
The default value for this setting is
DEFAULT_SPIN_LIMIT.
eBus.dispatcher.name.parkTime:
If runQueueType is set to spin+park,
then this is the nanosecond park time.
The default value for this setting is
DEFAULT_PARK_TIME.
eBus.dispatcher.name.priority:
The dispatcher threads are run at this thread
priority. The specified value must be
≥ Thread.MIN_PRIORITY and
≤ Thread.MAX_PRIORITY.
The default value for this setting is
Thread.NORM_PRIORITY.
eBus.dispatcher.name.quantum:
This is the maximum number of nanoseconds a client may
consume on a dispatcher thread before it musts yield
to another consumer. Note that this is not a
preemptive yield. The dispatcher thread tracks how
long a client takes processing each message, adding up
total time spent. When the accumulated time equals or
exceeds the quantum, the client is posted back to the
run queue if it has more messages to process. The
quantum is reset each time the client is acquired by a
dispatcher thread.
Note: it is possible for a client to monopolize a dispatcher thread, denying the thread to other clients associated with the dispatcher.
The default value for this setting is
DEFAULT_QUANTUM
eBus.dispatcher.name.classes:
specifies the client classes associated with this
dispatcher. A class should appear in at most one
dispatcher classes list. eBus does not detect
if a class is assigned to multiple dispatchers and it
is unknown to which dispatcher this class will be
assigned.
This property is ignored if isDefault is
true.
This property is required if this not a default dispatcher.
eBus.dispatcher.name.numberThreads:
The number of threads in this dispatcher. Must be
> zero.
The default value is DEFAULT_NUMBER_THREADS.
EConfigure.Dispatcher for information about two
special, pre-defined Dispatcher types:
EConfigure.DispatcherType.SWING and EConfigure.DispatcherType.JAVAFX
which deliver eBus messages via the GUI thread.
See the eBus overview section on connecting eBus applications for a detailed description in configuring eBus connections.
eBus release 5.1.0 introduces the ability to automatically pause a connection when it has been idle or continuously connected for a given time. When paused, messages are kept on a backlog for later transmission when the connection is resumed. The message backlog queue size may be limited. Once the queue size reaches that limit, then messages are discarded based on the specified discard policy.
The connection is resumed when the pause time is reached. This pause time is always used. Optionally a resume-on-backlog-size may also be set. When the backlog size reaches this size while paused, the connection is resumed even if the pause time is not yet reached.
The connection pause time and maximum backlog size are negotiated between the two connection ends. The lesser pause time and backlog size values are used by both ends.
This feature is added with an eye towards mobile devices which cannot support keeping connections up for an extended time due to battery limitations.
eBus now supports
typesafe
JSON configuration. This represents a subset of JSON known as
HOCON (Human-Optimized Config Object Notation).
The following is an eBus configuration in HOCON. Going forward
typesafe HOCON will be the preferred method for configuring
eBus with java.util.Properties and
java.util.prefs.Preferences being deprecated.
selectors : [
{
name : selector1
type : "spin+park"
isDefault : true
priority : 7
spinLimit : 1000000
parkTime : 500
}
]
services : [
{
name : service1
port : 12345
addressFilter : [
"127.0.0.1",
"127.0.0.1:54321"
]
serviceSelector : selector1
connectionSelector : selector1
byteOrder : LITTLE_ENDIAN
inputBufferSize : 8192
outputBufferSize : 65536
messageQueueSize : 100
canPause : true
// Connection pause/resume configuration.
pause : {
pauseTime : 10m
maxBacklogSize : 50
}
}
]
connections : [
{
name : conn1
host : "127.0.0.1"
port : 12346
bindPort : 0
byteOrder : BIG_ENDIAN
selector : selector1
inputBufferSize : 8192
outputBufferSize : 65536
messageQueueSize : 100
reconnect : true
reconnectTime : 500
canPause : true
// Connection pause/resume configuration.
pause : {
pauseTime : 5m
maxBacklogSize : 100
discardPolicy : YOUNGEST_FIRST
idleTime : 1m
maxConnectTime : 2m
resumeOnBacklogSize : 10
}
}
]
dispatchers : [
{
name : d1
runQueueType : "spin+park"
spinLimit : 2500000
parkTime : 500
isDefault : true
priority : 5
quantum : 1000
numberOfThreads : 4
}
]| Modifier and Type | Class and Description |
|---|---|
static class |
EConfigure.AbstractBuilder<T extends EConfigure.AbstractBuilder>
Base class for
EConfigure.ServerBuilder and
EConfigure.ConnectionBuilder, containing the properties
common to both. |
static class |
EConfigure.AbstractConfig
Base class for service and remote connections.
|
static class |
EConfigure.ConnectionBuilder
Constructs an
EConfigure.RemoteConnection instance
based on the parameters set via the builder's API. |
static class |
EConfigure.ConnectionRole
Defines remote connection side, either acceptor or
initiator.
|
static class |
EConfigure.ConnectionType
Enumerates the channel types supported by eBus
ERemoteApp. |
static class |
EConfigure.DiscardPolicy
When a connection is paused and the server message backlog
breaches the maximum allowed message backlog limit, this
policy specifies which messages should be discarded to
keep the backlog at the limit.
|
static class |
EConfigure.Dispatcher
An application may create dispatch threads with a given
unique name and the following parameters:
Thread priority: minimum,
maximum, or normal thread priority. |
static class |
EConfigure.DispatcherBuilder
Constructs an
EConfigure.Dispatcher configuration
instance based on the parameters set via the builder's
API. |
static class |
EConfigure.DispatcherType
Enumerates the supported eBus dispatcher thread types.
|
static class |
EConfigure.PauseBuilder
Constructs a
EConfigure.PauseConfig instance based on the
parameters set via the builder API. |
static class |
EConfigure.PauseConfig
If a remote connection may be paused, then this is the
allowed pause configuration.
|
static class |
EConfigure.RemoteConnection
This immutable class stores the information pertaining
to a remote eBus connection.
|
static class |
EConfigure.ServerBuilder
Constructs an
EConfigure.Service instance based on
the parameters set via this builder's API. |
static class |
EConfigure.Service
This immutable class stores the configuration for an
eBus service.
|
| Modifier and Type | Field and Description |
|---|---|
static String |
BIND_PORT_KEY
The connection definition uses the "bindPort" key suffix.
|
static String |
BYTE_ORDER_KEY
Both the service and connection definitions use the
"byteOrder" key suffix.
|
static String |
CAN_PAUSE_KEY
If a remote client connection may be paused, then this
property is defined and set to
true. |
static String |
CLASSES_KEY
The key "classes" defines the classes which are
posted to this dispatcher.
|
static String |
CONFIG_FILE_ENV
Use
-D to set system property "net.sf.eBus.config.file" to point to
the eBus configuration property file. |
static String |
CONN_SELECTOR_KEY
The service definition uses the key suffix
"connectionSelector" to define the selector used to monitor TCP socket
channels accepted by the service socket.
|
static String |
CONN_TYPE_KEY
Both service and connection definitions use the "connectionType"
to define the connection protocol type.
|
static String |
CONNECTION_PREFIX
Remote connection keys are prefixed by "eBus.connection." and
followed by the connection name as found in
CONNECTIONS_KEY. |
static String |
CONNECTIONS_KEY
The key "connections" contains a comma-separated list of remote
connection names.
|
static long |
DEFAULT_HEARTBEAT_DELAY
By default heart-beating is turned off.
|
static long |
DEFAULT_HEARTBEAT_REPLY_DELAY
By default wait indefinitely for a heartbeat reply.
|
static String |
DEFAULT_KEY
The boolean "isDefault" property is used to specify when this
dispatcher should be used as the default dispatcher.
|
static int |
DEFAULT_NUMBER_THREADS
The default dispatcher thread count is 4.
|
static int |
DEFAULT_PARK_TIME
The default park time after spinning is 1000
nanoseconds.
|
static int |
DEFAULT_PRIORITY
The default dispatcher thread priority is 5.
|
static int |
DEFAULT_QUANTUM
The default run quantum is 500000 nanoseconds.
|
static int |
DEFAULT_QUEUE_SIZE
This value specifies that there is no limit to the
transmit queue size.
|
static boolean |
DEFAULT_RECONNECT_FLAG
By default a lost connection is not reconnected.
|
static long |
DEFAULT_RECONNECT_TIME
The default reconnect time is 5 seconds.
|
static String |
DEFAULT_SELECTOR
The default selector thread name.
|
static int |
DEFAULT_SPIN_LIMIT
The default spin limit is 2500000 calls to
Queue.poll() before parking or yielding. |
static String |
DEFAULT_THREAD_TYPE
The default Dispatcher thread type is
ThreadType.BLOCKING. |
static String |
DISCARD_POLICY_KEY
When the maximum message backlog limit is breached, then
this policy defines which messages should be discarded.
|
static String |
DISPATCHER_PREFIX
Dispatcher keys are prefixed by "dispatcher." and followed by
the dispatcher name as found in
DISPATCHERS_KEY. |
static String |
DISPATCHER_TYPE_KEY
The
EConfigure.DispatcherType "dispatcherType" property is used to
specify the dispatcher thread type. |
static String |
DISPATCHERS_KEY
The key "dispatchers" contains a comma-separated list of
unique, client dispatcher names.
|
static String |
EBUS_KEY
All properties keys are prefixed with "eBus".
|
static String |
FILTER_KEY
The service definition uses the "addressFilter" key suffix.
|
static String |
HB_DELAY_KEY
The connection definition uses the "heartbeatDelay" key suffix.
|
static String |
HB_REPLY_DELAY_KEY
The connection definition uses the "heartbeatReplyDelay" key suffix.
|
static String |
HOST_KEY
The connection definition uses the "host" key suffix.
|
static String |
IDLE_TIME_KEY
When a connection is idle (no messages sent or received)
for a given time, that connection is automatically paused.
|
static String |
INBUFFER_SIZE_KEY
Both the service and connection definitions use the
"inputBufferSize" key suffix.
|
static String |
JSON_FILE_ENV
Use
-D to set system property "net.sf.eBus.config.jsonFile" to point to
the eBus JSON configuration file. |
static String |
MAX_BACKLOG_SIZE_KEY
Maximum allowed message backlog when paused.
|
static String |
MAX_CONNECT_TIME_KEY
Maximum allowed time between pauses, irrespective of
connection being busy.
|
static String |
MSG_QUEUE_SIZE_KEY
Both the service and connection definitions use the
"messageQueueSize" key suffix.
|
static String |
NAME_KEY
Key "name" is used to extract the configuration object's
name.
|
static String |
NUM_THREADS_KEY
The dispatcher definition uses "numberThreads"
key suffix to specify the number of threads in the
dispatcher.
|
static String |
OUTBUFFER_SIZE_KEY
Both the service and connection definitions use the
"outputBufferSize" key suffix.
|
static String |
PARK_TIME_KEY
If the thread type is
spin+park, then the
integer .parkTime property may be specified. |
static String |
PAUSE_DURATION_KEY
The pause duration is stored in "pauseTime".
|
static String |
PAUSE_KEY
If
CAN_PAUSE_KEY is set to true, then
the connection pause parameters are stored under the
"pause" key. |
static String |
PORT_KEY
Both the service and connection definitions use the
"port" key suffix.
|
static String |
PRIORITY_KEY
The integer "priority" property is used to set the dispatcher
thread priority.
|
static String |
QUANTUM_KEY
The key "quantum" defines the run quantum each
client is initially assigned.
|
static String |
RECONNECT_DELAY_KEY
The connection definition uses the "reconnectTime" key suffix.
|
static String |
RECONNECT_KEY
The connection definition uses the "reconnect" key suffix.
|
static String |
RESUME_ON_BACKLOG_SIZE_KEY
Resumes the client connection automatically when the
transmit queue reaches this size (application messages
only).
|
static String |
SELECTOR_KEY
Both the service and connection definitions use the
"selector" key suffix.
|
static String |
SERVICE_PREFIX
Service keys are prefixed by "eBus.service." and followed by the
service name.
|
static String |
SERVICES_KEY
The key "services" contains a comma-separated list of local
service names.
|
static String |
SPIN_LIMIT_KEY
If the thread type is
spin+park or
ThreadType.SPINYIELD, then the
integer .spinLimit property may be specified. |
static String |
SVC_SELECTOR_KEY
The service definition uses the key suffix
"serviceSelector" to define the selector used to monitor the
service socket.
|
static String |
THREAD_TYPE_KEY
The
run queue "runQueueType" property is used
to specify how the dispatcher thread acquires the next
available EClient from the run queue by either
blocking, spinning, spin+park, or spin+yield. |
| Modifier and Type | Method and Description |
|---|---|
EConfigure.RemoteConnection |
connection(String name) |
static EConfigure.ConnectionBuilder |
connectionBuilder()
Returns a new
EConfigure.ConnectionBuilder instance used to
construct a ERemoteApp programmatically. |
static EConfigure |
create(Map<String,EConfigure.Service> services,
Map<String,EConfigure.RemoteConnection> connections,
Map<String,EConfigure.Dispatcher> dispatchers)
Creates an eBus configuration for the given service and
remote connections.
|
static EConfigure.DispatcherBuilder |
dispatcherBuilder()
Returns a new
EConfigure.DispatcherBuilder instance used to
construct a EConfigure.Dispatcher. |
Map<String,EConfigure.Dispatcher> |
dispatchers()
Returns the set of client dispatcher configurations.
|
boolean |
equals(Object o)
Returns
true if o is a non-null
EConfigure instance with the same settings;
returns false otherwise. |
int |
hashCode()
Returns the configuration hash code.
|
boolean |
hasRemoteConnection(String name)
Returns
true if there is an remote connection
defined with the given name. |
boolean |
hasRemoteConnections()
Returns
true if remote connections are configured
and false if not. |
boolean |
hasService(String name)
Returns
true if there is an eBus service defined
with the given name. |
boolean |
hasServices()
Returns
true if at least one service is
configured and false otherwise. |
static EConfigure |
load(com.typesafe.config.Config config)
Returns the eBus service, remote connection, and
dispatcher configurations found in the given JSON
configuration.
|
static EConfigure |
load(Preferences prefs)
Deprecated.
Preferences-based configuration will be
removed at a future date. Please consider moving to
the JSON-based configuration file supported by
load(com.typesafe.config.Config). |
static EConfigure |
load(Properties props)
Returns the eBus service, remote connection, and
dispatcher configurations found in the given properties.
|
static Map<String,EConfigure.RemoteConnection> |
loadConnections(com.typesafe.config.Config config)
Returns the remote eBus connections found in the
preferences.
|
static Map<String,EConfigure.RemoteConnection> |
loadConnections(Preferences p)
Deprecated.
Preferences-based configuration will be
removed at a future date. Please consider moving to
the JSON-based configuration file supported by
load(com.typesafe.config.Config). |
static Map<String,EConfigure.RemoteConnection> |
loadConnections(Properties props)
Returns the remote eBus connections found in the
properties.
|
static Map<String,EConfigure.Dispatcher> |
loadDispatchers(com.typesafe.config.Config config)
Returns the eBus dispatcher configuration found in the
given JSON configuration.
|
static Map<String,EConfigure.Dispatcher> |
loadDispatchers(Preferences p)
Deprecated.
Preferences-based configuration will be
removed at a future date. Please consider moving to
the JSON-based configuration file supported by
load(com.typesafe.config.Config). |
static Map<String,EConfigure.Dispatcher> |
loadDispatchers(Properties props)
Returns the eBus dispatcher configuration found in the
given properties.
|
static Map<String,EConfigure.Service> |
loadServices(com.typesafe.config.Config config)
Returns the eBus TCP services.
|
static Map<String,EConfigure.Service> |
loadServices(Preferences p)
Deprecated.
Preferences-based configuration will be
removed at a future date. Please consider moving to
the JSON-based configuration file supported by
load(com.typesafe.config.Config). |
static Map<String,EConfigure.Service> |
loadServices(Properties props)
Extracts the services from the properties, returning the
service name to configuration map.
|
static EConfigure.PauseBuilder |
pauseBuilder(EConfigure.ConnectionRole role)
Returns a new
EConfigure.PauseBuilder instance used to
construct a EConfigure.PauseConfig. |
Map<String,EConfigure.RemoteConnection> |
remoteConnections()
Returns the set of remote eBus connections.
|
static EConfigure.ServerBuilder |
serverBuilder()
Returns a new
ServerBuilder instance used to
construct an EServer programmatically. |
EConfigure.Service |
service(String name)
Returns the eBus service for the given name.
|
Map<String,EConfigure.Service> |
services()
Returns the eBus services map.
|
void |
store(Preferences prefs)
Deprecated.
|
void |
store(Properties props)
Stores the eBus configuration to the given properties.
|
String |
toString()
Returns the configuration text representation.
|
public static final String CONFIG_FILE_ENV
-D to set system property "net.sf.eBus.config.file" to point to
the eBus configuration property file. eBus will configure
itself as per the file's properties.
Please note: either
-Dnet.sf.eBus.config.file or
-Dnet.sf.eBus.config.jsonFile or neither is
defined but not both. The application will exit if that
is the case since eBus will not attempt to merge the
two configurations.
JSON_FILE_ENV,
Constant Field Valuespublic static final String JSON_FILE_ENV
-D to set system property "net.sf.eBus.config.jsonFile" to point to
the eBus JSON configuration file. eBus will configure
itself as per the file.
Please note: either
-Dnet.sf.eBus.config.file or
-Dnet.sf.eBus.config.jsonFile or neither is
defined but not both. The application will exit if that
is the case since eBus will not attempt to merge the
two configurations.
CONFIG_FILE_ENV,
Constant Field Valuespublic static final String EBUS_KEY
public static final String NAME_KEY
public static final String SERVICES_KEY
public static final String SERVICE_PREFIX
public static final String CONNECTIONS_KEY
public static final String CONNECTION_PREFIX
CONNECTIONS_KEY.public static final String DISPATCHERS_KEY
public static final String DISPATCHER_PREFIX
DISPATCHERS_KEY.public static final String CONN_TYPE_KEY
public static final String PORT_KEY
public static final String INBUFFER_SIZE_KEY
public static final String OUTBUFFER_SIZE_KEY
public static final String BYTE_ORDER_KEY
ByteOrder.BIG_ENDIAN or
ByteOrder.LITTLE_ENDIAN.
The default is ByteOrder.LITTLE_ENDIAN.
public static final String MSG_QUEUE_SIZE_KEY
public static final String SVC_SELECTOR_KEY
AsyncChannel.defaultSelector.public static final String CONN_SELECTOR_KEY
AsyncChannel.defaultSelector.public static final String SELECTOR_KEY
AsyncChannel.defaultSelector.public static final String HOST_KEY
public static final String BIND_PORT_KEY
public static final String RECONNECT_KEY
public static final String RECONNECT_DELAY_KEY
public static final String HB_DELAY_KEY
public static final String HB_REPLY_DELAY_KEY
public static final String FILTER_KEY
public static final String DEFAULT_KEY
.isDefault keys are ignored.
If no user-defined dispatcher is marked as default, then
a blocking,
normal priority dispatcher
named EClient.DEFAULT_DISPATCHER is used as
the default dispatcher.
The default value is false
(not the default selector).
public static final String DISPATCHER_TYPE_KEY
EConfigure.DispatcherType "dispatcherType" property is used to
specify the dispatcher thread type. This property allows
eBus tasks to be executed on supported third-party
threads.
The default value is EConfigure.DispatcherType.EBUS.
public static final String THREAD_TYPE_KEY
run queue "runQueueType" property is used
to specify how the dispatcher thread acquires the next
available EClient from the run queue by either
blocking, spinning, spin+park, or spin+yield.
The default value is DEFAULT_THREAD_TYPE.
public static final String SPIN_LIMIT_KEY
spin+park or
ThreadType.SPINYIELD, then the
integer .spinLimit property may be specified. This
setting defines the number of times the Dispatcher thread
may call
Queue.poll() before parking or yielding.
This value must be > zero.
Default values is DEFAULT_SPIN_LIMIT.
This property is ignored is the thread type is not spin+park or spin+yield.
public static final String PARK_TIME_KEY
spin+park, then the
integer .parkTime property may be specified. This
setting specifies the nanosecond park time taken
between Queue.poll() spin cycles.
This value must be > zero.
Default values is DEFAULT_PARK_TIME.
This property is ignored is the thread type is not spin+park.
public static final String PRIORITY_KEY
The default value is Thread.NORM_PRIORITY.
public static final String QUANTUM_KEY
public static final String CLASSES_KEY
.isDefault is set to true.public static final String NUM_THREADS_KEY
public static final String CAN_PAUSE_KEY
true. If not set
then assumed to be false and the connection cannot
be paused. This key may be defined for both acceptor and
initiator connections.public static final String PAUSE_KEY
CAN_PAUSE_KEY is set to true, then
the connection pause parameters are stored under the
"pause" key. This key may be defined for both acceptor
and initiator connections.public static final String PAUSE_DURATION_KEY
PAUSE_KEY. This key may be defined
for both acceptor and initiator connections.public static final String MAX_BACKLOG_SIZE_KEY
public static final String DISCARD_POLICY_KEY
public static final String IDLE_TIME_KEY
public static final String MAX_CONNECT_TIME_KEY
public static final String RESUME_ON_BACKLOG_SIZE_KEY
public static final String DEFAULT_THREAD_TYPE
ThreadType.BLOCKING.public static final int DEFAULT_SPIN_LIMIT
Queue.poll() before parking or yielding.public static final int DEFAULT_PARK_TIME
public static final int DEFAULT_PRIORITY
public static final int DEFAULT_QUANTUM
public static final int DEFAULT_NUMBER_THREADS
public static final int DEFAULT_QUEUE_SIZE
public static final String DEFAULT_SELECTOR
public static final boolean DEFAULT_RECONNECT_FLAG
public static final long DEFAULT_RECONNECT_TIME
true when the
connection was
ERemoteApp.openConnection(EConfigure.RemoteConnection) opened.public static final long DEFAULT_HEARTBEAT_DELAY
public static final long DEFAULT_HEARTBEAT_REPLY_DELAY
public boolean equals(Object o)
true if o is a non-null
EConfigure instance with the same settings;
returns false otherwise.public int hashCode()
public String toString()
public boolean hasServices()
true if at least one service is
configured and false otherwise.true if there is a service.public boolean hasService(String name)
true if there is an eBus service defined
with the given name.name - service name.true if service exists.public Map<String,EConfigure.Service> services()
public EConfigure.Service service(String name)
null if there is no service for name.name - service name.public boolean hasRemoteConnections()
true if remote connections are configured
and false if not.true if there are remote connections.public boolean hasRemoteConnection(String name)
true if there is an remote connection
defined with the given name.name - connection name.true if connection exists.public Map<String,EConfigure.RemoteConnection> remoteConnections()
public EConfigure.RemoteConnection connection(String name)
public Map<String,EConfigure.Dispatcher> dispatchers()
public static EConfigure create(Map<String,EConfigure.Service> services, Map<String,EConfigure.RemoteConnection> connections, Map<String,EConfigure.Dispatcher> dispatchers)
connections.services - the local eBus services.connections - the remote eBus connections.dispatchers - dispatcher thread configurations.EConfigure.RemoteConnection,
EConfigure.Servicepublic static EConfigure.ServerBuilder serverBuilder()
ServerBuilder instance used to
construct an EServer programmatically.ServerBuilder instance.public static EConfigure.ConnectionBuilder connectionBuilder()
EConfigure.ConnectionBuilder instance used to
construct a ERemoteApp programmatically.ConnectionBuilder instance.public static EConfigure.DispatcherBuilder dispatcherBuilder()
EConfigure.DispatcherBuilder instance used to
construct a EConfigure.Dispatcher.DispatcherBuilder instance.public static EConfigure.PauseBuilder pauseBuilder(EConfigure.ConnectionRole role)
EConfigure.PauseBuilder instance used to
construct a EConfigure.PauseConfig.role - build pause configuration for this connection
role.EConfigure.PauseBuilder instance.public static EConfigure load(Properties props)
net,
eBus.messageLoaders, optional eBus.server
and ebus.remoteConnections.
Both keys have a comma-separated list of unique
names as the value. Each name is used to extract one
server or remote connection configuration.
Note: Each name must be unique within the remote connection list.
The optional server configuration keys are:
eBus.service.port: The TCP
service port integer. Must be > zero and < 65,535.
eBus.service.socketBufferSize:
The accepted connection's output buffer size.
The remote configuration keys are:
eBus.connection.name.host:
The remote eBus host name or dotted notation IP
address.
eBus.connection.name.port: The
remote eBus TCP service port.
eBus.connection.name.bindPort:
the connection's local end is bound to this TCP port.
If this key is unspecified or zero, then the local
end is bound to any available TCP port.
eBus.connection.name.socketBufferSize:
The maximum number of outbound bytes that may be
waiting for transmission at a time.
eBus.connection.name.reconnect:
Either true of false. If true,
then a lost connection will be re-established.
eBus.connection.name.reconnectTime:
When reconnecting, wait this many milliseconds between
connect attempts.
The dispatcher configuration keys are:
eBus.dispatcher.name.runQueueType:
the dispatcher uses either a blocking, spinning, or
spin+park run queue.
eBus.dispatcher.name.isDefault:
marks this as the default run queue used by all eBus
clients not explicitly assigned a run queue. There
should be only one dispatcher marked as default.
eBus.dispatcher.name.priority:
dispatcher threads are all assigned this priority.
eBus.dispatcher.name.quantum:
the maximum run quantum assigned to clients.
eBus.dispatcher.name.classes:
Instances of these client classes are assigned to this
dispatcher. A class should appear in at most one
dispatcher classes list.
eBus.dispatcher.name.numberThreads:
The number of threads in this dispatcher.
eBus.dispatcher.name.spinLimit:
If runQueueType is spin+park, then this is the
spin limit.
eBus.dispatcher.name.parkTime:
If runQueueType is spin+park, then this is the
nanosecond park time.
props - extract the eBus configuration information
from these properties.com.typesafe.config.ConfigException - if a required property is missing or contains an invalid
value.public static Map<String,EConfigure.Service> loadServices(Properties props)
props - eBus configuration properties.com.typesafe.config.ConfigException - if a service property is missing or contains an invalid
value.public static Map<String,EConfigure.RemoteConnection> loadConnections(Properties props)
props - the eBus configuration properties.com.typesafe.config.ConfigException - if there are properties missing for a specified remote
connection or a property contains an invalid value.public static Map<String,EConfigure.Dispatcher> loadDispatchers(Properties props)
props - eBus configuration properties.com.typesafe.config.ConfigException - if there are properties missing for a specified remote
connection or a property is invalid.@Deprecated public static EConfigure load(Preferences prefs)
load(com.typesafe.config.Config).net,
eBus.messageLoaders, optional eBus.server
and ebus.remoteConnections.
Both keys have a comma-separated list of unique
names as the value. Each name is used to extract one
server or remote connection configuration.
Note: Each name must be unique with the remote remote connection list.
The optional server configuration keys are:
eBus.service.port: The TCP
service port integer. Must be > zero and < 65,535.
eBus.service.socketBufferSize:
The accepted connection's output buffer size.
The remote configuration keys are:
eBus.connection.name.host:
The remote eBus host name or dotted notation IP
address.
eBus.connection.name.port: The
remote eBus TCP service port.
eBus.connection.name.bindPort:
the connection's local end is bound to this TCP port.
If this key is unspecified or zero, then the local
end is bound to any available TCP port.
eBus.connection.name.socketBufferSize:
The maximum number of outbound bytes that may be
waiting for transmission at a time.
eBus.connection.name.reconnect:
Either true of false. If true,
then a lost connection will be re-established.
eBus.connection.name.reconnectTime:
When reconnecting, wait this many milliseconds between
connect attempts.
The dispatcher configuration keys are:
eBus.dispatcher.name.runQueueType:
the dispatcher uses either a blocking, spinning, or
spin+park run queue.
eBus.dispatcher.name.isDefault:
marks this as the default run queue used by all eBus
clients not explicitly assigned a run queue. There
should be only one dispatcher marked as default.
eBus.dispatcher.name.priority:
dispatcher threads are all assigned this priority.
eBus.dispatcher.name.quantum:
the maximum run quantum assigned to clients.
eBus.dispatcher.name.classes:
Instances of these client classes are assigned to this
dispatcher. A class should appear in at most one
dispatcher classes list.
eBus.dispatcher.name.numberThreads:
The number of threads in this dispatcher.
eBus.dispatcher.name.spinLimit:
If runQueueType is spin+park, then this is the
spin limit.
eBus.dispatcher.name.parkTime:
If runQueueType is spin+park, then this is the
nanosecond park time.
prefs - Read in the eBus configuration from these
preferences.MissingResourceException - if a required property is missing.IllegalStateException - if a property contains an invalid value.load(Properties),
load(com.typesafe.config.Config)@Deprecated public static Map<String,EConfigure.Service> loadServices(Preferences p)
load(com.typesafe.config.Config).p - eBus configuration preferences.MissingResourceException - if a service property is missing.IllegalStateException - if a service property is invalid.load(Preferences)@Deprecated public static Map<String,EConfigure.RemoteConnection> loadConnections(Preferences p)
load(com.typesafe.config.Config).p - the eBus configuration preferences.MissingResourceException - if there are properties missing for a specified remote
connection.IllegalStateException - if a property is invalid.load(Preferences)@Deprecated public static Map<String,EConfigure.Dispatcher> loadDispatchers(Preferences p)
load(com.typesafe.config.Config).p - the eBus configuration preferences.MissingResourceException - if there are properties missing for a specified remote
connection.load(Preferences)public static EConfigure load(com.typesafe.config.Config config)
An example of the eBus JSON configuration:
Note: Each name must be unique within the selectors, services, and connections lists.
"selectors" : [
{
"name" : "mdSelector"
"type" : "spinning"
"isDefault" : "false"
"priority" : 9
},
{
"name" : "stockSelector"
"type" : "spin+park"
"isDefault" : "false"
"priority" : 6
"spinLimit" : 3000000
"parkTime" : 1000
}
]
"services" : [
{
"name" : "stockService"
"port" : 12345
"addressFilter" : [
"198.168.3.2",
"198.168.3.3:55001"
]
"serviceSelector" : "stockSelector"
"connectionSelector" : "stockSelector"
"byteOrder" : "BIG_ENDIAN"
"inputBufferSize" : 8192
"outputBufferSize" : 65536
"messageQueueSize" : 100
"heartbeatDelay" : 30000
"heartbeatReply" : 500
"canPause" : false
}
]
"connections" : [
{
"name" : "marketData"
"host" : "192.168.3.4"
"port" : 10000
"inputBufferSize" : 65536
"outputBufferSize" : 8192
"byteOrder" : "BIG_ENDIAN"
"messageQueueSize" : 0
"selector" : "mdSelector"
"reconnect" : true
"reconnectTime" : 500
"canPause" : false
},
{
"name" : "stockOrders"
"host" : "StocksRUs.com"
"port" : 10001
"bindPort" : 55000
"inputBufferSize" : 8192
"outputBufferSize" : 65536
"byteOrder" : "BIG_ENDIAN"
"messageQueueSize" : 10
"selector" : "stockSelector"
"reconnect" : true
"reconnectTime" : 500
"canPause" : false
}
]config - extract the eBus configuration from these
JSON properties.com.typesafe.config.ConfigException - if config contains an invalid or incomplete eBus
configuration.public static Map<String,EConfigure.Service> loadServices(com.typesafe.config.Config config)
config - typesafe.config HOCON configuration
containing service definition.com.typesafe.config.ConfigException - if a service definition is invalid.load(Config)public static Map<String,EConfigure.RemoteConnection> loadConnections(com.typesafe.config.Config config)
config - typesafe.config HOCON configuration
containing connection definition.com.typesafe.config.ConfigException - if a remote connection definition is invalid.load(Preferences)public static Map<String,EConfigure.Dispatcher> loadDispatchers(com.typesafe.config.Config config)
config - JSON configuration.com.typesafe.config.ConfigException - if config contains an invalid dispatcher
configuration.public void store(Properties props)
props - store the configuration to this properties
map.load(java.util.Properties),
load(java.util.prefs.Preferences),
store(java.util.prefs.Preferences)@Deprecated public void store(Preferences prefs)
prefs - store the configuration to these preferences.load(Preferences),
load(java.util.Properties),
store(java.util.Properties)Copyright © 2020. All rights reserved.