public static final class DOF.Config.Builder
extends java.lang.Object
build()
to create
an immutable DOF.Config
object that stores all the chosen settings. Pass that Config to
DOF.DOF(Config)
to create your customized DOF.
For example, by default DOFs cannot be proxies. To create a DOF that
is capable of being a proxy node, you must set routing to true, as in the following example:
final DOF.Config config = new DOF.Config.Builder() .setRouter(true) .build(); DOF dof = new DOF(config);The following are the default configuration parameters:
setConnectionLimit(int)
to set a different value.DOF.Config.DEFAULT_THREADPOOL_SIZE
. Use setThreadPoolSize(short)
to set a different value.setName(java.lang.String)
to set a different value.setSourceID(org.opendof.core.oal.DOFObjectID.Source)
to set a different value.DOF.Config.DEFAULT_RANK
. Use setRank(short)
to set a different value.setParameterValidation(boolean)
to
disable validation.setRouter(boolean)
to set routing to true.DOF.DefaultProtocolFactory
. Use setProtocolFactory(org.opendof.core.oal.DOFProtocolFactory)
to set a different protocol factory.Constructor and Description |
---|
Builder()
Constructs a Builder with configuration parameters set to their defaults.
|
Builder(DOF.Config config)
Copies configuration parameters from a
DOF.Config and constructs a Builder with the same initial configuration
parameters. |
Builder(DOF.State state)
Copies configuration parameters from a
DOF.State and constructs a Builder with the same initial configuration
parameters. |
Modifier and Type | Method and Description |
---|---|
DOF.Config |
build()
Builds a
DOF.Config object based on the parameters set in this Builder. |
DOF.Config.Builder |
setConnectionLimit(int limit)
Sets the maximum number of simultaneous connections, both inbound and outbound, that a DOF can support.
|
DOF.Config.Builder |
setName(java.lang.String name)
Sets the name that will be used to identify a DOF in logging.
|
DOF.Config.Builder |
setParameterValidation(boolean isValidate)
|
DOF.Config.Builder |
setProtocolFactory(DOFProtocolFactory protocolFactory)
Sets the
DOFProtocolFactory . |
DOF.Config.Builder |
setRank(short rank)
Sets the node's desire to manage a secure multicast group.
|
DOF.Config.Builder |
setRouter(boolean isRouter)
Sets whether a DOF will route operations other than those it directly requests or provides.
|
DOF.Config.Builder |
setSourceID(DOFObjectID.Source sourceID)
Sets the identifier that is used for a DOF's operations in the unsecured domain.
|
DOF.Config.Builder |
setThreadPoolSize(short max)
Sets the maximum number of threads that a DOF can create to process operations.
|
public Builder()
public Builder(DOF.Config config)
DOF.Config
and constructs a Builder with the same initial configuration
parameters.
Because each DOF must have a unique name and a unique source identifier, they are reset to null. You can set a
new name using setName(java.lang.String)
and a new source identifier using setSourceID(org.opendof.core.oal.DOFObjectID.Source)
. If you leave the name or sourceID value at null,
a unique name or source identifier will be randomly generated when a DOF is created from the new DOF.Config.config
- The DOF.Config instance whose parameters to copy. This must not be null.public Builder(DOF.State state)
DOF.State
and constructs a Builder with the same initial configuration
parameters.
Because each DOF must have a unique name and a unique source identifier, they are reset to null. You can set a
new name using setName(java.lang.String)
and a new source identifier using setSourceID(org.opendof.core.oal.DOFObjectID.Source)
. If you leave the name or sourceID value at null,
a unique name or source identifier will be randomly generated when a DOF is created from the new DOF.Config.state
- The DOF.State instance whose parameters to copy. This must not be null.DOF.getState()
public DOF.Config.Builder setSourceID(DOFObjectID.Source sourceID)
DOF.cancelAllOperations()
in the DOF's startup routines.
sourceID
- The DOFObjectID.Source
to use as an identifier in the unsecured domain. Null to randomly generate a source identifier.DOFObjectID.Source.create(org.opendof.core.oal.DOFObjectID)
,
DOF.State.getSourceID()
,
DOF.Config.getSourceID()
public DOF.Config.Builder setRouter(boolean isRouter)
isRouter
- True sets the node to be a centralized router. False sets the node to be a network endpoint.DOF.State.isRouter()
,
DOF.Config.isRouter()
public DOF.Config.Builder setName(java.lang.String name)
name
- The name to assign to the DOF for logging. Null to randomly generate a name.DOF.setName(java.lang.String)
,
DOF.State.getName()
,
DOF.Config.getName()
public DOF.Config.Builder setConnectionLimit(int limit)
DOFServer
instances on the node, although this parameter does not limit the number of servers you can create or start. Outbound
connections are instances of DOFConnection
for which you've called DOFConnection.connect(int)
or DOFConnection.beginConnect(int)
, although
this parameter does not limit the number of connections you can create. In addition, only calls to connect or beginConnect that establish a new connection
on the physical wire count toward the total—not calls for connections that have already been established. The sum of all inbound plus all outbound
connections on the node must always be less than or equal to the value set for this parameter. If the node reaches its maximum, it will not allow you to
initiate or accept new connections until some connections are dropped.
Inbound DOFConnection.Type.DATAGRAM_STATELESS
connections are not limited by this parameter, although outbound DATAGRAM_STATELESS connections
do count toward the total.
If you input a value for the maximum number of connections that is greater than the limit the underlying operating system can handle, the number of
connections you can initiate and accept will be constrained by the operating system. In addition, inputting DOF.UNLIMITED
means that the library
will not limit the maximum number of connections, but the operating system limits still apply.
By default, this parameter is set to DOF.UNLIMITED
so that the operating system will manage the maximum number of connections. You would typically change this
setting only for nodes with limited resources where you want to limit the connections to fewer than the operating system allows. If you enforce a
limit, it should be carefully considered so that you do not prevent necessary connections.
limit
- The connection limit that the DOF can support. This must be greater than or equal to zero.DOF.setConnectionLimit(int)
,
DOF.UNLIMITED
,
DOF.State.getConnectionLimit()
,
DOF.Config.getConnectionLimit()
public DOF.Config.Builder setThreadPoolSize(short max)
max
- The maximum number of threads that the DOF can create. The value must be positive. Negative values
are converted to zero.DOF.setThreadPoolSize(short)
,
DOF.Config.DEFAULT_THREADPOOL_SIZE
,
DOF.State.getThreadPoolSize()
,
DOF.Config.getThreadPoolSize()
public DOF.Config.Builder setRank(short rank)
rank
- The DOF's rank. The valid range is zero to 255.DOF.setRank(short)
,
DOF.Config.DEFAULT_RANK
,
DOFConnection.Type.GROUP
,
DOF.State.getRank()
,
DOF.Config.getRank()
public DOF.Config.Builder setProtocolFactory(DOFProtocolFactory protocolFactory)
DOFProtocolFactory
. Defining and using protocol factories is a very advanced
use case. You should not change the default value for this parameter without a detailed knowledge
of DOF protocol specifications.protocolFactory
- The protocol factory. This must not be null.DOF.setProtocolFactory(org.opendof.core.oal.DOFProtocolFactory)
,
DOF.State.getProtocolFactory()
,
DOF.Config.getProtocolFactory()
public DOF.Config.Builder setParameterValidation(boolean isValidate)
DOFValue
objects to verify that their associated DOFType
matches the type required for an interface item. The default is true. If you set validation to false, the
library will bypass its normal type checking, so you should ensure that the application is using valid types.isValidate
- True to perform validation. False to turn validation off.DOF.State.isParameterValidation()
,
DOF.Config.isParameterValidation()
public DOF.Config build()
DOF.Config
object based on the parameters set in this Builder.DOF.DOF(Config)