Example #1
0
 def phase_2_continuous_migrate_interactive(self):
     last_seq = self.last_seq
     replicator = ContinuousReplicator(self.source_db, self.target_db,
                                       self.doc_types)
     changes = stream_changes_forever(db=self.source_db, since=last_seq)
     count = 0
     for change in changes:
         if change is Ellipsis:
             # all caught up
             if last_seq != self.last_seq:
                 replicator.commit()
                 self._record_seq(last_seq)
             yield StatusUpdate(changes_read=count,
                                last_seq=last_seq,
                                caught_up=True)
         else:
             count += 1
             last_seq = change.seq
             replicator.replicate_change(change)
             if replicator.should_commit():
                 replicator.commit()
                 self._record_seq(last_seq)
                 yield StatusUpdate(changes_read=count,
                                    last_seq=last_seq,
                                    caught_up=False)
Example #2
0
    def test_continuous_replicator(self):
        replicator = ContinuousReplicator(
            self.migration.source_db, self.migration.target_db, self.migration.doc_types)
        for i, doc in enumerate(self.docs):
            change = CouchChange(seq=i, id=doc['_id'], rev=doc['_rev'], deleted=False)
            replicator.replicate_change(change)
        replicator.commit()
        self.assert_in_sync()

        for i, doc in enumerate(self.docs):
            # deleted=true changes contain a theoretical "next rev" of the deleted doc
            # that is completely useless, replicate_change has to work without it
            change = CouchChange(seq=i, id=doc['_id'], rev='go f**k yourself', deleted=True)
            replicator.replicate_change(change)
        replicator.commit()
        self.assert_no_docs_in_target_db()
Example #3
0
    def test_continuous_replicator(self):
        replicator = ContinuousReplicator(
            self.migration.source_db, self.migration.target_db, self.migration.doc_types)
        for i, doc in enumerate(self.docs):
            change = CouchChange(seq=i, id=doc['_id'], rev=doc['_rev'], deleted=False)
            replicator.replicate_change(change)
        replicator.commit()
        self.assert_in_sync()

        for i, doc in enumerate(self.docs):
            # deleted=true changes contain a theoretical "next rev" of the deleted doc
            # that is completely useless, replicate_change has to work without it
            change = CouchChange(seq=i, id=doc['_id'], rev='go f**k yourself', deleted=True)
            replicator.replicate_change(change)
        replicator.commit()
        self.assert_no_docs_in_target_db()
Example #4
0
 def phase_2_continuous_migrate_interactive(self):
     last_seq = self.last_seq
     replicator = ContinuousReplicator(self.source_db, self.target_db, self.doc_types)
     changes = stream_changes_forever(db=self.source_db, since=last_seq)
     count = 0
     for change in changes:
         if change is Ellipsis:
             # all caught up
             if last_seq != self.last_seq:
                 replicator.commit()
                 self._record_seq(last_seq)
             yield StatusUpdate(changes_read=count, last_seq=last_seq, caught_up=True)
         else:
             count += 1
             last_seq = change.seq
             replicator.replicate_change(change)
             if replicator.should_commit():
                 replicator.commit()
                 self._record_seq(last_seq)
                 yield StatusUpdate(changes_read=count, last_seq=last_seq, caught_up=False)