01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tctest;
05:
06: import com.tc.object.config.ConfigVisitor;
07: import com.tc.object.config.DSOClientConfigHelper;
08: import com.tc.object.config.TransparencyClassSpec;
09: import com.tc.simulator.app.ApplicationConfig;
10: import com.tc.simulator.listener.ListenerProvider;
11: import com.tctest.runner.AbstractTransparentApp;
12:
13: import java.util.HashMap;
14: import java.util.HashSet;
15: import java.util.Map;
16: import java.util.Set;
17:
18: public class BatchCollectionRetrieveTestApp extends
19: AbstractTransparentApp {
20: private TestRoot root;
21: private Set nodes = new HashSet();
22:
23: public BatchCollectionRetrieveTestApp(String appId,
24: ApplicationConfig cfg, ListenerProvider listenerProvider) {
25: super (appId, cfg, listenerProvider);
26: }
27:
28: public void run() {
29:
30: synchronized (nodes) {
31:
32: this .root = new TestRoot();
33: if (nodes.size() == 0) {
34: root.setBigMap(createBigHashMap());
35: } else {
36: long l = System.currentTimeMillis();
37: root.getBigMap().toString();
38: System.out.println("******Took******:"
39: + (System.currentTimeMillis() - l));
40: }
41: nodes.add(new Object());
42: }
43: }
44:
45: private Map createBigHashMap() {
46: Map m = new HashMap();
47: for (int i = 0; i < 1000; i++) {
48: m.put(new Integer(i), new HashMap());
49: }
50: return m;
51: }
52:
53: private static class TestRoot {
54: private Map bigMap;
55:
56: public void setBigMap(Map m) {
57: this .bigMap = m;
58: }
59:
60: public Map getBigMap() {
61: return this .bigMap;
62: }
63: }
64:
65: public static void visitL1DSOConfig(ConfigVisitor visitor,
66: DSOClientConfigHelper config) {
67: String testClass = BatchCollectionRetrieveTestApp.class
68: .getName();
69: config.getOrCreateSpec(TestRoot.class.getName());
70: TransparencyClassSpec spec = config.getOrCreateSpec(testClass);
71:
72: String methodExpression = "* " + testClass + "*.*(..)";
73: config.addWriteAutolock(methodExpression);
74: spec.addRoot("root", "root");
75: spec.addRoot("nodes", "nodes");
76: }
77: }
|