-
Notifications
You must be signed in to change notification settings - Fork 121
/
RuleStatistics.java
169 lines (148 loc) · 5.82 KB
/
RuleStatistics.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.unomi.api.rules;
import org.apache.unomi.api.Item;
import java.util.Date;
/**
* A separate item to track rule statistics, because we will manage the persistence and updating of
* these seperately from the rules themselves. This object contains all the relevant statistics
* concerning the execution of a rule, including accumulated execution times.
*/
public class RuleStatistics extends Item {
/**
* The RuleStatistics ITEM_TYPE.
*
* @see Item for a discussion of ITEM_TYPE
*/
public static final String ITEM_TYPE = "rulestats";
private static final long serialVersionUID = 1L;
private long executionCount = 0;
private long localExecutionCount = 0;
private long conditionsTime = 0;
private long localConditionsTime = 0;
private long actionsTime = 0;
private long localActionsTime = 0;
private Date lastSyncDate;
public RuleStatistics() {
}
public RuleStatistics(String itemId) {
super(itemId);
}
/**
* Retrieve the execution count of the rule in the cluster
* @return a long that is the total number of executions of the rule without the local node execution
* count
*/
public long getExecutionCount() {
return executionCount;
}
/**
* Set the execution count of the rule in the cluster
* @param executionCount a long that represents the number of execution of the rule in the cluster
*/
public void setExecutionCount(long executionCount) {
this.executionCount = executionCount;
}
/**
* Retrieve the execution count of the rule on this single node since the last sync with the cluster
* @return a long that is the total number of executions on this node since the last sync with the
* cluster
*/
public long getLocalExecutionCount() {
return localExecutionCount;
}
/**
* Sets the number of local execution counts for this node since the last sync with the cluster
* @param localExecutionCount a long that represents the number of execution of the rule since the
* last sync with the cluster
*/
public void setLocalExecutionCount(long localExecutionCount) {
this.localExecutionCount = localExecutionCount;
}
/**
* Retrieve the accumulated time evaluating the conditions of the rule in the cluster
* @return a long representing the accumulated time in milliseconds that represents the time spent
* evaluating the conditions of the rule for the whole cluster
*/
public long getConditionsTime() {
return conditionsTime;
}
/**
* Sets the execution time of the condition of the rule for the whole cluster
* @param conditionsTime a long representing a time in milliseconds
*/
public void setConditionsTime(long conditionsTime) {
this.conditionsTime = conditionsTime;
}
/**
* Retrieve the accumulated execution time of the rule's condition since the last sync with the cluster
* @return a long that represents the accumulated time in milliseconds
*/
public long getLocalConditionsTime() {
return localConditionsTime;
}
/**
* Sets the accumulated execution time of the rule's condition since the last sync with the cluster
* @param localConditionsTime a long that represents the accumulated time in milliseconds
*/
public void setLocalConditionsTime(long localConditionsTime) {
this.localConditionsTime = localConditionsTime;
}
/**
* Retrieve the accumulated time of the rule's actions
* @return a long representing the accumulated time in milliseconds
*/
public long getActionsTime() {
return actionsTime;
}
/**
* Sets the accumulated time for the rule's actions
* @param actionsTime a long representing the accumulated time in milliseconds
*/
public void setActionsTime(long actionsTime) {
this.actionsTime = actionsTime;
}
/**
* Retrieve the accumulated time spent executing the rule's actions since the last sync with the cluster
* @return a long representing the accumulated time in milliseconds
*/
public long getLocalActionsTime() {
return localActionsTime;
}
/**
* Sets the accumulated time spend executing the rule's actions since the last sync with the cluster
* @param localActionsTime a long representing the accumulated time in milliseconds
*/
public void setLocalActionsTime(long localActionsTime) {
this.localActionsTime = localActionsTime;
}
/**
* Retrieve the last sync date
* @return a date that was set the last time the statistics were synchronized with the cluster
*/
public Date getLastSyncDate() {
return lastSyncDate;
}
/**
* Sets the last sync date
* @param lastSyncDate a date that represents the last time the statistics were synchronized
* with the cluster
*/
public void setLastSyncDate(Date lastSyncDate) {
this.lastSyncDate = lastSyncDate;
}
}