Skip to content
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

Allow more flexible database purge policy configuration #268

Merged
merged 3 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,23 @@ protected void doStart() throws SensorHubException
}

// start auto-purge timer thread if policy is specified and enabled
if (config.autoPurgeConfig != null && config.autoPurgeConfig.enabled)
for(var autoPurgeConfig : config.autoPurgeConfig)
{
var uids = Collections.unmodifiableCollection(config.autoPurgeConfig.systemUIDs);
final IObsSystemDbAutoPurgePolicy policy = config.autoPurgeConfig.getPolicy();
autoPurgeTimer = new Timer();
TimerTask task = new TimerTask() {
public void run()
{
if (!db.isReadOnly())
policy.trimStorage(db, logger, uids);
}
};

autoPurgeTimer.schedule(task, 0, (long)(config.autoPurgeConfig.purgePeriod*1000));
if (autoPurgeConfig != null && autoPurgeConfig.enabled)
{
var uids = Collections.unmodifiableCollection(autoPurgeConfig.systemUIDs);
final IObsSystemDbAutoPurgePolicy policy = autoPurgeConfig.getPolicy();
autoPurgeTimer = new Timer();
earocorn marked this conversation as resolved.
Show resolved Hide resolved
TimerTask task = new TimerTask() {
public void run()
{
if (!db.isReadOnly())
policy.trimStorage(db, logger, uids);
}
};

autoPurgeTimer.schedule(task, 0, (long)(autoPurgeConfig.purgePeriod*1000));
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

package org.sensorhub.impl.database.system;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import org.sensorhub.api.config.DisplayInfo;
Expand Down Expand Up @@ -46,7 +48,7 @@ public class SystemDriverDatabaseConfig extends DatabaseConfig


@DisplayInfo(label="Automatic Purge Policy", desc="Policy for automatically purging historical data")
public HistoricalObsAutoPurgeConfig autoPurgeConfig;
public List<HistoricalObsAutoPurgeConfig> autoPurgeConfig = new ArrayList<>();


@DisplayInfo(desc="Minimum period between database commits (in ms)")
Expand Down
Loading