瀏覽代碼

HUE-1337 [impala] Cleanup some old Beeswax classes

Remove for real now.
Required for previous patch.
Romain Rigaux 12 年之前
父節點
當前提交
43ec833

+ 15 - 0
apps/beeswax/gen-py/__init__.py

@@ -0,0 +1,15 @@
+# Licensed to Cloudera, Inc. under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  Cloudera, Inc. licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.

+ 0 - 2
apps/beeswax/src/beeswax/forms.py

@@ -18,8 +18,6 @@
 from django import forms
 from django.utils.translation import ugettext as _, ugettext_lazy as _t
 
-import hive_metastore
-
 from desktop.lib.django_forms import simple_formset_factory, DependencyAwareForm
 from desktop.lib.django_forms import ChoiceOrOtherField, MultiForm, SubmitButton
 from filebrowser.forms import PathField

+ 0 - 1
apps/beeswax/src/beeswax/management/commands/beeswax_install_examples.py

@@ -25,7 +25,6 @@ from django.contrib.auth.models import User
 from django.utils.translation import ugettext as _
 
 import beeswax.conf
-import hive_metastore.ttypes
 from beeswax.models import SavedQuery
 from beeswax.server.dbms import get_query_server_config, QueryServerException
 

+ 7 - 79
apps/beeswax/src/beeswax/models.py

@@ -19,7 +19,6 @@ import copy
 import base64
 import datetime
 import logging
-import traceback
 
 from django.db import models
 from django.contrib.auth.models import User
@@ -30,7 +29,6 @@ from enum import Enum
 from desktop.lib.exceptions_renderable import PopupException
 
 from beeswax.design import HQLdesign, hql_query
-from beeswaxd.ttypes import QueryHandle as BeeswaxdQueryHandle, QueryState
 from TCLIService.ttypes import TSessionHandle, THandleIdentifier,\
   TOperationState, TOperationHandle, TOperationType
 
@@ -80,23 +78,14 @@ class QueryHistory(models.Model):
 
   @staticmethod
   def build(*args, **kwargs):
-    if kwargs['server_type'] == HIVE_SERVER2:
-      return HiveServerQueryHistory(*args, **kwargs)
-    else:
-      return BeeswaxQueryHistory(*args, **kwargs)
+    return HiveServerQueryHistory(*args, **kwargs)
 
   def get_full_object(self):
-    if self.server_type == HiveServerQueryHistory.node_type:
-      return HiveServerQueryHistory.objects.get(id=self.id)
-    else:
-      return BeeswaxQueryHistory.objects.get(id=self.id)
+    return HiveServerQueryHistory.objects.get(id=self.id)
 
   @staticmethod
   def get(id):
-    if QueryHistory.objects.filter(id=id, server_type=BEESWAX).exists():
-      return BeeswaxQueryHistory.objects.get(id=id)
-    else:
-      return HiveServerQueryHistory.objects.get(id=id)
+    return HiveServerQueryHistory.objects.get(id=id)
 
   def get_type_name(self):
     if self.query_type == 1:
@@ -198,67 +187,6 @@ class HiveServerQueryHistory(QueryHistory):
     self.save()
 
 
