1 4 package com.tctest; 5 6 import com.tc.object.config.ConfigVisitor; 7 import com.tc.object.config.DSOClientConfigHelper; 8 import com.tc.object.config.TransparencyClassSpec; 9 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 AbstractTransparentApp { 19 private TestRoot root; 20 private Set nodes = new HashSet (); 21 22 public BatchCollectionRetrieveTestApp(String appId, ApplicationConfig cfg, ListenerProvider listenerProvider) { 23 super(appId, cfg, listenerProvider); 24 } 25 26 public void run() { 27 28 synchronized (nodes) { 29 30 this.root = new TestRoot(); 31 if (nodes.size() == 0) { 32 root.setBigMap(createBigHashMap()); 33 } else { 34 long l = System.currentTimeMillis(); 35 root.getBigMap().toString(); 36 System.out.println("******Took******:" + (System.currentTimeMillis() - l)); 37 } 38 nodes.add(new Object ()); 39 } 40 } 41 42 private Map createBigHashMap() { 43 Map m = new HashMap (); 44 for (int i = 0; i < 1000; i++) { 45 m.put(new Integer (i), new HashMap ()); 46 } 47 return m; 48 } 49 50 private static class TestRoot { 51 private Map bigMap; 52 53 public void setBigMap(Map m) { 54 this.bigMap = m; 55 } 56 57 public Map getBigMap() { 58 return this.bigMap; 59 } 60 } 61 62 public static void visitL1DSOConfig(ConfigVisitor visitor, DSOClientConfigHelper config) { 63 String testClass = BatchCollectionRetrieveTestApp.class.getName(); 64 config.getOrCreateSpec(TestRoot.class.getName()); 65 TransparencyClassSpec spec = config.getOrCreateSpec(testClass); 66 67 String methodExpression = "* " + testClass + "*.*(..)"; 68 config.addWriteAutolock(methodExpression); 69 spec.addRoot("root", "root"); 70 spec.addRoot("nodes", "nodes"); 71 } 72 }
| Popular Tags
|