Changeset 41014
- Timestamp:
- Oct 31, 2019, 11:57:27 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20191011/Nebulous-Server/lib/Nebulous/Server.pm
r40980 r41014 12 12 13 13 use base qw( Class::Accessor::Fast ); 14 15 use Carp; 14 16 15 17 use Cache::Memcached; … … 723 725 { 724 726 type => SCALAR|UNDEF, 725 # callbacks => {726 # # check that the volume name requested is valid727 # 'is valid volume name' => sub {728 # return 1 if not defined $_[0];729 # $self->_is_valid_volume_name($_[0])730 # },731 # },732 727 optional => 1, 733 728 }, … … 737 732 738 733 # if a volume name is explicity specified then we should make the 739 # replication onto that volume (even if there is alread an instance on that734 # replication onto that volume (even if there is already an instance on that 740 735 # volume) if at all possible and throw an error if we can not. 736 741 737 # if a volume name IS NOT specified then we should make the replication 742 738 # onto any (hopefully the best) volume that DOES NOT already have an 743 # instance on it. If all av ilable volumealready have an instance on them739 # instance on it. If all available volumes already have an instance on them 744 740 # then we should throw an error 741 745 742 # volume names implied as part of the key are *IGNORED* as the source and 746 743 # *SHOULD NOT* be used as the destination either 747 744 748 745 eval { 749 $key = parse_neb_key($key); 746 # EAM 2019.10.31 : if I supply dest_vol_name here, then 747 # $key->volume will point at that volume and the section below 748 # will correctly be testing the validity of dest_vol_name 749 $key = parse_neb_key($key, $dest_vol_name); 750 750 }; 751 751 $log->logdie("$@") if $@; … … 753 753 my $db = $self->db($key); 754 754 755 ## Old comment: 755 756 # puke if the source volume is bogus, we may want to actually use this as 756 757 # the instance to be copied later 758 759 # EAM 2019.10.31 : in the past, the key-implied volume was 760 # supplied here, which was inconsistent since above it says the 761 # key-implied volume is ignored. By supplying $dest_vol_name to 762 # parse_neb_key above, the key->volume now refers to the 763 # dest_volume 757 764 if (defined $key->volume and not $self->_is_valid_volume_name($key, $key->volume)) { 758 765 unless ($key->hard_volume) { … … 762 769 } 763 770 } 771 764 772 # puke if the destination volume is bogus 765 if (defined $dest_vol_name 766 and not $self->_is_valid_volume_name($key, $dest_vol_name)) { 767 $log->logdie($key->volume . " is not a valid volume name"); 768 } 773 ## XXX if I supply dest_vol_name to parse_neb_key above, this section below is redundant with the above 774 ## if (defined $dest_vol_name 775 ## and not $self->_is_valid_volume_name($key, $dest_vol_name)) { 776 ## $log->logdie($key->volume . " is not a valid volume name"); 777 ## } 769 778 770 779 $get_storage_volume_calls = 0; … … 772 781 my ($vol_id, $vol_host, $vol_path, $vol_xattr); 773 782 if (defined $dest_vol_name) { 783 # if we supplied dest_vol_name, then the call to parse_neb_key above 784 # will have set $key->volume to that value and hard_volume to match 774 785 ($vol_id, $vol_host, $vol_path, $vol_xattr) 775 = $self->_get_storage_volume($key, $ dest_vol_name);786 = $self->_get_storage_volume($key, $key->volume, $key->hard_volume); 776 787 } else { 777 788 ($vol_id, $vol_host, $vol_path, $vol_xattr) 778 789 = $self->_get_replication_volume($key); 779 790 } 791 792 # print "selected target: $vol_id, $vol_host\n"; 780 793 781 794 my $uri; … … 1789 1802 { 1790 1803 type => SCALAR|UNDEF, 1791 # callbacks => {1792 # # check that the volume name requested is valid1793 # 'is valid volume name' => sub {1794 # return 1 if not defined $_[0];1795 # $self->_is_valid_volume_name($_[0])1796 # },1797 # },1798 1804 optional => 1, 1799 1805 }, … … 1807 1813 my $sql = $self->sql; 1808 1814 1809 # unless ($key) { 1810 # $log->warn("key was undefined after validate_pos(), trying again..."); 1811 # return $self->find_instances(@_); 1812 # } 1815 # default value for find_invalid is false 1816 if (not defined $find_invalid) { $find_invalid = 0; } 1813 1817 1814 1818 # vol_name overrides the key implied volume … … 1848 1852 my $rows; 1849 1853 # ext_id, available 1850 if (defined($find_invalid) ) {1854 if (defined($find_invalid) and $find_invalid) { 1851 1855 # XXX returns instances which are NOT available 1852 1856 $rows = $query->execute($key->path, 0); … … 1903 1907 { 1904 1908 type => SCALAR|UNDEF, 1905 # callbacks => {1906 # # check that the volume name requested is valid1907 # 'is valid volume name' => sub {1908 # return 1 if not defined $_[0];1909 # $self->_is_valid_volume_name($_[0])1910 # },1911 # },1912 1909 optional => 1, 1913 1910 }, … … 1920 1917 my $sql = $self->sql; 1921 1918 1922 # unless ($key) { 1923 # $log->warn("key was undefined after validate_pos(), trying again..."); 1924 # return $self->find_instances(@_); 1925 # } 1919 if (not defined $find_invalid) { $find_invalid = 0; } 1926 1920 1927 1921 # vol_name overrides the key implied volume … … 1991 1985 # host_vol_id host_cab_id host_site_id ext_id available 1992 1986 1993 ### XXX EAM if find_invalid is true, the last arguement here should be 0 1994 my $rows = $query->execute($h_vol_id, $h_cab_id, $h_site_id, $key->path, 1); 1987 my $rows; 1988 if (defined($find_invalid) and $find_invalid) { 1989 # returns instances which are NOT available (volume not available) 1990 $rows = $query->execute($h_vol_id, $h_cab_id, $h_site_id, $key->path, 0); 1991 } else { 1992 $rows = $query->execute($h_vol_id, $h_cab_id, $h_site_id, $key->path, 1); 1993 } 1995 1994 unless ($rows > 0) { 1996 1995 $query->finish; … … 1999 1998 } else { 2000 1999 $query = $db->prepare_cached( $sql->get_object_instances ); 2000 # ext_id, available 2001 2001 2002 my $rows; 2002 # ext_id, available 2003 if (defined($find_invalid)) { 2003 if (defined($find_invalid) and $find_invalid) { 2004 2004 # returns instances which are NOT available (volume not available) 2005 2005 $rows = $query->execute($key->path, 0); 2006 } 2007 else { 2006 } else { 2008 2007 $rows = $query->execute($key->path, 1); 2009 2008 } … … 2020 2019 my $instance = $row->{ 'uri' }; 2021 2020 push @locations, $instance if $instance; 2021 2022 # Carp::carp ("instance 2: $row->{ 'uri' }, $row->{ 'vol_id' }, $row->{ 'cab_id' }, $row->{ 'vol_idx' }\n"); 2022 2023 } 2023 2024 }; … … 2027 2028 if (defined $vol_name and not defined $key->hard_volume) { 2028 2029 $log->debug("retrying with 'any' volume"); 2029 return $self->find_instances($key->path, 'any' );2030 return $self->find_instances($key->path, 'any', $find_invalid); 2030 2031 } 2031 2032 $log->logdie("database error: $@"); … … 2463 2464 # %free, name, avaiable, allocate 2464 2465 $rows = $query->execute($max_used_space, $name, 1, 1); 2465 # XXX d estinguish between non-existant and unavailable2466 # XXX distinguish between non-existant and unavailable 2466 2467 unless ($rows > 0) { 2467 2468 $query->finish; … … 2572 2573 2573 2574 $rows = $query->execute($key->path, $max_used_space, 1, 1, $forbidden_cabinet, $forbidden_site, $topfew_count); 2574 # XXX d estinguish between non-existant and unavailable2575 # XXX distinguish between non-existant and unavailable 2575 2576 unless ($rows > 0) { 2576 2577 $query->finish;
Note:
See TracChangeset
for help on using the changeset viewer.
