use of org.apache.accumulo.core.client.AccumuloClient in project accumulo by apache.
the class AccumuloInputFormatIT method testMapWithBatchScanner.
@Test
public void testMapWithBatchScanner() throws Exception {
final String TEST_TABLE_2 = getUniqueNames(1)[0];
try (AccumuloClient c = Accumulo.newClient().from(getClientProps()).build()) {
c.tableOperations().create(TEST_TABLE_2);
AccumuloOutputFormatIT.insertData(c, TEST_TABLE_2);
assertEquals(0, MRTester.main(new String[] { TEST_TABLE_2, org.apache.accumulo.core.client.mapreduce.AccumuloInputFormat.class.getName(), "True", "False" }));
assertEquals(1, assertionErrors.get(TEST_TABLE_2 + "_map").size());
assertEquals(1, assertionErrors.get(TEST_TABLE_2 + "_cleanup").size());
}
}
use of org.apache.accumulo.core.client.AccumuloClient in project accumulo by apache.
the class AccumuloInputFormatIT method testCorrectRangeInputSplits.
@Test
public void testCorrectRangeInputSplits() throws Exception {
Job job = Job.getInstance();
String table = getUniqueNames(1)[0];
Authorizations auths = new Authorizations("foo");
Collection<Pair<Text, Text>> fetchColumns = Collections.singleton(new Pair<>(new Text("foo"), new Text("bar")));
boolean isolated = true, localIters = true;
Level level = Level.WARN;
try (AccumuloClient accumuloClient = Accumulo.newClient().from(getClientProps()).build()) {
accumuloClient.tableOperations().create(table);
ClientInfo ci = getClientInfo();
org.apache.accumulo.core.client.mapreduce.AccumuloInputFormat.setZooKeeperInstance(job, ci.getInstanceName(), ci.getZooKeepers());
org.apache.accumulo.core.client.mapreduce.AccumuloInputFormat.setConnectorInfo(job, ci.getPrincipal(), ci.getAuthenticationToken());
org.apache.accumulo.core.client.mapreduce.AccumuloInputFormat.setInputTableName(job, table);
org.apache.accumulo.core.client.mapreduce.AccumuloInputFormat.setScanAuthorizations(job, auths);
org.apache.accumulo.core.client.mapreduce.AccumuloInputFormat.setScanIsolation(job, isolated);
org.apache.accumulo.core.client.mapreduce.AccumuloInputFormat.setLocalIterators(job, localIters);
org.apache.accumulo.core.client.mapreduce.AccumuloInputFormat.fetchColumns(job, fetchColumns);
org.apache.accumulo.core.client.mapreduce.AccumuloInputFormat.setLogLevel(job, level);
org.apache.accumulo.core.client.mapreduce.AccumuloInputFormat aif = new org.apache.accumulo.core.client.mapreduce.AccumuloInputFormat();
List<InputSplit> splits = aif.getSplits(job);
assertEquals(1, splits.size());
InputSplit split = splits.get(0);
assertEquals(org.apache.accumulo.core.client.mapreduce.RangeInputSplit.class, split.getClass());
org.apache.accumulo.core.client.mapreduce.RangeInputSplit risplit = (org.apache.accumulo.core.client.mapreduce.RangeInputSplit) split;
assertEquals(table, risplit.getTableName());
assertEquals(isolated, risplit.isIsolatedScan());
assertEquals(localIters, risplit.usesLocalIterators());
assertEquals(fetchColumns, risplit.getFetchedColumns());
assertEquals(level, risplit.getLogLevel());
}
}
use of org.apache.accumulo.core.client.AccumuloClient in project accumulo by apache.
the class AccumuloRowInputFormatIT method test.
@Test
public void test() throws Exception {
try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) {
String tableName = getUniqueNames(1)[0];
client.tableOperations().create(tableName);
try (BatchWriter writer = client.createBatchWriter(tableName)) {
insertList(writer, row1);
insertList(writer, row2);
insertList(writer, row3);
}
MRTester.main(new String[] { tableName });
assertNull(e1);
assertNull(e2);
}
}
use of org.apache.accumulo.core.client.AccumuloClient in project accumulo by apache.
the class MetricsIT method doWorkToGenerateMetrics.
private void doWorkToGenerateMetrics() throws Exception {
try (AccumuloClient client = Accumulo.newClient().from(getClientProperties()).build()) {
String tableName = this.getClass().getSimpleName();
client.tableOperations().create(tableName);
BatchWriterConfig config = new BatchWriterConfig().setMaxMemory(0);
try (BatchWriter writer = client.createBatchWriter(tableName, config)) {
Mutation m = new Mutation("row");
m.put("cf", "cq", new Value("value"));
writer.addMutation(m);
}
client.tableOperations().flush(tableName);
try (BatchWriter writer = client.createBatchWriter(tableName, config)) {
Mutation m = new Mutation("row");
m.put("cf", "cq", new Value("value"));
writer.addMutation(m);
}
client.tableOperations().compact(tableName, new CompactionConfig());
client.tableOperations().delete(tableName);
while (client.tableOperations().exists(tableName)) {
Thread.sleep(1000);
}
}
}
use of org.apache.accumulo.core.client.AccumuloClient in project accumulo by apache.
the class AccumuloInputFormatIT method testSample.
@Test
public void testSample() throws Exception {
final String TEST_TABLE_3 = getUniqueNames(1)[0];
try (AccumuloClient c = Accumulo.newClient().from(getClientProps()).build()) {
c.tableOperations().create(TEST_TABLE_3, new NewTableConfiguration().enableSampling(SAMPLER_CONFIG));
BatchWriter bw = c.createBatchWriter(TEST_TABLE_3);
for (int i = 0; i < 100; i++) {
Mutation m = new Mutation(new Text(String.format("%09x", i + 1)));
m.put("", "", String.format("%09x", i));
bw.addMutation(m);
}
bw.close();
MRTester.main(TEST_TABLE_3, "False", "True");
assertEquals(38, e1Count);
assertEquals(1, e2Count);
e2Count = e1Count = 0;
MRTester.main(TEST_TABLE_3, "False", "False");
assertEquals(0, e1Count);
assertEquals(0, e2Count);
e2Count = e1Count = 0;
MRTester.main(TEST_TABLE_3, "True", "True");
assertEquals(38, e1Count);
assertEquals(1, e2Count);
}
}
Aggregations