MogileFS-Server

 view release on metacpan or  search on metacpan

lib/MogileFS/FID.pm  view on Meta::CPAN

sub _tryload {
    return 1 if $_[0]{_loaded};
    my $self = shift;
    my $row = Mgd::get_store()->file_row_from_fidid($self->{fidid})
        or return 0;
    $self->{$_} = $row->{$_} foreach qw(dmid dkey length classid devcount);
    $self->{_loaded} = 1;
    return 1;
}

sub update_devcount {
    my ($self, %opts) = @_;

    my $no_lock = delete $opts{no_lock};
    croak "Bogus options" if %opts;

    return 1 if MogileFS::Config->server_setting_cached('skip_devcount');

    my $fidid = $self->{fidid};

    my $sto = Mgd::get_store();
    if ($no_lock) {
        return $sto->update_devcount($fidid);
    } else {
        return $sto->update_devcount_atomic($fidid);
    }
}

sub update_class {
    my ($self, %opts) = @_;

    my $classid = delete $opts{classid};
    croak "Bogus options" if %opts;

    my $sto = Mgd::get_store();
    return $sto->update_classid($self->{fidid}, $classid);
}

sub enqueue_for_replication {

lib/MogileFS/Store.pm  view on Meta::CPAN

            if ($dbh->{AutoCommit} == 0) { eval { $dbh->rollback }; }
            throw("dup");
        }
    }
    $self->condthrow; # this will rollback on errors
    return $clsid if $rv;
    die;
}

# return 1 on success, throw "dup" on duplicate name error, die otherwise
sub update_class_name {
    my $self = shift;
    my %arg  = $self->_valid_params([qw(dmid classid classname)], @_);
    my $rv = eval {
        $self->dbh->do("UPDATE class SET classname=? WHERE dmid=? AND classid=?",
                       undef, $arg{classname}, $arg{dmid}, $arg{classid});
    };
    throw("dup") if $self->was_duplicate_error;
    $self->condthrow;
    return 1;
}

# return 1 on success, die otherwise
sub update_class_mindevcount {
    my $self = shift;
    my %arg  = $self->_valid_params([qw(dmid classid mindevcount)], @_);
    eval {
    $self->dbh->do("UPDATE class SET mindevcount=? WHERE dmid=? AND classid=?",
                   undef, $arg{mindevcount}, $arg{dmid}, $arg{classid});
    };
    $self->condthrow;
    return 1;
}

# return 1 on success, die otherwise
sub update_class_replpolicy {
    my $self = shift;
    my %arg  = $self->_valid_params([qw(dmid classid replpolicy)], @_);
    eval {
    $self->dbh->do("UPDATE class SET replpolicy=? WHERE dmid=? AND classid=?",
                   undef, $arg{replpolicy}, $arg{dmid}, $arg{classid});
    };
    $self->condthrow;
    return 1;
}

# return 1 on success, die otherwise
sub update_class_hashtype {
    my $self = shift;
    my %arg  = $self->_valid_params([qw(dmid classid hashtype)], @_);
    eval {
    $self->dbh->do("UPDATE class SET hashtype=? WHERE dmid=? AND classid=?",
                   undef, $arg{hashtype}, $arg{dmid}, $arg{classid});
    };
    $self->condthrow;
}

sub nfiles_with_dmid_classid_devcount {

lib/MogileFS/Store/SQLite.pm  view on Meta::CPAN

    }

    return $sql;
}

# eh.  this is really atomic at all, but a) this is a demo db module,
# nobody should use SQLite in production, b) this method is going
# away, c) everything in SQLite is pretty atomic anyway with the
# db-level locks, d) the devcount field is no longer used.  so i'm not
# caring much about doing this correctly.
sub update_devcount_atomic {
    my ($self, $fidid) = @_;
    $self->update_devcount($fidid);
}

# SQLite is just for testing, so don't upgrade
sub upgrade_add_device_drain {
    return 1;
}
sub upgrade_modify_server_settings_value { 1 }
sub upgrade_add_file_to_queue_arg { 1 }

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.675 second using v1.00-cache-2.02-grep-82fe00e-cpan-4673cadbf75 )