Loading TOC...

cma:apply-config

cma:apply-config(
   $config as (binary()|node())*,
   [$config-options as map:map?],
   [$params as map:map?],
   [$format as xs:string?]
) as (empty-seq|node())

Summary

Apply a named configuration, overriding parameters and setting options.

Parameters
config A zip file or xml|json configuration to be applied.
config-options Configuration options control how the configuration is applied. This function supports the following configuration options:
name
The configuration profile name to be run, for example "myClusterTestConfig".
format
The configuration format; the value supplied in the $format parameter of the function overrides this value. The allowed values are xml | json. The default value is xml.
resource-type
The resource type the configuration applies to. The allowed values are: "forest", "database", "server", "group", "user", "role".
resource-id
The list of specific resources' identifiers to apply the configuration to. The value is string array, for example ["resource-id1", "resource-id2", ...].
resource-name
The regular expression to select specific resources by their names, for example "ha-*".
params Scenario-specific values for parameters to override default values when the configuration is applied. See Usage Notes for details.
format The response format. The allowed values are empty sequence or xml | json. The default value is xml.

Usage Notes

This function applies a named configuration, overriding parameters and setting options.

The default namespace for configuration packages is http://marklogic.com/manage/config.

XML root element:
<configuration xmlns="http://marklogic.com/manage/config">
      

The available core scenarios are summarized below. The details on each scenario follow.

HA Local Failover

Local disk failover provides High Availability (HA) by replicating forest data to other hosts. When any particular host goes down, forests' replicas will mount on the other hosts.

The parameters for HA Local Failover scenario are:

replica-same-zone-as-master
Create forests on hosts in the same zone. The allowed values are true or false. The default value is true.
master-database
Create if does not exist, add replicas (if none exist). The value is string, for example "myHADatabase".
triggers-database
Create if does not exist, add replicas (if none exist). The value is string, for example "myHATriggers".
schemas-database
Create if does not exist, add replicas (if none exist). The value is string, for example "myHASchemas".
security-database
When defined, will attempt to add replicas to xdmp:security-database() (if none exist). The value is string, for example "Security".
add-replica-to-existing-forests
When set to false - no attempt is made to add replicas; when set to true - replicas will be added to the forest, with total summing up to number-of-replicas-per-forest. The allowed values are true or false. The default value is false.
number-of-master-forests
Calculated number of master forests. The value is positive integer.
number-of-replicas-per-forest
Calculated number of replicas per forest. The value is positive integer.
number-of-forests-per-host
Calculated based on number of available hosts, equally balance forests across hosts. The value is positive integer.
master-data-directory
Data directory used by master forests. The value is string, for example "/tmp" (e.g. returned by xdmp:data-directory()) function call).
master-fast-data-directory
Fast directory used by master forests. The value is string, for example "/tmp".
master-large-data-directory
Large directory used by master forests. The value is string, for example "/tmp".
master-replica-data-directory
Data directory used by master forest replicas. The value is string, for example "/tmp".
master-replica-fast-data-directory
Fast directory used by master forest replicas. The value is string, for example "/tmp".
master-replica-large-data-directory
Large directory used by master forest replicas. The value is string, for example "/tmp".

Example

(: Apply configuration to create three forests. :)
xquery version "1.0-ml";
import module namespace cma="http://marklogic.com/manage/config"
   at "/MarkLogic/cma.xqy";
cma:apply-config(
    <configuration xmlns="http://marklogic.com/manage/config">
      <configs>
        <config>
          <forests>
            <forest>
              <forest-name>f11</forest-name>
            </forest>
            <forest>
              <forest-name>f21</forest-name>
            </forest>
            <forest>
              <forest-name>f31</forest-name>
            </forest>
          </forests>
        </config>
      </configs>
    </configuration>)
    

Example

(: Apply configuration ZIP. :)
xquery version "1.0-ml";
import module namespace cma="http://marklogic.com/manage/config"
   at "/MarkLogic/cma.xqy";
cma:apply-config($zip)
    

Example

(: Create server embedding tokens for replacement by parameters. :)
xquery version "1.0-ml";
 
import module namespace cma="http://marklogic.com/manage/config"
at "/MarkLogic/cma.xqy";
 
let $config := <configuration xmlns="http://marklogic.com/manage/config">
    <configs>
      <config>
      <servers>
        <server>
          <server-name>test1</server-name>
          <server-type>http</server-type>
          <group-name>Default</group-name>
          <root>/</root>
          <port>%%mlFinalPort%%</port>
          <modules-database>Modules</modules-database>
          <content-database>Documents</content-database>
          <authentication>basic</authentication>
        </server>
      </servers>
      </config>
    </configs>
  </configuration>
 
let $params := map:new()
        =>map:with("mlFinalPort", 8011)
     
return cma:apply-config($config,(),$params)
    

Example

(: Create protected-paths and query-rolesets. :)
xquery version "1.0-ml";
 
import module namespace cma="http://marklogic.com/manage/config"
at "/MarkLogic/cma.xqy";
 
let $config := <configuration xmlns="http://marklogic.com/manage/config">
    <configs>
      <config>
      <protected-paths>
        <protected-path>
            <path-expression>//h</path-expression>
            <path-namespaces/>
            <permissions>
               <permission>
                  <role-name>manage-user</role-name>
                  <capability>read</capability>
               </permission>
            </permissions>
        </protected-path>
      </protected-paths>
      <query-rolesets>
        <query-roleset>
          <role-name>manage-admin</role-name>
        </query-roleset>
      </query-rolesets>
      </config>
    </configs>
  </configuration>
     
return cma:apply-config($config)
    

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.