I have a process that has to sync up a database between a master server and a
number of remote servers before submitting tasks to those servers. In some
cases the sync may be a complete copy of the database, which can take an hour
or more to sync. In many cases the sync will either be unnecessary or a quick
sync of a few updated docs.
My task submission process cycles through the pool of remote servers, checking
their general status and submitting tasks to them.
However, I don't want to submit any tasks until any flexrep syncs are done.
I've worked out this function:
declare function er:is-flexrep-in-progress(
$server
)
{
let $domain-ids := flexrep:configuration-domain-ids()
let $missing-counts as xs:integer* :=
for $domain-id in $domain-ids
let $cfg := flexrep:configuration-get($domain-id)
let $targets := flexrep:configuration-targets($cfg)
return
for $target in $targets
let $target-id as xs:unsignedLong := $target/flexrep:target-id
let $status := flexrep:target-status($domain-id, $target-id)
let $target-name as xs:string := $status/flexrep:target-name
let $missing-count := xs:integer($status/flexrep:missing-count)
return
if (contains($target-name, $server) and $missing-count gt 0)
then $missing-count
else 0
let $result := sum($missing-counts) gt 0
return $result
};
But it's kind of slow--in my initial profiling through qconsole it could take
as much as 800 ms and typically took about 500 ms. The time could be an
unavoidable side effect of having 100s of 1000s of fragments in this db--my
profiling showed that most of time came from doing 1000s of small operations
down in the flexrep code.
I'm wondering if there's a better or more efficient way to determine if flexrep
is still in progress?
Thanks,
E.
--
Eliot Kimber
http://contrext.com
_______________________________________________
General mailing list
[email protected]
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general