Class RouteToServerRequestControl
- java.lang.Object
-
- com.unboundid.ldap.sdk.Control
-
- com.unboundid.ldap.sdk.unboundidds.controls.RouteToServerRequestControl
-
- All Implemented Interfaces:
java.io.Serializable
@NotMutable @ThreadSafety(level=COMPLETELY_THREADSAFE) public final class RouteToServerRequestControl extends Control
This class provides a request control which may be used to request that the associated request be routed to a specific server. It is primarily intended for use when the request will pass through a Directory Proxy Server to indicate that which backend server should be used to process the request. The server ID for the server to use may be obtained using theGetServerIDRequestControl
.
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.
If the request is processed successfully, then the result should include aGetServerIDResponseControl
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.
The criticality for this control may be eithertrue
orfalse
. 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, ... }
Example
The following example demonstrates the process of performing a search to retrieve an entry using the get server ID request control and then sending a modify request to that same server using the route to server request control.// 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);
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field 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 Summary
Constructors Constructor 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.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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.-
Methods inherited from class com.unboundid.ldap.sdk.Control
decode, decode, decodeControls, decodeJSONControl, deregisterDecodeableControl, encode, encodeControls, equals, getOID, getValue, hashCode, hasValue, isCritical, readFrom, registerDecodeableControl, registerDecodeableControl, toString, writeTo
-
-
-
-
Field Detail
-
ROUTE_TO_SERVER_REQUEST_OID
@NotNull public static final 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.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RouteToServerRequestControl
public RouteToServerRequestControl(boolean isCritical, @NotNull java.lang.String serverID, boolean allowAlternateServer, boolean preferLocalServer, boolean preferNonDegradedServer)
Creates a new route to server request control with the provided information.- Parameters:
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 benull
.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 offalse
and the target server is unknown or unavailable, then the associated operation will be rejected. If this has a value oftrue
, 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 ifallowAlternateServer
istrue
.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 ifallowAlternateServer
istrue
.
-
RouteToServerRequestControl
public RouteToServerRequestControl(@NotNull Control control) throws LDAPException
Creates a new route to server request control which is decoded from the provided generic control.- Parameters:
control
- The generic control to be decoded as a route to server request control.- Throws:
LDAPException
- If the provided control cannot be decoded as a route to server request control.
-
-
Method Detail
-
getServerID
@NotNull public java.lang.String getServerID()
Retrieves the server ID for the server to which the request should be sent.- Returns:
- The server ID for the server to which the request should be sent.
-
allowAlternateServer
public 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.- Returns:
true
if the request may be routed to an alternate server if the target server is not suitable for use, orfalse
if the operation should be rejected if it cannot be routed to the target server.
-
preferLocalServer
public 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. This will only returntrue
ifallowAlternateServer
also returnstrue
.- Returns:
true
if the request may be routed to a suitable local server if the target server is nonlocal, orfalse
if the nonlocal target server should still be used.
-
preferNonDegradedServer
public 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. This will only returntrue
ifallowAlternateServer
also returnstrue
.- Returns:
true
if the request may be routed to a suitable non-degraded server if the target server is degraded, orfalse
if the degraded target server should still be used.
-
getControlName
@NotNull public java.lang.String getControlName()
Retrieves the user-friendly name for this control, if available. If no user-friendly name has been defined, then the OID will be returned.- Overrides:
getControlName
in classControl
- Returns:
- The user-friendly name for this control, or the OID if no user-friendly name is available.
-
toJSONControl
@NotNull public JSONObject toJSONControl()
Retrieves a representation of this route to server request control as a JSON object. The JSON object uses the following fields:-
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, theoid
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 thevalue-base64
andvalue-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 thevalue-base64
andvalue-json
fields must be present, and if thevalue-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.
-
- Overrides:
toJSONControl
in classControl
- Returns:
- A JSON object that contains a representation of this control.
-
-
decodeJSONControl
@NotNull public static RouteToServerRequestControl decodeJSONControl(@NotNull JSONObject controlObject, boolean strict) throws LDAPException
Attempts to decode the provided object as a JSON representation of a route to server request control.- Parameters:
controlObject
- The JSON object to be decoded. It must not benull
.strict
- Indicates whether to use strict mode when decoding the provided JSON object. If this istrue
, then this method will throw an exception if the provided JSON object contains any unrecognized fields. If this isfalse
, then unrecognized fields will be ignored.- Returns:
- The route to server request control that was decoded from the provided JSON object.
- Throws:
LDAPException
- If the provided JSON object cannot be parsed as a valid route to server request control.
-
-