MarkLogic 9 Product Documentation
cma.generateConfigcma.generateConfig(
[config as (binary()|node())?],
[config-options as Object?],
[default-params as Object?],
[format as String?],
[scenario as String?]
) as (binary()|node())
Summary
Retrieve an individual resource, set of resources, or full cluster
configuration; generate a configuration from scenarios.
Parameters |
config |
A zip file or xml|json
configuration which filters resource configurations returned by the function. |
config-options |
Configuration options
control how the configuration is created. This function supports the following configuration
options:
- name
- The configuration profile name, for example
"myClusterTestConfig" .
- desc
- The configuration description, for example
"Test configuration for my
cluster" .
- embedTokens
- Embed replacement tokens (ex. %%sometoken%%) in configuration. The allowed values
are
true or false . The default value is false
for xml|json format and true for zip format.
- includeProperties
- Include resource properties in the configuration. By default, all resource
properties are provided. If set
false - only resource name and identifier
are provided. The allowed values are true or false . The
default value is true .
- format
- The response format; the value supplied in the
$format parameter of the
function overrides this value. The allowed values are xml | json | zip .
The default value is json .
- scenario
- The scenario to generate configuration from; the value supplied in the
$scenario parameter of the function overrides this value. The allowed
values are: "ha-local", "ha-shared" .
- installer
- The type of the installer script to include (with a configuration in
zip format). Currently the only supported value is
"ml-gradle" .
- resourceType
- The resource type - for selecting/filtering resources by type. The allowed values
are:
"forest", "database", "server", "group", "user", "role" .
- resourceId
- The list of resources' identifiers to select specific resources. The value is string
array, for example:
["resource-id1", "resource-id2", ...] .
- resourceName
- The regular expression to select specific resources by their names, for example
"ha-*" .
|
default-params |
Scenario-specific default
values for parameters to be embedded into the configuration. See Usage Notes for details. |
format |
The response format. The
allowed values are xml | json | zip . The default value is json . |
scenario |
The scenario to generate the
configuration from. The allowed values are: "ha-local", "ha-shared" .
|
Usage Notes
This function retrieves selected resource(s) configuration or generates a configuration
from scenarios. Configuration options define how the configuration is generated.
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:
replicaSameZoneAsMaster
- Create forests on hosts in the same zone. The allowed values are
true
or
false
. The default value is true
.
masterDatabase
- Create if does not exist, add replicas (if none exist). The value is string, for
example
"myHADatabase"
.
triggersDatabase
- Create if does not exist, add replicas (if none exist). The value is string, for
example
"myHATriggers"
.
schemasDatabase
- Create if does not exist, add replicas (if none exist). The value is string, for
example
"myHASchemas"
.
securityDatabase
- When defined, will attempt to add replicas to xdmp:security-database() (if none
exist) if create-security-database-replicas is set to
true
.
addReplicaToExistingForests
- 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
.
createSecurityDatabaseReplicas
- When set to
true
, will create replicas for security database. Note that
this is particularly dangerous when uninstalling a package. The default value is
false
.
numberOfMasterForests
- Calculated number of master forests. The value is positive integer.
numberOfAncillaryForests
- Number of master forests for ancillary databases (e.g. triggers and schemas
databases). The value is positive integer.
numberOfReplicasPerMasterForest
- Calculated number of replicas per master forest. The value is positive integer.
numberOfReplicasPerAncillaryForest
- Calculated number of replicas per ancillary forest. The value is positive
integer.
numberOfMasterForestsPerHost
- When set overrides
number-of-forests-per-host
, arbitrarily setting
absolute number of master forests per host. The value is positive integer.
numberOfForestsPerHost
- Calculated based on number of available hosts, equally balance forests across hosts.
The value is positive integer.
masterDataDirectory
- Data directory used by master forests. The value is string, for example
"/tmp"
(e.g. returned by xdmp:data-directory())
function
call).
masterFastDataDirectory
- Fast directory used by master forests. The value is string, for example
"/tmp"
.
masterLargeDataDirectory
- Large directory used by master forests. The value is string, for example
"/tmp"
.
masterReplicaDataDirectory
- Data directory used by master forest replicas. The value is string, for example
"/tmp"
.
masterReplicaFastDataDirectory
- Fast directory used by master forest replicas. The value is string, for example
"/tmp"
.
masterReplicaLargeDataDirectory
- Large directory used by master forest replicas. The value is string, for example
"/tmp"
.
Example
// Generate configuration of the entire cluster.
'use strict';
const cma = require('/MarkLogic/cma.sjs');
cma.generateConfig();
Example
// Generate configuration, selecting all forests with resourceType configuration option.
'use strict';
const cma = require('/MarkLogic/cma.sjs');
cma.generateConfig({},{"resourceType":"forest"});
Example
// Generate configuration JSON of ha-local scenario.
'use strict';
const cma = require('/MarkLogic/cma.sjs');
cma.generateConfig({},{},{},"json","ha-local");
Example
// Generate configuration XML of ha-local scenario where replicas will be added to the existing forests.
'use strict';
const cma = require('/MarkLogic/cma.sjs');
cma.generateConfig(null,null,{"numberOfForestsPerHost":3},"xml","ha-local");
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.