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)
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)
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)
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)
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)
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)
def handle_error(self, header): raise RequestError("\n".join([header.exceptionClassName, header.errorMsg]))