Class: ReplicationPolicy

ReplicationPolicy()

new ReplicationPolicy()

Replication policy value object for System Metadata.
Since:
  • 2.39.0
Source:

Methods

add(node, type) → {ReplicationPolicy}

Append one preferred or blocked member node.
Parameters:
Name Type Description
node string Member node identifier.
type "preferred" | "blocked" Node-list type.
Source:
Throws:
When type is not `preferred` or `blocked`
Type
Error
Returns:
The same policy instance.
Type
ReplicationPolicy

clear(typeopt) → {ReplicationPolicy}

Clear one or both preferred/blocked node lists and optionally the scalar policy values.
Parameters:
Name Type Attributes Description
type "preferred" | "blocked" <optional>
Node-list type to clear.
Source:
Throws:
When type is not `preferred` or `blocked`
Type
Error
Returns:
The same policy instance.
Type
ReplicationPolicy

hasValues() → {boolean}

Whether the policy contains any serialized values.
Source:
Returns:
`true` when any field is populated.
Type
boolean

normalize() → {ReplicationPolicy}

Normalize the policy in place.
Source:
Returns:
The same policy instance.
Type
ReplicationPolicy

remove(index, type) → {ReplicationPolicy}

Remove one preferred or blocked member node.
Parameters:
Name Type Description
index number Node index to remove.
type "preferred" | "blocked" Node-list type.
Source:
Throws:
When type or index is invalid
Type
Error
Returns:
The same policy instance.
Type
ReplicationPolicy

replace(index, node, type) → {ReplicationPolicy}

Replace one preferred or blocked member node.
Parameters:
Name Type Description
index number Node index to replace.
node string Replacement member node.
type "preferred" | "blocked" Node-list type.
Source:
Throws:
When type or index is invalid
Type
Error
Returns:
The same policy instance.
Type
ReplicationPolicy

toElement(doc) → {Element|null}

Serialize the replication policy to XML.
Parameters:
Name Type Description
doc XMLDocument XML document used to create elements.
Source:
Returns:
Serialized XML element, or `null` when empty.
Type
Element | null

toJSON() → {object}

Return a JSON-serializable representation of the replication policy.
Source:
Returns:
Plain replication policy data.
Type
object

validate(pathopt) → {Array.<object>}

Validate the replication policy state.
Parameters:
Name Type Attributes Default Description
path string <optional>
replicationPolicy Base path used in validation errors. Defaults to `replicationPolicy`.
Source:
Returns:
Validation errors for invalid fields.
Type
Array.<object>

fromElement(element) → {ReplicationPolicy}

Create a ReplicationPolicy from a `replicationPolicy` XML element.
Parameters:
Name Type Description
element Element XML element to parse.
Source:
Returns:
Parsed replication policy instance.
Type
ReplicationPolicy

fromValue(value) → {ReplicationPolicy}

Coerce unknown input into a ReplicationPolicy instance.
Parameters:
Name Type Description
value ReplicationPolicy | object | null | undefined Replication policy-like input.
Source:
Returns:
Normalized policy.
Type
ReplicationPolicy

parse(element, parseWarningsopt, pathopt) → {ReplicationPolicy}

Parse a `replicationPolicy` XML element, dropping it when invalid. Unknown child nodes and ordering issues are ignored silently.
Parameters:
Name Type Attributes Default Description
element Element | null XML element to parse.
parseWarnings Array.<object> <optional>
Lossy parse warnings.
path string <optional>
replicationPolicy Field path used in warnings and validation.
Source:
Returns:
Parsed policy or an empty policy when invalid.
Type
ReplicationPolicy

ReplicationPolicy(dataopt)

new ReplicationPolicy(dataopt)

Create a ReplicationPolicy instance.
Parameters:
Name Type Attributes Description
data object <optional>
Initial replication policy values.
Properties
Name Type Attributes Description
replicationAllowed boolean | string | number | null <optional>
Whether replication is allowed.
numberReplicas number | string | null <optional>
Requested replica count.
preferredNodes Array.<string> <optional>
Preferred member nodes.
blockedNodes Array.<string> <optional>
Blocked member nodes.
Source:

Methods

add(node, type) → {ReplicationPolicy}

Append one preferred or blocked member node.
Parameters:
Name Type Description
node string Member node identifier.
type "preferred" | "blocked" Node-list type.
Source:
Throws:
When type is not `preferred` or `blocked`
Type
Error
Returns:
The same policy instance.
Type
ReplicationPolicy

clear(typeopt) → {ReplicationPolicy}

Clear one or both preferred/blocked node lists and optionally the scalar policy values.
Parameters:
Name Type Attributes Description
type "preferred" | "blocked" <optional>
Node-list type to clear.
Source:
Throws:
When type is not `preferred` or `blocked`
Type
Error
Returns:
The same policy instance.
Type
ReplicationPolicy

hasValues() → {boolean}

Whether the policy contains any serialized values.
Source:
Returns:
`true` when any field is populated.
Type
boolean

normalize() → {ReplicationPolicy}

Normalize the policy in place.
Source:
Returns:
The same policy instance.
Type
ReplicationPolicy

remove(index, type) → {ReplicationPolicy}

Remove one preferred or blocked member node.
Parameters:
Name Type Description
index number Node index to remove.
type "preferred" | "blocked" Node-list type.
Source:
Throws:
When type or index is invalid
Type
Error
Returns:
The same policy instance.
Type
ReplicationPolicy

replace(index, node, type) → {ReplicationPolicy}

Replace one preferred or blocked member node.
Parameters:
Name Type Description
index number Node index to replace.
node string Replacement member node.
type "preferred" | "blocked" Node-list type.
Source:
Throws:
When type or index is invalid
Type
Error
Returns:
The same policy instance.
Type
ReplicationPolicy

toElement(doc) → {Element|null}

Serialize the replication policy to XML.
Parameters:
Name Type Description
doc XMLDocument XML document used to create elements.
Source:
Returns:
Serialized XML element, or `null` when empty.
Type
Element | null

toJSON() → {object}

Return a JSON-serializable representation of the replication policy.
Source:
Returns:
Plain replication policy data.
Type
object

validate(pathopt) → {Array.<object>}

Validate the replication policy state.
Parameters:
Name Type Attributes Default Description
path string <optional>
replicationPolicy Base path used in validation errors. Defaults to `replicationPolicy`.
Source:
Returns:
Validation errors for invalid fields.
Type
Array.<object>

fromElement(element) → {ReplicationPolicy}

Create a ReplicationPolicy from a `replicationPolicy` XML element.
Parameters:
Name Type Description
element Element XML element to parse.
Source:
Returns:
Parsed replication policy instance.
Type
ReplicationPolicy

fromValue(value) → {ReplicationPolicy}

Coerce unknown input into a ReplicationPolicy instance.
Parameters:
Name Type Description
value ReplicationPolicy | object | null | undefined Replication policy-like input.
Source:
Returns:
Normalized policy.
Type
ReplicationPolicy

parse(element, parseWarningsopt, pathopt) → {ReplicationPolicy}

Parse a `replicationPolicy` XML element, dropping it when invalid. Unknown child nodes and ordering issues are ignored silently.
Parameters:
Name Type Attributes Default Description
element Element | null XML element to parse.
parseWarnings Array.<object> <optional>
Lossy parse warnings.
path string <optional>
replicationPolicy Field path used in warnings and validation.
Source:
Returns:
Parsed policy or an empty policy when invalid.
Type
ReplicationPolicy