You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by sh...@apache.org on 2017/05/01 19:54:12 UTC
incubator-unomi git commit: UNOMI-93 Add rule execution statistics to
rule service endpoint - Global statistics endpoint
Repository: incubator-unomi
Updated Branches:
refs/heads/master 64bf3a96a -> 7e81374d3
UNOMI-93 Add rule execution statistics to rule service endpoint
- Global statistics endpoint
Signed-off-by: Serge Huber <sh...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/incubator-unomi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-unomi/commit/7e81374d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-unomi/tree/7e81374d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-unomi/diff/7e81374d
Branch: refs/heads/master
Commit: 7e81374d35e3bd5e581530af9dd452c15bb2c767
Parents: 64bf3a9
Author: Serge Huber <sh...@apache.org>
Authored: Mon May 1 21:54:07 2017 +0200
Committer: Serge Huber <sh...@apache.org>
Committed: Mon May 1 21:54:07 2017 +0200
----------------------------------------------------------------------
.../org/apache/unomi/api/services/RulesService.java | 7 +++++++
.../org/apache/unomi/rest/RulesServiceEndPoint.java | 12 ++++++++++++
.../unomi/services/services/RulesServiceImpl.java | 4 ++++
3 files changed, 23 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/7e81374d/api/src/main/java/org/apache/unomi/api/services/RulesService.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/unomi/api/services/RulesService.java b/api/src/main/java/org/apache/unomi/api/services/RulesService.java
index 63f6dda..acfd9b4 100644
--- a/api/src/main/java/org/apache/unomi/api/services/RulesService.java
+++ b/api/src/main/java/org/apache/unomi/api/services/RulesService.java
@@ -25,6 +25,7 @@ import org.apache.unomi.api.query.Query;
import org.apache.unomi.api.rules.Rule;
import org.apache.unomi.api.rules.RuleStatistics;
+import java.util.Map;
import java.util.Set;
/**
@@ -63,6 +64,12 @@ public interface RulesService {
RuleStatistics getRuleStatistics(String ruleId);
/**
+ * Retrieves the statistics for all the rules
+ * @return a map containing rule IDs as key, and the RuleStatistics object as a value
+ */
+ Map<String,RuleStatistics> getAllRuleStatistics();
+
+ /**
* Persists the specified rule to the context server.
*
* @param rule the rule to be persisted
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/7e81374d/rest/src/main/java/org/apache/unomi/rest/RulesServiceEndPoint.java
----------------------------------------------------------------------
diff --git a/rest/src/main/java/org/apache/unomi/rest/RulesServiceEndPoint.java b/rest/src/main/java/org/apache/unomi/rest/RulesServiceEndPoint.java
index d619a7f..1327731 100644
--- a/rest/src/main/java/org/apache/unomi/rest/RulesServiceEndPoint.java
+++ b/rest/src/main/java/org/apache/unomi/rest/RulesServiceEndPoint.java
@@ -31,6 +31,7 @@ import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
+import java.util.Map;
import java.util.Set;
/**
@@ -81,6 +82,17 @@ public class RulesServiceEndPoint {
}
/**
+ * Retrieves the metadata for all known rules.
+ *
+ * @return the Set of known metadata
+ */
+ @GET
+ @Path("/statistics")
+ public Map<String,RuleStatistics> getAllRuleStatistics() {
+ return rulesService.getAllRuleStatistics();
+ }
+
+ /**
* Retrieves rule metadatas for rules matching the specified {@link Query}.
*
* @param query the query the rules which metadata we want to retrieve must match
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/7e81374d/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 c289891..b3062c1 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
@@ -281,6 +281,10 @@ public class RulesServiceImpl implements RulesService, EventListenerService, Syn
return persistenceService.load(ruleId, RuleStatistics.class);
}
+ public Map<String,RuleStatistics> getAllRuleStatistics() {
+ return allRuleStatistics;
+ }
+
public Set<Metadata> getRuleMetadatas() {
Set<Metadata> metadatas = new HashSet<Metadata>();
for (Rule rule : persistenceService.getAllItems(Rule.class, 0, 50, null).getList()) {