Skip to content

Commit 3bc2502

Browse files
committed
modify write method to write to a single tablet
1 parent a176b85 commit 3bc2502

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

test/src/main/java/org/apache/accumulo/test/MaxWalReferencedIT.java

+14-14
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public class MaxWalReferencedIT extends ConfigurableMacBase {
5252
private static final Logger log = LoggerFactory.getLogger(MaxWalReferencedIT.class);
5353

5454
final int WAL_MAX_REFERENCED = 3;
55+
final int hdfsMinBlockSize = 1048576;
5556

5657
@Override
5758
protected Duration defaultTimeout() {
@@ -60,10 +61,8 @@ protected Duration defaultTimeout() {
6061

6162
@Override
6263
protected void configure(MiniAccumuloConfigImpl cfg, Configuration hadoopCoreSite) {
63-
final String hdfsMinBlockSize = "1048576";
64-
6564
// Set a small WAL size so we roll frequently
66-
cfg.setProperty(Property.TSERV_WAL_MAX_SIZE, hdfsMinBlockSize);
65+
cfg.setProperty(Property.TSERV_WAL_MAX_SIZE, Integer.toString(hdfsMinBlockSize));
6766
// Set the max number of WALs that can be referenced
6867
cfg.setProperty(Property.TSERV_WAL_MAX_REFERENCED, Integer.toString(WAL_MAX_REFERENCED));
6968
cfg.setNumTservers(1);
@@ -89,16 +88,13 @@ public void testWALMaxReferenced() throws Exception {
8988
final int rowsPerIteration = 30000;
9089
AtomicInteger iteration = new AtomicInteger(0);
9190
Wait.waitFor(() -> {
92-
int startRow = iteration.get() * rowsPerIteration;
93-
int endRow = (iteration.get() + 1) * rowsPerIteration;
9491

9592
// Write data that should fill or partially fill the WAL
96-
writeData(client, tableName, startRow, endRow);
93+
writeData(client, tableName);
9794

9895
// Check the current number of WALs in use
9996
long walCount = getWalCount(getServerContext());
100-
log.info("After iteration {}, wrote rows [{}..{}), WAL count is {}", iteration, startRow,
101-
endRow, walCount);
97+
log.info("After iteration {}, WAL count is {}", iteration, walCount);
10298
iteration.getAndIncrement();
10399

104100
if (walCount > WAL_MAX_REFERENCED) {
@@ -108,21 +104,25 @@ public void testWALMaxReferenced() throws Exception {
108104
} else {
109105
return false;
110106
}
111-
}, 60000, 250, "Expected to see WAL count exceed " + WAL_MAX_REFERENCED);
107+
}, 60000, 10, "Expected to see WAL count exceed " + WAL_MAX_REFERENCED);
112108

113109
// wait for minor compactions to reduce the WAL count
114110
Wait.waitFor(() -> getWalCount(getServerContext()) <= WAL_MAX_REFERENCED, 30000, 1000,
115111
"WAL count never dropped within 30 seconds");
116112
}
117113
}
118114

119-
private void writeData(AccumuloClient client, String table, int startRow, int endRow)
120-
throws Exception {
115+
/**
116+
* Writes data to a single tablet until the total written data size exceeds 2 * TSERV_WAL_MAX_SIZE
117+
*/
118+
private void writeData(AccumuloClient client, String table) throws Exception {
121119
try (BatchWriter bw = client.createBatchWriter(table, new BatchWriterConfig())) {
122-
for (int r = startRow; r < endRow; r++) {
123-
Mutation m = new Mutation(String.format("row_%07d", r));
124-
m.put("cf", "cq", String.format("val_%d", r));
120+
long totalWritten = 0;
121+
while (totalWritten < 2 * hdfsMinBlockSize) {
122+
Mutation m = new Mutation("target_row");
123+
m.put("cf", "cq", "value");
125124
bw.addMutation(m);
125+
totalWritten += m.estimatedMemoryUsed();
126126
}
127127
}
128128
}

0 commit comments

Comments
 (0)