version 1.4, 2006/10/13 18:34:07
|
version 1.8, 2012/02/22 17:06:42
|
Line 8 use GDBM_File;
|
Line 8 use GDBM_File;
|
use File::Find; |
use File::Find; |
use LONCAPA; |
use LONCAPA; |
use LONCAPA::Configuration; |
use LONCAPA::Configuration; |
use Cwd; |
use Fcntl qw(:flock); |
|
|
my $dump_db = '/home/httpd/perl/debug/dump_db_static_32'; |
my $dump_db = '/home/httpd/perl/debug/dump_db_static_32'; |
my $create_db = '/home/httpd/perl/debug/create_db_dynamic'; |
my $create_db = '/home/httpd/perl/debug/create_db_dynamic_64'; |
if (!-x $dump_db || !-x $create_db) { |
if (!-x $dump_db || !-x $create_db) { |
print("Unable to run needed helper programs\n $dump_db\n $create_db\n."); |
print("Unable to run needed helper programs\n $dump_db\n $create_db\n."); |
exit(-1); |
exit(-1); |
} |
} |
|
|
|
|
|
my $return_code = system("/bin/bash -c '$create_db >& /dev/null'"); |
|
# create_db exits on 1 if no filename to create was specified and is thus |
|
# a successful start and stop of the program |
|
if ($return_code == -1 |
|
|| (($return_code >> 8) != 1)) { |
|
$create_db = '/home/httpd/perl/debug/create_db_dynamic_64_so.3'; |
|
printf("booM %d %d!\n",$return_code,($return_code >> 8 )); |
|
$return_code = system("/bin/bash -c '$create_db >& /dev/null'"); |
|
if ($return_code == -1 |
|
|| (($return_code >> 8) != 1)) { |
|
printf("booM2 %d %d!\n",$return_code,($return_code >> 8 )); |
|
die("Unable to run need helper program create_db_dynamic_64"); |
|
} |
|
} |
|
|
my %perlvar=%{&LONCAPA::Configuration::read_conf('loncapa.conf')}; |
my %perlvar=%{&LONCAPA::Configuration::read_conf('loncapa.conf')}; |
|
|
my $do_locks = 1; |
my $do_locks = 1; |
Line 46 sub count_db {
|
Line 62 sub count_db {
|
} |
} |
|
|
my $done=0; |
my $done=0; |
|
my $skip=0; |
my $starttime; |
my $starttime; |
my $last_100_start_time; |
my $last_100_start_time; |
sub process_db { |
sub process_db { |
Line 54 sub process_db {
|
Line 71 sub process_db {
|
my $file = $_; |
my $file = $_; |
my $dbref =&lock_db($file); |
my $dbref =&lock_db($file); |
#print("attempting $file\n"); |
#print("attempting $file\n"); |
system("$dump_db -f $file|$create_db -f $file.new"); |
system("/bin/bash -c '$dump_db -f $file|$create_db -f $file.new'"); |
# print("finishing $dbref\n"); |
# print("finishing $dbref\n"); |
rename($file,"$file.old"); |
rename($file,"$file.old"); |
rename("$file.new","$file"); |
rename("$file.new","$file"); |
&unlock_db($dbref); |
&unlock_db($dbref); |
|
} else { |
|
#print("skip $_\n"); |
|
$skip++; |
} |
} |
$done++; |
$done++; |
if (!($done %100)) { |
if (!($done %100)) { |
Line 66 sub process_db {
|
Line 86 sub process_db {
|
my $took = time()-$starttime; |
my $took = time()-$starttime; |
my $togo = int(($took/$done) * ($count-$done)); |
my $togo = int(($took/$done) * ($count-$done)); |
my $total = $togo+$took; |
my $total = $togo+$took; |
my $per = $took/$done; |
my $per = ($done-$skip)?$took/($done-$skip):0; |
my $last_per = (time()-$last_100_start_time)/100; |
my $last_per = (time()-$last_100_start_time)/100; |
printf("%6d in %6d, togo %6d, overall %6d, %.4f (for one), %.4f)\n", |
printf("%6d (%6d) in %6d, togo %6d, overall %6d, %.3f (each), %.3f\n", |
$done,$took,$togo,$total,$per,$last_per); |
$done,$skip,$took,$togo,$total,$per,$last_per); |
$last_100_start_time = time(); |
$last_100_start_time = time(); |
} |
} |
} |
} |
|
|
sub main { |
sub main { |
my $dir = $perlvar{'lonUsersDir'}.'/temp/y/'; |
my $dir = $perlvar{'lonUsersDir'}; |
print("Doing $dir\n"); |
print("Doing $dir\n"); |
&find({ no_chdir => 1, |
&find({ no_chdir => 1, |
wanted => \&count_db, }, |
wanted => \&count_db, }, |