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