- Timestamp:
- 12/23/08 13:33:08 (11 months ago)
- Location:
- branches/empty-files/server
- Files:
-
- 5 modified
-
lib/MogileFS/DevFID.pm (modified) (1 diff)
-
lib/MogileFS/HTTPFile.pm (modified) (1 diff)
-
lib/MogileFS/Worker/Query.pm (modified) (3 diffs)
-
lib/MogileFS/Worker/Replicate.pm (modified) (2 diffs)
-
t/00-startup.t (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/empty-files/server/lib/MogileFS/DevFID.pm
r1147 r1242 72 72 my $self = shift; 73 73 my $fid = $self->fid; 74 my $disk_size = $self->size_on_disk 75 or return 0; 74 my $disk_size = $self->size_on_disk; 75 76 return 0 if $disk_size == MogileFS::HTTPFile::FILE_MISSING; 77 76 78 return $disk_size == $fid->length; 77 79 } -
branches/empty-files/server/lib/MogileFS/HTTPFile.pm
r1198 r1242 120 120 # returns 0 on file missing (404 or -1 from sidechannel), 121 121 # returns undef on connectivity error 122 use constant FILE_MISSING => 0;122 use constant FILE_MISSING => -1; 123 123 sub size { 124 124 my $self = shift; -
branches/empty-files/server/lib/MogileFS/Worker/Query.pm
r1239 r1242 9 9 use MogileFS::Util qw(error error_code first weighted_list 10 10 device_state eurl decode_url_args); 11 use MogileFS::HTTPFile; 11 12 12 13 sub new { … … 386 387 my $size = MogileFS::HTTPFile->at($path)->size; 387 388 388 if ($args->{size} > 0 && ! $size) {389 # size is either: 0 (file doesn't exist) or undef (host unreachable)389 if ($args->{size} >= 0 && (!defined($size) || $size == MogileFS::HTTPFile::FILE_MISSING)) { 390 # size check has been requested and that storage node is unreachable or the file is missing 390 391 my $type = defined $size ? "missing" : "cantreach"; 391 392 my $lasterr = MogileFS::Util::last_error(); … … 397 398 398 399 # TODO: check for EIO? 399 return $self->err_line("empty_file") unless $size;400 400 401 401 # insert file_on row -
branches/empty-files/server/lib/MogileFS/Worker/Replicate.pm
r1238 r1242 838 838 $clen = $1; 839 839 } 840 return $error_unreachable->("File $spath has a content-length of 0; unable to replicate")841 unless $clen;842 840 return $error_unreachable->("File $spath has unexpected content-length of $clen, not $expected_clen") 843 841 if defined $expected_clen && $clen != $expected_clen; … … 857 855 my $finished_read = 0; 858 856 859 while (!$pipe_closed && (my $bytes = $sock->read($data, $bytes_to_read))) { 860 # now we've read in $bytes bytes 861 $remain -= $bytes; 862 $bytes_to_read = $remain if $remain < $bytes_to_read; 863 864 my $wbytes = $dsock->send($data); 865 $written += $wbytes; 866 return $dest_error->("Error: wrote $wbytes; expected to write $bytes; failed putting to $dpath") 867 unless $wbytes == $bytes; 868 $intercopy_cb->(); 869 870 die if $bytes_to_read < 0; 871 next if $bytes_to_read; 857 if ($bytes_to_read) { 858 while (!$pipe_closed && (my $bytes = $sock->read($data, $bytes_to_read))) { 859 # now we've read in $bytes bytes 860 $remain -= $bytes; 861 $bytes_to_read = $remain if $remain < $bytes_to_read; 862 863 my $wbytes = $dsock->send($data); 864 $written += $wbytes; 865 return $dest_error->("Error: wrote $wbytes; expected to write $bytes; failed putting to $dpath") 866 unless $wbytes == $bytes; 867 $intercopy_cb->(); 868 869 die if $bytes_to_read < 0; 870 next if $bytes_to_read; 871 $finished_read = 1; 872 last; 873 } 874 } else { 875 # 0 byte file copy. 872 876 $finished_read = 1; 873 last;874 877 } 875 878 return $dest_error->("closed pipe writing to destination") if $pipe_closed; -
branches/empty-files/server/t/00-startup.t
r1169 r1242 21 21 my $sto = eval { temp_store(); }; 22 22 if ($sto) { 23 plan tests => 59;23 plan tests => 64; 24 24 } else { 25 25 plan skip_all => "Can't create temporary test database: $@"; … … 109 109 } 110 110 111 { 112 my $fh = $mogc->new_file('no_content', "2copies"); 113 ok(close($fh), "closed file"); 114 } 115 116 { 117 my $fh = $mogc->new_file('no_content', "2copies"); 118 ok(close($fh), "closed file"); 119 } 120 121 # wait for it to replicate 122 ok(try_for(10, sub { 123 my @urls = $mogc->get_paths("no_content"); 124 my $nloc = @urls; 125 if ($nloc < 2) { 126 diag("no_content still only on $nloc devices"); 127 return 0; 128 } 129 return 1; 130 }), "replicated to 2 paths"); 131 132 ok(try_for(3, sub { 133 my $to_repl_rows = $dbh->selectrow_array("SELECT COUNT(*) FROM file_to_replicate"); 134 return $to_repl_rows == 0; 135 }), "no more files to replicate"); 136 137 # quick delete test 138 ok($mogc->delete("no_content"), "deleted no_content") 139 or die "Error: " . $mogc->errstr; 140 111 141 # create two sample files 112 142 my $data = "My test file.\n" x 1024;
