def parse_persistence_uri(cls, persistence_uri):
        """Parse a database URI and the persistence state ID from
        the given persistence URI
        """
        regex = cls.persistence_uri_re
        match = re.match(regex, persistence_uri)
        if not match:
            raise ValueError("Couldn't parse persistence URI: %s -- regex: %s)"
                             % (persistence_uri, regex))

        conn_params = match.groupdict()
        missing = {'proto', 'job_id', 'database'} - set(conn_params)
        if missing:
            raise ValueError('Missing required parameters: %s (given params: %s)'
                             % (tuple(missing), conn_params))

        persistence_state_id = int(conn_params.pop('job_id'))
        db_uri = cls.build_db_conn_uri(**conn_params)
        return db_uri, persistence_state_id
Parse a database URI and the persistence state ID from
        the given persistence URI