Package londiste :: Module playback :: Class Replicator
[frames] | no frames]

Class Replicator

source code

                 object --+            
                          |            
skytools.scripting.DBScript --+        
                              |        
          pgq.consumer.Consumer --+    
                                  |    
        pgq.consumer.SerialConsumer --+
                                      |
                                     Replicator
Known Subclasses:
table_copy.CopyTable, file_write.FileWrite

Replication core.

Instance Methods
 
__init__(self, args) source code
 
change_table_state(self, dst_db, tbl, state, tick_id=None) source code
 
fill_mirror_queue(self, ev_list, dst_curs) source code
 
flush_sql(self, dst_curs) source code
 
get_table_by_name(self, name) source code
 
get_table_by_state(self, state)
get first table with specific state
source code
 
handle_data_event(self, ev, dst_curs) source code
 
handle_events(self, dst_curs, ev_list)
Actual event processing happens here.
source code
 
handle_seqs(self, dst_curs) source code
 
handle_system_event(self, ev, dst_curs)
System event.
source code
 
interesting(self, ev) source code
 
launch_copy(self, tbl_stat) source code
 
load_table_state(self, curs)
Load table state from database.
source code
 
process_remote_batch(self, src_db, batch_id, ev_list, dst_db)
All work for a batch.
source code
 
remove_table(self, tbl, dst_curs) source code
 
save_table_state(self, curs)
Store changed table state in database.
source code
 
sync_from_copy_thread(self, cnt, dst_db)
Copy thread sync logic.
source code
 
sync_from_main_thread(self, cnt, dst_db)
Main thread sync logic.
source code
 
sync_tables(self, dst_db)
Table sync loop.
source code

Inherited from pgq.consumer.SerialConsumer: attach, clean_completed_tick, detach, dst_reset, init_optparse, is_batch_done, process_batch, rewind, set_batch_done, startup

Inherited from pgq.consumer.Consumer: get_batch_info, process_event, register_consumer, stat_end, stat_start, unregister_consumer, work

Inherited from skytools.scripting.DBScript: close_database, get_database, hook_sighup, hook_sigint, reload, reset, run, run_once, send_signal, send_stats, set_single_loop, start, stat_add, stat_increase, stat_put, stop

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Class Variables
  cur_tick = 0
  prev_tick = 0
  sql_command = {'D': 'delete from only %s where %s;', 'I': 'ins...

Inherited from skytools.scripting.DBScript: cf, job_name, log, service_name

Properties

Inherited from object: __class__

Method Details

__init__(self, args)
(Constructor)

source code 
Overrides: pgq.consumer.SerialConsumer.__init__

load_table_state(self, curs)

source code 

Load table state from database.

Todo: if all tables are OK, there is no need to load state on every batch.

process_remote_batch(self, src_db, batch_id, ev_list, dst_db)

source code 
All work for a batch. Entry point from SerialConsumer.
Overrides: pgq.consumer.SerialConsumer.process_remote_batch

sync_tables(self, dst_db)

source code 

Table sync loop.

Calls appropriate handles, which is expected to return one of SYNC_* constants.

Class Variable Details

sql_command

Value:
{'D': 'delete from only %s where %s;',
 'I': 'insert into %s %s;',
 'U': 'update only %s set %s;'}