Modified:
trunk/conf/clustering.properties.defaults
trunk/lib/flaptor-util-trunk.jar
trunk/src/com/flaptor/clusterfest/monitoring/MonitorNodeDescriptor.java
Log:
much more aggressive state cleaning
Modified: trunk/conf/clustering.properties.defaults
==============================================================================
--- trunk/conf/clustering.properties.defaults (original)
+++ trunk/conf/clustering.properties.defaults Thu Jul 24 14:19:26 2008
@@ -5,8 +5,10 @@
clustering.monitor.formatter=com.flaptor.clusterfest.monitoring.DefaultPropertyFormatter
clustering.monitor.checker=com.flaptor.clusterfest.monitoring.DefaultChecker
+clustering.monitor.states.maxcount=50
clustering.monitor.states.saving.enable=true
clustering.monitor.states.saving.dir=states
+
clustering.monitor.logs.defaults=
clustering.monitor.logs.size=50000
Modified: trunk/lib/flaptor-util-trunk.jar
==============================================================================
Binary files. No diff available.
Modified: trunk/src/com/flaptor/clusterfest/monitoring/MonitorNodeDescriptor.java
==============================================================================
---
trunk/src/com/flaptor/clusterfest/monitoring/MonitorNodeDescriptor.java (original)
+++
trunk/src/com/flaptor/clusterfest/monitoring/MonitorNodeDescriptor.java
Thu Jul 24 14:19:26 2008
@@ -61,7 +61,7 @@
super(node);
stateFileSerializer = new FileSerializer(new File(statesDir, node.getHost()+"."+node.getPort()+".states"));
-
+
if
(Config.getConfig("clustering.properties").getBoolean("clustering.monitor.states.saving.enable")) {
states = (List<NodeState>)stateFileSerializer.deserialize(true);
}
@@ -192,9 +192,11 @@
private void cleanupStateList() {
synchronized (states) {
+
long now = System.currentTimeMillis();
List<NodeState> statesToRemove = new ArrayList<NodeState>();
NodeState lastState = null;
+
for (NodeState state: states) {
//keep all states of the last hour
//keep the first & last state
@@ -207,23 +209,13 @@
continue;
}
- if (now - state.getTimestamp() > 7 *
DateUtil.MILLIS_IN_DAY) {
+ if (now - state.getTimestamp() >
DateUtil.MILLIS_IN_DAY) {
if (state.getTimestamp() -
lastState.getTimestamp() < DateUtil.MILLIS_IN_DAY) {
statesToRemove.add(state);
continue;
}
- } else if (now - state.getTimestamp() >
DateUtil.MILLIS_IN_DAY) {
- if (state.getTimestamp() -
lastState.getTimestamp() < DateUtil.MILLIS_IN_HOUR) {
- statesToRemove.add(state);
- continue;
- }
- } else if (now - state.getTimestamp() >
DateUtil.MILLIS_IN_HOUR * 12) {
- if (state.getTimestamp() -
lastState.getTimestamp() < 30 * DateUtil.MILLIS_IN_MINUTE) {
- statesToRemove.add(state);
- continue;
- }
} else {
- if (state.getTimestamp() -
lastState.getTimestamp() < 10 * DateUtil.MILLIS_IN_MINUTE) {
+ if (state.getTimestamp() -
lastState.getTimestamp() < DateUtil.MILLIS_IN_HOUR) {
statesToRemove.add(state);
continue;
}
@@ -232,11 +224,11 @@
}
states.removeAll(statesToRemove);
- //finally trim the list to keep it under 100 states
- int MAX_SIZE = 100;
+ //finally trim the list to keep it the max count
+ int MAX_SIZE = Config.getConfig("clustering.properties").getInt("clustering.monitor.states.maxcount");
int size = states.size();
if (size > MAX_SIZE) {
- List tempList = new
ArrayList<NodeState>(states.subList(size - MAX_SIZE, size));
+ List<NodeState> tempList = new
ArrayList<NodeState>(states.subList(size - MAX_SIZE, size));
states.clear();
states.addAll(tempList);
}