001: /*
002: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright
003: * notice. All rights reserved.
004: */
005: package com.tctest;
006:
007: import EDU.oswego.cs.dl.util.concurrent.CyclicBarrier;
008:
009: import com.tc.config.schema.builder.InstrumentedClassConfigBuilder;
010: import com.tc.config.schema.builder.LockConfigBuilder;
011: import com.tc.config.schema.builder.RootConfigBuilder;
012: import com.tc.config.schema.test.InstrumentedClassConfigBuilderImpl;
013: import com.tc.config.schema.test.L1ConfigBuilder;
014: import com.tc.config.schema.test.L2ConfigBuilder;
015: import com.tc.config.schema.test.LockConfigBuilderImpl;
016: import com.tc.config.schema.test.RootConfigBuilderImpl;
017: import com.tc.config.schema.test.TerracottaConfigBuilder;
018: import com.tc.util.TIMUtil;
019: import com.tctest.TimeExpiryMapGlobalEvictionTestApp.DataRoot;
020: import com.tctest.TimeExpiryMapGlobalEvictionTestApp.L1Client;
021: import com.tctest.TimeExpiryMapGlobalEvictionTestApp.MockTimeExpiryMap;
022:
023: public class TimeExpiryMapGlobalEvictionTest extends
024: ServerCrashingTestBase {
025: private final static int NODE_COUNT = 1;
026:
027: public TimeExpiryMapGlobalEvictionTest() {
028: super (NODE_COUNT);
029: // disableAllUntil("2007-08-31");
030: }
031:
032: public void setUp() throws Exception {
033: super .setUp();
034:
035: getTransparentAppConfig().setClientCount(NODE_COUNT)
036: .setIntensity(1);
037: initializeTestRunner();
038: }
039:
040: protected Class getApplicationClass() {
041: return TimeExpiryMapGlobalEvictionTestApp.class;
042: }
043:
044: protected void createConfig(TerracottaConfigBuilder cb) {
045: cb.getServers().getL2s()[0]
046: .setPersistenceMode(L2ConfigBuilder.PERSISTENCE_MODE_TEMPORARY_SWAP_ONLY);
047:
048: String testClassName = TimeExpiryMapGlobalEvictionTestApp.class
049: .getName();
050: String clientClassName = L1Client.class.getName();
051: String dataRootClassName = DataRoot.class.getName();
052: String expiryMapClassName = MockTimeExpiryMap.class.getName();
053: String barrierClassName = CyclicBarrier.class.getName();
054:
055: L1ConfigBuilder l1Config = cb.getClient();
056: l1Config.addModule(TIMUtil.EHCACHE_1_2_4, TIMUtil
057: .getVersion(TIMUtil.EHCACHE_1_2_4));
058:
059: LockConfigBuilder lock1 = new LockConfigBuilderImpl(
060: LockConfigBuilder.TAG_AUTO_LOCK);
061: lock1.setMethodExpression("* " + testClassName + "*.*(..)");
062: setLockLevel(lock1);
063:
064: LockConfigBuilder lock2 = new LockConfigBuilderImpl(
065: LockConfigBuilder.TAG_AUTO_LOCK);
066: lock2.setMethodExpression("* " + clientClassName + "*.*(..)");
067: setLockLevel(lock2);
068:
069: LockConfigBuilder lock3 = new LockConfigBuilderImpl(
070: LockConfigBuilder.TAG_AUTO_LOCK);
071: lock3.setMethodExpression("* " + dataRootClassName + "*.*(..)");
072: setLockLevel(lock3);
073:
074: LockConfigBuilder lock4 = new LockConfigBuilderImpl(
075: LockConfigBuilder.TAG_AUTO_LOCK);
076: lock4
077: .setMethodExpression("* " + expiryMapClassName
078: + "*.*(..)");
079: setLockLevel(lock4);
080:
081: LockConfigBuilder lock5 = new LockConfigBuilderImpl(
082: LockConfigBuilder.TAG_AUTO_LOCK);
083: lock5.setMethodExpression("* " + barrierClassName + "*.*(..)");
084: setLockLevel(lock5);
085:
086: cb.getApplication().getDSO().setLocks(
087: new LockConfigBuilder[] { lock1, lock2, lock3, lock4,
088: lock5 });
089:
090: RootConfigBuilder root = new RootConfigBuilderImpl();
091: root.setFieldName(clientClassName + ".barrier");
092: root.setRootName("barrier");
093: RootConfigBuilder root2 = new RootConfigBuilderImpl();
094: root2.setFieldName(clientClassName + ".dataRoot");
095: root2.setRootName("dataRoot");
096: cb.getApplication().getDSO().setRoots(
097: new RootConfigBuilder[] { root, root2 });
098:
099: InstrumentedClassConfigBuilder instrumented1 = new InstrumentedClassConfigBuilderImpl();
100: instrumented1.setClassExpression(testClassName + "*");
101:
102: InstrumentedClassConfigBuilder instrumented2 = new InstrumentedClassConfigBuilderImpl();
103: instrumented2.setClassExpression(clientClassName + "*");
104:
105: InstrumentedClassConfigBuilder instrumented3 = new InstrumentedClassConfigBuilderImpl();
106: instrumented3.setClassExpression(dataRootClassName + "*");
107:
108: InstrumentedClassConfigBuilder instrumented4 = new InstrumentedClassConfigBuilderImpl();
109: instrumented4.setClassExpression(expiryMapClassName + "*");
110:
111: InstrumentedClassConfigBuilder instrumented5 = new InstrumentedClassConfigBuilderImpl();
112: instrumented5.setClassExpression(barrierClassName + "*");
113:
114: cb.getApplication().getDSO().setInstrumentedClasses(
115: new InstrumentedClassConfigBuilder[] { instrumented1,
116: instrumented2, instrumented3, instrumented4,
117: instrumented5 });
118:
119: }
120:
121: private void setLockLevel(LockConfigBuilder lock) {
122: lock.setLockLevel(LockConfigBuilder.LEVEL_WRITE);
123: }
124:
125: private void setReadLockLevel(LockConfigBuilder lock) {
126: lock.setLockLevel(LockConfigBuilder.LEVEL_READ);
127: }
128:
129: }
|