-
Notifications
You must be signed in to change notification settings - Fork 3
Sed 4415 optimize reporting request and query performance #566
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 29
Are you sure you want to change the base?
Changes from all commits
95daef3
fcc5eb3
eb71b1f
1394e08
f77d472
e91414a
8b99727
3074e70
e2dfa3d
993b011
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,8 +3,10 @@ | |
| import ch.exense.commons.app.Configuration; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
| import step.controller.services.async.AsyncTaskManager; | ||
| import step.core.Controller; | ||
| import step.core.GlobalContext; | ||
| import step.core.artefacts.reports.aggregated.ReportNodeTimeSeries; | ||
| import step.core.controller.errorhandling.ErrorFilter; | ||
| import step.core.deployment.ControllerServices; | ||
| import step.core.execution.model.Execution; | ||
|
|
@@ -124,6 +126,17 @@ public void recover(GlobalContext context) throws Exception { | |
| @Override | ||
| public void finalizeStart(GlobalContext context) throws Exception { | ||
| context.require(ExecutionScheduler.class).start(); | ||
| //Initialize new empty resolutions after start (require the async task manager) | ||
| //Because the ReportNodeTimeSeries is created in ControllerServer.init directly and not in a plugin, this the right place to do it | ||
| ReportNodeTimeSeries reportNodeTimeSeries = context.require(ReportNodeTimeSeries.class); | ||
| AsyncTaskManager asyncTaskManager = context.require(AsyncTaskManager.class); | ||
| asyncTaskManager.scheduleAsyncTask((empty) -> { | ||
| logger.info("ReportNode timeSeries ingestion for empty resolutions has started"); | ||
| reportNodeTimeSeries.getTimeSeries().ingestDataForEmptyCollections(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have the same logic implemented for the time-series (response times) but it did not exists for the reportNodeTimeSeries.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the clarification. Agree that it should be done asynchronously. There's however a few things we should think about:
|
||
| logger.info("ReportNode timeSeries ingestion for empty resolutions has finished"); | ||
| return null; | ||
| }); | ||
|
|
||
| } | ||
|
|
||
| @Override | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| /* | ||
| * ****************************************************************************** | ||
| * * Copyright (C) 2020, exense GmbH | ||
| * * | ||
| * * This file is part of STEP | ||
| * * | ||
| * * STEP is free software: you can redistribute it and/or modify | ||
| * * it under the terms of the GNU Affero General Public License as published by | ||
| * * the Free Software Foundation, either version 3 of the License, or | ||
| * * (at your option) any later version. | ||
| * * | ||
| * * STEP is distributed in the hope that it will be useful, | ||
| * * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * * GNU Affero General Public License for more details. | ||
| * * | ||
| * * You should have received a copy of the GNU Affero General Public License | ||
| * * along with STEP. If not, see <http://www.gnu.org/licenses/>. | ||
| * ***************************************************************************** | ||
| */ | ||
| package step.migration.tasks; | ||
|
|
||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
| import step.core.Version; | ||
| import step.core.collections.Collection; | ||
| import step.core.collections.CollectionFactory; | ||
| import step.core.collections.Document; | ||
| import step.core.collections.Filters; | ||
| import step.core.timeseries.Resolution; | ||
| import step.migration.MigrationContext; | ||
| import step.migration.MigrationTask; | ||
|
|
||
| import java.util.Optional; | ||
| import java.util.concurrent.atomic.AtomicInteger; | ||
|
|
||
| import static step.core.controller.ControllerSettingPlugin.SETTINGS; | ||
|
|
||
| public class V29_1_UpdateTimeSeriesCollectionsAndSettings extends MigrationTask { | ||
|
|
||
| public static final String TIME_SERIES_MAIN_COLLECTION = "timeseries"; | ||
| public static final String TIME_SERIES_MAIN_COLLECTION_NEW_NAME = "timeseries_5_seconds"; | ||
| public static final String TIME_SERIES_MAIN_COLLECTION_REPORTS = "reportNodeTimeSeries"; | ||
| public static final String TIME_SERIES_MAIN_COLLECTION_REPORTS_NEW_NAME = "reportNodeTimeSeries_5_seconds"; | ||
| public static final String HOUSEKEEPING_TIME_SERIES_DEFAULT_TTL = "housekeeping_time_series_default_ttl"; | ||
| public static final String HOUSEKEEPING_TIME_SERIES_PER_MINUTE_TTL = "housekeeping_time_series_per_minute_ttl"; | ||
| public static final String HOUSEKEEPING_TIME_SERIES_HOURLY_TTL = "housekeeping_time_series_hourly_ttl"; | ||
| public static final String HOUSEKEEPING_TIME_SERIES_DAILY_TTL = "housekeeping_time_series_daily_ttl"; | ||
| public static final String HOUSEKEEPING_TIME_SERIES_WEEKLY_TTL = "housekeeping_time_series_weekly_ttl"; | ||
| public static final String HOUSEKEEPING_TIME_SERIES_TTL_PREFIX = "housekeeping_time_series_"; | ||
| public static final String HOUSEKEEPING_TIME_SERIES_TTL_SUFFIX = "_ttl"; | ||
|
|
||
| private static final Logger log = LoggerFactory.getLogger(V29_1_UpdateTimeSeriesCollectionsAndSettings.class); | ||
| private final Collection<Document> timeseriesCollection; | ||
| private final Collection<Document> settings; | ||
| private final Collection<Document> reportNodeTimeseriesCollection; | ||
| protected AtomicInteger successCount; | ||
|
|
||
| public V29_1_UpdateTimeSeriesCollectionsAndSettings(CollectionFactory collectionFactory, MigrationContext migrationContext) { | ||
| super(new Version(3,29,1), collectionFactory, migrationContext); | ||
| timeseriesCollection = collectionFactory.getCollection(TIME_SERIES_MAIN_COLLECTION, Document.class); | ||
| reportNodeTimeseriesCollection = collectionFactory.getCollection(TIME_SERIES_MAIN_COLLECTION_REPORTS, Document.class); | ||
| settings = collectionFactory.getCollection(SETTINGS, Document.class); | ||
| } | ||
|
|
||
| @Override | ||
| public void runUpgradeScript() { | ||
| log.info("Renaming the 'main' collection of the response times time-series to include its resolution"); | ||
| timeseriesCollection.rename(TIME_SERIES_MAIN_COLLECTION_NEW_NAME); | ||
|
|
||
| log.info("Renaming the 'main' collection of the report nodes time-series to include its resolution"); | ||
| reportNodeTimeseriesCollection.rename(TIME_SERIES_MAIN_COLLECTION_REPORTS_NEW_NAME); | ||
|
|
||
|
|
||
| log.info("Renaming time-series housekeeping setting keys"); | ||
| //use names from enum which will then be aligned with the collection names | ||
| updateSettingKeyIfPresent(HOUSEKEEPING_TIME_SERIES_DEFAULT_TTL, HOUSEKEEPING_TIME_SERIES_TTL_PREFIX + Resolution.FIVE_SECONDS.name + HOUSEKEEPING_TIME_SERIES_TTL_SUFFIX); | ||
| updateSettingKeyIfPresent(HOUSEKEEPING_TIME_SERIES_PER_MINUTE_TTL, HOUSEKEEPING_TIME_SERIES_TTL_PREFIX + Resolution.ONE_MINUTE.name + HOUSEKEEPING_TIME_SERIES_TTL_SUFFIX); | ||
| updateSettingKeyIfPresent(HOUSEKEEPING_TIME_SERIES_HOURLY_TTL, HOUSEKEEPING_TIME_SERIES_TTL_PREFIX + Resolution.ONE_HOUR.name + HOUSEKEEPING_TIME_SERIES_TTL_SUFFIX); | ||
| updateSettingKeyIfPresent(HOUSEKEEPING_TIME_SERIES_DAILY_TTL, HOUSEKEEPING_TIME_SERIES_TTL_PREFIX + Resolution.ONE_DAY.name + HOUSEKEEPING_TIME_SERIES_TTL_SUFFIX); | ||
| updateSettingKeyIfPresent(HOUSEKEEPING_TIME_SERIES_WEEKLY_TTL, HOUSEKEEPING_TIME_SERIES_TTL_PREFIX + Resolution.ONE_WEEK.name + HOUSEKEEPING_TIME_SERIES_TTL_SUFFIX); | ||
| log.info("Time-series housekeeping setting keys renamed"); | ||
| } | ||
|
|
||
| private void updateSettingKeyIfPresent(String oldKey, String newKey) { | ||
| Optional<Document> setting = settings.find(Filters.equals("key", oldKey), null, null, null, 0).findFirst(); | ||
| setting.ifPresent(s -> { | ||
| s.put("key", newKey); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would add an explicit log entry here to be fully transparent |
||
| settings.save(s); | ||
| logger.info("Time-series housekeeping setting key {} renamed to {}", oldKey, newKey); | ||
| }); | ||
|
|
||
| } | ||
|
|
||
| @Override | ||
| public void runDowngradeScript() { | ||
|
|
||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.