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

jesse at bestpractical.com jesse at bestpractical.com
Sun Jan 4 17:46:18 EST 2009


Author: jesse
Date: Sun Jan  4 17:46:18 2009
New Revision: 17552

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

Log:
* a bit of renaming and doc


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 17:46:18 2009
@@ -4,29 +4,6 @@
 
 extends 'Prophet::ForeignReplica';
 
-=head2 prophet_has_seen_foreign_transaction $transaction_id $foreign_record_id
-
-Given an transaction id, will return true if this transaction originated in Prophet 
-and was pushed to RT or originated in RT and has already been pulled to the prophet replica.
-
-
-This is a mapping of all the transactions we have pushed to the
-remote replica we'll only ever care about remote sequence #s greater
-than the last transaction # we've pulled from the remote replica
-once we've done a pull from the remote replica, we can safely expire
-all records of this type for the remote replica (they'll be
-obsolete)
-
-We use this cache to avoid integrating changesets we've pushed to the remote replica when doing a subsequent pull
-
-=cut
-
-sub prophet_has_seen_foreign_transaction {
-    my $self = shift;
-    my ($id, $record) = validate_pos( @_, 1, 1);
-    return $self->_changeset_id_storage->( $self->uuid . '-txn-' . $id );
-}
-
 
 =head2 integrate_change $change $changeset
 
@@ -60,17 +37,23 @@
 
 
 my $TXN_METATYPE = 'txn-source';
-sub _changeset_id_storage {
+sub _foreign_txn_id_storage {
     my $self = shift;
     return $self->state_handle->metadata_storage( $TXN_METATYPE, 'prophet-txn-source' );
 }
 
+=head2 record_pushed_transaction $foreign_transaction_id, $changeset
+
+Record that this replica was the original source of $foreign_transaction_id (with changeset $changeset)
+
+=cut
+
 sub record_pushed_transaction {
     my $self = shift;
     my %args = validate( @_,
         { transaction => 1, changeset => { isa => 'Prophet::ChangeSet' } } );
 
-    $self->_changeset_id_storage->(
+    $self->_foreign_txn_id_storage->(
         $self->uuid . '-txn-' . $args{transaction},
         join( ':',
             $args{changeset}->original_source_uuid,
@@ -78,6 +61,30 @@
     );
 }
 
+=head2 prophet_has_seen_foreign_transaction $transaction_id $foreign_record_id
+
+Given an transaction id, will return true if this transaction originated in Prophet 
+and was pushed to RT or originated in RT and has already been pulled to the prophet replica.
+
+
+This is a mapping of all the transactions we have pushed to the
+remote replica we'll only ever care about remote sequence #s greater
+than the last transaction # we've pulled from the remote replica
+once we've done a pull from the remote replica, we can safely expire
+all records of this type for the remote replica (they'll be
+obsolete)
+
+We use this cache to avoid integrating changesets we've pushed to the 
+remote replica when doing a subsequent pull
+
+=cut
+
+sub prophet_has_seen_foreign_transaction {
+    my $self = shift;
+    my ($id, $record) = validate_pos( @_, 1, 1);
+    return $self->_foreign_txn_id_storage->( $self->uuid . '-txn-' . $id );
+}
+
 sub traverse_changesets {
     my $self = shift;
     my %args = validate( @_,

Modified: sd/trunk/lib/App/SD/Replica/hm/PullEncoder.pm
==============================================================================
--- sd/trunk/lib/App/SD/Replica/hm/PullEncoder.pm	(original)
+++ sd/trunk/lib/App/SD/Replica/hm/PullEncoder.pm	Sun Jan  4 17:46:18 2009
@@ -102,8 +102,12 @@
     my $txns = $self->sync_source->hm->search( 'TaskTransaction', task_id => $args{task} ) || [];
     my @matched;
     for my $txn (@$txns) {
-        next if $txn->{'id'} < $args{'starting_transaction'};    # Skip things we've pushed
 
+        # Skip things we know we don't want
+        next if $txn->{'id'} < $args{'starting_transaction'};    
+        
+        
+        # Skip things we've pushed
         next if $self->sync_source->prophet_has_seen_foreign_transaction( $txn->{'id'}, $args{task} );
 
         $txn->{history_entries} = $self->sync_source->hm->search( 'TaskHistory', transaction_id => $txn->{'id'} );

Modified: sd/trunk/lib/App/SD/Replica/rt/PullEncoder.pm
==============================================================================
--- sd/trunk/lib/App/SD/Replica/rt/PullEncoder.pm	(original)
+++ sd/trunk/lib/App/SD/Replica/rt/PullEncoder.pm	Sun Jan  4 17:46:18 2009
@@ -138,8 +138,13 @@
     my $rt_handle = $self->sync_source->rt;
 
     for my $txn ( sort $rt_handle->get_transaction_ids( parent_id => $args{'ticket'} ) ) {
-        next if $txn < $args{'starting_transaction'}; # Skip things we've pushed
+        # Skip things we know we've already pulled
+        next if $txn < $args{'starting_transaction'}; 
+        
+        # Skip things we've pushed
         next if $self->sync_source->prophet_has_seen_foreign_transaction($txn, $args{'ticket'});
+
+
         my $txn_hash = $rt_handle->get_transaction(
             parent_id => $args{'ticket'},
             id        => $txn,



More information about the Bps-public-commit mailing list