[Bps-public-commit] r17546 - in sd/trunk/lib/App/SD: . Replica Replica/hm Replica/rt

jesse at bestpractical.com jesse at bestpractical.com
Sun Jan 4 16:28:33 EST 2009


Author: jesse
Date: Sun Jan  4 16:28:33 2009
New Revision: 17546

Modified:
   sd/trunk/lib/App/SD/ForeignReplica.pm
   sd/trunk/lib/App/SD/Replica/debbugs.pm
   sd/trunk/lib/App/SD/Replica/debbugs/PushEncoder.pm
   sd/trunk/lib/App/SD/Replica/hm/PushEncoder.pm
   sd/trunk/lib/App/SD/Replica/rt/PushEncoder.pm

Log:
* some renaming toward being able to keep track of per-record transaction count when pulling from remote


Modified: sd/trunk/lib/App/SD/ForeignReplica.pm
==============================================================================
--- sd/trunk/lib/App/SD/ForeignReplica.pm	(original)
+++ sd/trunk/lib/App/SD/ForeignReplica.pm	Sun Jan  4 16:28:33 2009
@@ -42,16 +42,15 @@
 
 
 
-sub _txn_storage {
+sub _changeset_id_storage {
     my $self = shift;
-    return $self->state_handle->metadata_storage( $TXN_METATYPE,
-        'prophet-txn-source' );
+    return $self->state_handle->metadata_storage( $TXN_METATYPE, 'prophet-txn-source' );
 }
 
 sub prophet_has_seen_transaction {
     my $self = shift;
     my ($id) = validate_pos( @_, 1 );
-    return $self->_txn_storage->( $self->uuid . '-txn-' . $id );
+    return $self->_changeset_id_storage->( $self->uuid . '-txn-' . $id );
 }
 
 sub record_pushed_transaction {
@@ -59,7 +58,7 @@
     my %args = validate( @_,
         { transaction => 1, changeset => { isa => 'Prophet::ChangeSet' } } );
 
-    $self->_txn_storage->(
+    $self->_changeset_id_storage->(
         $self->uuid . '-txn-' . $args{transaction},
         join( ':',
             $args{changeset}->original_source_uuid,
@@ -86,28 +85,35 @@
 
 }
 
+=head2 uuid_for_remote_id $id
+
+lookup the uuid for the remote record id. If we don't find it, 
+construct it out of the remote url and the remote uri path for the record id;
+
+=cut
+
+
 sub uuid_for_remote_id {
     my ( $self, $id ) = @_;
+
+
     return $self->_lookup_uuid_for_remote_id($id)
-        || $self->uuid_for_url(
-        $self->remote_url . $self->remote_uri_path_for_id($id) );
+        || $self->uuid_for_url( $self->remote_url . $self->remote_uri_path_for_id($id) );
 }
 
 sub _lookup_uuid_for_remote_id {
     my $self = shift;
     my ($id) = validate_pos( @_, 1 );
 
-    return $self->_remote_id_storage(
-        $self->uuid_for_url(
-            $self->remote_url . $self->remote_uri_path_for_id($id)
-        )
+    return $self->_remote_record_id_storage(
+        $self->uuid_for_url( $self->remote_url . $self->remote_uri_path_for_id($id))
     );
 }
 
 sub _set_uuid_for_remote_id {
     my $self = shift;
     my %args = validate( @_, { uuid => 1, remote_id => 1 } );
-    return $self->_remote_id_storage(
+    return $self->_remote_record_id_storage(
         $self->uuid_for_url(
                   $self->remote_url
                 . $self->remote_uri_path_for_id( $args{'remote_id'} )
@@ -116,10 +122,10 @@
     );
 }
 
-# This cache stores uuids for tickets we've synced from a remote RT
+# This mapping table stores uuids for tickets we've synced from a remote database
 # Basically, if we created the ticket to begin with, then we'll know its uuid
-# if we pulled the ticket from RT then its uuid will be generated based on a UUID-from-ticket-url scheme
-# This cache is PERMANENT. - aka not a cache but a mapping table
+# if we pulled the ticket from the foreign replica then its uuid will be generated
+# based on a UUID-from-ticket-url scheme
 
 sub remote_id_for_uuid {
     my ( $self, $uuid_or_luid ) = @_;
@@ -159,8 +165,15 @@
 }
 
 
-# XXX TODO, rename this
-sub record_pushed_ticket {
+=head2 record_remote_id_for_pushed_record
+
+When pushing a record created within the prophet cloud to a foreign replica, we
+need to do bookkeeping to record the prophet uuid to remote id mapping.
+
+=cut
+
+
+sub record_remote_id_for_pushed_record {
     my $self = shift;
     my %args = validate(
         @_,

Modified: sd/trunk/lib/App/SD/Replica/debbugs.pm
==============================================================================
--- sd/trunk/lib/App/SD/Replica/debbugs.pm	(original)
+++ sd/trunk/lib/App/SD/Replica/debbugs.pm	Sun Jan  4 16:28:33 2009
@@ -27,20 +27,6 @@
 
 sub record_pushed_transactions {}
 
-# XXX record_pushed_tikcet should go up to the base class
-
-sub record_pushed_ticket {
-    my $self = shift;
-    my %args = validate(
-        @_,
-        {   uuid      => 1,
-            remote_id => 1,
-        }
-    );
-    $self->_set_uuid_for_remote_id(%args);
-    $self->_set_remote_id_for_uuid(%args);
-}
-
 __PACKAGE__->meta->make_immutable;
 no Moose;
 1;

Modified: sd/trunk/lib/App/SD/Replica/debbugs/PushEncoder.pm
==============================================================================
--- sd/trunk/lib/App/SD/Replica/debbugs/PushEncoder.pm	(original)
+++ sd/trunk/lib/App/SD/Replica/debbugs/PushEncoder.pm	Sun Jan  4 16:28:33 2009
@@ -28,7 +28,7 @@
     )
         {
             $id = $self->integrate_ticket_create( $change, $changeset );
-            $self->sync_source->record_pushed_ticket(
+            $self->sync_source->record_remote_id_for_pushed_record(
                 uuid      => $change->record_uuid,
                 remote_id => $id
             );

Modified: sd/trunk/lib/App/SD/Replica/hm/PushEncoder.pm
==============================================================================
--- sd/trunk/lib/App/SD/Replica/hm/PushEncoder.pm	(original)
+++ sd/trunk/lib/App/SD/Replica/hm/PushEncoder.pm	Sun Jan  4 16:28:33 2009
@@ -48,7 +48,7 @@
     )
         {
             $id = $self->integrate_ticket_create( $change, $changeset );
-            $self->sync_source->record_pushed_ticket(
+            $self->sync_source->record_remote_id_for_pushed_record(
                 uuid      => $change->record_uuid,
                 remote_id => $id
             );

Modified: sd/trunk/lib/App/SD/Replica/rt/PushEncoder.pm
==============================================================================
--- sd/trunk/lib/App/SD/Replica/rt/PushEncoder.pm	(original)
+++ sd/trunk/lib/App/SD/Replica/rt/PushEncoder.pm	Sun Jan  4 16:28:33 2009
@@ -22,7 +22,7 @@
     )
         {
             $id = $self->integrate_ticket_create( $change, $changeset );
-            $self->sync_source->record_pushed_ticket(
+            $self->sync_source->record_remote_id_for_pushed_record(
                 uuid      => $change->record_uuid,
                 remote_id => $id
             );



More information about the Bps-public-commit mailing list