|
21 | 21 | import static java.util.concurrent.TimeUnit.SECONDS;
|
22 | 22 |
|
23 | 23 | import java.time.Duration;
|
24 |
| -import java.util.TreeSet; |
25 | 24 | import java.util.concurrent.atomic.AtomicReference;
|
26 | 25 |
|
27 | 26 | import org.apache.accumulo.core.client.Accumulo;
|
28 | 27 | import org.apache.accumulo.core.client.AccumuloClient;
|
29 | 28 | import org.apache.accumulo.core.conf.Property;
|
| 29 | +import org.apache.accumulo.core.data.Mutation; |
30 | 30 | import org.apache.accumulo.miniclusterImpl.MiniAccumuloConfigImpl;
|
31 | 31 | import org.apache.accumulo.test.functional.ConfigurableMacBase;
|
32 | 32 | import org.apache.hadoop.conf.Configuration;
|
33 |
| -import org.apache.hadoop.io.Text; |
34 | 33 | import org.junit.jupiter.api.Test;
|
35 | 34 |
|
36 | 35 | // ACCUMULO-2480
|
@@ -60,25 +59,40 @@ public void test() throws Exception {
|
60 | 59 | }
|
61 | 60 | final String tableName = getUniqueNames(1)[0];
|
62 | 61 | client.tableOperations().create(tableName);
|
| 62 | + |
| 63 | + // do an initial write to host the tablet and get its location in cache as we may not be able |
| 64 | + // to read the metadata table later |
| 65 | + try (var writer = client.createBatchWriter(tableName)) { |
| 66 | + Mutation m = new Mutation("001"); |
| 67 | + m.put("a", "b", "c"); |
| 68 | + writer.addMutation(m); |
| 69 | + } |
| 70 | + |
63 | 71 | // Kill dfs
|
64 | 72 | cluster.getMiniDfs().shutdown();
|
65 | 73 | // ask the tserver to do something
|
66 | 74 | final AtomicReference<Exception> ex = new AtomicReference<>();
|
67 |
| - Thread splitter = new Thread(() -> { |
| 75 | + Thread backgroundWriter = new Thread(() -> { |
68 | 76 | try {
|
69 |
| - TreeSet<Text> splits = new TreeSet<>(); |
70 |
| - splits.add(new Text("X")); |
71 |
| - client.tableOperations().addSplits(tableName, splits); |
| 77 | + for (int i = 0; i < 100; i++) { |
| 78 | + // These writes should cause the tserver to attempt to write to walog, which should |
| 79 | + // repeatedly fail. Relying on the client side cache to have the tablet location so the |
| 80 | + // writes make it to the tserver where the wal write fails. |
| 81 | + try (var writer = client.createBatchWriter(tableName)) { |
| 82 | + Mutation m = new Mutation("001"); |
| 83 | + m.put("a", "b", "c"); |
| 84 | + writer.addMutation(m); |
| 85 | + } |
| 86 | + } |
72 | 87 | } catch (Exception e) {
|
73 | 88 | ex.set(e);
|
74 | 89 | }
|
75 | 90 | });
|
76 |
| - splitter.start(); |
| 91 | + backgroundWriter.start(); |
77 | 92 | // wait for the tserver to give up on writing to the WAL
|
78 | 93 | while (client.instanceOperations().getTabletServers().size() == 1) {
|
79 | 94 | Thread.sleep(SECONDS.toMillis(1));
|
80 | 95 | }
|
81 | 96 | }
|
82 | 97 | }
|
83 |
| - |
84 | 98 | }
|
0 commit comments