Merge lp:~pbeaman/akiban-persistit/parameterize-tests into lp:akiban-persistit

Proposed by Peter Beaman
Status: Merged
Approved by: Nathan Williams
Approved revision: 384
Merged at revision: 384
Proposed branch: lp:~pbeaman/akiban-persistit/parameterize-tests
Merge into: lp:akiban-persistit
Diff against target: 250 lines (+99/-13)
4 files modified
src/main/java/com/persistit/CheckpointManager.java (+3/-8)
src/main/java/com/persistit/Configuration.java (+40/-3)
src/main/java/com/persistit/mxbeans/CheckpointManagerMXBean.java (+6/-0)
src/test/java/com/persistit/stress/AbstractSuite.java (+50/-2)
To merge this branch: bzr merge lp:~pbeaman/akiban-persistit/parameterize-tests
Reviewer Review Type Date Requested Status
Nathan Williams Approve
Review via email: mp+131075@code.launchpad.net

Description of the change

This branch makes it easier to global modify configuration parameters for stress tests so that we can easily scale the the buffer pool size, checkpoint interval and commit policy for different hardware environments. Adds a Configuration property to set the default checkpoint interval. Adds logic to AbstractSuite to scale buffer pool configuration up or down, set checkpoint interval and default commit policy.

This branch is in preparation for a Matrix Jenkins test configuration. In the future we may want to do something even more general, but for now these settings are sufficient.

To post a comment you must log in.
Revision history for this message
Nathan Williams (nwilliams) wrote :

