@Override public void visit(State state, Properties props) throws Exception { Connector conn = state.getConnector(); Random rand = (Random) state.get("rand"); @SuppressWarnings("unchecked") List<String> tableNames = (List<String>) state.get("tables"); String tableName = tableNames.get(rand.nextInt(tableNames.size())); // TODO need to sometimes do null start and end ranges TreeSet<Text> range = new TreeSet<Text>(); range.add(new Text(String.format("%016x", Math.abs(rand.nextLong())))); range.add(new Text(String.format("%016x", Math.abs(rand.nextLong())))); try { boolean wait = rand.nextBoolean(); conn.tableOperations().compact(tableName, range.first(), range.last(), false, wait); log.debug((wait ? "compacted " : "initiated compaction ") + tableName); } catch (TableNotFoundException tne) { log.debug("compact " + tableName + " failed, doesnt exist"); } catch (TableOfflineException toe) { log.debug("compact " + tableName + " failed, offline"); } }
@Override public void visit(State state, Properties props) throws Exception { Connector conn = state.getConnector(); Random rand = (Random) state.get("rand"); @SuppressWarnings("unchecked") List<String> tableNames = (List<String>) state.get("tables"); String tableName = tableNames.get(rand.nextInt(tableNames.size())); try { Scanner scanner = conn.createScanner(tableName, Constants.NO_AUTHS); Iterator<Entry<Key, Value>> iter = scanner.iterator(); while (iter.hasNext()) { iter.next(); } log.debug("Scanned " + tableName); } catch (TableDeletedException e) { log.debug("Scan " + tableName + " failed, table deleted"); } catch (TableNotFoundException e) { log.debug("Scan " + tableName + " failed, doesnt exist"); } catch (TableOfflineException e) { log.debug("Scan " + tableName + " failed, offline"); } catch (RuntimeException e) { if (e.getCause() instanceof AccumuloSecurityException) { log.debug("BatchScan " + tableName + " failed, permission error"); } else { throw e; } } }
@Override public void visit(State state, Properties props) throws Exception { Connector conn = state.getConnector(); Random rand = (Random) state.get("rand"); @SuppressWarnings("unchecked") List<String> tableNames = (List<String>) state.get("tables"); String tableName = tableNames.get(rand.nextInt(tableNames.size())); Configuration conf = CachedConfiguration.getInstance(); FileSystem fs = FileSystem.get(conf); String bulkDir = "/tmp/concurrent_bulk/b_" + String.format("%016x", Math.abs(rand.nextLong())); fs.mkdirs(new Path(bulkDir)); fs.mkdirs(new Path(bulkDir + "_f")); try { BatchWriter bw = new RFileBatchWriter(conf, fs, bulkDir + "/file01.rf"); try { TreeSet<Long> rows = new TreeSet<Long>(); int numRows = rand.nextInt(100000); for (int i = 0; i < numRows; i++) { rows.add(Math.abs(rand.nextLong())); } for (Long row : rows) { Mutation m = new Mutation(String.format("%016x", row)); long val = Math.abs(rand.nextLong()); for (int j = 0; j < 10; j++) { m.put("cf", "cq" + j, new Value(String.format("%016x", val).getBytes())); } bw.addMutation(m); } } finally { bw.close(); } conn.tableOperations() .importDirectory(tableName, bulkDir, bulkDir + "_f", rand.nextBoolean()); log.debug("BulkImported to " + tableName); } catch (TableNotFoundException e) { log.debug("BulkImport " + tableName + " failed, doesnt exist"); } catch (TableOfflineException toe) { log.debug("BulkImport " + tableName + " failed, offline"); } finally { fs.delete(new Path(bulkDir), true); fs.delete(new Path(bulkDir + "_f"), true); } }
@Override public void visit(State state, Properties props) throws Exception { Connector conn = state.getConnector(); Random rand = (Random) state.get("rand"); @SuppressWarnings("unchecked") List<String> tableNames = (List<String>) state.get("tables"); String tableName = tableNames.get(rand.nextInt(tableNames.size())); try { conn.tableOperations().create(tableName); log.debug("Created table " + tableName); } catch (TableExistsException e) { log.debug("Create " + tableName + " failed, it exist"); } }