(self, xlog_dir, chunk, daemon_mode)
Send the partial log chunk to slave. Use SSH with input redirection for the copy,
        consider other options if the overhead becomes visible.
Send the partial log chunk to slave. Use SSH with input redirection for the copy,
        consider other options if the overhead becomes visible.
Send the partial log chunk to slave . Use SSH with input redirection for the copy consider other options if the overhead becomes visible .
def master_send_partial(self, xlog_dir, chunk, daemon_mode):
        """
        Send the partial log chunk to slave. Use SSH with input redirection for the copy,
        consider other options if the overhead becomes visible.
        """

        try:
            xlog = open(os.path.join(xlog_dir, chunk.filename))
        except IOError, det:
            self.log.warning("Cannot access file %s", chunk.filename)
            return

        xlog.seek(chunk.pos)

        # Fork the sync process
        childpid = os.fork()
        syncstart = time.time()
        if childpid == 0:
            os.dup2(xlog.fileno(), sys.stdin.fileno())
            try:
                self.remote_walmgr("xpartialsync %s %d %d" % (chunk.filename, chunk.pos, chunk.bytes), False)
            except:
                os._exit(1)
            os._exit(0)
        chunk.sync_time += (time.time() - syncstart)

        status = os.waitpid(childpid, 0)
        rc = os.WEXITSTATUS(status[1])
        if rc == 0:
            log = daemon_mode and self.log.debug or self.log.info
            log("sent to slave: %s" % chunk)
            chunk.pos += chunk.bytes
            chunk.sync_count += 1
        else:
            # Start from zero after an error
            chunk.pos = 0
            self.log.error("xpartialsync exited with status %d, restarting from zero.", rc)
            time.sleep(5)
def master_send_partial ( self , xlog_dir , chunk , daemon_mode ) : try : xlog = open ( os . path . join ( xlog_dir , chunk . filename ) ) except IOError , det : self . log . warning ( "Cannot access file %s" , chunk . filename ) return xlog . seek ( chunk . pos ) # Fork the sync process childpid = os . fork ( ) syncstart = time . time ( ) if childpid == 0 : os . dup2 ( xlog . fileno ( ) , sys . stdin . fileno ( ) ) try : self . remote_walmgr ( "xpartialsync %s %d %d" % ( chunk . filename , chunk . pos , chunk . bytes ) , False ) except : os . _exit ( 1 ) os . _exit ( 0 ) chunk . sync_time += ( time . time ( ) - syncstart ) status = os . waitpid ( childpid , 0 ) rc = os . WEXITSTATUS ( status [ 1 ] ) if rc == 0 : log = daemon_mode and self . log . debug or self . log . info log ( "sent to slave: %s" % chunk ) chunk . pos += chunk . bytes chunk . sync_count += 1 else : # Start from zero after an error chunk . pos = 0 self . log . error ( "xpartialsync exited with status %d, restarting from zero." , rc ) time . sleep ( 5 )