1 4 package com.tctest.performance.throughput; 5 6 import EDU.oswego.cs.dl.util.concurrent.LinkedQueue; 7 8 import com.tc.object.config.ConfigVisitor; 9 import com.tc.object.config.DSOApplicationConfig; 10 import com.tc.object.config.DSOClientConfigHelper; 11 import com.tc.object.config.TransparencyClassSpec; 12 import com.tc.object.config.spec.LinkedQueueSpec; 13 import com.tc.simulator.app.ApplicationConfig; 14 import com.tc.simulator.listener.ListenerProvider; 15 import com.tctest.performance.generate.load.Metronome; 16 17 public final class DualOswegoQueueThroughputTestApp extends AbstractDualQueueThroughputTestApp { 18 19 private final LinkedQueue rootQueue1; 20 private final LinkedQueue rootQueue2; 21 22 public DualOswegoQueueThroughputTestApp(String appId, ApplicationConfig cfg, ListenerProvider listenerProvider) { 23 super(appId, cfg, listenerProvider); 24 rootQueue1 = new LinkedQueue(); 25 rootQueue2 = new LinkedQueue(); 26 } 27 28 public static void visitL1DSOConfig(ConfigVisitor visitor, DSOClientConfigHelper config) { 29 TransparencyClassSpec spec = config.getOrCreateSpec(Metronome.class.getName()); 30 String className = DualOswegoQueueThroughputTestApp.class.getName(); 31 spec = config.getOrCreateSpec(className); 32 String methodExpression = "* " + className + "*.*(..)"; 33 config.addWriteAutolock(methodExpression); 34 spec.addRoot("rootQueue1", "rootQueue1"); 35 spec.addRoot("rootQueue2", "rootQueue2"); 36 new LinkedQueueSpec().visit(visitor, config); 37 } 38 39 public static void visitDSOApplicationConfig(ConfigVisitor visitor, DSOApplicationConfig config) { 40 config.addIncludePattern(Metronome.class.getName()); 41 String className = DualOswegoQueueThroughputTestApp.class.getName(); 42 config.addIncludePattern(className); 43 String methodExpression = "* " + className + "*.*(..)"; 44 config.addWriteAutolock(methodExpression); 45 config.addRoot("rootQueue1", className + ".rootQueue1"); 46 config.addRoot("rootQueue2", className + ".rootQueue2"); 47 new LinkedQueueSpec().visit(visitor, config); 48 } 49 50 protected void populate1(Object data) throws InterruptedException { 52 if (data instanceof Metronome) { 53 synchronized (data) { 54 ((Metronome) data).starttime = System.nanoTime(); 55 } 56 } 57 rootQueue1.put(data); 58 } 59 60 protected void populate2(Object data) throws InterruptedException { 61 if (data instanceof Metronome) { 62 synchronized (data) { 63 ((Metronome) data).starttime = System.nanoTime(); 64 } 65 } 66 rootQueue2.put(data); 67 } 68 69 protected void retrieve1() throws InterruptedException { 70 Object data; 71 data = rootQueue1.take(); 72 if (data instanceof Metronome) { 73 synchronized (data) { 74 ((Metronome) data).endtime = System.nanoTime(); 75 } 76 results1().add(data); 77 } 78 } 79 80 protected void retrieve2() throws InterruptedException { 81 Object data; 82 data = rootQueue2.take(); 83 if (data instanceof Metronome) { 84 synchronized (data) { 85 ((Metronome) data).endtime = System.nanoTime(); 86 } 87 results2().add(data); 88 } 89 } 90 91 protected String title() { 92 return "Dual Shared Oswego Queue Throughput"; 93 } 94 } 95 | Popular Tags |