(self)
Read 'bytes' worth of data from stdin, append to the partial log file
        starting from 'offset'. On error it is assumed that master restarts
        from zero.

        The resulting file is always padded to XLOG_SEGMENT_SIZE bytes to
        simplify recovery.
Read 'bytes' worth of data from stdin, append to the partial log file
        starting from 'offset'. On error it is assumed that master restarts
        from zero.
Read bytes worth of data from stdin append to the partial log file starting from offset . On error it is assumed that master restarts from zero .
def slave_append_partial(self):
        """
        Read 'bytes' worth of data from stdin, append to the partial log file
        starting from 'offset'. On error it is assumed that master restarts
        from zero.

        The resulting file is always padded to XLOG_SEGMENT_SIZE bytes to
        simplify recovery.
        """

        def fail(message):
            self.log.error("Slave: %s: %s", filename, message)
            sys.exit(1)

        self.assert_is_master(False)
        if len(self.args) < 3:
            die(1, "usage: xpartialsync <filename> <offset> <bytes>")

        filename = self.args[0]
        offset = int(self.args[1])
        bytes = int(self.args[2])

        data = sys.stdin.read(bytes)
        if len(data) != bytes:
            fail("not enough data, expected %d, got %d" % (bytes, len(data)))

        chunk = WalChunk(filename, offset, bytes)
        self.log.debug("Slave: adding to %s", chunk)

        name = os.path.join(self.cf.getfile("partial_wals"), filename)

        if self.not_really:
            self.log.info("Adding to partial: %s", name)
            return

        try:
            xlog = open(name, (offset == 0) and "w+" or "r+")
        except:
            fail("unable to open partial WAL: %s" % name)
        xlog.seek(offset)
        xlog.write(data)

        # padd the file to 16MB boundary, use sparse files
        padsize = XLOG_SEGMENT_SIZE - xlog.tell()
        if padsize > 0:
            xlog.seek(XLOG_SEGMENT_SIZE-1)
            xlog.write('\0')

        xlog.close()
def slave_append_partial ( self ) : def fail ( message ) : self . log . error ( "Slave: %s: %s" , filename , message ) sys . exit ( 1 ) self . assert_is_master ( False ) if len ( self . args ) < 3 : die ( 1 , "usage: xpartialsync <filename> <offset> <bytes>" ) filename = self . args [ 0 ] offset = int ( self . args [ 1 ] ) bytes = int ( self . args [ 2 ] ) data = sys . stdin . read ( bytes ) if len ( data ) != bytes : fail ( "not enough data, expected %d, got %d" % ( bytes , len ( data ) ) ) chunk = WalChunk ( filename , offset , bytes ) self . log . debug ( "Slave: adding to %s" , chunk ) name = os . path . join ( self . cf . getfile ( "partial_wals" ) , filename ) if self . not_really : self . log . info ( "Adding to partial: %s" , name ) return try : xlog = open ( name , ( offset == 0 ) and "w+" or "r+" ) except : fail ( "unable to open partial WAL: %s" % name ) xlog . seek ( offset ) xlog . write ( data ) # padd the file to 16MB boundary, use sparse files padsize = XLOG_SEGMENT_SIZE - xlog . tell ( ) if padsize > 0 : xlog . seek ( XLOG_SEGMENT_SIZE - 1 ) xlog . write ( '\0' ) xlog . close ( )