Changeset 381
- Timestamp:
- 08/25/06 02:36:18 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/server-newrepl/lib/MogileFS/Worker/Monitor.pm
r380 r381 109 109 my $num = int(rand 10000); # this was "$$-$now" before, but we don't yet have a cleaner in mogstored for these files 110 110 my $puturl = "http://$host->{hostip}:$port/dev$dev->{devid}/test-write/test-write-$num"; 111 my $content = "time=$now rand=$num"; 111 112 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); 116 114 117 # TODO: re-check the file was written as put.118 # TODO: put something unique in the file119 115 # TODO: guard against race-conditions with double-check on failure 120 116 … … 122 118 my $resp = $ua->request($req); 123 119 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 132 133 } 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; 133 140 } 134 141
