'Position the cursor appropriately.
The cursor is set to either the beginning of the oplog, or
wherever it was last left off.
Returns the cursor and True if the cursor is empty.'

def init_cursor(self):

    timestamp = self.read_last_checkpoint()
    if (timestamp is None):
        if self.collection_dump:
            timestamp = self.dump_collection()
            self.update_checkpoint(timestamp)
            if (timestamp is None):
                return (None, True)
        else:
            cursor = self.get_oplog_cursor()
            return (cursor, self._cursor_empty(cursor))
    cursor = self.get_oplog_cursor(timestamp)
    cursor_empty = self._cursor_empty(cursor)
    if cursor_empty:
        LOG.debug('OplogThread:    Initiating    rollback    from    get_oplog_cursor')
        self.update_checkpoint(self.rollback())
        return self.init_cursor()
    first_oplog_entry = next(cursor)
    oldest_ts_long = util.bson_ts_to_long(self.get_oldest_oplog_timestamp())
    checkpoint_ts_long = util.bson_ts_to_long(timestamp)
    if (checkpoint_ts_long < oldest_ts_long):
        return (None, True)
    cursor_ts_long = util.bson_ts_to_long(first_oplog_entry['ts'])
    if (cursor_ts_long > checkpoint_ts_long):
        LOG.debug('OplogThread:    Initiating    rollback    from    get_oplog_cursor:    new    oplog    entries    found    but    checkpoint    is    not    present')
        self.update_checkpoint(self.rollback())
        return self.init_cursor()
    return (cursor, cursor_empty)
