Selaa lähdekoodia

HUE-4252 [core] Handle 307 redirect from YARN upon standby failover

Jenny Kim 9 vuotta sitten
vanhempi
commit
bd6a0ebac2

+ 5 - 3
desktop/core/src/desktop/lib/rest/resource.py

@@ -110,7 +110,7 @@ class Resource(object):
     return self.invoke("DELETE", relpath, params, headers=headers)
 
 
-  def post(self, relpath=None, params=None, data=None, contenttype=None, headers=None, files=None):
+  def post(self, relpath=None, params=None, data=None, contenttype=None, headers=None, files=None, allow_redirects=False):
     """
     Invoke the POST method on a resource.
     @param relpath: Optional. A relative path to this resource's path.
@@ -118,23 +118,25 @@ class Resource(object):
     @param data: Optional. Body of the request.
     @param contenttype: Optional.
     @param headers: Optional. Base set of headers.
+    @param allow_redirects: Optional. Allow request to automatically resolve redirects.
 
     @return: A dictionary of the JSON result.
     """
     return self.invoke("POST", relpath, params, data, self._make_headers(contenttype, headers), files)
 
 
-  def put(self, relpath=None, params=None, data=None, contenttype=None):
+  def put(self, relpath=None, params=None, data=None, contenttype=None, allow_redirects=False):
     """
     Invoke the PUT method on a resource.
     @param relpath: Optional. A relative path to this resource's path.
     @param params: Key-value data.
     @param data: Optional. Body of the request.
     @param contenttype: Optional.
+    @param allow_redirects: Optional. Allow request to automatically resolve redirects.
 
     @return: A dictionary of the JSON result.
     """
-    return self.invoke("PUT", relpath, params, data, self._make_headers(contenttype))
+    return self.invoke("PUT", relpath, params, data, self._make_headers(contenttype), allow_redirects)
 
 
   def _make_headers(self, contenttype=None, headers=None):

+ 1 - 1
desktop/libs/hadoop/src/hadoop/yarn/resource_manager_api.py

@@ -140,7 +140,7 @@ class ResourceManagerApi(object):
 
     try:
       params = self._get_params()
-      return self._execute(self._root.put, 'cluster/apps/%(app_id)s/state' % {'app_id': app_id}, params=params, data=json.dumps(data), contenttype=_JSON_CONTENT_TYPE)
+      return self._execute(self._root.put, 'cluster/apps/%(app_id)s/state' % {'app_id': app_id}, params=params, data=json.dumps(data), allow_redirects=True, contenttype=_JSON_CONTENT_TYPE)
     finally:
       if token:
         self.cancel_token(token)