Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1021 from sirensolutions/issue-287-enterprise-2
Browse files Browse the repository at this point in the history
added an index refresh command to make sure preloaded objects will be…
  • Loading branch information
szydan committed May 18, 2016
2 parents 4fda79e + f080333 commit f6843a3
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/plugins/kibi_core/lib/query_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ QueryEngine.prototype.loadPredefinedData = function () {
if (self.config.get('pkg.kibiEnterpriseEnabled')) {
return self._loadDatasources().then(function () {
return self._loadQueries().then(function () {
fulfill(true);
return self._refreshKibiIndex().then(function () {
fulfill(true);
});
});
});
} else {
Expand Down Expand Up @@ -144,6 +146,14 @@ QueryEngine.prototype._loadTemplatesMapping = function () {
});
};

QueryEngine.prototype._refreshKibiIndex = function () {
var self = this;
return self.client.indices.refresh({
index: self.config.get('kibana.index'),
force: true
});
};

QueryEngine.prototype.gremlin = function (datasourceParams, options) {
// TODO: remove when https://github.com/sirensolutions/kibi-internal/issues/906 is fixed
var parsedTimeout = parseInt(datasourceParams.timeout);
Expand Down Expand Up @@ -370,8 +380,9 @@ QueryEngine.prototype.reloadQueries = function () {
var queryDefinitions = [];
var datasourcesIds = [];
if (resp.hits && resp.hits.hits && resp.hits.hits.length > 0) {
self.log.info('Reloading ' + resp.hits.hits.length + ' queries into memory:');
_.each(resp.hits.hits, function (hit) {

self.log.info('Reloading [' + hit._id + ']');
var queryDefinition = {
id: hit._id,
label: hit._source.title,
Expand Down Expand Up @@ -442,6 +453,7 @@ QueryEngine.prototype.reloadQueries = function () {
queryDef.datasource = datasource._source;
return true;
}
self.log.error('Query [' + queryDef.id + '] not loaded because datasource [' + queryDef.datasourceId + '] not found');
return false;
}).map(function (queryDef) {
// now once we have query definitions and datasources load queries
Expand Down

0 comments on commit f6843a3

Please sign in to comment.