Changeset 381

Show
Ignore:
Timestamp:
08/25/06 02:36:18 (2 years ago)
Author:
marksmith
Message:

* implement storing unique data in test-write file

* read back test-write file on the get_port to verify that the write was actually

a successful operation by comparing the unique data

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/server-newrepl/lib/MogileFS/Worker/Monitor.pm

    r380 r381  
    109109            my $num = int(rand 10000);  # this was "$$-$now" before, but we don't yet have a cleaner in mogstored for these files 
    110110            my $puturl = "http://$host->{hostip}:$port/dev$dev->{devid}/test-write/test-write-$num"; 
     111            my $content = "time=$now rand=$num"; 
    111112            my $req = HTTP::Request->new(PUT => $puturl); 
    112             $req->content(<<EOREQUEST); 
    113 ## THIS IS AN AUTOMATICALLY GENERATED FILE USED TO TEST WRITEABILITY AND 
    114 ## WILL BE CLEANED BY THE MOGSTORED USAGE PROCESS 
    115 EOREQUEST 
     113            $req->content($content); 
    116114 
    117             # TODO: re-check the file was written as put. 
    118             # TODO: put something unique in the file 
    119115            # TODO: guard against race-conditions with double-check on failure 
    120116 
     
    122118            my $resp = $ua->request($req); 
    123119            if ($resp->is_success) { 
    124                 $self->broadcast_device_writeable($dev->{devid}); 
    125                 error("dev$dev->{devid}: used = $used, total = $total, writeable = 1") 
    126                     if $Mgd::DEBUG >= 1; 
    127             } else { 
    128                 # merely readable 
    129                 $self->broadcast_device_readable($dev->{devid}); 
    130                 error("dev$dev->{devid}: used = $used, total = $total, writeable = 0") 
    131                     if $Mgd::DEBUG >= 1; 
     120                # now let's get it back to verify; note we use the get_port to verify that 
     121                # the distinction works (if we have one) 
     122                my $geturl = "http://$host->{hostip}:$get_port/dev$dev->{devid}/test-write/test-write-$num"; 
     123                my $testwrite = $ua->get($geturl); 
     124 
     125                # if success and the content matches, mark it writeable 
     126                if ($testwrite->is_success && $testwrite->content eq $content) { 
     127                    $self->broadcast_device_writeable($dev->{devid}); 
     128                    error("dev$dev->{devid}: used = $used, total = $total, writeable = 1") 
     129                        if $Mgd::DEBUG >= 1; 
     130                    next; 
     131                } 
     132 
    132133            } 
     134 
     135            # if we fall through to here, then we know that something is not so good, so mark it readable 
     136            # which is guaranteed given we even tested writeability 
     137            $self->broadcast_device_readable($dev->{devid}); 
     138            error("dev$dev->{devid}: used = $used, total = $total, writeable = 0") 
     139                if $Mgd::DEBUG >= 1; 
    133140        } 
    134141