IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 41014


Ignore:
Timestamp:
Oct 31, 2019, 11:57:27 AM (7 years ago)
Author:
eugene
Message:

replicate_object should pass dest_vol_name to parse_neb_key so they hard_volume status is correctly assessed; treat find_invalid as a boolean (previously it was treated as true if defined even as 0); if find_instaces is passed find_invalid = TRUE, the ensure this is passed to nested calls to find_instance

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20191011/Nebulous-Server/lib/Nebulous/Server.pm

    r40980 r41014  
    1212
    1313use base qw( Class::Accessor::Fast );
     14
     15use Carp;
    1416
    1517use Cache::Memcached;
     
    723725        {
    724726            type        => SCALAR|UNDEF,
    725 #            callbacks   => {
    726 #                # check that the volume name requested is valid
    727 #                'is valid volume name' => sub {
    728 #                    return 1 if not defined $_[0];
    729 #                    $self->_is_valid_volume_name($_[0])
    730 #                },
    731 #            },
    732727            optional    => 1,
    733728        },
     
    737732
    738733    # 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 that
     734    # replication onto that volume (even if there is already an instance on that
    740735    # volume) if at all possible and throw an error if we can not.
     736
    741737    # if a volume name IS NOT specified then we should make the replication
    742738    # onto any (hopefully the best) volume that DOES NOT already have an
    743     # instance on it.  If all avilable volume already have an instance on them
     739    # instance on it.  If all available volumes already have an instance on them
    744740    # then we should throw an error
     741
    745742    # volume names implied as part of the key are *IGNORED* as the source and
    746743    # *SHOULD NOT* be used as the destination either
    747744
    748745    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);
    750750    };
    751751    $log->logdie("$@") if $@;
     
    753753    my $db  = $self->db($key);
    754754
     755    ## Old comment:
    755756    # puke if the source volume is bogus, we may want to actually use this as
    756757    # 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
    757764    if (defined $key->volume and not $self->_is_valid_volume_name($key, $key->volume)) {
    758765        unless ($key->hard_volume) {
     
    762769        }
    763770    }
     771
    764772    # 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    ## }
    769778
    770779    $get_storage_volume_calls = 0;
     
    772781    my ($vol_id, $vol_host, $vol_path, $vol_xattr);
    773782    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
    774785        ($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);
    776787    } else {
    777788        ($vol_id, $vol_host, $vol_path, $vol_xattr)
    778789            = $self->_get_replication_volume($key);
    779790    }
     791
     792    # print "selected target: $vol_id, $vol_host\n";
    780793
    781794    my $uri;
     
    17891802        {
    17901803            type        => SCALAR|UNDEF,
    1791 #            callbacks   => {
    1792 #                # check that the volume name requested is valid
    1793 #                'is valid volume name' => sub {
    1794 #                    return 1 if not defined $_[0];
    1795 #                    $self->_is_valid_volume_name($_[0])
    1796 #                },
    1797 #            },
    17981804            optional    => 1,
    17991805        },
     
    18071813    my $sql = $self->sql;
    18081814
    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; }
    18131817
    18141818    # vol_name overrides the key implied volume
     
    18481852            my $rows;
    18491853            # ext_id, available
    1850             if (defined($find_invalid)) {
     1854            if (defined($find_invalid) and $find_invalid) {
    18511855                # XXX returns instances which are NOT available
    18521856                $rows = $query->execute($key->path, 0);
     
    19031907        {
    19041908            type        => SCALAR|UNDEF,
    1905 #            callbacks   => {
    1906 #                # check that the volume name requested is valid
    1907 #                'is valid volume name' => sub {
    1908 #                    return 1 if not defined $_[0];
    1909 #                    $self->_is_valid_volume_name($_[0])
    1910 #                },
    1911 #            },
    19121909            optional    => 1,
    19131910        },
     
    19201917    my $sql = $self->sql;
    19211918
    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; }
    19261920
    19271921    # vol_name overrides the key implied volume
     
    19911985            # host_vol_id host_cab_id host_site_id ext_id available
    19921986
    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            }           
    19951994            unless ($rows > 0) {
    19961995                $query->finish;
     
    19991998        } else {
    20001999            $query = $db->prepare_cached( $sql->get_object_instances );
     2000            # ext_id, available
     2001
    20012002            my $rows;
    2002             # ext_id, available
    2003             if (defined($find_invalid)) {
     2003            if (defined($find_invalid) and $find_invalid) {
    20042004                # returns instances which are NOT available (volume not available)
    20052005                $rows = $query->execute($key->path, 0);
    2006             }
    2007             else {
     2006            } else {
    20082007                $rows = $query->execute($key->path, 1);
    20092008            }
     
    20202019            my $instance = $row->{ 'uri' };
    20212020            push @locations, $instance if $instance;
     2021
     2022            # Carp::carp ("instance 2: $row->{ 'uri' }, $row->{ 'vol_id' }, $row->{ 'cab_id' }, $row->{ 'vol_idx' }\n");
    20222023        }
    20232024    };
     
    20272028        if (defined $vol_name and not defined $key->hard_volume) {
    20282029            $log->debug("retrying with 'any' volume");
    2029             return $self->find_instances($key->path, 'any');
     2030            return $self->find_instances($key->path, 'any', $find_invalid);
    20302031        }
    20312032        $log->logdie("database error: $@");
     
    24632464            # %free, name, avaiable, allocate
    24642465            $rows = $query->execute($max_used_space, $name, 1, 1);
    2465             # XXX destinguish between non-existant and unavailable
     2466            # XXX distinguish between non-existant and unavailable
    24662467            unless ($rows > 0) {
    24672468                $query->finish;
     
    25722573
    25732574        $rows = $query->execute($key->path, $max_used_space, 1, 1, $forbidden_cabinet, $forbidden_site, $topfew_count);
    2574         # XXX destinguish between non-existant and unavailable
     2575        # XXX distinguish between non-existant and unavailable
    25752576        unless ($rows > 0) {
    25762577            $query->finish;
Note: See TracChangeset for help on using the changeset viewer.