Exemplo n.º 1
0
 def _on_join_follower(self):
     # send follower's sync group with an empty assignment
     request = SyncGroupRequest(self.group_id, self.generation,
                                self.member_id, {})
     log.debug("Issuing follower SyncGroup (%s) to coordinator %s", request,
               self.coordinator_id)
     return (yield from self._send_sync_group_request(request))
Exemplo n.º 2
0
    def _on_join_leader(self, response):
        """
        Perform leader synchronization and send back the assignment
        for the group via SyncGroupRequest

        Arguments:
            response (JoinResponse): broker response to parse

        Returns:
            Future: resolves to member assignment encoded-bytes
        """
        try:
            group_assignment = \
                yield from self._coordinator._perform_assignment(
                    response.leader_id,
                    response.group_protocol,
                    response.members)
        except Exception as e:
            raise Errors.KafkaError(repr(e))

        assignment_req = []
        for member_id, assignment in group_assignment.items():
            if not isinstance(assignment, bytes):
                assignment = assignment.encode()
            assignment_req.append((member_id, assignment))

        request = SyncGroupRequest(self.group_id, self._coordinator.generation,
                                   self._coordinator.member_id, assignment_req)

        log.debug(
            "Sending leader SyncGroup for group %s to coordinator %s: %s",
            self.group_id, self.coordinator_id, request)
        return (yield from self._send_sync_group_request(request))
Exemplo n.º 3
0
    def _on_join_leader(self, response):
        """
        Perform leader synchronization and send back the assignment
        for the group via SyncGroupRequest

        Arguments:
            response (JoinResponse): broker response to parse

        Returns:
            Future: resolves to member assignment encoded-bytes
        """
        try:
            group_assignment = self._perform_assignment(response.leader_id,
                                                        response.group_protocol,
                                                        response.members)
        except Exception as e:
            return Future().failure(e)

        request = SyncGroupRequest(
            self.group_id,
            self.generation,
            self.member_id,
            [(member_id,
              assignment if isinstance(assignment, bytes) else assignment.encode())
             for member_id, assignment in six.iteritems(group_assignment)])

        log.debug("Issuing leader SyncGroup (%s) to coordinator %s",
                  request, self.coordinator_id)
        return self._send_sync_group_request(request)