Skip to main content

Switch Operations to a Different Node

  • By default, when working with multiple nodes,
    all client requests will access the server node that is defined by the client configuration.
    (Learn more in: Load balancing client requests).

  • However, server maintenance operations can be executed on a specific node by using the ForNode method.
    (An exception is thrown if that node is not available).

  • In this page:

Server maintenance operations - ForNode

  • For reference, all server maintenance operations are listed here.
// Default node access can be defined on the store
var documentStore = new DocumentStore
{
Urls = new[] { "ServerURL_1", "ServerURL_2", "..." },
Database = "DefaultDB",
Conventions = new DocumentConventions
{
// For example:
// With ReadBalanceBehavior set to: 'FastestNode':
// Client READ requests will address the fastest node
// Client WRITE requests will address the preferred node
ReadBalanceBehavior = ReadBalanceBehavior.FastestNode
}
}.Initialize();

using (documentStore)
{
// Use 'ForNode' to override the default node configuration
// The Maintenance.Server operation will be executed on the specified node
var dbNames = documentStore.Maintenance.Server.ForNode("C")
.Send(new GetDatabaseNamesOperation(0, 25));
}

Syntax:

ServerOperationExecutor ForNode(string nodeTag);
ParametersTypeDescription
nodeTagstringThe tag of the node to operate on
Return Value
ServerOperationExecutorNew instance of Server Operation Executor that is scoped to the requested node