diff options
author | jbj <devnull@localhost> | 2004-10-16 01:31:54 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2004-10-16 01:31:54 +0000 |
commit | d03f220fde879509cab2ac1c73b71b7efb52b737 (patch) | |
tree | 1e34bfadac0a6618d0e9a7933bad90063a785acf /db/test/rep036script.tcl | |
parent | 2dc699bfe049b9319ea3719f604d25940ff52004 (diff) | |
download | librpm-tizen-d03f220fde879509cab2ac1c73b71b7efb52b737.tar.gz librpm-tizen-d03f220fde879509cab2ac1c73b71b7efb52b737.tar.bz2 librpm-tizen-d03f220fde879509cab2ac1c73b71b7efb52b737.zip |
... and in with the New ...
CVS patchset: 7471
CVS date: 2004/10/16 01:31:54
Diffstat (limited to 'db/test/rep036script.tcl')
-rw-r--r-- | db/test/rep036script.tcl | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/db/test/rep036script.tcl b/db/test/rep036script.tcl new file mode 100644 index 000000000..85d612677 --- /dev/null +++ b/db/test/rep036script.tcl @@ -0,0 +1,107 @@ +# See the file LICENSE for redistribution information. +# +# Copyright (c) 2004 +# Sleepycat Software. All rights reserved. +# +# $Id: rep036script.tcl,v 11.2 2004/09/22 18:01:06 bostic Exp $ +# +# Rep036 script - create additional writers in master env. +# +# Usage: masterdir writerid +# masterdir: Directory of replication master +# writerid: i.d. number for writer +source ./include.tcl +source $test_path/test.tcl +source $test_path/testutils.tcl +source $test_path/reputils.tcl + +global rand_init +set usage "repscript masterdir writerid nentries method" + +# Verify usage +if { $argc != 4 } { + puts stderr "FAIL:[timestamp] Usage: $usage" + exit +} + +# Initialize arguments +set masterdir [ lindex $argv 0 ] +set writerid [ lindex $argv 1 ] +set nentries [ lindex $argv 2 ] +set method [ lindex $argv 3 ] + +# Join the queue env. We assume the rep test convention of +# placing the messages in $testdir/MSGQUEUEDIR. +set queueenv [eval berkdb_env -home $testdir/MSGQUEUEDIR] +error_check_good script_qenv_open [is_valid_env $queueenv] TRUE +# We need to set up our own machid. +repladd 1 +repladd 2 + +# Join the master env. +set envid 1 +set env_cmd "berkdb_env_noerr -home $masterdir \ + -errfile /dev/stderr -errpfx WRITER.$writerid \ + -txn -rep_master -rep_transport \[list $envid replsend\]" +# set env_cmd "berkdb_env_noerr -home $masterdir \ +# -errfile /dev/stderr -errpfx WRITER.$writerid \ +# -verbose {rep on} \ +# -txn -rep_master -rep_transport \[list $envid replsend\]" +set masterenv [eval $env_cmd] +error_check_good script_env_open [is_valid_env $masterenv] TRUE + +# Open database. +set testfile "rep036.db" +set omethod [convert_method $method] +set mdb [eval {berkdb_open_noerr} -env $masterenv -auto_commit \ + -create $omethod $testfile] +error_check_good dbopen [is_valid_db $mdb] TRUE + +# Write records to the database. +set did [open $dict] +set count 0 +set dictsize 10000 +berkdb srand $rand_init +while { $count < $nentries } { + # + # If nentries exceeds the dictionary size, close + # and reopen to start from the beginning again. + if { [expr [expr $count + 1] % $dictsize] == 0 } { + close $did + set did [open $dict] + } + + gets $did str + set key WRITER.$writerid.$str + set str [reverse $str] + + set t [$masterenv txn] + error_check_good txn [is_valid_txn $t $masterenv] TRUE + set txn "-txn $t" + set ret [eval \ + {$mdb put} $txn {$key [chop_data $method $str]}] + error_check_good put $ret 0 + error_check_good txn [$t commit] 0 + + if { [expr $count % 100] == 1 } { + puts "Wrote WRITER.$writerid record $count" + set sleep [berkdb random_int 0 10] + puts "Writer.$writerid sleeping $sleep seconds" + tclsleep $sleep + } + incr count +} +close $did + +# Clean up. +error_check_good mdb_close [$mdb close] 0 +error_check_good masterenv_close [$masterenv close] 0 +replclose $testdir/MSGQUEUEDIR + +# Communicate with parent by creating a marker file. +set markerenv [berkdb_env -create -home $testdir -txn] +error_check_good markerenv_open [is_valid_env $markerenv] TRUE +set marker [eval "berkdb_open \ + -create -btree -auto_commit -env $markerenv $writerid.db"] +error_check_good marker_close [$marker close] 0 +error_check_good markerenv_close [$markerenv close] 0 |