use of org.apache.accumulo.core.client.Connector in project accumulo by apache.
the class BatchWriterIT method test.
@Test
public void test() throws Exception {
// call the batchwriter with buffer of size zero
String table = getUniqueNames(1)[0];
Connector c = getConnector();
c.tableOperations().create(table);
BatchWriterConfig config = new BatchWriterConfig();
config.setMaxMemory(0);
BatchWriter writer = c.createBatchWriter(table, config);
Mutation m = new Mutation("row");
m.put("cf", "cq", new Value("value".getBytes()));
writer.addMutation(m);
writer.close();
}
use of org.apache.accumulo.core.client.Connector in project accumulo by apache.
the class BulkImportMonitoringIT method test.
@Test
public void test() throws Exception {
getCluster().getClusterControl().start(ServerType.MONITOR);
final Connector c = getConnector();
final String tableName = getUniqueNames(1)[0];
c.tableOperations().create(tableName);
c.tableOperations().setProperty(tableName, Property.TABLE_MAJC_RATIO.getKey(), "1");
// splits to slow down bulk import
SortedSet<Text> splits = new TreeSet<>();
for (int i = 1; i < 0xf; i++) {
splits.add(new Text(Integer.toHexString(i)));
}
c.tableOperations().addSplits(tableName, splits);
MasterMonitorInfo stats = getCluster().getMasterMonitorInfo();
assertEquals(1, stats.tServerInfo.size());
assertEquals(0, stats.bulkImports.size());
assertEquals(0, stats.tServerInfo.get(0).bulkImports.size());
log.info("Creating lots of bulk import files");
final FileSystem fs = getCluster().getFileSystem();
final Path basePath = getCluster().getTemporaryPath();
CachedConfiguration.setInstance(fs.getConf());
final Path base = new Path(basePath, "testBulkLoad" + tableName);
fs.delete(base, true);
fs.mkdirs(base);
ExecutorService es = Executors.newFixedThreadPool(5);
List<Future<Pair<String, String>>> futures = new ArrayList<>();
for (int i = 0; i < 10; i++) {
final int which = i;
futures.add(es.submit(new Callable<Pair<String, String>>() {
@Override
public Pair<String, String> call() throws Exception {
Path bulkFailures = new Path(base, "failures" + which);
Path files = new Path(base, "files" + which);
fs.mkdirs(bulkFailures);
fs.mkdirs(files);
for (int i = 0; i < 10; i++) {
FileSKVWriter writer = FileOperations.getInstance().newWriterBuilder().forFile(files.toString() + "/bulk_" + i + "." + RFile.EXTENSION, fs, fs.getConf()).withTableConfiguration(DefaultConfiguration.getInstance()).build();
writer.startDefaultLocalityGroup();
for (int j = 0x100; j < 0xfff; j += 3) {
writer.append(new Key(Integer.toHexString(j)), new Value(new byte[0]));
}
writer.close();
}
return new Pair<>(files.toString(), bulkFailures.toString());
}
}));
}
List<Pair<String, String>> dirs = new ArrayList<>();
for (Future<Pair<String, String>> f : futures) {
dirs.add(f.get());
}
log.info("Importing");
long now = System.currentTimeMillis();
List<Future<Object>> errs = new ArrayList<>();
for (Pair<String, String> entry : dirs) {
final String dir = entry.getFirst();
final String err = entry.getSecond();
errs.add(es.submit(new Callable<Object>() {
@Override
public Object call() throws Exception {
c.tableOperations().importDirectory(tableName, dir, err, false);
return null;
}
}));
}
es.shutdown();
while (!es.isTerminated() && stats.bulkImports.size() + stats.tServerInfo.get(0).bulkImports.size() == 0) {
es.awaitTermination(10, TimeUnit.MILLISECONDS);
stats = getCluster().getMasterMonitorInfo();
}
log.info(stats.bulkImports.toString());
assertTrue(stats.bulkImports.size() > 0);
// look for exception
for (Future<Object> err : errs) {
err.get();
}
es.awaitTermination(2, TimeUnit.MINUTES);
assertTrue(es.isTerminated());
log.info(String.format("Completed in %.2f seconds", (System.currentTimeMillis() - now) / 1000.));
}
use of org.apache.accumulo.core.client.Connector in project accumulo by apache.
the class CleanWalIT method offlineTraceTable.
@Before
public void offlineTraceTable() throws Exception {
Connector conn = getConnector();
String traceTable = conn.instanceOperations().getSystemConfiguration().get(Property.TRACE_TABLE.getKey());
if (conn.tableOperations().exists(traceTable)) {
conn.tableOperations().offline(traceTable, true);
}
}
use of org.apache.accumulo.core.client.Connector in project accumulo by apache.
the class BinaryIT method testPreSplit.
@Test
public void testPreSplit() throws Exception {
String tableName = getUniqueNames(1)[0];
Connector c = getConnector();
c.tableOperations().create(tableName);
SortedSet<Text> splits = new TreeSet<>();
splits.add(new Text("8"));
splits.add(new Text("256"));
c.tableOperations().addSplits(tableName, splits);
runTest(c, tableName);
}
use of org.apache.accumulo.core.client.Connector in project accumulo by apache.
the class BulkSplitOptimizationIT method alterConfig.
@Before
public void alterConfig() throws Exception {
Connector conn = getConnector();
majcDelay = conn.instanceOperations().getSystemConfiguration().get(Property.TSERV_MAJC_DELAY.getKey());
if (!"1s".equals(majcDelay)) {
conn.instanceOperations().setProperty(Property.TSERV_MAJC_DELAY.getKey(), "1s");
getClusterControl().stopAllServers(ServerType.TABLET_SERVER);
getClusterControl().startAllServers(ServerType.TABLET_SERVER);
}
}
Aggregations