[Bps-public-commit] r12436 - in Prophet/trunk: .
jesse at bestpractical.com
jesse at bestpractical.com
Sat May 17 05:30:10 EDT 2008
Author: jesse
Date: Sat May 17 05:30:09 2008
New Revision: 12436
Modified:
Prophet/trunk/ (props changed)
Prophet/trunk/lib/Prophet/Replica.pm
Log:
r31101 at dhcp113 (orig r12370): sartak | 2008-05-16 18:05:10 +0900
r55956 at onn: sartak | 2008-05-16 05:04:55 -0400
Replica->find_or_create_luid and its subclassable methods
Modified: Prophet/trunk/lib/Prophet/Replica.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/Replica.pm (original)
+++ Prophet/trunk/lib/Prophet/Replica.pm Sat May 17 05:30:09 2008
@@ -488,6 +488,41 @@
sub latest_sequence_no {return undef }
+=head2 find_or_create_luid { uuid => UUID }
+
+Finds or creates a LUID for the given UUID.
+
+=cut
+
+sub find_or_create_luid {
+ my $self = shift;
+ my %args = validate( @_, { uuid => 1 } );
+
+ my $mapping = $self->_read_guid2luid_mappings;
+
+ if (!exists($mapping->{ $args{'uuid'} })) {
+ $mapping->{ $args{'uuid'} } = $self->_create_luid($mapping);
+ $self->_write_guid2luid_mappings($mapping);
+ }
+
+ return $mapping->{ $args{'uuid'} };
+}
+
+sub _create_luid {
+ my $self = shift;
+ my $map = shift;
+
+ return ++$map->{'_maximum_luid'};
+}
+
+sub _read_guid2luid_mappings {
+ Carp::confess "Someone has failed to implement a '_read_guid2luid_mappings' method for their replica type.";
+}
+
+sub _write_guid2luid_mappings {
+ Carp::confess "Someone has failed to implement a '_write_guid2luid_mappings' method for their replica type.";
+}
+
=head2 traverse_changesets { after => SEQUENCE_NO, callback => sub {} }
Walk through each changeset in the replica after SEQUENCE_NO, calling the C<callback> for each one in turn.
More information about the Bps-public-commit
mailing list