Exemple #1
0
    def _get_conn(self, host, port, afi):
        """Get or create a connection to a broker using host and port"""
        host_key = (host, port)
        if host_key not in self._conns:
            self._conns[host_key] = BrokerConnection(
                host,
                port,
                afi,
                request_timeout_ms=self.timeout * 1000,
                client_id=self.client_id)

        conn = self._conns[host_key]
        if not conn.connect_blocking(self.timeout):
            conn.close()
            raise KafkaConnectionError("%s:%s (%s)" % (host, port, afi))
        return conn
Exemple #2
0
    def _get_conn(self, host, port, afi, node_id='bootstrap'):
        """Get or create a connection to a broker using host and port"""
        host_key = (host, port)
        if host_key not in self._conns:

            self._conns[host_key] = BrokerConnection(
                host,
                port,
                afi,
                request_timeout_ms=self.timeout * 1000,
                client_id=self.client_id,
                metrics=self._metrics_registry,
                metric_group_prefix='simple-client',
                node_id=node_id,
            )

        conn = self._conns[host_key]
        if not conn.connect_blocking(self.timeout):
            conn.close()
            raise KafkaConnectionError("%s:%s (%s)" % (host, port, afi))
        return conn
Exemple #3
0
 def raise_kafka_error():
     """Raise a kafka error."""
     raise KafkaConnectionError('Test')