Exemplo n.º 1
0
    def check_invocation_allowed(self):
        state = self._client_state
        if state == _ClientState.INITIALIZED_ON_CLUSTER and self.active_connections:
            return

        if state == _ClientState.INITIAL:
            if self._async_start:
                raise ClientOfflineError()
            else:
                raise IOError(
                    "No connection found to cluster since the client is starting."
                )
        elif self._reconnect_mode == ReconnectMode.ASYNC:
            raise ClientOfflineError()
        else:
            raise IOError("No connection found to cluster")
Exemplo n.º 2
0
    def check_invocation_allowed(self):
        if self.active_connections:
            return

        if self._async_start or self._reconnect_mode == ReconnectMode.ASYNC:
            raise ClientOfflineError()
        else:
            raise IOError("No connection found to cluster")
 def get_partition_id(self, key):
     if self.partition_count == 0:
         # Partition count can not be zero for the SYNC mode.
         # On the SYNC mode, we are waiting for the first connection to be established.
         # We are initializing the partition count with the value coming from the server with authentication.
         # This error is used only for ASYNC mode client.
         raise ClientOfflineError()
     return hash_to_index(key.get_partition_hash(), self.partition_count)
 def test_read_many_on_client_offline_error(self):
     self.error_on_first_read_many(ClientOfflineError())
     self.topic.add_listener(no_op)
     self.assertEqual(2, self.ringbuffer.read_many.call_count)
     self.assertEqual(1, len(self.topic._runners))