Răsfoiți Sursa

HUE-4918 [assist] Mutually clear the Hive and Impala cache from the metastore and editor

Johan Ahlen 8 ani în urmă
părinte
comite
9ff10c7

+ 5 - 1
apps/metastore/src/metastore/static/metastore/js/metastore.ko.js

@@ -70,7 +70,7 @@ var MetastoreViewModel = (function () {
     self.loadDatabases();
 
     huePubSub.subscribe('assist.db.refresh', function (options) {
-      if (options.sourceType !== 'hive') {
+      if (options.sourceTypes.indexOf('hive') === -1 && options.sourceTypes.indexOf('impala') === -1) {
         return;
       }
       self.reloading(true);
@@ -78,6 +78,10 @@ var MetastoreViewModel = (function () {
         sourceType: 'hive',
         clearAll: true
       });
+      huePubSub.publish('assist.clear.db.cache', {
+        sourceType: 'impala',
+        clearAll: true
+      });
       var currentDatabase = null;
       var currentTable = null;
       if (self.database()) {

+ 4 - 4
apps/metastore/src/metastore/templates/metastore.mako

@@ -575,7 +575,7 @@ ${ components.menubar(is_embeddable) }
 
 <script type="text/html" id="metastore-databases-actions">
   <div class="inline-block pull-right">
-    <a class="inactive-action" href="javascript:void(0)" data-bind="tooltip: { placement: 'bottom', delay: 750 }, click: function () { huePubSub.publish('assist.db.refresh', { sourceType: 'hive' }); }"><i class="pointer fa fa-refresh" data-bind="css: { 'fa-spin blue' : $root.reloading }" title="${_('Refresh')}"></i></a>
+    <a class="inactive-action" href="javascript:void(0)" data-bind="tooltip: { placement: 'bottom', delay: 750 }, click: function () { huePubSub.publish('assist.db.refresh', { sourceTypes: ['hive', 'impala'] }); }"><i class="pointer fa fa-refresh" data-bind="css: { 'fa-spin blue' : $root.reloading }" title="${_('Refresh')}"></i></a>
     % if has_write_access:
       % if is_embeddable:
         <a class="inactive-action margin-left-10" data-bind="tooltip: { placement: 'bottom', delay: 750 }, click: function () { huePubSub.publish('open.link', '${ url('indexer:importer_prefill', source_type='manual', target_type='database') }'); }" title="${_('Create a new database')}" href="javascript:void(0)"><i class="fa fa-plus"></i></a>
@@ -590,7 +590,7 @@ ${ components.menubar(is_embeddable) }
 
 <script type="text/html" id="metastore-tables-actions">
   <div class="inline-block pull-right">
-    <a class="inactive-action" href="javascript:void(0)" data-bind="tooltip: { placement: 'bottom', delay: 750 }, click: function () { huePubSub.publish('assist.db.refresh', { sourceType: 'hive' }); }" title="${_('Refresh')}"><i class="pointer fa fa-refresh" data-bind="css: { 'fa-spin blue' : $root.reloading }"></i></a>
+    <a class="inactive-action" href="javascript:void(0)" data-bind="tooltip: { placement: 'bottom', delay: 750 }, click: function () { huePubSub.publish('assist.db.refresh', { sourceTypes: ['hive', 'impala'] }); }" title="${_('Refresh')}"><i class="pointer fa fa-refresh" data-bind="css: { 'fa-spin blue' : $root.reloading }"></i></a>
     % if has_write_access:
       % if is_embeddable:
         <a class="inactive-action margin-left-10" data-bind="tooltip: { placement: 'bottom', delay: 750 }, click: function () { huePubSub.publish('open.link', '${ url('indexer:importer_prefill', source_type='all', target_type='table') }' + database().name ); }" title="${_('Create a new table')}" href="javascript:void(0)"><i class="fa fa-plus"></i></a>
@@ -618,7 +618,7 @@ ${ components.menubar(is_embeddable) }
     % else:
       <a class="inactive-action" data-bind="tooltip: { placement: 'bottom', delay: 750 }, attr: { 'href': '/metastore/table/'+ database.name + '/' + name + '/read' }" title="${_('Browse Data')}"><i class="fa fa-play fa-fw"></i></a>
     % endif
-    <a class="inactive-action" data-bind="tooltip: { placement: 'bottom', delay: 750 }, click: function () { huePubSub.publish('assist.db.refresh', { sourceType: 'hive' }); }" title="${_('Refresh')}" href="javascript:void(0)"><i class="pointer fa fa-refresh fa-fw" data-bind="css: { 'fa-spin blue' : $root.reloading }"></i></a>
+    <a class="inactive-action" data-bind="tooltip: { placement: 'bottom', delay: 750 }, click: function () { huePubSub.publish('assist.db.refresh', { sourceTypes: ['hive', 'impala'] }); }" title="${_('Refresh')}" href="javascript:void(0)"><i class="pointer fa fa-refresh fa-fw" data-bind="css: { 'fa-spin blue' : $root.reloading }"></i></a>
     % if has_write_access:
       <a class="inactive-action" href="#" data-bind="tooltip: { placement: 'bottom', delay: 750 }, click: showImportData, visible: tableDetails() && ! tableDetails().is_view" title="${_('Import Data')}"><i class="fa fa-upload fa-fw"></i></a>
     % endif
@@ -1301,7 +1301,7 @@ ${ components.menubar(is_embeddable) }
       ko.applyBindings(viewModel, $('#metastoreComponents')[0]);
 
       if (location.getParameter('refresh') === 'true') {
-        huePubSub.publish('assist.db.refresh', { sourceType: 'hive' });
+        huePubSub.publish('assist.db.refresh', { sourceTypes: ['hive', 'impala'] });
         hueUtils.replaceURL('?');
       }
 

+ 5 - 3
desktop/core/src/desktop/static/desktop/js/assist/assistDbSource.js

@@ -298,8 +298,10 @@ var AssistDbSource = (function () {
     };
 
     huePubSub.subscribe('assist.db.refresh', function (options) {
-      if (self.sourceType === options.sourceType) {
-        self.reload(options.allCacheTypes);
+      if (options.sourceTypes.indexOf(self.sourceType) !== -1) {
+        window.setTimeout(function () {
+          self.reload(options.allCacheTypes);
+        }, 0);
       }
     });
   }
@@ -366,7 +368,7 @@ var AssistDbSource = (function () {
 
   AssistDbSource.prototype.triggerRefresh = function (data, event) {
     var self = this;
-    huePubSub.publish('assist.db.refresh', { sourceType: self.sourceType, allCacheTypes: event.shiftKey });
+    huePubSub.publish('assist.db.refresh', { sourceTypes: [self.sourceType], allCacheTypes: event.shiftKey });
   };
 
   return AssistDbSource;

+ 1 - 1
desktop/core/src/desktop/templates/ko_components.mako

@@ -341,7 +341,7 @@ from desktop.views import _ko
                   // or if still on initial spinner we redirect automatically to onSuccessUrl
                   if (notebook.onSuccessUrl()) {
                     if (notebook.onSuccessUrl() == 'assist.db.refresh') { // TODO: Similar if in in FB directory, also refresh FB dir
-                      huePubSub.publish('assist.db.refresh', { sourceType: 'hive' });
+                      huePubSub.publish('assist.db.refresh', { sourceTypes: ['hive', 'impala'] });
                     } else {
                       huePubSub.publish('open.link', notebook.onSuccessUrl());
                     }

+ 2 - 2
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -343,7 +343,7 @@ var EditorViewModel = (function() {
     };
 
     huePubSub.subscribe('assist.db.refresh', function (options) {
-      if (self.type() == options.sourceType) {
+      if (options.sourceTypes.indexOf(self.type()) !== -1) {
         updateDatabases();
       }
     }, 'editor');
@@ -631,7 +631,7 @@ var EditorViewModel = (function() {
     if (! vm.isNotificationManager()) {
       window.setTimeout(function () {
         self.delayedDDLNotification.subscribe(function (val) {
-          huePubSub.publish('assist.db.refresh', { sourceType: self.type() });
+          huePubSub.publish('assist.db.refresh', { sourceTypes: self.type() === 'impala' || self.type() === 'hive' ? ['hive', 'impala'] : [self.type()] });
         });
       }, 0);
     }