示例#1
0
    def run(self):
        try:
            self.oplogs['backup'] = Oplog(self.mongodump_oplog['file'],
                                          self.do_gzip(), 'a+',
                                          self.flush_docs, self.flush_secs)
            self.oplogs['tailed'] = Oplog(self.tailed_oplog['file'],
                                          self.do_gzip())
            logging.info("Resolving oplog for %s to max ts: %s" %
                         (self.uri, self.max_end_ts))
            self.state.set('running', True)
            self.state.set('first_ts', self.mongodump_oplog['first_ts'])
            if not self.state.get('first_ts'):
                self.state.set('first_ts', self.tailed_oplog['first_ts'])
            for change in decode_file_iter(
                    self.oplogs['tailed'],
                    CodecOptions(unicode_decode_error_handler="ignore")):
                self.last_ts = change['ts']
                if not self.mongodump_oplog[
                        'last_ts'] or self.last_ts > self.mongodump_oplog[
                            'last_ts']:
                    if self.last_ts < self.max_end_ts:
                        self.oplogs['backup'].add(change)
                        self.changes += 1
                    elif self.last_ts > self.max_end_ts:
                        break

            self.state.set('count',
                           self.mongodump_oplog['count'] + self.changes)
            self.state.set('last_ts', self.last_ts)
            self.state.set('running', False)
            self.exit_code = 0
        except Exception, e:
            raise Error("Resolving of oplogs failed! Error: %s" % e)
 def oplog(self):
     if not self._oplog:
         self._oplog = Oplog(
             self.oplog_file,
             self.dump_gzip,
             'w+',
             self.flush_docs,
             self.flush_secs
         )
     return self._oplog
示例#3
0
 def oplog(self):
     if not self._oplog:
         self._oplog = Oplog(self.oplog_file, self.dump_gzip, 'w+')
     return self._oplog