use of org.apache.accumulo.core.client.AccumuloClient in project accumulo by apache.
the class CompactionExecutorIT method testIncorrectConfigurerType.
@Test
public void testIncorrectConfigurerType() throws Exception {
String tableName = "tict";
try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) {
client.tableOperations().create(tableName);
addFiles(client, tableName, 5);
var msg = assertThrows(AccumuloException.class, () -> {
client.tableOperations().compact(tableName, new CompactionConfig().setConfigurer(new PluginConfig(TooManyDeletesSelector.class.getName())).setWait(true));
}).getMessage();
assertTrue("Unexpected message : " + msg, msg.contains("TabletServer could not load CompactionConfigurer"));
}
}
use of org.apache.accumulo.core.client.AccumuloClient in project accumulo by apache.
the class CompactionExecutorIT method testIteratorsWithRange.
@Test
public void testIteratorsWithRange() throws Exception {
String tableName = "tiwr";
try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) {
SortedSet<Text> splits = new TreeSet<>();
for (String s : List.of("f", "m", "r", "t")) splits.add(new Text(s));
NewTableConfiguration ntc = new NewTableConfiguration().withSplits(splits);
client.tableOperations().create(tableName, ntc);
Map<String, String> expected = new TreeMap<>();
try (var writer = client.createBatchWriter(tableName)) {
int v = 0;
for (String row : List.of("a", "h", "o", "s", "x")) {
Mutation m = new Mutation(row);
for (int q = 0; q < 10; q++) {
String qual = String.format("%03d", q);
String val = "v" + v++;
m.at().family("f").qualifier(qual).put(val);
expected.put(row + ":f:" + qual, val);
}
writer.addMutation(m);
}
}
IteratorSetting iterSetting = new IteratorSetting(20, "rf", RegExFilter.class.getName());
RegExFilter.setRegexs(iterSetting, null, null, "004|007", null, false);
RegExFilter.setNegate(iterSetting, true);
client.tableOperations().compact(tableName, new CompactionConfig().setStartRow(new Text("b")).setEndRow(new Text("m")).setIterators(List.of(iterSetting)).setWait(true).setFlush(true));
for (String row : List.of("a", "h")) {
assertTrue(expected.remove(row + ":f:004") != null);
assertTrue(expected.remove(row + ":f:007") != null);
}
Map<String, String> actual = scanTable(client, tableName);
assertEquals(expected, actual);
iterSetting = new IteratorSetting(20, "rf", RegExFilter.class.getName());
RegExFilter.setRegexs(iterSetting, null, null, "002|005|009", null, false);
RegExFilter.setNegate(iterSetting, true);
client.tableOperations().compact(tableName, new CompactionConfig().setStartRow(new Text("m")).setEndRow(new Text("u")).setIterators(List.of(iterSetting)).setWait(true));
for (String row : List.of("o", "s", "x")) {
assertTrue(expected.remove(row + ":f:002") != null);
assertTrue(expected.remove(row + ":f:005") != null);
assertTrue(expected.remove(row + ":f:009") != null);
}
actual = scanTable(client, tableName);
assertEquals(expected, actual);
iterSetting = new IteratorSetting(20, "rf", RegExFilter.class.getName());
RegExFilter.setRegexs(iterSetting, null, null, "00[18]", null, false);
RegExFilter.setNegate(iterSetting, true);
client.tableOperations().compact(tableName, new CompactionConfig().setIterators(List.of(iterSetting)).setWait(true));
for (String row : List.of("a", "h", "o", "s", "x")) {
assertTrue(expected.remove(row + ":f:001") != null);
assertTrue(expected.remove(row + ":f:008") != null);
}
actual = scanTable(client, tableName);
assertEquals(expected, actual);
// add all data back and force a compaction to ensure iters do not run again
try (var writer = client.createBatchWriter(tableName)) {
int v = 1000;
for (String row : List.of("a", "h", "o", "s", "x")) {
Mutation m = new Mutation(row);
for (int q = 0; q < 10; q++) {
String qual = String.format("%03d", q);
String val = "v" + v++;
m.at().family("f").qualifier(qual).put(val);
expected.put(row + ":f:" + qual, val);
}
writer.addMutation(m);
}
}
client.tableOperations().compact(tableName, new CompactionConfig().setWait(true).setFlush(true));
actual = scanTable(client, tableName);
assertEquals(expected, actual);
}
}
use of org.apache.accumulo.core.client.AccumuloClient in project accumulo by apache.
the class BadIteratorMincIT method test.
@Test
public void test() throws Exception {
try (AccumuloClient c = Accumulo.newClient().from(getClientProps()).build()) {
String tableName = getUniqueNames(1)[0];
c.tableOperations().create(tableName);
IteratorSetting is = new IteratorSetting(30, BadIterator.class);
c.tableOperations().attachIterator(tableName, is, EnumSet.of(IteratorScope.minc));
try (BatchWriter bw = c.createBatchWriter(tableName)) {
Mutation m = new Mutation(new Text("r1"));
m.put("acf", tableName, "1");
bw.addMutation(m);
}
c.tableOperations().flush(tableName, null, null, false);
sleepUninterruptibly(1, TimeUnit.SECONDS);
// minc should fail, so there should be no files
FunctionalTestUtils.checkRFiles(c, tableName, 1, 1, 0, 0);
// try to scan table
try (Scanner scanner = c.createScanner(tableName, Authorizations.EMPTY)) {
int count = Iterators.size(scanner.iterator());
assertEquals("Did not see expected # entries " + count, 1, count);
// remove the bad iterator
c.tableOperations().removeIterator(tableName, BadIterator.class.getSimpleName(), EnumSet.of(IteratorScope.minc));
sleepUninterruptibly(5, TimeUnit.SECONDS);
// minc should complete
FunctionalTestUtils.checkRFiles(c, tableName, 1, 1, 1, 1);
count = Iterators.size(scanner.iterator());
if (count != 1)
throw new Exception("Did not see expected # entries " + count);
// now try putting bad iterator back and deleting the table
c.tableOperations().attachIterator(tableName, is, EnumSet.of(IteratorScope.minc));
try (BatchWriter bw = c.createBatchWriter(tableName)) {
Mutation m = new Mutation(new Text("r2"));
m.put("acf", tableName, "1");
bw.addMutation(m);
}
// make sure property is given time to propagate
sleepUninterruptibly(500, TimeUnit.MILLISECONDS);
c.tableOperations().flush(tableName, null, null, false);
// make sure the flush has time to start
sleepUninterruptibly(1, TimeUnit.SECONDS);
// this should not hang
c.tableOperations().delete(tableName);
}
}
}
use of org.apache.accumulo.core.client.AccumuloClient in project accumulo by apache.
the class BalanceAfterCommsFailureIT method test.
@Test
public void test() throws Exception {
try (AccumuloClient c = Accumulo.newClient().from(getClientProperties()).build()) {
c.tableOperations().create("test");
Collection<ProcessReference> tservers = getCluster().getProcesses().get(ServerType.TABLET_SERVER);
ArrayList<Integer> tserverPids = new ArrayList<>(tservers.size());
for (ProcessReference tserver : tservers) {
Process p = tserver.getProcess();
if (!p.getClass().getName().equals("java.lang.UNIXProcess")) {
log.info("Found process that was not UNIXProcess, exiting test");
return;
}
Field f = p.getClass().getDeclaredField("pid");
f.setAccessible(true);
tserverPids.add(f.getInt(p));
}
for (int pid : tserverPids) {
assertEquals(0, Runtime.getRuntime().exec(new String[] { "kill", "-SIGSTOP", Integer.toString(pid) }).waitFor());
}
UtilWaitThread.sleep(20_000);
for (int pid : tserverPids) {
assertEquals(0, Runtime.getRuntime().exec(new String[] { "kill", "-SIGCONT", Integer.toString(pid) }).waitFor());
}
SortedSet<Text> splits = new TreeSet<>();
for (String split : "a b c d e f g h i j k l m n o p q r s t u v w x y z".split(" ")) {
splits.add(new Text(split));
}
c.tableOperations().addSplits("test", splits);
// Ensure all of the tablets are actually assigned
assertEquals(0, Iterables.size(c.createScanner("test", Authorizations.EMPTY)));
UtilWaitThread.sleep(30_000);
checkBalance(c);
}
}
use of org.apache.accumulo.core.client.AccumuloClient in project accumulo by apache.
the class BatchWriterFlushIT method run.
@Test
public void run() throws Exception {
try (AccumuloClient c = Accumulo.newClient().from(getClientProps()).build()) {
String[] tableNames = getUniqueNames(2);
String bwft = tableNames[0];
c.tableOperations().create(bwft);
String bwlt = tableNames[1];
c.tableOperations().create(bwlt);
runFlushTest(c, bwft);
runLatencyTest(c, bwlt);
}
}
Aggregations