예제 #1
0
    def finish_remote_batch(self, src_db, dst_db, tick_id):
        """Worker-specific cleanup on target node.
        """

        # merge-leaf on branch should not update tick pos
        wst = self._worker_state
        if wst.wait_behind:
            dst_db.commit()
            return

        if self.main_worker:
            st = self._worker_state
            dst_curs = dst_db.cursor()

            self.flush_events(dst_curs)

            # send tick event into queue
            if st.send_tick_event:
                q = "select pgq.insert_event(%s, 'pgq.tick-id', %s, %s, null, null, null)"
                dst_curs.execute(q, [st.target_queue, str(tick_id), self.pgq_queue_name])

        CascadedConsumer.finish_remote_batch(self, src_db, dst_db, tick_id)

        if self.main_worker:
            if st.create_tick:
                # create actual tick
                tick_id = self.batch_info['tick_id']
                tick_time = self.batch_info['batch_end']
                self.create_branch_tick(dst_db, tick_id, tick_time)
예제 #2
0
    def finish_remote_batch(self, src_db, dst_db, tick_id):
        """Worker-specific cleanup on target node.
        """

        # merge-leaf on branch should not update tick pos
        wst = self._worker_state
        if wst.wait_behind:
            dst_db.commit()
            return

        if self.main_worker:
            st = self._worker_state
            dst_curs = dst_db.cursor()

            self.flush_events(dst_curs)

            # send tick event into queue
            if st.send_tick_event:
                q = "select pgq.insert_event(%s, 'pgq.tick-id', %s, %s, null, null, null)"
                dst_curs.execute(
                    q, [st.target_queue,
                        str(tick_id), self.pgq_queue_name])

        CascadedConsumer.finish_remote_batch(self, src_db, dst_db, tick_id)

        if self.main_worker:
            if st.create_tick:
                # create actual tick
                tick_id = self.batch_info['tick_id']
                tick_time = self.batch_info['batch_end']
                self.create_branch_tick(dst_db, tick_id, tick_time)
예제 #3
0
    def finish_remote_batch(self, src_db, dst_db, tick_id):
        """Worker-specific cleanup on target node.
        """

        if self.main_worker:
            st = self._worker_state
            dst_curs = dst_db.cursor()

            self.flush_events(dst_curs)

            # send tick event into queue
            if st.send_tick_event:
                q = "select pgq.insert_event(%s, 'pgq.tick-id', %s, %s, null, null, null)"
                dst_curs.execute(
                    q, [st.target_queue,
                        str(tick_id), self.pgq_queue_name])
            if st.create_tick:
                # create actual tick
                tick_id = self._batch_info['tick_id']
                tick_time = self._batch_info['batch_end']
                q = "select pgq.ticker(%s, %s, %s, %s)"
                dst_curs.execute(
                    q,
                    [self.pgq_queue_name, tick_id, tick_time, self.cur_max_id])

        CascadedConsumer.finish_remote_batch(self, src_db, dst_db, tick_id)
예제 #4
0
    def finish_remote_batch(self, src_db, dst_db, tick_id):
        """Worker-specific cleanup on target node.
        """

        if self.main_worker:
            st = self._worker_state
            dst_curs = dst_db.cursor()

            self.flush_events(dst_curs)

            # send tick event into queue
            if st.send_tick_event:
                q = "select pgq.insert_event(%s, 'pgq.tick-id', %s, %s, null, null, null)"
                dst_curs.execute(q, [st.target_queue, str(tick_id), self.pgq_queue_name])
            if st.create_tick:
                # create actual tick
                tick_id = self._batch_info['tick_id']
                tick_time = self._batch_info['batch_end']
                q = "select pgq.ticker(%s, %s, %s, %s)"
                dst_curs.execute(q, [self.pgq_queue_name, tick_id, tick_time, self.cur_max_id])

        CascadedConsumer.finish_remote_batch(self, src_db, dst_db, tick_id)