You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by dg...@apache.org on 2018/10/19 13:52:13 UTC
incubator-unomi git commit: UNOMI-202 fix issue with scheduler,
add missing parameters to setup the scheduler
Repository: incubator-unomi
Updated Branches:
refs/heads/master 9b29b848e -> dede058d6
UNOMI-202 fix issue with scheduler, add missing parameters to setup the scheduler
Project: http://git-wip-us.apache.org/repos/asf/incubator-unomi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-unomi/commit/dede058d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-unomi/tree/dede058d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-unomi/diff/dede058d
Branch: refs/heads/master
Commit: dede058d6eee431f940e7008c31a389c30cac084
Parents: 9b29b84
Author: dgaillard <dg...@jahia.com>
Authored: Fri Oct 19 15:52:04 2018 +0200
Committer: dgaillard <dg...@jahia.com>
Committed: Fri Oct 19 15:52:04 2018 +0200
----------------------------------------------------------------------
.../unomi/geonames/services/GeonamesServiceImpl.java | 13 +++++++++----
.../main/resources/OSGI-INF/blueprint/blueprint.xml | 5 +++--
.../src/main/resources/org.apache.unomi.geonames.cfg | 5 ++++-
.../unomi/services/services/ClusterServiceImpl.java | 2 +-
.../unomi/services/services/RulesServiceImpl.java | 15 +++++++++++++--
.../main/resources/OSGI-INF/blueprint/blueprint.xml | 4 ++++
.../src/main/resources/org.apache.unomi.services.cfg | 6 ++++++
7 files changed, 40 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/dede058d/extensions/geonames/services/src/main/java/org/apache/unomi/geonames/services/GeonamesServiceImpl.java
----------------------------------------------------------------------
diff --git a/extensions/geonames/services/src/main/java/org/apache/unomi/geonames/services/GeonamesServiceImpl.java b/extensions/geonames/services/src/main/java/org/apache/unomi/geonames/services/GeonamesServiceImpl.java
index 44695b5..2645281 100644
--- a/extensions/geonames/services/src/main/java/org/apache/unomi/geonames/services/GeonamesServiceImpl.java
+++ b/extensions/geonames/services/src/main/java/org/apache/unomi/geonames/services/GeonamesServiceImpl.java
@@ -46,6 +46,7 @@ public class GeonamesServiceImpl implements GeonamesService {
private String pathToGeonamesDatabase;
private Boolean forceDbImport;
+ private Integer refreshDbInterval = 5000;
public void setForceDbImport(Boolean forceDbImport) {
this.forceDbImport = forceDbImport;
@@ -67,6 +68,10 @@ public class GeonamesServiceImpl implements GeonamesService {
this.pathToGeonamesDatabase = pathToGeonamesDatabase;
}
+ public void setRefreshDbInterval(Integer refreshDbInterval) {
+ this.refreshDbInterval = refreshDbInterval;
+ }
+
public void start() {
importDatabase();
}
@@ -93,12 +98,12 @@ public class GeonamesServiceImpl implements GeonamesService {
}
final File f = new File(pathToGeonamesDatabase);
if (f.exists()) {
- schedulerService.getScheduleExecutorService().schedule(new TimerTask() {
+ schedulerService.getScheduleExecutorService().scheduleWithFixedDelay(new TimerTask() {
@Override
public void run() {
importGeoNameDatabase(f);
}
- }, 5000, TimeUnit.MILLISECONDS);
+ }, 0, refreshDbInterval, TimeUnit.MILLISECONDS);
}
}
@@ -106,12 +111,12 @@ public class GeonamesServiceImpl implements GeonamesService {
Map<String,Map<String,Object>> typeMappings = persistenceService.getPropertiesMapping(GeonameEntry.ITEM_TYPE);
if (typeMappings == null || typeMappings.size() == 0) {
logger.warn("Type mappings for type {} are not yet installed, delaying import until they are ready!", GeonameEntry.ITEM_TYPE);
- schedulerService.getScheduleExecutorService().schedule(new TimerTask() {
+ schedulerService.getScheduleExecutorService().scheduleWithFixedDelay(new TimerTask() {
@Override
public void run() {
importGeoNameDatabase(f);
}
- }, 5000, TimeUnit.MILLISECONDS);
+ }, 0, refreshDbInterval, TimeUnit.MILLISECONDS);
return;
} else {
// let's check that the mappings are correct
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/dede058d/extensions/geonames/services/src/main/resources/OSGI-INF/blueprint/blueprint.xml
----------------------------------------------------------------------
diff --git a/extensions/geonames/services/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/extensions/geonames/services/src/main/resources/OSGI-INF/blueprint/blueprint.xml
index 05d11e7..01a1a80 100644
--- a/extensions/geonames/services/src/main/resources/OSGI-INF/blueprint/blueprint.xml
+++ b/extensions/geonames/services/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -21,11 +21,11 @@
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
- <cm:property-placeholder persistent-id="org.apache.unomi.geonames"
- update-strategy="reload">
+ <cm:property-placeholder persistent-id="org.apache.unomi.geonames" update-strategy="reload">
<cm:default-properties>
<cm:property name="request.geonamesDatabase.location" value="file:${karaf.etc}/allCountries.zip"/>
<cm:property name="request.geonamesDatabase.forceImport" value="false"/>
+ <cm:property name="service.geonames.refresh.interval" value="5000"/>
</cm:default-properties>
</cm:property-placeholder>
@@ -43,6 +43,7 @@
<property name="schedulerService" ref="schedulerService"/>
<property name="pathToGeonamesDatabase" value="${request.geonamesDatabase.location}"/>
<property name="forceDbImport" value="${request.geonamesDatabase.forceImport}"/>
+ <property name="refreshDbInterval" value="${service.geonames.refresh.interval}"/>
</bean>
<service id="geonamesService" ref="geonamesServiceImpl" interface="org.apache.unomi.geonames.services.GeonamesService"/>
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/dede058d/extensions/geonames/services/src/main/resources/org.apache.unomi.geonames.cfg
----------------------------------------------------------------------
diff --git a/extensions/geonames/services/src/main/resources/org.apache.unomi.geonames.cfg b/extensions/geonames/services/src/main/resources/org.apache.unomi.geonames.cfg
index db10ab2..625e535 100644
--- a/extensions/geonames/services/src/main/resources/org.apache.unomi.geonames.cfg
+++ b/extensions/geonames/services/src/main/resources/org.apache.unomi.geonames.cfg
@@ -16,4 +16,7 @@
#
request.geonamesDatabase.location=${karaf.etc}/allCountries.zip
-request.geonamesDatabase.forceImport=false
\ No newline at end of file
+request.geonamesDatabase.forceImport=false
+
+# The interval in milliseconds to use to check if the database is ready to be loaded
+service.geonames.refresh.interval=5000
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/dede058d/services/src/main/java/org/apache/unomi/services/services/ClusterServiceImpl.java
----------------------------------------------------------------------
diff --git a/services/src/main/java/org/apache/unomi/services/services/ClusterServiceImpl.java b/services/src/main/java/org/apache/unomi/services/services/ClusterServiceImpl.java
index 2503833..03a4dc6 100644
--- a/services/src/main/java/org/apache/unomi/services/services/ClusterServiceImpl.java
+++ b/services/src/main/java/org/apache/unomi/services/services/ClusterServiceImpl.java
@@ -162,7 +162,7 @@ public class ClusterServiceImpl implements ClusterService {
updateSystemStats();
}
};
- schedulerService.getScheduleExecutorService().schedule(statisticsTask, nodeStatisticsUpdateFrequency, TimeUnit.MILLISECONDS);
+ schedulerService.getScheduleExecutorService().scheduleWithFixedDelay(statisticsTask, 0, nodeStatisticsUpdateFrequency, TimeUnit.MILLISECONDS);
}
logger.info("Cluster service initialized.");
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/dede058d/services/src/main/java/org/apache/unomi/services/services/RulesServiceImpl.java
----------------------------------------------------------------------
diff --git a/services/src/main/java/org/apache/unomi/services/services/RulesServiceImpl.java b/services/src/main/java/org/apache/unomi/services/services/RulesServiceImpl.java
index f4ceb94..ac4baf0 100644
--- a/services/src/main/java/org/apache/unomi/services/services/RulesServiceImpl.java
+++ b/services/src/main/java/org/apache/unomi/services/services/RulesServiceImpl.java
@@ -55,6 +55,9 @@ public class RulesServiceImpl implements RulesService, EventListenerService, Syn
private Map<String,RuleStatistics> allRuleStatistics = new ConcurrentHashMap<>();
+ private Integer rulesRefreshInterval = 1000;
+ private Integer rulesStatisticsRefreshInterval = 10000;
+
public void setBundleContext(BundleContext bundleContext) {
this.bundleContext = bundleContext;
}
@@ -79,6 +82,14 @@ public class RulesServiceImpl implements RulesService, EventListenerService, Syn
this.actionExecutorDispatcher = actionExecutorDispatcher;
}
+ public void setRulesRefreshInterval(Integer rulesRefreshInterval) {
+ this.rulesRefreshInterval = rulesRefreshInterval;
+ }
+
+ public void setRulesStatisticsRefreshInterval(Integer rulesStatisticsRefreshInterval) {
+ this.rulesStatisticsRefreshInterval = rulesStatisticsRefreshInterval;
+ }
+
public void bindExecutor(ServiceReference<ActionExecutor> actionExecutorServiceReference) {
ActionExecutor actionExecutor = bundleContext.getService(actionExecutorServiceReference);
actionExecutorDispatcher.addExecutor(actionExecutorServiceReference.getProperty("actionExecutorId").toString(), actionExecutor);
@@ -379,7 +390,7 @@ public class RulesServiceImpl implements RulesService, EventListenerService, Syn
allRules = getAllRules();
}
};
- schedulerService.getScheduleExecutorService().schedule(task, 1000, TimeUnit.MILLISECONDS);
+ schedulerService.getScheduleExecutorService().scheduleWithFixedDelay(task, 0,rulesRefreshInterval, TimeUnit.MILLISECONDS);
TimerTask statisticsTask = new TimerTask() {
@Override
@@ -387,7 +398,7 @@ public class RulesServiceImpl implements RulesService, EventListenerService, Syn
syncRuleStatistics();
}
};
- schedulerService.getScheduleExecutorService().schedule(statisticsTask, 10000, TimeUnit.MILLISECONDS);
+ schedulerService.getScheduleExecutorService().scheduleWithFixedDelay(statisticsTask, 0, rulesStatisticsRefreshInterval, TimeUnit.MILLISECONDS);
}
public void bundleChanged(BundleEvent event) {
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/dede058d/services/src/main/resources/OSGI-INF/blueprint/blueprint.xml
----------------------------------------------------------------------
diff --git a/services/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/services/src/main/resources/OSGI-INF/blueprint/blueprint.xml
index 3d47400..085eec6 100644
--- a/services/src/main/resources/OSGI-INF/blueprint/blueprint.xml
+++ b/services/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -35,6 +35,8 @@
<cm:property name="properties.refresh.interval" value="10000"/>
<cm:property name="segment.refresh.interval" value="1000"/>
<cm:property name="segment.recalculate.period" value="1"/>
+ <cm:property name="rules.refresh.interval" value="1000"/>
+ <cm:property name="rules.statistics.refresh.interval" value="10000"/>
</cm:default-properties>
</cm:property-placeholder>
@@ -144,6 +146,8 @@
<property name="actionExecutorDispatcher" ref="actionExecutorDispatcherImpl"/>
<property name="bundleContext" ref="blueprintBundleContext"/>
<property name="schedulerService" ref="schedulerServiceImpl"/>
+ <property name="rulesRefreshInterval" value="${services.rules.refresh.interval}"/>
+ <property name="rulesStatisticsRefreshInterval" value="${services.rules.statistics.refresh.interval}"/>
</bean>
<service id="rulesService" ref="rulesServiceImpl">
<interfaces>
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/dede058d/services/src/main/resources/org.apache.unomi.services.cfg
----------------------------------------------------------------------
diff --git a/services/src/main/resources/org.apache.unomi.services.cfg b/services/src/main/resources/org.apache.unomi.services.cfg
index 0afd3ff..d92325c 100644
--- a/services/src/main/resources/org.apache.unomi.services.cfg
+++ b/services/src/main/resources/org.apache.unomi.services.cfg
@@ -42,3 +42,9 @@ segment.refresh.interval=1000
# The interval in days to use to recalculate segments/scoring plans on profile
segment.recalculate.period=1
+
+# The interval in milliseconds to use to reload the rules
+rules.refresh.interval=1000
+
+# The interval in milliseconds to use to reload the rules statistics
+rules.statistics.refresh.interval=10000