Mercurial > hg > blitz_stable
comparison examples/entrysizer/TestSizer.java @ 0:3dc0c5604566
Initial checkin of blitz 2.0 fcs - no installer yet.
author | Dan Creswell <dan.creswell@gmail.com> |
---|---|
date | Sat, 21 Mar 2009 11:00:06 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:3dc0c5604566 |
---|---|
1 package entrysizer; | |
2 | |
3 import net.jini.core.entry.Entry; | |
4 | |
5 import org.dancres.blitz.mangler.EntrySizer; | |
6 | |
7 /** | |
8 This class demonstrates how to use the Blitz EntrySizer which can be | |
9 used to give an approximate size for an Entry once it's marshalled and | |
10 ready for storage in the Blitz backend. This is useful for sizing heap, | |
11 caches and disk storage (for a persistent or time-barrier-persistent | |
12 Blitz). | |
13 */ | |
14 public class TestSizer { | |
15 public static void main(String args[]) { | |
16 try { | |
17 /* | |
18 Create an EntrySizer instance (EntrySizer is stateless) | |
19 */ | |
20 EntrySizer mySizer = new EntrySizer(); | |
21 | |
22 /* | |
23 Create some example Entry's | |
24 */ | |
25 Entry[] myEntrys = new Entry[] {new DummyEntry("a"), | |
26 new DummyEntry("abcdefgh"), | |
27 new DummyEntry(null)}; | |
28 | |
29 /* | |
30 For each example, get a size estimate from the Sizer. | |
31 */ | |
32 for (int i = 0; i < myEntrys.length; i++) { | |
33 System.out.println("Size of: " + myEntrys[i] + " = " + | |
34 mySizer.computeSize(myEntrys[i])); | |
35 } | |
36 } catch (Exception anE) { | |
37 System.err.println("Whoops, didn't work"); | |
38 anE.printStackTrace(System.err); | |
39 } | |
40 } | |
41 } |