Răsfoiți Sursa

HUE-3078 [impala] Make the flush_all an option on invalidate when refreshing

Johan Ahlen 9 ani în urmă
părinte
comite
c9743fdc15

+ 2 - 2
desktop/core/src/desktop/static/desktop/js/assist/assistDbSource.js

@@ -45,7 +45,7 @@
     self.isSearchVisible = ko.observable(false);
     self.editingSearch = ko.observable(false);
 
-    self.invalidateOnRefresh = ko.observable(false);
+    self.invalidateOnRefresh = ko.observable('cache');
 
     self.filter = {
       query: ko.observable("").extend({ rateLimit: 150 })
@@ -189,7 +189,7 @@
         clearAll: true,
         invalidateImpala: self.invalidateOnRefresh()
       });
-      self.invalidateOnRefresh(false);
+      self.invalidateOnRefresh('cache');
       self.initDatabases();
     };
 

+ 6 - 4
desktop/core/src/desktop/static/desktop/js/assist/assistHelper.js

@@ -45,7 +45,7 @@
     self.user = user;
     self.lastKnownDatabases = {};
     self.fetchQueue = {};
-    self.invalidateImpala = false;
+    self.invalidateImpala = 'cache';
 
     huePubSub.subscribe('assist.clear.db.cache', function (options) {
       self.clearDbCache(options);
@@ -447,7 +447,7 @@
    */
   AssistHelper.prototype.clearDbCache = function (options) {
     var self = this;
-    self.invalidateImpala = options.invalidateImpala || false;
+    self.invalidateImpala = options.invalidateImpala || 'cache';
     if (options.clearAll) {
       $.totalStorage("hue.assist." + self.getTotalStorageUserPrefix(options.sourceType), {});
     } else {
@@ -479,7 +479,7 @@
     var self = this;
 
     var loadFunction = function () {
-      self.invalidateImpala = false;
+      self.invalidateImpala = 'cache';
       fetchAssistData.bind(self)($.extend({}, options, {
         url: AUTOCOMPLETE_API_PREFIX,
         successCallback: function (data) {
@@ -508,8 +508,10 @@
       }));
     };
 
-    if (options.sourceType === 'impala' && self.invalidateImpala) {
+    if (options.sourceType === 'impala' && self.invalidateImpala == 'invalidateAndFlush') {
       $.post(IMPALA_INVALIDATE_API, { flush_all: true }, loadFunction);
+    } else if (options.sourceType === 'impala' && self.invalidateImpala == 'invalidate') {
+      $.post(IMPALA_INVALIDATE_API, {flush_all: false}, loadFunction);
     } else {
       loadFunction();
     }

+ 15 - 3
desktop/core/src/desktop/templates/assist.mako

@@ -580,9 +580,21 @@ from desktop.views import _ko
   </script>
 
   <script type="text/html" id="ask-for-invalidate-content">
-    <label class="checkbox" style="margin-bottom: 2px;"><input type="checkbox" data-bind="checked: invalidateOnRefresh" /> ${ _('Invalidate metadata') }</label>
-    <div style="display: inline-block; margin-left: 20px; font-style: italic">${ _('This is a resource- and time-intensive operation that will rebuild the entire metadata store index.') }</div>
-    <div style="width: 100%; display: inline-block; margin-top: 5px;"><button class="pull-right btn btn-primary" data-bind="css: { 'btn-primary': !invalidateOnRefresh(), 'btn-danger': invalidateOnRefresh }, click: function () { huePubSub.publish('close.popover'); triggerRefresh(); }, clickBubble: false">${ _('Refresh') }</button></div>
+    <label class="radio" style="margin-bottom: 2px;">
+      <input type="radio" name="refreshImpala" value="cache" data-bind="checked: invalidateOnRefresh" />
+      ${ _('Clear cache') }
+    </label>
+    <label class="radio" style="margin-bottom: 2px;">
+      <input type="radio" name="refreshImpala" value="invalidate" data-bind="checked: invalidateOnRefresh" />
+      ${ _('Perform incremental metadata update') }
+    </label>
+    <div style="display: inline-block; margin-left: 20px; font-style: italic; color: #999;">${ _('This will sync missing tables in Hive.') }</div>
+    <label class="radio" style="margin-bottom: 2px;">
+      <input type="radio" name="refreshImpala" value="invalidateAndFlush" data-bind="checked: invalidateOnRefresh"  />
+      ${ _('Invalidate all metadata and rebuild index') }
+    </label>
+    <div style="display: inline-block; margin-left: 20px; font-style: italic; color: #999;">${ _('WARNING: This can be both resource and time-intensive.') }</div>
+    <div style="width: 100%; display: inline-block; margin-top: 5px;"><button class="pull-right btn btn-primary" data-bind="css: { 'btn-primary': invalidateOnRefresh() !== 'invalidateAndFlush', 'btn-danger': invalidateOnRefresh() === 'invalidateAndFlush' }, click: function () { huePubSub.publish('close.popover'); triggerRefresh(); }, clickBubble: false">${ _('Refresh') }</button></div>
   </script>
 
   <script type="text/html" id="assist-db-header-actions">