2
* Copyright © 2005-2012 Akiban Technologies, Inc. All rights reserved.
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU Affero General Public License as
6
* published by the Free Software Foundation, version 3 (only) of the
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU Affero General Public License for more details.
14
* You should have received a copy of the GNU Affero General Public License
15
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17
* This program may also be available under different license terms. For more
18
* information, see www.akiban.com or contact licensing@akiban.com.
21
package com.persistit.stress;
23
import com.persistit.Exchange;
24
import com.persistit.Key;
25
import com.persistit.Value;
26
import com.persistit.exception.PersistitException;
27
import com.persistit.suite.TestResult;
28
import com.persistit.util.ArgParser;
30
public class Stress5 extends StressBase {
32
public Stress5(String argsString) {
36
private final static String[] ARGS_TEMPLATE = { "repeat|int:1:0:1000000000|Repetitions",
37
"count|int:10000:0:1000000000|Number of nodes to populate", "size|int:4029:10:10000000|Data record size",
38
"splay0|int:12:1:1000|Splay 0", "splay1|int:3:1:1000|Splay 1", "splay2|int:7:1:1000|Splay 2", };
46
public void setUp() throws Exception {
48
_ap = new ArgParser("com.persistit.Stress5", _args, ARGS_TEMPLATE);
49
_total = _ap.getIntValue("count");
50
_repeatTotal = _ap.getIntValue("repeat");
51
_total = _ap.getIntValue("count");
53
_splay0 = _ap.getIntValue("splay0");
54
_splay1 = _ap.getIntValue("splay1");
55
_splay2 = _ap.getIntValue("splay2");
56
_size = _ap.getIntValue("size");
59
// Exchange with Thread-private Tree
60
_ex = getPersistit().getExchange("persistit", _rootName + _threadIndex, true);
61
_exs = getPersistit().getExchange("persistit", "shared", true);
62
} catch (final Exception ex) {
68
* Implements tests with long keys and values of borderline length
71
public void executeTest() {
72
final Value value = new Value(getPersistit());
74
final int baselineCount = 500;
75
final int keyLength = 2041;
76
final int maxDepth = keyLength - 10;
77
final int minDepth = 20;
79
for (_repeat = 0; (_repeat < _repeatTotal || isUntilStopped()) && !isStopped(); _repeat++) {
83
_ex.clear().remove(Key.GTEQ);
87
for (_count = 0; (_count < baselineCount) && !isStopped(); _count++) {
88
setupKey(_ex, keyLength, keyLength - 5, _count, _count, '5');
89
setupTestValue(_ex, _count, _size);
99
for (_count = 0, depth = maxDepth; (depth > minDepth) && !isStopped(); depth -= _splay1, _count++) {
100
setupKey(_ex, keyLength, depth, minDepth + (depth % _splay0), 55555 + depth, '5');
101
setupTestValue(_ex, 55555 + depth, _size);
111
for (_count = 0, depth = maxDepth; (depth > minDepth) && !isStopped(); depth -= _splay2, _count++) {
112
setupKey(_ex, keyLength, depth, minDepth + (depth % _splay0), 55555 - depth, '5');
113
setupTestValue(_ex, 55555 - depth, _size);
123
for (_count = 0, depth = maxDepth; (depth > minDepth) && !isStopped(); depth -= _splay1, _count++) {
124
setupKey(_ex, keyLength, depth, minDepth + (depth % _splay0), 55555 + depth, '5');
125
setupTestValue(_ex, 55555 + depth, _size);
129
compareValues(_ex.getValue(), value);
140
for (_count = 0, depth = maxDepth; (depth > minDepth) && !isStopped(); depth -= _splay2, _count++) {
141
setupKey(_ex, keyLength, depth, minDepth + (depth % _splay0), 55555 - depth, '5');
142
setupTestValue(_ex, 55555 - depth, _size);
146
compareValues(_ex.getValue(), value);
152
_result = new TestResult(false, "Failed to remove depth=" + depth);
162
for (_count = 0; _count < baselineCount; _count++) {
163
setupKey(_ex, keyLength, keyLength - 5, _count, _count, '5');
166
System.out.println("Failed to remove counter=" + _count);
174
if (_ex.traverse(Key.GT, true)) {
175
System.out.println("Tree is not empty");
178
} catch (final PersistitException de) {
184
private void setupKey(final Exchange ex, final int length, final int depth, final int a, final int b,
187
for (int i = 0; i < length; i++) {
190
fillLong(b, depth, 5, true);
191
ex.clear().append(a).append(_sb1);