@NotMutable @ThreadSafety(level=COMPLETELY_THREADSAFE) public final class RouteToServerRequestControl extends Control
GetServerIDRequestControl
.
NOTE: This class, and other classes within the
com.unboundid.ldap.sdk.unboundidds
package structure, are only
supported for use against Ping Identity, UnboundID, and
Nokia/Alcatel-Lucent 8661 server products. These classes provide support
for proprietary functionality or for external specifications that are not
considered stable or mature enough to be guaranteed to work in an
interoperable way with other types of LDAP servers.
GetServerIDResponseControl
with the server ID of the server that was
used to process the request. It may or may not be the same as the server ID
included in the request control, depending on whether an alternate server was
determined to be better suited to handle the request.
true
or false
.
It must have a value with the following encoding:
RouteToServerRequest ::= SEQUENCE { serverID [0] OCTET STRING, allowAlternateServer [1] BOOLEAN, preferLocalServer [2] BOOLEAN DEFAULT TRUE, preferNonDegradedServer [3] BOOLEAN DEFAULT TRUE, ... }
// Perform a search to find an entry, and use the get server ID request // control to figure out which server actually processed the request. SearchRequest searchRequest = new SearchRequest("dc=example,dc=com", SearchScope.BASE, Filter.createPresenceFilter("objectClass"), "description"); searchRequest.addControl(new GetServerIDRequestControl()); SearchResultEntry entry = connection.searchForEntry(searchRequest); GetServerIDResponseControl serverIDControl = GetServerIDResponseControl.get(entry); String serverID = serverIDControl.getServerID(); // Send a modify request to update the target entry, and include the route // to server request control to request that the change be processed on the // same server that processed the request. ModifyRequest modifyRequest = new ModifyRequest("dc=example,dc=com", new Modification(ModificationType.REPLACE, "description", "new description value")); modifyRequest.addControl(new RouteToServerRequestControl(false, serverID, true, true, true)); LDAPResult modifyResult = connection.modify(modifyRequest);
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ROUTE_TO_SERVER_REQUEST_OID
The OID (1.3.6.1.4.1.30221.2.5.16) for the route to server request control.
|
Constructor and Description |
---|
RouteToServerRequestControl(boolean isCritical,
java.lang.String serverID,
boolean allowAlternateServer,
boolean preferLocalServer,
boolean preferNonDegradedServer)
Creates a new route to server request control with the provided
information.
|
RouteToServerRequestControl(Control control)
Creates a new route to server request control which is decoded from the
provided generic control.
|
Modifier and Type | Method and Description |
---|---|
boolean |
allowAlternateServer()
Indicates whether the request may be routed to an alternate server if the
target server is unknown, unavailable, or otherwise unsuited for use.
|
static RouteToServerRequestControl |
decodeJSONControl(JSONObject controlObject,
boolean strict)
Attempts to decode the provided object as a JSON representation of a
route to server request control.
|
java.lang.String |
getControlName()
Retrieves the user-friendly name for this control, if available.
|
java.lang.String |
getServerID()
Retrieves the server ID for the server to which the request should be sent.
|
boolean |
preferLocalServer()
Indicates whether the request may be routed to an alternate server if the
target server is nonlocal and a suitable server is available locally.
|
boolean |
preferNonDegradedServer()
Indicates whether the request may be routed to an alternate server if the
target server is in a degraded state and a suitable non-degraded server is
available.
|
JSONObject |
toJSONControl()
Retrieves a representation of this route to server request control as a
JSON object.
|
void |
toString(java.lang.StringBuilder buffer)
Appends a string representation of this LDAP control to the provided
buffer.
|
decode, decode, decodeControls, decodeJSONControl, deregisterDecodeableControl, encode, encodeControls, equals, getOID, getValue, hashCode, hasValue, isCritical, readFrom, registerDecodeableControl, registerDecodeableControl, toString, writeTo
@NotNull public static final java.lang.String ROUTE_TO_SERVER_REQUEST_OID
public RouteToServerRequestControl(boolean isCritical, @NotNull java.lang.String serverID, boolean allowAlternateServer, boolean preferLocalServer, boolean preferNonDegradedServer)
isCritical
- Indicates whether this control should be
considered critical.serverID
- The server ID for the server to which the
request should be sent. It must not be
null
.allowAlternateServer
- Indicates whether the request may be
routed to an alternate server in the
event that the target server is not known,
is not available, or is otherwise unsuited
for use. If this has a value of
false
and the target server is
unknown or unavailable, then the
associated operation will be rejected. If
this has a value of true
, then an
intermediate Directory Proxy Server may be
allowed to route the request to a
different server if deemed desirable or
necessary.preferLocalServer
- Indicates whether the associated request
may be routed to an alternate server if
the target server is in a remote location
and a suitable alternate server is
available locally. This will only be used
if allowAlternateServer
is
true
.preferNonDegradedServer
- Indicates whether the associated request
may be routed to an alternate server if
the target server is in a degraded state
and an alternate server is not in a
degraded state. This will only be used if
allowAlternateServer
is
true
.public RouteToServerRequestControl(@NotNull Control control) throws LDAPException
control
- The generic control to be decoded as a route to server
request control.LDAPException
- If the provided control cannot be decoded as a
route to server request control.@NotNull public java.lang.String getServerID()
public boolean allowAlternateServer()
true
if the request may be routed to an alternate server
if the target server is not suitable for use, or false
if
the operation should be rejected if it cannot be routed to the
target server.public boolean preferLocalServer()
true
if allowAlternateServer
also returns
true
.true
if the request may be routed to a suitable local
server if the target server is nonlocal, or false
if the
nonlocal target server should still be used.public boolean preferNonDegradedServer()
true
if
allowAlternateServer
also returns true
.true
if the request may be routed to a suitable
non-degraded server if the target server is degraded, or
false
if the degraded target server should still be used.@NotNull public java.lang.String getControlName()
getControlName
in class Control
@NotNull public JSONObject toJSONControl()
oid
-- A mandatory string field whose value is the object
identifier for this control. For the route to server request control,
the OID is "1.3.6.1.4.1.30221.2.5.16".
control-name
-- An optional string field whose value is a
human-readable name for this control. This field is only intended for
descriptive purposes, and when decoding a control, the oid
field should be used to identify the type of control.
criticality
-- A mandatory Boolean field used to indicate
whether this control is considered critical.
value-base64
-- An optional string field whose value is a
base64-encoded representation of the raw value for this route to server
request control. Exactly one of the value-base64
and
value-json
fields must be present.
value-json
-- An optional JSON object field whose value is a
user-friendly representation of the value for this route to server
request control. Exactly one of the value-base64
and
value-json
fields must be present, and if the
value-json
field is used, then it will use the following
fields:
server-id
-- A mandatory string field whose value is the
server ID for the server to which the request should be sent.
allow-alternate-server
-- A mandatory Boolean field that
indicates whether the Directory Proxy Server may choose to use a
different server than the one requested if the requested server is
not known or is not available.
prefer-local-server
-- An optional Boolean field that
indicates whether the request may be routed to an alternative
server if the requested server is not in the same location as the
Directory Proxy Server.
prefer-non-degraded-server
-- An optional Boolean field
that indicates whether the request may be routed to an alternative
server if the requested server is in a degraded state.
toJSONControl
in class Control
@NotNull public static RouteToServerRequestControl decodeJSONControl(@NotNull JSONObject controlObject, boolean strict) throws LDAPException
controlObject
- The JSON object to be decoded. It must not be
null
.strict
- Indicates whether to use strict mode when decoding
the provided JSON object. If this is true
,
then this method will throw an exception if the
provided JSON object contains any unrecognized
fields. If this is false
, then unrecognized
fields will be ignored.LDAPException
- If the provided JSON object cannot be parsed as a
valid route to server request control.