コード例 #1
0
ファイル: client_test.py プロジェクト: zline/snakebite
 def test_ha_client_standby_errror(self):
     e = RequestError("org.apache.hadoop.ipc.StandbyException foo bar")
     mocked_client_cat = Mock(side_effect=e)
     ha_client = HAClient([Namenode("foo"), Namenode("bar")])
     ha_client.cat = HAClient._ha_gen_method(mocked_client_cat)
     cat_result_gen = ha_client.cat(ha_client, ['foobar'])
     self.assertRaises(OutOfNNException, all, cat_result_gen)
コード例 #2
0
ファイル: client_test.py プロジェクト: monoid/snakebite-py3
 def test_ha_client_retry(self, rpc_call):
     retry_attempts = 3
     e = RequestError("org.apache.hadoop.ipc.RetriableException foo bar")
     rpc_call.side_effect = e
     nns = [Namenode("foo"), Namenode("bar")]
     ha_client = HAClient(nns, max_retries=retry_attempts)
     cat_result_gen = ha_client.cat(['foobar'])
     self.assertRaises(RequestError, all, cat_result_gen)
     self.assertEquals(rpc_call.call_count, 1 + retry_attempts)
コード例 #3
0
ファイル: client_test.py プロジェクト: monoid/snakebite-py3
 def test_ha_client_failover_retry_for_exception(self, rpc_call):
     failover_attempts = 3
     e = RequestError("org.apache.hadoop.ipc.StandbyException foo bar")
     rpc_call.side_effect = e
     nns = [Namenode("foo", 8020), Namenode("bar", 8020)]
     ha_client = HAClient(nns, max_failovers=failover_attempts)
     cat_result_gen = ha_client.cat(['foobar'])
     self.assertRaises(OutOfNNException, all, cat_result_gen)
     self.assertEquals(rpc_call.call_count, 1 + failover_attempts)
コード例 #4
0
ファイル: client_test.py プロジェクト: monoid/snakebite-py3
 def test_ha_client_retry2(self, get_connection):
     retry_attempts = 2
     e = RequestError("org.apache.hadoop.ipc.RetriableException foo bar")
     get_connection.side_effect = e
     nns = [Namenode("foo", 8020), Namenode("bar", 8020)]
     ha_client = HAClient(nns, max_retries=retry_attempts)
     cat_result_gen = ha_client.cat(['foobar'])
     self.assertRaises(RequestError, all, cat_result_gen)
     calls = [call("foo", 8020), call("foo", 8020), call("foo", 8020)]
     get_connection.assert_has_calls(calls)
コード例 #5
0
ファイル: client_test.py プロジェクト: monoid/snakebite-py3
 def test_ha_client_failover_retry_for_exception2(self, get_connection):
     failover_attempts = 2
     e = RequestError("org.apache.hadoop.ipc.StandbyException foo bar")
     get_connection.side_effect = e
     nns = [Namenode("foo"), Namenode("bar")]
     ha_client = HAClient(nns, max_failovers=failover_attempts)
     cat_result_gen = ha_client.cat(['foobar'])
     self.assertRaises(OutOfNNException, all, cat_result_gen)
     calls = [call("foo", 8020), call("bar", 8020), call("foo", 8020)]
     get_connection.assert_has_calls(calls)
コード例 #6
0
ファイル: channel.py プロジェクト: cyroxx/snakebite
    def handle_error(self, byte_stream):
        '''Handle errors'''
        length = self.get_length(byte_stream)
        log.debug("Class name length: %d" % (length))
        if length == -1:
            class_name = None
        else:
            class_name = byte_stream.read(length)
            log.debug("Class name (%d): %s" % (len(class_name), class_name))

        length = self.get_length(byte_stream)
        log.debug("Stack trace length: %d" % (length))
        if length == -1:
            stack_trace = None
        else:
            stack_trace = byte_stream.read(length)
            log.debug("Stack trace (%d): %s" % (len(stack_trace), stack_trace))

        stack_trace_msg = stack_trace.split("\n")[0]
        log.debug(stack_trace_msg)

        raise RequestError(stack_trace_msg)
コード例 #7
0
 def handle_error(self, header):
     raise RequestError("\n".join([header.exceptionClassName, header.errorMsg]))