annotate src/org/dancres/blitz/stats/StoreStat.java @ 23:b7e52953b7a6

Add some cache/memory statistics to help spot potential exhaustion and other tuning issues.
author Dan Creswell <dan.creswell@gmail.com>
date Fri, 28 Aug 2009 17:23:33 +0100
parents src/org/dancres/blitz/stats/SearchStat.java@3dc0c5604566
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
1 package org.dancres.blitz.stats;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
2
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
3 /**
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
4 */
23
b7e52953b7a6 Add some cache/memory statistics to help spot potential exhaustion and other tuning issues.
Dan Creswell <dan.creswell@gmail.com>
parents: 0
diff changeset
5 public class StoreStat implements Stat {
b7e52953b7a6 Add some cache/memory statistics to help spot potential exhaustion and other tuning issues.
Dan Creswell <dan.creswell@gmail.com>
parents: 0
diff changeset
6 private static final long _minimalFree;
b7e52953b7a6 Add some cache/memory statistics to help spot potential exhaustion and other tuning issues.
Dan Creswell <dan.creswell@gmail.com>
parents: 0
diff changeset
7
0
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
8 private long _id;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
9 private String _type;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
10 private String[] _titles;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
11 private long[] _missed;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
12 private long[] _deleted;
23
b7e52953b7a6 Add some cache/memory statistics to help spot potential exhaustion and other tuning issues.
Dan Creswell <dan.creswell@gmail.com>
parents: 0
diff changeset
13 private boolean _safe;
0
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
14
23
b7e52953b7a6 Add some cache/memory statistics to help spot potential exhaustion and other tuning issues.
Dan Creswell <dan.creswell@gmail.com>
parents: 0
diff changeset
15 private int _activeCache;
b7e52953b7a6 Add some cache/memory statistics to help spot potential exhaustion and other tuning issues.
Dan Creswell <dan.creswell@gmail.com>
parents: 0
diff changeset
16 private int _totalCache;
b7e52953b7a6 Add some cache/memory statistics to help spot potential exhaustion and other tuning issues.
Dan Creswell <dan.creswell@gmail.com>
parents: 0
diff changeset
17 private long _free;
b7e52953b7a6 Add some cache/memory statistics to help spot potential exhaustion and other tuning issues.
Dan Creswell <dan.creswell@gmail.com>
parents: 0
diff changeset
18 private long _max;
b7e52953b7a6 Add some cache/memory statistics to help spot potential exhaustion and other tuning issues.
Dan Creswell <dan.creswell@gmail.com>
parents: 0
diff changeset
19
b7e52953b7a6 Add some cache/memory statistics to help spot potential exhaustion and other tuning issues.
Dan Creswell <dan.creswell@gmail.com>
parents: 0
diff changeset
20 static {
b7e52953b7a6 Add some cache/memory statistics to help spot potential exhaustion and other tuning issues.
Dan Creswell <dan.creswell@gmail.com>
parents: 0
diff changeset
21 _minimalFree = Runtime.getRuntime().maxMemory() / 5;
b7e52953b7a6 Add some cache/memory statistics to help spot potential exhaustion and other tuning issues.
Dan Creswell <dan.creswell@gmail.com>
parents: 0
diff changeset
22 }
b7e52953b7a6 Add some cache/memory statistics to help spot potential exhaustion and other tuning issues.
Dan Creswell <dan.creswell@gmail.com>
parents: 0
diff changeset
23
b7e52953b7a6 Add some cache/memory statistics to help spot potential exhaustion and other tuning issues.
Dan Creswell <dan.creswell@gmail.com>
parents: 0
diff changeset
24 public StoreStat(long anId, String aType,
0
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
25 String[] aTitles,
23
b7e52953b7a6 Add some cache/memory statistics to help spot potential exhaustion and other tuning issues.
Dan Creswell <dan.creswell@gmail.com>
parents: 0
diff changeset
26 long[] aMisses, long[] aDeld, int anActiveCacheSize, int aCacheSize) {
0
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
27 _id = anId;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
28 _type = aType;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
29 _titles = aTitles;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
30 _missed = aMisses;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
31 _deleted = aDeld;
23
b7e52953b7a6 Add some cache/memory statistics to help spot potential exhaustion and other tuning issues.
Dan Creswell <dan.creswell@gmail.com>
parents: 0
diff changeset
32
b7e52953b7a6 Add some cache/memory statistics to help spot potential exhaustion and other tuning issues.
Dan Creswell <dan.creswell@gmail.com>
parents: 0
diff changeset
33 _activeCache = anActiveCacheSize;
b7e52953b7a6 Add some cache/memory statistics to help spot potential exhaustion and other tuning issues.
Dan Creswell <dan.creswell@gmail.com>
parents: 0
diff changeset
34 _totalCache = aCacheSize;
b7e52953b7a6 Add some cache/memory statistics to help spot potential exhaustion and other tuning issues.
Dan Creswell <dan.creswell@gmail.com>
parents: 0
diff changeset
35 _free = Runtime.getRuntime().freeMemory();
b7e52953b7a6 Add some cache/memory statistics to help spot potential exhaustion and other tuning issues.
Dan Creswell <dan.creswell@gmail.com>
parents: 0
diff changeset
36 _max = Runtime.getRuntime().maxMemory();
b7e52953b7a6 Add some cache/memory statistics to help spot potential exhaustion and other tuning issues.
Dan Creswell <dan.creswell@gmail.com>
parents: 0
diff changeset
37
b7e52953b7a6 Add some cache/memory statistics to help spot potential exhaustion and other tuning issues.
Dan Creswell <dan.creswell@gmail.com>
parents: 0
diff changeset
38 _safe = (anActiveCacheSize == aCacheSize) &&
b7e52953b7a6 Add some cache/memory statistics to help spot potential exhaustion and other tuning issues.
Dan Creswell <dan.creswell@gmail.com>
parents: 0
diff changeset
39 (Runtime.getRuntime().freeMemory() >= _minimalFree);
0
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
40 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
41
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
42 public long getId() {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
43 return _id;
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
44 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
45
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
46 public String toString() {
23
b7e52953b7a6 Add some cache/memory statistics to help spot potential exhaustion and other tuning issues.
Dan Creswell <dan.creswell@gmail.com>
parents: 0
diff changeset
47 StringBuffer myBuffer = new StringBuffer("Store: " + _type);
0
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
48
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
49 for (int i = 0; i < _titles.length; i++) {
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
50 myBuffer.append(" ");
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
51 myBuffer.append(_titles[i]);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
52 myBuffer.append(" miss: ");
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
53 myBuffer.append(_missed[i]);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
54 myBuffer.append(" deld: ");
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
55 myBuffer.append(_deleted[i]);
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
56 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
57
23
b7e52953b7a6 Add some cache/memory statistics to help spot potential exhaustion and other tuning issues.
Dan Creswell <dan.creswell@gmail.com>
parents: 0
diff changeset
58 myBuffer.append(" sustainable: ");
b7e52953b7a6 Add some cache/memory statistics to help spot potential exhaustion and other tuning issues.
Dan Creswell <dan.creswell@gmail.com>
parents: 0
diff changeset
59 myBuffer.append(_safe);
b7e52953b7a6 Add some cache/memory statistics to help spot potential exhaustion and other tuning issues.
Dan Creswell <dan.creswell@gmail.com>
parents: 0
diff changeset
60 myBuffer.append(" (" + _activeCache + ", " + _totalCache + ", " + _free + ", " + _max + ")");
b7e52953b7a6 Add some cache/memory statistics to help spot potential exhaustion and other tuning issues.
Dan Creswell <dan.creswell@gmail.com>
parents: 0
diff changeset
61
0
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
62 return myBuffer.toString();
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
63 }
3dc0c5604566 Initial checkin of blitz 2.0 fcs - no installer yet.
Dan Creswell <dan.creswell@gmail.com>
parents:
diff changeset
64 }