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 EDU.oswego.cs.dl.util.concurrent.SynchronizedInt;
07:
08: import com.tc.object.config.ConfigVisitor;
09: import com.tc.object.config.DSOClientConfigHelper;
10: import com.tc.object.config.TransparencyClassSpec;
11: import com.tc.object.config.spec.SynchronizedIntSpec;
12: import com.tc.simulator.app.ApplicationConfig;
13: import com.tc.simulator.listener.ListenerProvider;
14: import com.tctest.runner.AbstractTransparentApp;
15:
16: public class FastReadSlowWriteTestApp extends AbstractTransparentApp {
17:
18: public static final int NODE_COUNT = 10;
19: SynchronizedInt idGenerator = new SynchronizedInt(0);
20:
21: public FastReadSlowWriteTestApp(String appId,
22: ApplicationConfig config, ListenerProvider listenerProvider) {
23: super (appId, config, listenerProvider);
24: }
25:
26: public static void visitL1DSOConfig(ConfigVisitor visitor,
27: DSOClientConfigHelper config) {
28:
29: TransparencyClassSpec this Spec = config
30: .getOrCreateSpec(FastReadSlowWriteTestApp.class
31: .getName());
32: this Spec.addRoot("idGenerator", "idGenerator");
33: new SynchronizedIntSpec().visit(visitor, config);
34:
35: TransparencyClassSpec readerSpec = config
36: .getOrCreateSpec("com.tctest.TestReader");
37: TransparencyClassSpec writerSpec = config
38: .getOrCreateSpec("com.tctest.TestWriter");
39:
40: readerSpec.addRoot("stuff", "rootBabyRoot");
41: writerSpec.addRoot("stuff", "rootBabyRoot");
42: config.addReadAutolock("* com.tctest.TestReader.*(..)");
43: config.addWriteAutolock("* com.tctest.TestWriter.*(..)");
44: }
45:
46: public void run() {
47: int myId = idGenerator.increment();
48: if (myId % 5 == 1) {
49: new TestWriter().write();
50: } else {
51: new TestReader("" + myId).read();
52: }
53:
54: }
55:
56: }
|