@@ -234,8 +234,9 @@ def _check_response(self, response):
234234 self .logger .debug (
235235 f"Alluxio server returned { response .status_code } : { message } "
236236 )
237-
238- if response .status_code == 404 :
237+ if response .status_code == 104 :
238+ raise ConnectionResetError ("Connection reset by peer" )
239+ elif response .status_code == 404 :
239240 raise FileNotFoundError (message )
240241 elif response .status_code == 400 :
241242 raise ValueError (message )
@@ -826,23 +827,14 @@ def get_ufs_info_from_worker(self):
826827 worker_host = self .config .load_balance_domain
827828 else :
828829 worker_host = self .loadbalancer .get_worker ().host
829- try :
830- url = GET_UFS_SECRET_INFO .format (
831- domain = worker_host ,
832- http_port = self .config .worker_http_port ,
833- )
834- response = requests .get (url )
835- response .raise_for_status ()
836- info = response .content
837- return info
838- except Exception as e :
839- raise Exception (
840- EXCEPTION_CONTENT .format (
841- worker_host = worker_host ,
842- http_port = self .config .worker_http_port ,
843- error = f"Error when get ufsInfo, { e } " ,
844- )
845- )
830+ url = GET_UFS_SECRET_INFO .format (
831+ domain = worker_host ,
832+ http_port = self .config .worker_http_port ,
833+ )
834+ response = requests .get (url )
835+ self ._check_response (response )
836+ info = response .content
837+ return info
846838
847839 def _all_chunk_generator (
848840 self , worker_host , worker_http_port , path_id , file_path , chunk_size
@@ -881,10 +873,7 @@ def _all_chunk_generator(
881873 url_chunk , headers = headers , stream = True
882874 ) as response :
883875 # Check for connection reset error (status code 104)
884- if response .status_code == 104 :
885- raise ConnectionResetError ("Connection reset by peer" )
886-
887- response .raise_for_status ()
876+ self ._check_response (response )
888877 for chunk in response .iter_content (chunk_size = chunk_size ):
889878 if chunk :
890879 out .write (chunk )
@@ -1727,7 +1716,7 @@ def _get_preferred_worker_address(self, full_ufs_path):
17271716 )
17281717 try :
17291718 response = requests .get (url )
1730- response . raise_for_status ( )
1719+ self . _check_response ( response )
17311720 data = json .loads (response .content )
17321721 ip = data ["Host" ]
17331722 port = data ["HttpServerPort" ]
@@ -2228,7 +2217,7 @@ def _get_preferred_worker_host(self, full_ufs_path):
22282217 )
22292218 try :
22302219 response = requests .get (url )
2231- response . raise_for_status ( )
2220+ self . _check_response ( response )
22322221 data = json .loads (response .content )
22332222 ip = data ["Host" ]
22342223 except HTTPError :
0 commit comments