As described.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/main/java/com/persistit/CheckpointManager.java'
--- src/main/java/com/persistit/CheckpointManager.java 2012-10-11 14:38:30 +0000
+++ src/main/java/com/persistit/CheckpointManager.java 2012-10-23 19:13:24 +0000
@@ -93,17 +93,11 @@
93 /**93 /**
94 * Default interval in nanoseconds between checkpoints - two minutes.94 * Default interval in nanoseconds between checkpoints - two minutes.
95 */95 */
96 private final static long DEFAULT_CHECKPOINT_INTERVAL = 120;
97
98 private final static long MINIMUM_CHECKPOINT_INTERVAL = 10;
99
100 private final static long MAXIMUM_CHECKPOINT_INTERVAL = 1800;
101
102 private final static Checkpoint UNAVALABLE_CHECKPOINT = new Checkpoint(0, 0);96 private final static Checkpoint UNAVALABLE_CHECKPOINT = new Checkpoint(0, 0);
10397
104 private final SessionId _checkpointTxnSessionId = new SessionId();98 private final SessionId _checkpointTxnSessionId = new SessionId();
10599
106 private volatile long _checkpointIntervalNanos = DEFAULT_CHECKPOINT_INTERVAL * NS_PER_S;100 private volatile long _checkpointIntervalNanos;
107101
108 private volatile long _lastCheckpointNanos = Long.MAX_VALUE;102 private volatile long _lastCheckpointNanos = Long.MAX_VALUE;
109103
@@ -125,6 +119,7 @@
125119
126 public void start() {120 public void start() {
127 _closed.set(false);121 _closed.set(false);
122 _checkpointIntervalNanos = _persistit.getConfiguration().getCheckpointInterval() * NS_PER_S;
128 start("CHECKPOINT_WRITER", FLUSH_CHECKPOINT_INTERVAL);123 start("CHECKPOINT_WRITER", FLUSH_CHECKPOINT_INTERVAL);
129 }124 }
130125
@@ -161,7 +156,7 @@
161156
162 @Override157 @Override
163 public void setCheckpointInterval(final long interval) {158 public void setCheckpointInterval(final long interval) {
164 Util.rangeCheck(interval, MINIMUM_CHECKPOINT_INTERVAL, MAXIMUM_CHECKPOINT_INTERVAL);159 Util.rangeCheck(interval, MINIMUM_CHECKPOINT_INTERVAL_S, MAXIMUM_CHECKPOINT_INTERVAL_S);
165 _checkpointIntervalNanos = interval * NS_PER_S;160 _checkpointIntervalNanos = interval * NS_PER_S;
166 }161 }
167162
168163
=== modified file 'src/main/java/com/persistit/Configuration.java'
--- src/main/java/com/persistit/Configuration.java 2012-10-15 21:22:32 +0000
+++ src/main/java/com/persistit/Configuration.java 2012-10-23 19:13:24 +0000
@@ -15,6 +15,10 @@
1515
16package com.persistit;16package com.persistit;
1717
18import static com.persistit.mxbeans.CheckpointManagerMXBean.DEFAULT_CHECKPOINT_INTERVAL_S;
19import static com.persistit.mxbeans.CheckpointManagerMXBean.MAXIMUM_CHECKPOINT_INTERVAL_S;
20import static com.persistit.mxbeans.CheckpointManagerMXBean.MINIMUM_CHECKPOINT_INTERVAL_S;
21
18import java.io.File;22import java.io.File;
19import java.io.FileInputStream;23import java.io.FileInputStream;
20import java.io.FileNotFoundException;24import java.io.FileNotFoundException;
@@ -39,6 +43,7 @@
39import com.persistit.exception.PersistitIOException;43import com.persistit.exception.PersistitIOException;
40import com.persistit.exception.PropertiesNotFoundException;44import com.persistit.exception.PropertiesNotFoundException;
41import com.persistit.logging.DefaultPersistitLogger;45import com.persistit.logging.DefaultPersistitLogger;
46import com.persistit.mxbeans.CheckpointManagerMXBean;
42import com.persistit.policy.JoinPolicy;47import com.persistit.policy.JoinPolicy;
43import com.persistit.policy.SplitPolicy;48import com.persistit.policy.SplitPolicy;
44import com.persistit.util.Util;49import com.persistit.util.Util;
@@ -168,6 +173,11 @@
168 public final static String SYSTEM_VOLUME_PROPERTY_NAME = "sysvolume";173 public final static String SYSTEM_VOLUME_PROPERTY_NAME = "sysvolume";
169174
170 /**175 /**
176 * Property name for checkpoint interval in seconds
177 */
178 public final static String CHECKPOINT_INTERVAL_PROPERTY_NAME = "checkpointinterval";
179
180 /**
171 * Property name for specifying default temporary volume page size181 * Property name for specifying default temporary volume page size
172 */182 */
173 public final static String TEMPORARY_VOLUME_PAGE_SIZE_PROPERTY_NAME = "tmpvolpagesize";183 public final static String TEMPORARY_VOLUME_PAGE_SIZE_PROPERTY_NAME = "tmpvolpagesize";
@@ -628,6 +638,7 @@
628 private final List<VolumeSpecification> volumeSpecifications = new ArrayList<VolumeSpecification>();638 private final List<VolumeSpecification> volumeSpecifications = new ArrayList<VolumeSpecification>();
629 private String journalPath = DEFAULT_JOURNAL_PATH;639 private String journalPath = DEFAULT_JOURNAL_PATH;
630 private long journalSize = JournalManager.DEFAULT_BLOCK_SIZE;640 private long journalSize = JournalManager.DEFAULT_BLOCK_SIZE;
641 private long checkpointInterval = DEFAULT_CHECKPOINT_INTERVAL_S;
631 private String sysVolume = DEFAULT_SYSTEM_VOLUME_NAME;642 private String sysVolume = DEFAULT_SYSTEM_VOLUME_NAME;
632 private CommitPolicy commitPolicy = DEFAULT_TRANSACTION_COMMIT_POLICY;643 private CommitPolicy commitPolicy = DEFAULT_TRANSACTION_COMMIT_POLICY;
633 private JoinPolicy joinPolicy = DEFAULT_JOIN_POLICY;644 private JoinPolicy joinPolicy = DEFAULT_JOIN_POLICY;
@@ -1045,7 +1056,7 @@
1045 * @throws IllegalArgumentException1056 * @throws IllegalArgumentException
1046 * if the supplied String is not a valid integer representation.1057 * if the supplied String is not a valid integer representation.
1047 */1058 */
1048 static long parseLongProperty(final String propName, final String str) {1059 public static long parseLongProperty(final String propName, final String str) {
1049 if (str != null) {1060 if (str != null) {
1050 try {1061 try {
1051 long multiplier = 1;1062 long multiplier = 1;
@@ -1097,7 +1108,7 @@
1097 * if the supplied String is not a valid floating point1108 * if the supplied String is not a valid floating point
1098 * representation, or is outside the supplied bounds.1109 * representation, or is outside the supplied bounds.
1099 */1110 */
1100 static float parseFloatProperty(final String propName, final String str) {1111 public static float parseFloatProperty(final String propName, final String str) {
1101 if (str != null) {1112 if (str != null) {
1102 try {1113 try {
1103 return Float.parseFloat(str);1114 return Float.parseFloat(str);
@@ -1117,7 +1128,7 @@
1117 * @param str1128 * @param str
1118 * @return the boolean value1129 * @return the boolean value
1119 */1130 */
1120 static boolean parseBooleanValue(final String propName, final String str) {1131 public static boolean parseBooleanValue(final String propName, final String str) {
1121 if ("true".equalsIgnoreCase(str))1132 if ("true".equalsIgnoreCase(str))
1122 return true;1133 return true;
1123 if ("false".equalsIgnoreCase(str))1134 if ("false".equalsIgnoreCase(str))
@@ -1290,6 +1301,32 @@
1290 }1301 }
12911302
1292 /**1303 /**
1304 * Return the value defined by {@link #setCheckpointInterval(long)}
1305 *
1306 * @return the checkpoint interval, in seconds
1307 */
1308 public long getCheckpointInterval() {
1309 return checkpointInterval;
1310 }
1311
1312 /**
1313 * <p>
1314 * Set the checkpoint interval, in seconds. This setting controls the
1315 * elapsed time between attempts to write a checkpoint to the journal. A
1316 * longer interval allows more updates to accumulate in buffers before they
1317 * are required to be written to disk, but also potentially causes recovery
1318 * from an abrupt termination (crash) to take more time.
1319 * </p>
1320 * Default size is
1321 * {@value CheckpointManagerMXBean#DEFAULT_CHECKPOINT_INTERVAL_S} <br/>
1322 * Property name is {@value #CHECKPOINT_INTERVAL_PROPERTY_NAME}
1323 */
1324 public void setCheckpointInterval(final long checkpointInterval) {
1325 this.checkpointInterval = Util.rangeCheck(checkpointInterval, MINIMUM_CHECKPOINT_INTERVAL_S,
1326 MAXIMUM_CHECKPOINT_INTERVAL_S);
1327 }
1328
1329 /**
1293 * Return the value defined by {@link #setSysVolume}1330 * Return the value defined by {@link #setSysVolume}
1294 * 1331 *
1295 * @return the system volume name1332 * @return the system volume name
12961333
=== modified file 'src/main/java/com/persistit/mxbeans/CheckpointManagerMXBean.java'
--- src/main/java/com/persistit/mxbeans/CheckpointManagerMXBean.java 2012-08-02 04:45:28 +0000
+++ src/main/java/com/persistit/mxbeans/CheckpointManagerMXBean.java 2012-10-23 19:13:24 +0000
@@ -24,6 +24,12 @@
24@MXBean24@MXBean
25public interface CheckpointManagerMXBean {25public interface CheckpointManagerMXBean {
2626
27 public final static long DEFAULT_CHECKPOINT_INTERVAL_S = 120;
28
29 public final static long MINIMUM_CHECKPOINT_INTERVAL_S = 10;
30
31 public final static long MAXIMUM_CHECKPOINT_INTERVAL_S = 3600;
32
27 public final static String MXBEAN_NAME = "com.persistit:type=Persistit,class=CheckpointManager";33 public final static String MXBEAN_NAME = "com.persistit:type=Persistit,class=CheckpointManager";
2834
29 @Description("Checkpoint most recently proposed")35 @Description("Checkpoint most recently proposed")
3036
=== modified file 'src/test/java/com/persistit/stress/AbstractSuite.java'
--- src/test/java/com/persistit/stress/AbstractSuite.java 2012-10-04 20:40:40 +0000
+++ src/test/java/com/persistit/stress/AbstractSuite.java 2012-10-23 19:13:24 +0000
@@ -42,7 +42,9 @@
4242
43 private final static String[] ARGS_TEMPLATE = { "duration|int::10|Maximum duration in seconds",43 private final static String[] ARGS_TEMPLATE = { "duration|int::10|Maximum duration in seconds",
44 "datapath|String:/tmp/persistit_test_data|Data path",44 "datapath|String:/tmp/persistit_test_data|Data path",
45 "progress|int:60:1:|Progress message interval in seconds", "_flag|S|Save on failure", };45 "progress|int:60:1:|Progress message interval in seconds", "_flag|S|Save on failure",
46 "checkpointinterval|int:120:10:3600|Checkpoint interval in seconds",
47 "commitpolicy|String:|Default commit policy", "memoryadjustment|String:|Memory adjustment" };
4648
47 protected final static long PROGRESS_LOG_INTERVAL = 600000;49 protected final static long PROGRESS_LOG_INTERVAL = 600000;
4850
@@ -56,6 +58,9 @@
56 final private String _dataPath;58 final private String _dataPath;
57 final private long _progressLogInterval;59 final private long _progressLogInterval;
58 final private boolean _saveOnFailure;60 final private boolean _saveOnFailure;
61 private final int _checkpointInterval;
62 private final String _commitPolicyOverride;
63 private final String _memoryAdjustment;
5964
60 private long _duration;65 private long _duration;
61 private boolean _untilStopped;66 private boolean _untilStopped;
@@ -76,6 +81,9 @@
76 _progressLogInterval = ap.getLongValue("progress");81 _progressLogInterval = ap.getLongValue("progress");
77 _untilStopped = ap.isSpecified("duration");82 _untilStopped = ap.isSpecified("duration");
78 _saveOnFailure = ap.isFlag('S');83 _saveOnFailure = ap.isFlag('S');
84 _checkpointInterval = ap.isSpecified("checkpointinterval") ? ap.getIntValue("checkpointinterval") : 0;
85 _commitPolicyOverride = ap.getStringValue("commitpolicy");
86 _memoryAdjustment = ap.getStringValue("memoryadjustment");
79 }87 }
8088
81 public String getName() {89 public String getName() {
@@ -292,7 +300,7 @@
292300
293 protected Configuration makeConfiguration(final int pageSize, final String mem, final CommitPolicy policy) {301 protected Configuration makeConfiguration(final int pageSize, final String mem, final CommitPolicy policy) {
294 final Configuration c = new Configuration();302 final Configuration c = new Configuration();
295 c.setCommitPolicy(policy);303 c.setCommitPolicy(overrideCommitPolicy(policy, _commitPolicyOverride));
296 c.setJmxEnabled(true);304 c.setJmxEnabled(true);
297 c.setJournalPath(substitute("$datapath$/persistit_journal"));305 c.setJournalPath(substitute("$datapath$/persistit_journal"));
298 c.setLogFile(substitute("$datapath$/persistit_$timestamp$.log"));306 c.setLogFile(substitute("$datapath$/persistit_$timestamp$.log"));
@@ -306,6 +314,46 @@
306 c.getVolumeList().add(314 c.getVolumeList().add(
307 new VolumeSpecification(substitute("$datapath$/persistit,create,pageSize:" + pageSize315 new VolumeSpecification(substitute("$datapath$/persistit,create,pageSize:" + pageSize
308 + ",initialSize:100M,extensionSize:100M,maximumSize:500G")));316 + ",initialSize:100M,extensionSize:100M,maximumSize:500G")));
317 if (_checkpointInterval > 0) {
318 c.setCheckpointInterval(_checkpointInterval);
319 }
320 adjustMemory(bpc);
309 return c;321 return c;
310 }322 }
323
324 private CommitPolicy overrideCommitPolicy(final CommitPolicy policy, final String override) {
325 return override != null && !override.isEmpty() ? CommitPolicy.valueOf(override) : policy;
326 }
327
328 private void adjustMemory(final BufferPoolConfiguration bpc) {
329 final int minc = bpc.getMinimumCount();
330 final int maxc = bpc.getMaximumCount();
331 final long mins = bpc.getMinimumMemory();
332 final long maxs = bpc.getMaximumMemory();
333 if (_memoryAdjustment == null || _memoryAdjustment.isEmpty()) {
334 return;
335 }
336 if (_memoryAdjustment.startsWith("x")) {
337 final float fraction = Float.parseFloat(_memoryAdjustment.substring(1));
338 if (minc > 0 && maxc < Integer.MAX_VALUE) {
339 bpc.setMinimumCount((int) (minc * fraction));
340 bpc.setMaximumCount((int) (maxc * fraction));
341 } else {
342 if (mins > 0 && maxs < Long.MAX_VALUE) {
343 bpc.setMinimumMemory((long) (mins * fraction));
344 bpc.setMaximumMemory((long) (maxs * fraction));
345 }
346 }
347 } else if (_memoryAdjustment.startsWith("c")) {
348 final int count = Integer.parseInt(_memoryAdjustment.substring(1));
349 bpc.setMinimumCount(count);
350 bpc.setMaximumCount(count);
351 } else {
352 final long size = Configuration.parseLongProperty("MemoryAdjustment", _memoryAdjustment);
353 bpc.setMinimumCount(0);
354 bpc.setMaximumCount(Integer.MAX_VALUE);
355 bpc.setMinimumMemory(0);
356 bpc.setMaximumMemory(size);
357 }
358 }
311}359}

Subscribers

People subscribed via source and target branches