|
|
flexrep:configuration-target-set-immediate-push(
|
|
$cfg as element(flexrep:configuration),
|
|
$target-id as xs:unsignedLong,
|
|
$immediate-push as xs:boolean
|
| ) as element(flexrep:configuration) |
|
 |
Summary:
Set a target's "immediate push" flag. This defaults to true when a target
is created. Normally, when a document is created or updated, flexrep will
attempt to replicate it to all push targets from a single CPF action, and
a single database transaction. When many targets are configured, there is
a danger that this transaction will run for a long time and eventually
time out. The "immmediate push" flag allows control over which targets
should have documents replicated immediately, and which targets should
have them replicated via the periodic retry scheduled task.
Query-based targets are always handled by the periodic retry scheduled
task.
|
Parameters:
$cfg
:
The replication configuration.
|
$target-id
:
The target ID.
|
$immediate-push
:
True if the target should attempt to push from the CPF action, false
if it should only be pushed from the retry task.
|
|
Example:
xquery version "1.0-ml";
import module namespace flexrep = "http://marklogic.com/xdmp/flexible-replication"
at "/MarkLogic/flexrep.xqy";
flexrep:configuration-insert(
flexrep:configuration-target-set-immediate-push(
$cfg, $target-id, fn:false()))
|
|
|
|
flexrep:document-reset(
|
|
$uri as xs:string,
|
|
$domain-id as xs:unsignedLong,
|
|
[$target-ids as xs:unsignedLong*]
|
| ) as empty-sequence() |
|
 |