-# Deprecated!
-
-class BeeswaxQueryHistory(QueryHistory):
-  # Map from (thrift) server state
-  STATE_MAP = {
-    QueryState.CREATED          : QueryHistory.STATE.submitted,
-    QueryState.INITIALIZED      : QueryHistory.STATE.submitted,
-    QueryState.COMPILED         : QueryHistory.STATE.running,
-    QueryState.RUNNING          : QueryHistory.STATE.running,
-    QueryState.FINISHED         : QueryHistory.STATE.available,
-    QueryState.EXCEPTION        : QueryHistory.STATE.failed
-  }
-
-  node_type = BEESWAX
-
-  class Meta:
-    proxy = True
-
-  def get_handle(self):
-    """
-    get_server_id() ->  (server-side query id)
-
-    The boolean indicates success/failure. The server_id follows, and may be None.
-    Note that the server_id can legally be None when the query is just submitted.
-    This method handles the various cases of the server_id being absent.
-
-    Does not issue RPC.
-    """
-    if self.server_id:
-      return BeeswaxQueryHandle(secret=self.server_id, has_result_set=self.has_results, log_context=self.log_context)
-    else:
-      # Query being submitted have no server_id?
-      if self.last_state == QueryHistory.STATE.submitted.index:
-        # (1) Really? Check the submission date.
-        #     This is possibly due to the server dying when compiling the query
-        if self.submission_date.now() - self.submission_date > QUERY_SUBMISSION_TIMEOUT:
-          LOG.error("Query submission taking too long. Expiring id %s: [%s]..." % (self.id, self.query[:40]))
-          self.save_state(QueryHistory.STATE.expired)
-        else:
-          # (2) It's not an error. Return the current state
-          LOG.debug("Query %s (submitted) has no server id yet" % (self.id,))
-      else:
-        # (3) It has no server_id for no good reason. A case (1) will become this
-        #     after we expire it. Note that we'll never be able to recover this
-        #     query.
-        LOG.error("Query %s (%s) has no server id [%s]..." %
-                  (self.id, QueryHistory.STATE[self.last_state], self.query[:40]))
-        self.save_state(QueryHistory.STATE.expired)
-      return None
-
-  def save_state(self, new_state):
-    """Set the last_state from an enum, and save"""
-    if self.last_state != new_state.index:
-      if new_state.index < self.last_state:
-        backtrace = ''.join(traceback.format_stack(limit=5))
-        LOG.error("Invalid query state transition: %s -> %s\n%s" % (QueryHistory.STATE[self.last_state], new_state, backtrace))
-        return
-      self.last_state = new_state.index
-      self.save()
-
-
 class SavedQuery(models.Model):
   """
   Stores the query that people have save or submitted.
@@ -322,11 +250,11 @@ class SavedQuery(models.Model):
     try:
       design = SavedQuery.objects.get(id=id)
     except SavedQuery.DoesNotExist, err:
-      msg = _('Cannot retrieve Beeswax design id %(id)s.') % {'id': id}
+      msg = _('Cannot retrieve query id %(id)s.') % {'id': id}
       raise err
 
     if owner is not None and design.owner != owner:
-      msg = _('Design id %(id)s does not belong to user %(user)s.') % {'id': id, 'user': owner}
+      msg = _('Query id %(id)s does not belong to user %(user)s.') % {'id': id, 'user': owner}
       LOG.error(msg)
       raise PopupException(msg)
 
@@ -421,16 +349,16 @@ class HiveServerQueryHandle(QueryHandle):
                             hasResultSet=self.has_result_set,
                             modifiedRowCount=self.modified_row_count)
 
-  # TODO hide
   @classmethod
   def get_decoded(cls, secret, guid):
     return base64.decodestring(secret), base64.decodestring(guid)
 
-  # TODO hide
   def get_encoded(self):
     return base64.encodestring(self.secret), base64.encodestring(self.guid)
 
 
+# Deprecated. Could be removed.
+
 class BeeswaxQueryHandle(QueryHandle):
   """
   QueryHandle for Beeswax.

+ 8 - 8
apps/beeswax/src/beeswax/tests.py

@@ -1533,30 +1533,30 @@ def search_log_line(component, expected_log, all_logs):
 def test_hiveserver2_get_security():
   # Bad but easy mocking
   hive_site.get_conf()
-  
+
   prev = hive_site._HIVE_SITE_DICT.get(hive_site._CNF_HIVESERVER2_AUTHENTICATION)
   try:
     hive_site._HIVE_SITE_DICT[hive_site._CNF_HIVESERVER2_KERBEROS_PRINCIPAL] = 'hive/hive@test.com'
-    
+
     principal = get_query_server_config('beeswax')['principal']
     assert_true(principal.startswith('hive/'), principal)
-  
+
     principal = get_query_server_config('impala')['principal']
     assert_true(principal.startswith('impala/'), principal)
-  
+
     beeswax_query_server = {'server_name': 'beeswax', 'principal': 'hive'}
     impala_query_server = {'server_name': 'impala', 'principal': 'impala'}
-  
+
     assert_equal((True, 'PLAIN', 'hive', False), HiveServerClient.get_security(beeswax_query_server))
     assert_equal((False, 'GSSAPI', 'impala', False), HiveServerClient.get_security(impala_query_server))
-  
+
     cluster_conf = hadoop.cluster.get_cluster_conf_for_job_submission()
     finish = cluster_conf.SECURITY_ENABLED.set_for_testing(True)
     try:
       assert_equal((True, 'GSSAPI', 'impala', False), HiveServerClient.get_security(impala_query_server))
     finally:
-      finish()    
-    
+      finish()
+
     hive_site._HIVE_SITE_DICT[hive_site._CNF_HIVESERVER2_AUTHENTICATION] = 'NOSASL'
     hive_site._HIVE_SITE_DICT[hive_site._CNF_HIVESERVER2_IMPERSONATION] = 'true'
     assert_equal((False, 'NOSASL', 'hive', True), HiveServerClient.get_security(beeswax_query_server))

+ 1 - 1
apps/impala/src/impala/settings.py

@@ -15,7 +15,7 @@
 # limitations under the License.
 
 DJANGO_APPS = ['impala']
-NICE_NAME = 'Cloudera Impala (TM) Query UI'
+NICE_NAME = 'Cloudera Impala Query UI'
 MENU_INDEX = 11
 ICON = '/impala/static/art/icon_impala_24.png'