[Bps-public-commit] r11750 - in Prophet/trunk: . lib/Prophet/Replica
jesse at bestpractical.com
jesse at bestpractical.com
Wed Apr 16 10:54:15 EDT 2008
Author: jesse
Date: Wed Apr 16 10:54:10 2008
New Revision: 11750
Modified:
Prophet/trunk/ (props changed)
Prophet/trunk/lib/Prophet/Replica/Native.pm
Prophet/trunk/lib/Prophet/ReplicaExporter.pm
Log:
r29753 at 31b: jesse | 2008-04-16 10:49:22 -0400
* more work toward having a local native replica type
Modified: Prophet/trunk/lib/Prophet/Replica/Native.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/Replica/Native.pm (original)
+++ Prophet/trunk/lib/Prophet/Replica/Native.pm Wed Apr 16 10:54:10 2008
@@ -42,14 +42,14 @@
my $self = shift;
my %args = validate( @_, { db_uuid => 0 } );
- $self->cas_root( dir( $self->fs_root => 'cas' ) );
+ $self->cas_root( dir( 'cas' ) );
$self->record_cas_dir( dir( $self->cas_root => 'records' ) );
$self->changeset_cas_dir( dir( $self->cas_root => 'changesets' ) );
- $self->record_dir( dir( $self->fs_root => 'records' ) );
+ $self->record_dir( dir( 'records' ) );
- _mkdir($_) for ( $self->fs_root, $self->record_dir, $self->cas_root );
- make_tiered_dirs( $self->record_cas_dir );
- make_tiered_dirs( $self->changeset_cas_dir );
+ _mkdir(dir($self->fs_root, $_)) for ('', $self->record_dir, $self->cas_root );
+ $self->make_tiered_dirs( $self->record_cas_dir );
+ $self->make_tiered_dirs( $self->changeset_cas_dir );
$self->set_latest_sequence_no("1");
$self->set_replica_uuid( Data::UUID->new->create_str );
@@ -92,8 +92,8 @@
my $self = shift;
my %args = validate( @_, { type => 1, uuid => 1, props =>1});
- my $record_root = dir( $self->fs_root, $self->_record_type_root($args{'type'}));
- make_tiered_dirs($record_root) unless -d $record_root;
+ my $record_root = dir( $self->_record_type_root($args{'type'}));
+ $self->make_tiered_dirs($record_root) unless -d dir($self->fs_root, $record_root);
my $content = YAML::Syck::Dump( $args{'props'});
my ($cas_key) = $self->_write_to_cas(
@@ -144,7 +144,7 @@
sub _record_type_root {
my $self = shift;
my $type = shift;
- return dir( 'records', $type);
+ return dir($self->record_dir, $type);
}
@@ -251,12 +251,13 @@
}
sub make_tiered_dirs {
+ my $self = shift;
my $base = shift;
- _mkdir( dir($base) );
+ _mkdir( dir($self->fs_root, $base) );
for my $a ( 0 .. 9, 'a' .. 'f' ) {
- _mkdir( dir( $base => $a ) );
+ _mkdir( dir( $self->fs_root, $base => $a ) );
for my $b ( 0 .. 9, 'a' .. 'f' ) {
- _mkdir( dir( $base => $a => $b ) );
+ _mkdir( dir($self->fs_root, $base => $a => $b ) );
}
}
@@ -268,7 +269,7 @@
my $content = ${ $args{'content_ref'} };
my $fingerprint = sha1_hex($content);
my $content_filename
- = file( $args{'cas_dir'}, substr( $fingerprint, 0, 1 ), substr( $fingerprint, 1, 1 ), $fingerprint );
+ = file( $self->fs_root, $args{'cas_dir'}, substr( $fingerprint, 0, 1 ), substr( $fingerprint, 1, 1 ), $fingerprint );
$self->_write_file( path => $content_filename, content => $content );
return $fingerprint;
@@ -315,10 +316,19 @@
my %args = validate( @_, { uuid => 1, type => 1 } );
# Write out an entry to the record's index file marking it as a special deleted uuid?
}
-sub set_record_props {
- my $self = shift;
- my %args = validate( @_, { uuid => 1, props => 1, type => 1 } );
+sub set_record_props {
+ my $self = shift;
+ my %args = validate( @_, { uuid => 1, props => 1, type => 1 } );
+ my %old_props = $self->get_record_props( uuid => $args{'uuid'}, type => $args{'type'} );
+ foreach my $prop ( %{ $args{props} } ) {
+ if ( !defined $args{props}->{$prop} ) {
+ delete $old_props{$prop};
+ } else {
+ $old_props{$prop} = $args{props}->{$prop};
+ }
+ }
+ $self->_write_serialized_record( type => $args{'type'}, uuid => $args{'uuid'}, props => \%old_props );
}
sub get_record_props {
my $self = shift;
@@ -334,9 +344,14 @@
sub list_records {
my $self = shift;
my %args = validate( @_ => { type => 1 } );
+ my @records = File::Find::Rule->file->in(dir($self->fs_root,$self->_record_type_root($args{'type'})))->maxdepth(3);
+ die "have not yet dealt with what's in ". at records;
}
sub list_types {
my $self = shift;
+ my @types = File::Find::Rule->file->in(dir($self->fs_root, $self->record_dir))->maxdepth(1);
+ die "have not post-processed ". at types;
+
}
sub type_exists {
my $self = shift;
Modified: Prophet/trunk/lib/Prophet/ReplicaExporter.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/ReplicaExporter.pm (original)
+++ Prophet/trunk/lib/Prophet/ReplicaExporter.pm Wed Apr 16 10:54:10 2008
@@ -8,7 +8,7 @@
use UNIVERSAL::require;
__PACKAGE__->mk_accessors(
- qw( source_replica target_path fs_root target_replica cas_root record_cas_dir changeset_cas_dir record_dir));
+ qw( source_replica target_path target_replica));
=head1 NAME
More information about the Bps-public-commit
mailing list