Summary:
This function resets the URI status for all replication targets.
A reset involves retaining any record of last success, clearing any failure status, and
setting the time for the next replication attempt to the current time. The status is reset
for the specified $target-ids. If no $target-ids parameter is
specified, then the URI status for all replication targets is reset.
Resetting the URI status for a target is useful if the document has errored out due to too
many failures, or if you want to replicate the document again.
|
Parameters:
$uri
:
The URI to be assigned the new status.
|
$domain-id
:
The ID of the replicated domain.
|
$target-ids
(optional):
The ID of the replication target.
|
|
Example:
xquery version "1.0-ml";
import module namespace flexrep = "http://marklogic.com/xdmp/flexible-replication"
at "/MarkLogic/flexrep.xqy";
(: Obtain the domain ID from the database used by the Master to enable CPF. :)
let $domain := xdmp:eval(
'xquery version "1.0-ml";
import module namespace dom = "http://marklogic.com/cpf/domains"
at "/MarkLogic/cpf/domains.xqy";
fn:data(dom:get( "Replicated Content" )//dom:domain-id)',
(),
<options xmlns="xdmp:eval">
<database>{xdmp:database("MyTriggers")}</database>
</options>)
let $cfg := flexrep:configuration-get($domain, fn:true())
let $target-id := flexrep:configuration-target-get-id($cfg, "Replica")
return
flexrep:document-reset("http://localhost:8011/", $domain, $target-id)
(: Resets the URI status for the "Replica" target. :)
http://marklogic.com/xdmp/privileges/flexrep-user
|
|
|
|
flexrep:domain-status(
|
|
$domain-id as xs:unsignedLong,
|
|
[$with-targets as xs:boolean],
|
|
[$terse as xs:boolean]
|
| ) as element(flexrep:domain-status) |
|
 |
Summary:
This function returns the replication status for the specified
replicated CPF domain.
|
Parameters:
$domain-id
:
The ID of the replicated domain.
|
$with-targets
(optional):
Set to true to include status information for each target.
Otherwise set to false.
|
$terse
(optional):
Set to true to prevent counts from being returned for
each of the individual states (deleted, error, updated, and so on).
Otherwise set to false.
|
|
Example:
xquery version "1.0-ml";
import module namespace flexrep = "http://marklogic.com/xdmp/flexible-replication"
at "/MarkLogic/flexrep.xqy";
(: Obtain the domain ID from the database used by the Master to enable CPF. :)
let $domain := xdmp:eval(
'xquery version "1.0-ml";
import module namespace dom = "http://marklogic.com/cpf/domains"
at "/MarkLogic/cpf/domains.xqy";
fn:data(dom:get( "Replicated Content" )//dom:domain-id)',
(),
<options xmlns="xdmp:eval">
<database>{xdmp:database("MyTriggers")}</database>
</options>)
let $cfg := flexrep:configuration-get($domain, fn:true())
let $target-id := flexrep:configuration-target-get-id($cfg, "Replica")
return flexrep:domain-status($domain, fn:true(), fn:false())
(: Returns the status of the domain and its targets. :)
http://marklogic.com/xdmp/privileges/flexrep-user
|
|
|
|
flexrep:domain-target-reset(
|
|
$domain-id as xs:unsignedLong,
|
|
$target-ids as xs:unsignedLong*,
|
|
[$errors-only as xs:boolean]
|
| ) as empty-sequence() |
|
 |
Summary:
This function resets the URI status for the specified replication targets.
A reset involves retaining any record of last success, clearing any failure status, and
setting the time for the next replication attempt to the current time. The status is reset
for the specified $target-ids.
Resetting the URI status for a target is useful if the document has errored out due to too
many failures, or if you want to replicate the document again.
|
Parameters:
$domain-id
:
The ID of the replicated domain.
|
$target-ids
:
The ID of the replication target.
|
$errors-only
(optional):
When set to true, only reset the status for documents with errors.
The default is false.
|
|
Example:
xquery version "1.0-ml";
import module namespace flexrep = "http://marklogic.com/xdmp/flexible-replication"
at "/MarkLogic/flexrep.xqy";
(: Obtain the domain ID from the database used by the Master to enable CPF. :)
let $domain := xdmp:eval(
'xquery version "1.0-ml";
import module namespace dom = "http://marklogic.com/cpf/domains"
at "/MarkLogic/cpf/domains.xqy";
fn:data(dom:get( "Replicated Content" )//dom:domain-id)',
(),
<options xmlns="xdmp:eval">
<database>{xdmp:database("MyTriggers")}</database>
</options>)
let $cfg := flexrep:configuration-get($domain, fn:true())
let $target-id := flexrep:configuration-target-get-id($cfg, "Replica")
return flexrep:domain-target-reset($domain, ($target-id))
(: Resets the URI status for the "Replica" target. :)
http://marklogic.com/xdmp/privileges/flexrep-admin
|
|
|
|
flexrep:inbound-filter-insert(
|
|
$filter as element(flexrep:inbound-filter)
|
| ) as empty-sequence() |
|
 |
Summary:
This function inserts an inbound filter configuration into the database.
A single inbound filter applies to all inbound flexible replication to
the database. The filter receives two external variables as input, and
should return the filtered form of the replication information. An example
is shown below.
|
Parameters:
$filter
:
An inbound filter configuration.
|
|
Example:
xquery version "1.0-ml";
import module namespace flexrep = "http://marklogic.com/xdmp/flexible-replication"
at "/MarkLogic/flexrep.xqy";
flexrep:inbound-filter-insert(
flexrep:inbound-filter-create(
"/my-inbound-filter.xqy",
<flexrep:filter-options xmlns="xdmp:eval">
<modules>{xdmp:database("my-modules-database")}</modules>
<root>/some/directory/</root>
</flexrep:filter-options>))
The following example shows an identity filter, that also inserts a log
document into the database to track the inbound replication information.
xquery version "1.0-ml";
import module
namespace flexrep = "http://marklogic.com/xdmp/flexible-replication"
at "/MarkLogic/flexrep.xqy";
declare namespace doc = "xdmp:document-load";
declare variable $dts as element(flexrep:domain-target-status) external;
declare variable $update as node()* external;
xdmp:document-insert(
"/inbound-log/" || xdmp:random() || ".xml",
<inbound-log time="{fn:current-dateTime()}">
{ for $u in $update
let $exists :=
attribute exists {
fn:exists(
( fn:doc($u/doc:uri),
xdmp:document-properties($u/doc:uri)
))
}
return
typeswitch ($u)
case element(flexrep:update) return
element flexrep:update {
$exists,
$u/@*,
$u/*
}
case element (flexrep:delete) return
element flexrep:delete {
$exists,
$u/@*,
$u/*
}
default return ()
}
</inbound-log>,
("read", "update") ! xdmp:permission("flexrep-user", .)),
$update
The $dts variable can be used to determine where the inbound replication
is coming from. Below is an example. The received-from element is either
the IP address that a push is coming from, or the URL that was used if
the replication was the result of a pull.
<document-target-status xmlns="http://marklogic.com/xdmp/flexible-replication">
<domain-id>82381923712932</domain-id>
<domain-name>Default Documents</domain-name>
<target-id>637261830239283</target-id>
<target-name>San Francisco</target-name>
<received-from>10.100.42.3</received-from>
<received-at>2014-11-20T16:14:57.876111-08:00</received-at>
</document-target-status>
http://marklogic.com/xdmp/privileges/flexrep-admin
|
|
|
|
flexrep:process(
|
|
$domain-id as xs:unsignedLong,
|
|
[$size as xs:unsignedInt?],
|
|
[$targets as xs:unsignedLong*],
|
|
[$forest-ids as xs:unsignedLong*],
|
|
[$uris as xs:string*]
|
| ) as element(flexrep:results) |
|
 |
Summary:
This function processes one or more replicated updates for the specified
domain ID, ordered by oldest changes first, and returns the results.
|
Parameters:
$domain-id
:
The ID of the replicated domain.
|
$size
(optional):
The maximum number of replications. If not specified, the maximum is
one.
|
$targets
(optional):
The IDs of the replication targets.
|
$forest-ids
(optional):
The forest IDs from which to process replications. If none are
specified, replications from all forests are considered.
|
$uris
(optional):
The URIs of specific documents to process.
|
|
Example:
xquery version "1.0-ml";
import module namespace flexrep = "http://marklogic.com/xdmp/flexible-replication"
at "/MarkLogic/flexrep.xqy";
(: Obtain the domain ID from the database used by the Master to enable CPF. :)
let $domain := xdmp:eval(
'xquery version "1.0-ml";
import module namespace dom = "http://marklogic.com/cpf/domains"
at "/MarkLogic/cpf/domains.xqy";
fn:data(dom:get( "Replicated Content" )//dom:domain-id)',
(),
<options xmlns="xdmp:eval">
<database>{xdmp:database("MyTriggers")}</database>
</options>)
return flexrep:process($domain)
(: Processes the replicated updates for the "Replicated Content" domain. :)
|
|
|
|
flexrep:target-create(
|
|
$cfg as element(flexrep:configuration),
|
|
$name as xs:string,
|
|
$urls as xs:string*,
|
|
$retry-seconds-min as xs:unsignedInt?,
|
|
$retry-seconds-max as xs:unsignedInt?,
|
|
$documents-per-batch as xs:unsignedInt?,
|
|
$enabled as xs:boolean?,
|
|
$http-options as element(flexrep:http-options)?,
|
|
$replicate-cpf as xs:boolean?,
|
|
$filter-module as xs:string?,
|
|
$filter-options as element(flexrep:filter-options)?,
|
|
[$user-id as xs:unsignedLong?],
|
|
[$immediate-push as xs:boolean]
|
| ) as element(flexrep:configuration) |
|
 |
Summary:
This function creates a new target and add it to the specified
configuration. A random ID is chosen for the target. You must subsequently use
flexrep:configuration-insert to write the modified configuration
into the database.
|
Parameters:
$cfg
:
The configuration to which to add the target.
|
$name
:
The name of the target.
|
$urls
:
The URLs to be used to push replicated content to, with the load spread
across them if there is more than one. If none are specified, the target is expected to
do a pull.
|
$retry-seconds-min
:
The minimum time to wait before scheduling a push retry.
|
$retry-seconds-max
:
The maximum time to wait before scheduling a push retry.
|
$documents-per-batch
:
The number of documents to attempt to replicate from a
single invocation of the scheduled replication task.
|
$enabled
:
Specifies whether or not this target is enabled.
|
$http-options
:
The HTTP options in XML format.
|
$replicate-cpf
:
Determines whether to replicate CPF. Set to fn:true to replicate CPF. Otherwise
set to fn:false. In most circumstances, you will not want to replicate CPF.
|
$filter-module
:
A main module to filter replication attempts.
|
$filter-options
:
The options to pass to the filter module.
|
$user-id
(optional):
The user ID if this is a query-based target.
|
$immediate-push
(optional):
Specifies whether to push to the query-based target immediately. The
default is fn:true().
|
|
Example:
xquery version "1.0-ml";
import module namespace flexrep = "http://marklogic.com/xdmp/flexible-replication"
at "/MarkLogic/flexrep.xqy";
(: Obtain the ID of the replicated CPF domain from the Triggers database. :)
let $domain:= xdmp:eval(
'xquery version "1.0-ml";
import module namespace dom = "http://marklogic.com/cpf/domains"
at "/MarkLogic/cpf/domains.xqy";
fn:data(dom:get( "Replicated Content" )//dom:domain-id)',
(),
<options xmlns="xdmp:eval">
<database>{xdmp:database("MyTriggers")}</database>
</options>)
(: Obtain the replication configuration. :)
let $cfg := flexrep:configuration-get($domain, fn:true())
(: Specify the HTTP options for the replication target. :)
let $http-options :=
<flexrep:http-options
xmlns:flexrep="http://marklogic.com/xdmp/flexible-replication">
<http:authentication xmlns:http="xdmp:http">
<http:username>admin</http:username>
<http:password>admin</http:password>
</http:authentication>
<http:client-cert xmlns:http="xdmp:http"/>
<http:client-key xmlns:http="xdmp:http"/>
<http:pass-phrase xmlns:http="xdmp:http"/>
</flexrep:http-options>
(: Create the replication target. :)
let $cfg := flexrep:target-create(
$cfg,
"Replica",
"http://localhost:8011/",
60,
300,
10,
fn:true(),
$http-options,
fn:false(),
(),
() )
(: Insert the changes to the replication configuration. :)
return flexrep:configuration-insert($cfg)
(: Creates a replication target, named "Replica." :)
|
|
|