http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/test/src/main/java/org/apache/accumulo/test/performance/metadata/MetadataBatchScanTest.java ---------------------------------------------------------------------- diff --git a/test/src/main/java/org/apache/accumulo/test/performance/metadata/MetadataBatchScanTest.java b/test/src/main/java/org/apache/accumulo/test/performance/metadata/MetadataBatchScanTest.java index a8b219c..979a6b0 100644 --- a/test/src/main/java/org/apache/accumulo/test/performance/metadata/MetadataBatchScanTest.java +++ b/test/src/main/java/org/apache/accumulo/test/performance/metadata/MetadataBatchScanTest.java @@ -52,96 +52,96 @@ import org.apache.log4j.Logger; import com.google.common.net.HostAndPort; /** - * This little program can be used to write a lot of metadata entries and measure the performance of varying numbers of threads doing metadata - * lookups using the batch scanner. - * - * + * This little program can be used to write a lot of metadata entries and measure the performance of varying numbers of threads doing metadata lookups using the + * batch scanner. + * + * */ public class MetadataBatchScanTest { - + private static final Logger log = Logger.getLogger(MetadataBatchScanTest.class); - + public static void main(String[] args) throws Exception { - + ClientOpts opts = new ClientOpts(); opts.parseArgs(MetadataBatchScanTest.class.getName(), args); Instance inst = new ZooKeeperInstance(new ClientConfiguration().withInstance("acu14").withZkHosts("localhost")); final Connector connector = inst.getConnector(opts.principal, opts.getToken()); - + TreeSet<Long> splits = new TreeSet<Long>(); Random r = new Random(42); - + while (splits.size() < 99999) { splits.add((r.nextLong() & 0x7fffffffffffffffl) % 1000000000000l); } - + Text tid = new Text("8"); Text per = null; - + ArrayList<KeyExtent> extents = new ArrayList<KeyExtent>(); - + for (Long split : splits) { Text er = new Text(String.format("%012d", split)); KeyExtent ke = new KeyExtent(tid, er, per); per = er; - + extents.add(ke); } - + extents.add(new KeyExtent(tid, null, per)); - + if (args[0].equals("write")) { - + BatchWriter bw = connector.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig()); - + for (KeyExtent extent : extents) { Mutation mut = extent.getPrevRowUpdateMutation(); new TServerInstance(HostAndPort.fromParts("192.168.1.100", 4567), "DEADBEEF").putLocation(mut); bw.addMutation(mut); } - + bw.close(); } else if (args[0].equals("writeFiles")) { BatchWriter bw = connector.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig()); - + for (KeyExtent extent : extents) { - + Mutation mut = new Mutation(extent.getMetadataEntry()); - + String dir = "/t-" + UUID.randomUUID(); - + TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.put(mut, new Value(dir.getBytes(UTF_8))); - + for (int i = 0; i < 5; i++) { mut.put(DataFileColumnFamily.NAME, new Text(dir + "/00000_0000" + i + ".map"), new Value("10000,1000000".getBytes(UTF_8))); } - + bw.addMutation(mut); } - + bw.close(); } else if (args[0].equals("scan")) { - + int numThreads = Integer.parseInt(args[1]); final int numLoop = Integer.parseInt(args[2]); int numLookups = Integer.parseInt(args[3]); - + HashSet<Integer> indexes = new HashSet<Integer>(); while (indexes.size() < numLookups) { indexes.add(r.nextInt(extents.size())); } - + final List<Range> ranges = new ArrayList<Range>(); for (Integer i : indexes) { ranges.add(extents.get(i).toMetadataRange()); } - + Thread threads[] = new Thread[numThreads]; - + for (int i = 0; i < threads.length; i++) { threads[i] = new Thread(new Runnable() { - + @Override public void run() { try { @@ -152,79 +152,79 @@ public class MetadataBatchScanTest { } }); } - + long t1 = System.currentTimeMillis(); - + for (int i = 0; i < threads.length; i++) { threads[i].start(); } - + for (int i = 0; i < threads.length; i++) { threads[i].join(); } - + long t2 = System.currentTimeMillis(); - + System.out.printf("tt : %6.2f%n", (t2 - t1) / 1000.0); - + } else { throw new IllegalArgumentException(); } - + } - + private static ScanStats runScanTest(Connector connector, int numLoop, List<Range> ranges) throws Exception { Scanner scanner = null; - + BatchScanner bs = connector.createBatchScanner(MetadataTable.NAME, Authorizations.EMPTY, 1); bs.fetchColumnFamily(TabletsSection.CurrentLocationColumnFamily.NAME); TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN.fetch(bs); - + bs.setRanges(ranges); - + // System.out.println(ranges); - + ScanStats stats = new ScanStats(); for (int i = 0; i < numLoop; i++) { ScanStat ss = scan(bs, ranges, scanner); stats.merge(ss); } - + return stats; } - + private static class ScanStat { long delta1; long delta2; int count1; int count2; } - + private static class ScanStats { Stat delta1 = new Stat(); Stat delta2 = new Stat(); Stat count1 = new Stat(); Stat count2 = new Stat(); - + void merge(ScanStat ss) { delta1.addStat(ss.delta1); delta2.addStat(ss.delta2); count1.addStat(ss.count1); count2.addStat(ss.count2); } - + @Override public String toString() { return "[" + delta1 + "] [" + delta2 + "]"; } } - + private static ScanStat scan(BatchScanner bs, List<Range> ranges, Scanner scanner) { - + // System.out.println("ranges : "+ranges); - + ScanStat ss = new ScanStat(); - + long t1 = System.currentTimeMillis(); int count = 0; for (@SuppressWarnings("unused") @@ -233,22 +233,22 @@ public class MetadataBatchScanTest { } bs.close(); long t2 = System.currentTimeMillis(); - + ss.delta1 = t2 - t1; ss.count1 = count; - + count = 0; t1 = System.currentTimeMillis(); /* * for (Range range : ranges) { scanner.setRange(range); for (Entry<Key, Value> entry : scanner) { count++; } } */ - + t2 = System.currentTimeMillis(); - + ss.delta2 = t2 - t1; ss.count2 = count; - + return ss; } - + }
http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/test/src/main/java/org/apache/accumulo/test/performance/scan/CollectTabletStats.java ---------------------------------------------------------------------- diff --git a/test/src/main/java/org/apache/accumulo/test/performance/scan/CollectTabletStats.java b/test/src/main/java/org/apache/accumulo/test/performance/scan/CollectTabletStats.java index 15c9861..3a45215 100644 --- a/test/src/main/java/org/apache/accumulo/test/performance/scan/CollectTabletStats.java +++ b/test/src/main/java/org/apache/accumulo/test/performance/scan/CollectTabletStats.java @@ -82,7 +82,7 @@ import com.google.common.net.HostAndPort; public class CollectTabletStats { private static final Logger log = Logger.getLogger(CollectTabletStats.class); - + static class CollectOptions extends ClientOnRequiredTable { @Parameter(names = "--iterations", description = "number of iterations") int iterations = 3; @@ -93,69 +93,69 @@ public class CollectTabletStats { @Parameter(names = "-c", description = "comma separated list of columns") String columns; } - + public static void main(String[] args) throws Exception { - + final CollectOptions opts = new CollectOptions(); final ScannerOpts scanOpts = new ScannerOpts(); opts.parseArgs(CollectTabletStats.class.getName(), args, scanOpts); - + String columnsTmp[] = new String[] {}; if (opts.columns != null) columnsTmp = opts.columns.split(","); final String columns[] = columnsTmp; - + final VolumeManager fs = VolumeManagerImpl.get(); - + Instance instance = opts.getInstance(); final ServerConfigurationFactory sconf = new ServerConfigurationFactory(instance); Credentials creds = new Credentials(opts.principal, opts.getToken()); ClientContext context = new ClientContext(instance, creds, sconf.getConfiguration()); - + String tableId = Tables.getNameToIdMap(instance).get(opts.getTableName()); if (tableId == null) { log.error("Unable to find table named " + opts.getTableName()); System.exit(-1); } - + TreeMap<KeyExtent,String> tabletLocations = new TreeMap<KeyExtent,String>(); List<KeyExtent> candidates = findTablets(context, !opts.selectFarTablets, opts.getTableName(), tabletLocations); - + if (candidates.size() < opts.numThreads) { System.err.println("ERROR : Unable to find " + opts.numThreads + " " + (opts.selectFarTablets ? "far" : "local") + " tablets"); System.exit(-1); } - + List<KeyExtent> tabletsToTest = selectRandomTablets(opts.numThreads, candidates); - + Map<KeyExtent,List<FileRef>> tabletFiles = new HashMap<KeyExtent,List<FileRef>>(); - + for (KeyExtent ke : tabletsToTest) { List<FileRef> files = getTabletFiles(context, tableId, ke); tabletFiles.put(ke, files); } - + System.out.println(); System.out.println("run location : " + InetAddress.getLocalHost().getHostName() + "/" + InetAddress.getLocalHost().getHostAddress()); System.out.println("num threads : " + opts.numThreads); System.out.println("table : " + opts.getTableName()); System.out.println("table id : " + tableId); - + for (KeyExtent ke : tabletsToTest) { System.out.println("\t *** Information about tablet " + ke.getUUID() + " *** "); System.out.println("\t\t# files in tablet : " + tabletFiles.get(ke).size()); System.out.println("\t\ttablet location : " + tabletLocations.get(ke)); reportHdfsBlockLocations(tabletFiles.get(ke)); } - + System.out.println("%n*** RUNNING TEST ***%n"); - + ExecutorService threadPool = Executors.newFixedThreadPool(opts.numThreads); - + for (int i = 0; i < opts.iterations; i++) { - + ArrayList<Test> tests = new ArrayList<Test>(); - + for (final KeyExtent ke : tabletsToTest) { final List<FileRef> files = tabletFiles.get(ke); Test test = new Test(ke) { @@ -163,19 +163,19 @@ public class CollectTabletStats { public int runTest() throws Exception { return readFiles(fs, sconf.getConfiguration(), files, ke, columns); } - + }; - + tests.add(test); } - + runTest("read files", tests, opts.numThreads, threadPool); } - + for (int i = 0; i < opts.iterations; i++) { - + ArrayList<Test> tests = new ArrayList<Test>(); - + for (final KeyExtent ke : tabletsToTest) { final List<FileRef> files = tabletFiles.get(ke); Test test = new Test(ke) { @@ -184,16 +184,16 @@ public class CollectTabletStats { return readFilesUsingIterStack(fs, sconf, files, opts.auths, ke, columns, false); } }; - + tests.add(test); } - + runTest("read tablet files w/ system iter stack", tests, opts.numThreads, threadPool); } - + for (int i = 0; i < opts.iterations; i++) { ArrayList<Test> tests = new ArrayList<Test>(); - + for (final KeyExtent ke : tabletsToTest) { final List<FileRef> files = tabletFiles.get(ke); Test test = new Test(ke) { @@ -202,19 +202,19 @@ public class CollectTabletStats { return readFilesUsingIterStack(fs, sconf, files, opts.auths, ke, columns, true); } }; - + tests.add(test); } - + runTest("read tablet files w/ table iter stack", tests, opts.numThreads, threadPool); } - + for (int i = 0; i < opts.iterations; i++) { - + ArrayList<Test> tests = new ArrayList<Test>(); - + final Connector conn = opts.getConnector(); - + for (final KeyExtent ke : tabletsToTest) { Test test = new Test(ke) { @Override @@ -222,16 +222,16 @@ public class CollectTabletStats { return scanTablet(conn, opts.getTableName(), opts.auths, scanOpts.scanBatchSize, ke.getPrevEndRow(), ke.getEndRow(), columns); } }; - + tests.add(test); } - + runTest("read tablet data through accumulo", tests, opts.numThreads, threadPool); } - + for (final KeyExtent ke : tabletsToTest) { final Connector conn = opts.getConnector(); - + threadPool.submit(new Runnable() { @Override public void run() { @@ -243,123 +243,123 @@ public class CollectTabletStats { } }); } - + threadPool.shutdown(); } - + private static abstract class Test implements Runnable { - + private int count; private long t1; private long t2; private CountDownLatch startCdl, finishCdl; private KeyExtent ke; - + Test(KeyExtent ke) { this.ke = ke; } - + public abstract int runTest() throws Exception; - + void setSignals(CountDownLatch scdl, CountDownLatch fcdl) { this.startCdl = scdl; this.finishCdl = fcdl; } - + @Override public void run() { - + try { startCdl.await(); } catch (InterruptedException e) { log.error("startCdl.await() failed.", e); } - + t1 = System.currentTimeMillis(); - + try { count = runTest(); } catch (Exception e) { log.error("runTest() failed.", e); } - + t2 = System.currentTimeMillis(); - + double time = (t2 - t1) / 1000.0; - + System.out.printf("\t\ttablet: " + ke.getUUID() + " thread: " + Thread.currentThread().getId() + " count: %,d cells time: %6.2f rate: %,6.2f cells/sec%n", count, time, count / time); - + finishCdl.countDown(); } - + int getCount() { return count; } - + long getStartTime() { return t1; } - + long getFinishTime() { return t2; } - + } - + private static void runTest(String desc, List<Test> tests, int numThreads, ExecutorService threadPool) throws Exception { - + System.out.println("\tRunning test : " + desc); - + CountDownLatch startSignal = new CountDownLatch(1); CountDownLatch finishedSignal = new CountDownLatch(numThreads); - + for (Test test : tests) { threadPool.submit(test); test.setSignals(startSignal, finishedSignal); } - + startSignal.countDown(); - + finishedSignal.await(); - + long minTime = Long.MAX_VALUE; long maxTime = Long.MIN_VALUE; long count = 0; - + for (Test test : tests) { minTime = Math.min(test.getStartTime(), minTime); maxTime = Math.max(test.getFinishTime(), maxTime); count += test.getCount(); } - + double time = (maxTime - minTime) / 1000.0; System.out.printf("\tAggregate stats count: %,d cells time: %6.2f rate: %,6.2f cells/sec%n", count, time, count / time); System.out.println(); - + // run the gc between test so that object created during previous test are not // collected in following test System.gc(); System.gc(); System.gc(); - + } - - private static List<KeyExtent> findTablets(ClientContext context, boolean selectLocalTablets, String tableName, - SortedMap<KeyExtent,String> tabletLocations) throws Exception { - + + private static List<KeyExtent> findTablets(ClientContext context, boolean selectLocalTablets, String tableName, SortedMap<KeyExtent,String> tabletLocations) + throws Exception { + String tableId = Tables.getNameToIdMap(context.getInstance()).get(tableName); MetadataServicer.forTableId(context, tableId).getTabletLocations(tabletLocations); - + InetAddress localaddress = InetAddress.getLocalHost(); - + List<KeyExtent> candidates = new ArrayList<KeyExtent>(); - + for (Entry<KeyExtent,String> entry : tabletLocations.entrySet()) { String loc = entry.getValue(); if (loc != null) { boolean isLocal = HostAndPort.fromString(entry.getValue()).getHostText().equals(localaddress.getHostName()); - + if (selectLocalTablets && isLocal) { candidates.add(entry.getKey()); } else if (!selectLocalTablets && !isLocal) { @@ -369,10 +369,10 @@ public class CollectTabletStats { } return candidates; } - + private static List<KeyExtent> selectRandomTablets(int numThreads, List<KeyExtent> candidates) { List<KeyExtent> tabletsToTest = new ArrayList<KeyExtent>(); - + Random rand = new Random(); for (int i = 0; i < numThreads; i++) { int rindex = rand.nextInt(candidates.size()); @@ -382,29 +382,29 @@ public class CollectTabletStats { } return tabletsToTest; } - + private static List<FileRef> getTabletFiles(ClientContext context, String tableId, KeyExtent ke) throws IOException { return new ArrayList<FileRef>(MetadataTableUtil.getDataFileSizes(ke, context).keySet()); } - //TODO Remove deprecation warning suppression when Hadoop1 support is dropped + // TODO Remove deprecation warning suppression when Hadoop1 support is dropped @SuppressWarnings("deprecation") private static void reportHdfsBlockLocations(List<FileRef> files) throws Exception { VolumeManager fs = VolumeManagerImpl.get(); - + System.out.println("\t\tFile block report : "); for (FileRef file : files) { FileStatus status = fs.getFileStatus(file.path()); - + if (status.isDir()) { // assume it is a map file status = fs.getFileStatus(new Path(file + "/data")); } FileSystem ns = fs.getVolumeByPath(file.path()).getFileSystem(); BlockLocation[] locs = ns.getFileBlockLocations(status, 0, status.getLen()); - + System.out.println("\t\t\tBlocks for : " + file); - + for (BlockLocation blockLocation : locs) { System.out.printf("\t\t\t\t offset : %,13d hosts :", blockLocation.getOffset()); for (String host : blockLocation.getHosts()) { @@ -413,39 +413,39 @@ public class CollectTabletStats { System.out.println(); } } - + System.out.println(); - + } - + private static SortedKeyValueIterator<Key,Value> createScanIterator(KeyExtent ke, Collection<SortedKeyValueIterator<Key,Value>> mapfiles, Authorizations authorizations, byte[] defaultLabels, HashSet<Column> columnSet, List<IterInfo> ssiList, Map<String,Map<String,String>> ssio, boolean useTableIterators, TableConfiguration conf) throws IOException { - + SortedMapIterator smi = new SortedMapIterator(new TreeMap<Key,Value>()); - + List<SortedKeyValueIterator<Key,Value>> iters = new ArrayList<SortedKeyValueIterator<Key,Value>>(mapfiles.size() + 1); - + iters.addAll(mapfiles); iters.add(smi); - + MultiIterator multiIter = new MultiIterator(iters, ke); DeletingIterator delIter = new DeletingIterator(multiIter, false); ColumnFamilySkippingIterator cfsi = new ColumnFamilySkippingIterator(delIter); ColumnQualifierFilter colFilter = new ColumnQualifierFilter(cfsi, columnSet); VisibilityFilter visFilter = new VisibilityFilter(colFilter, authorizations, defaultLabels); - + if (useTableIterators) return IteratorUtil.loadIterators(IteratorScope.scan, visFilter, ke, conf, ssiList, ssio, null); return visFilter; } - + private static int readFiles(VolumeManager fs, AccumuloConfiguration aconf, List<FileRef> files, KeyExtent ke, String[] columns) throws Exception { - + int count = 0; - + HashSet<ByteSequence> columnSet = createColumnBSS(columns); - + for (FileRef file : files) { FileSystem ns = fs.getVolumeByPath(file.path()).getFileSystem(); FileSKVIterator reader = FileOperations.getInstance().openReader(file.path().toString(), false, ns, ns.getConf(), aconf); @@ -457,10 +457,10 @@ public class CollectTabletStats { } reader.close(); } - + return count; } - + private static HashSet<ByteSequence> createColumnBSS(String[] columns) { HashSet<ByteSequence> columnSet = new HashSet<ByteSequence>(); for (String c : columns) { @@ -468,106 +468,106 @@ public class CollectTabletStats { } return columnSet; } - + private static int readFilesUsingIterStack(VolumeManager fs, ServerConfigurationFactory aconf, List<FileRef> files, Authorizations auths, KeyExtent ke, String[] columns, boolean useTableIterators) throws Exception { - + SortedKeyValueIterator<Key,Value> reader; - + List<SortedKeyValueIterator<Key,Value>> readers = new ArrayList<SortedKeyValueIterator<Key,Value>>(files.size()); - + for (FileRef file : files) { FileSystem ns = fs.getVolumeByPath(file.path()).getFileSystem(); readers.add(FileOperations.getInstance().openReader(file.path().toString(), false, ns, ns.getConf(), aconf.getConfiguration())); } - + List<IterInfo> emptyIterinfo = Collections.emptyList(); Map<String,Map<String,String>> emptySsio = Collections.emptyMap(); TableConfiguration tconf = aconf.getTableConfiguration(ke.getTableId().toString()); reader = createScanIterator(ke, readers, auths, new byte[] {}, new HashSet<Column>(), emptyIterinfo, emptySsio, useTableIterators, tconf); - + HashSet<ByteSequence> columnSet = createColumnBSS(columns); - + reader.seek(new Range(ke.getPrevEndRow(), false, ke.getEndRow(), true), columnSet, columnSet.size() == 0 ? false : true); - + int count = 0; - + while (reader.hasTop()) { count++; reader.next(); } - + return count; - + } - + private static int scanTablet(Connector conn, String table, Authorizations auths, int batchSize, Text prevEndRow, Text endRow, String[] columns) throws Exception { - + Scanner scanner = conn.createScanner(table, auths); scanner.setBatchSize(batchSize); scanner.setRange(new Range(prevEndRow, false, endRow, true)); - + for (String c : columns) { scanner.fetchColumnFamily(new Text(c)); } - + int count = 0; - + for (Entry<Key,Value> entry : scanner) { if (entry != null) count++; } - + return count; } - + private static void calcTabletStats(Connector conn, String table, Authorizations auths, int batchSize, KeyExtent ke, String[] columns) throws Exception { - + // long t1 = System.currentTimeMillis(); - + Scanner scanner = conn.createScanner(table, auths); scanner.setBatchSize(batchSize); scanner.setRange(new Range(ke.getPrevEndRow(), false, ke.getEndRow(), true)); - + for (String c : columns) { scanner.fetchColumnFamily(new Text(c)); } - + Stat rowLen = new Stat(); Stat cfLen = new Stat(); Stat cqLen = new Stat(); Stat cvLen = new Stat(); Stat valLen = new Stat(); Stat colsPerRow = new Stat(); - + Text lastRow = null; int colsPerRowCount = 0; - + for (Entry<Key,Value> entry : scanner) { - + Key key = entry.getKey(); Text row = key.getRow(); - + if (lastRow == null) { lastRow = row; } - + if (!lastRow.equals(row)) { colsPerRow.addStat(colsPerRowCount); lastRow = row; colsPerRowCount = 0; } - + colsPerRowCount++; - + rowLen.addStat(row.getLength()); cfLen.addStat(key.getColumnFamilyData().length()); cqLen.addStat(key.getColumnQualifierData().length()); cvLen.addStat(key.getColumnVisibilityData().length()); valLen.addStat(entry.getValue().get().length); } - + synchronized (System.out) { System.out.println(""); System.out.println("\tTablet " + ke.getUUID() + " statistics : "); @@ -579,13 +579,13 @@ public class CollectTabletStats { printStat("Columns per row", colsPerRow); System.out.println(""); } - + } - + private static void printStat(String desc, Stat s) { System.out.printf("\t\tDescription: [%30s] average: %,6.2f std dev: %,6.2f min: %,d max: %,d %n", desc, s.getAverage(), s.getStdDev(), s.getMin(), s.getMax()); - + } - + } http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/test/src/main/java/org/apache/accumulo/test/performance/thrift/NullTserver.java ---------------------------------------------------------------------- diff --git a/test/src/main/java/org/apache/accumulo/test/performance/thrift/NullTserver.java b/test/src/main/java/org/apache/accumulo/test/performance/thrift/NullTserver.java index 2ebc2e3..0afa243 100644 --- a/test/src/main/java/org/apache/accumulo/test/performance/thrift/NullTserver.java +++ b/test/src/main/java/org/apache/accumulo/test/performance/thrift/NullTserver.java @@ -254,7 +254,8 @@ public class NullTserver { TransactionWatcher watcher = new TransactionWatcher(); ThriftClientHandler tch = new ThriftClientHandler(new AccumuloServerContext(new ServerConfigurationFactory(HdfsZooInstance.getInstance())), watcher); Processor<Iface> processor = new Processor<Iface>(tch); - TServerUtils.startTServer(context.getConfiguration(), HostAndPort.fromParts("0.0.0.0", opts.port), processor, "NullTServer", "null tserver", 2, 1, 1000, 10 * 1024 * 1024, null, -1); + TServerUtils.startTServer(context.getConfiguration(), HostAndPort.fromParts("0.0.0.0", opts.port), processor, "NullTServer", "null tserver", 2, 1, 1000, + 10 * 1024 * 1024, null, -1); HostAndPort addr = HostAndPort.fromParts(InetAddress.getLocalHost().getHostName(), opts.port); http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/test/src/main/java/org/apache/accumulo/test/randomwalk/Environment.java ---------------------------------------------------------------------- diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/Environment.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/Environment.java index 72792ef..92f6427 100644 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/Environment.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/Environment.java @@ -77,7 +77,7 @@ public class Environment { /** * Creates a new test environment. - * + * * @param p * configuration properties * @throws NullPointerException @@ -90,7 +90,7 @@ public class Environment { /** * Gets a copy of the configuration properties. - * + * * @return a copy of the configuration properties */ Properties copyConfigProperties() { @@ -99,7 +99,7 @@ public class Environment { /** * Gets a configuration property. - * + * * @param key * key * @return property value @@ -110,7 +110,7 @@ public class Environment { /** * Gets the configured username. - * + * * @return username */ public String getUserName() { @@ -119,7 +119,7 @@ public class Environment { /** * Gets the configured password. - * + * * @return password */ public String getPassword() { @@ -137,7 +137,7 @@ public class Environment { /** * Gets an authentication token based on the configured password. - * + * * @return authentication token */ public AuthenticationToken getToken() { @@ -146,7 +146,7 @@ public class Environment { /** * Gets an Accumulo instance object. The same instance is reused after the first call. - * + * * @return instance */ public Instance getInstance() { @@ -160,7 +160,7 @@ public class Environment { /** * Gets an Accumulo connector. The same connector is reused after the first call. - * + * * @return connector */ public Connector getConnector() throws AccumuloException, AccumuloSecurityException { @@ -172,7 +172,7 @@ public class Environment { /** * Gets a multitable batch writer. The same object is reused after the first call unless it is reset. - * + * * @return multitable batch writer * @throws NumberFormatException * if any of the numeric batch writer configuration properties cannot be parsed @@ -192,7 +192,7 @@ public class Environment { /** * Checks if a multitable batch writer has been created by this wrapper. - * + * * @return true if multitable batch writer is already created */ public boolean isMultiTableBatchWriterInitialized() { http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/test/src/main/java/org/apache/accumulo/test/randomwalk/Fixture.java ---------------------------------------------------------------------- diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/Fixture.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/Fixture.java index 3f18201..f8d01d9 100644 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/Fixture.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/Fixture.java @@ -19,10 +19,10 @@ package org.apache.accumulo.test.randomwalk; import org.apache.log4j.Logger; public abstract class Fixture { - + protected final Logger log = Logger.getLogger(this.getClass()); - + public abstract void setUp(State state, Environment env) throws Exception; - + public abstract void tearDown(State state, Environment env) throws Exception; } http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/test/src/main/java/org/apache/accumulo/test/randomwalk/Framework.java ---------------------------------------------------------------------- diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/Framework.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/Framework.java index 0e54d90..f5b721b 100644 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/Framework.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/Framework.java @@ -27,31 +27,31 @@ import org.apache.log4j.xml.DOMConfigurator; import com.beust.jcommander.Parameter; public class Framework { - + private static final Logger log = Logger.getLogger(Framework.class); private HashMap<String,Node> nodes = new HashMap<String,Node>(); private String configDir = null; private static final Framework INSTANCE = new Framework(); - + /** * @return Singleton instance of Framework */ public static Framework getInstance() { return INSTANCE; } - + public void setConfigDir(String confDir) { configDir = confDir; } - + /** * Run random walk framework - * + * * @param startName * Full name of starting graph or test */ public int run(String startName, State state, Environment env, String confDir) { - + try { System.out.println("confDir " + confDir); setConfigDir(confDir); @@ -63,21 +63,21 @@ public class Framework { } return 0; } - + /** * Creates node (if it does not already exist) and inserts into map - * + * * @param id * Name of node * @return Node specified by id */ public Node getNode(String id) throws Exception { - + // check for node in nodes if (nodes.containsKey(id)) { return nodes.get(id); } - + // otherwise create and put in nodes Node node = null; if (id.endsWith(".xml")) { @@ -88,18 +88,18 @@ public class Framework { nodes.put(id, node); return node; } - + static class Opts extends org.apache.accumulo.core.cli.Help { - @Parameter(names="--configDir", required=true, description="directory containing the test configuration") + @Parameter(names = "--configDir", required = true, description = "directory containing the test configuration") String configDir; - @Parameter(names="--logDir", required=true, description="location of the local logging directory") + @Parameter(names = "--logDir", required = true, description = "location of the local logging directory") String localLogPath; - @Parameter(names="--logId", required=true, description="a unique log identifier (like a hostname, or pid)") + @Parameter(names = "--logId", required = true, description = "a unique log identifier (like a hostname, or pid)") String logId; - @Parameter(names="--module", required=true, description="the name of the module to run") + @Parameter(names = "--module", required = true, description = "the name of the module to run") String module; } - + public static void main(String[] args) throws Exception { Opts opts = new Opts(); opts.parseArgs(Framework.class.getName(), args); @@ -108,16 +108,16 @@ public class Framework { FileInputStream fis = new FileInputStream(opts.configDir + "/randomwalk.conf"); props.load(fis); fis.close(); - + System.setProperty("localLog", opts.localLogPath + "/" + opts.logId); System.setProperty("nfsLog", props.getProperty("NFS_LOGPATH") + "/" + opts.logId); - + DOMConfigurator.configure(opts.configDir + "logger.xml"); - + State state = new State(); Environment env = new Environment(props); int retval = getInstance().run(opts.module, state, env, opts.configDir); - + System.exit(retval); } } http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/test/src/main/java/org/apache/accumulo/test/randomwalk/Module.java ---------------------------------------------------------------------- diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/Module.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/Module.java index 93a8f61..e5af8e6 100644 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/Module.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/Module.java @@ -58,7 +58,6 @@ public class Module extends Node { private static final Logger log = Logger.getLogger(Module.class); - private class Dummy extends Node { String name; @@ -406,7 +405,7 @@ public class Module extends Node { try { timer.join(); } catch (InterruptedException e) { - log.error("Failed to join timer '"+timer.getName()+"'.", e); + log.error("Failed to join timer '" + timer.getName() + "'.", e); } } if (runningLong.get()) http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/test/src/main/java/org/apache/accumulo/test/randomwalk/Node.java ---------------------------------------------------------------------- diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/Node.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/Node.java index 1588d5a..cb0a468 100644 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/Node.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/Node.java @@ -25,41 +25,41 @@ import org.apache.log4j.Logger; * Represents a point in graph of RandomFramework */ public abstract class Node { - + protected final Logger log = Logger.getLogger(this.getClass()); long progress = System.currentTimeMillis(); - + /** * Visits node - * + * * @param state * Random walk state passed between nodes * @param env * test environment */ public abstract void visit(State state, Environment env, Properties props) throws Exception; - + @Override public boolean equals(Object o) { if (o == null) return false; return toString().equals(o.toString()); } - + @Override public String toString() { return this.getClass().getName(); } - + @Override public int hashCode() { return toString().hashCode(); } - + synchronized public void makingProgress() { progress = System.currentTimeMillis(); } - + synchronized public long lastProgress() { return progress; } http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/test/src/main/java/org/apache/accumulo/test/randomwalk/State.java ---------------------------------------------------------------------- diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/State.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/State.java index 6eb2568..18e21e2 100644 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/State.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/State.java @@ -19,8 +19,7 @@ package org.apache.accumulo.test.randomwalk; import java.util.HashMap; /** - * A structure for storing state kept during a test. This class is not - * thread-safe. + * A structure for storing state kept during a test. This class is not thread-safe. */ public class State { @@ -29,14 +28,15 @@ public class State { /** * Creates new empty state. */ - State() { - } + State() {} /** * Sets a state object. * - * @param key key for object - * @param value object + * @param key + * key for object + * @param value + * object */ public void set(String key, Object value) { stateMap.put(key, value); @@ -45,7 +45,8 @@ public class State { /** * Removes a state object. * - * @param key key for object + * @param key + * key for object */ public void remove(String key) { stateMap.remove(key); @@ -54,9 +55,11 @@ public class State { /** * Gets a state object. * - * @param key key for object + * @param key + * key for object * @return value object - * @throws RuntimeException if state object is not present + * @throws RuntimeException + * if state object is not present */ public Object get(String key) { if (stateMap.containsKey(key) == false) { @@ -68,7 +71,8 @@ public class State { /** * Gets a state object, returning null if it is absent. * - * @param key key for object + * @param key + * key for object * @return value object, or null if not present */ public Object getOkIfAbsent(String key) { @@ -76,8 +80,7 @@ public class State { } /** - * Gets the map of state objects. The backing map for state is returned, so - * changes to it affect the state. + * Gets the map of state objects. The backing map for state is returned, so changes to it affect the state. * * @return state map */ @@ -88,9 +91,11 @@ public class State { /** * Gets a state object as a string. * - * @param key key for object + * @param key + * key for object * @return value as string - * @throws ClassCastException if the value object is not a string + * @throws ClassCastException + * if the value object is not a string */ public String getString(String key) { return (String) stateMap.get(key); @@ -99,9 +104,11 @@ public class State { /** * Gets a state object as an integer. * - * @param key key for object + * @param key + * key for object * @return value as integer - * @throws ClassCastException if the value object is not an integer + * @throws ClassCastException + * if the value object is not an integer */ public Integer getInteger(String key) { return (Integer) stateMap.get(key); @@ -110,9 +117,11 @@ public class State { /** * Gets a state object as a long. * - * @param key key for object + * @param key + * key for object * @return value as long - * @throws ClassCastException if the value object is not a long + * @throws ClassCastException + * if the value object is not a long */ public Long getLong(String key) { return (Long) stateMap.get(key); http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/test/src/main/java/org/apache/accumulo/test/randomwalk/Test.java ---------------------------------------------------------------------- diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/Test.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/Test.java index a7db7dd..f781c9a 100644 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/Test.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/Test.java @@ -20,7 +20,7 @@ package org.apache.accumulo.test.randomwalk; * Tests are extended by users to perform actions on accumulo and are a node of the graph */ public abstract class Test extends Node { - + @Override public String toString() { return getClass().getName(); http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/test/src/main/java/org/apache/accumulo/test/randomwalk/bulk/Setup.java ---------------------------------------------------------------------- diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/bulk/Setup.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/bulk/Setup.java index a2af0bc..b95c141 100644 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/bulk/Setup.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/bulk/Setup.java @@ -34,10 +34,10 @@ import org.apache.accumulo.test.randomwalk.Test; import org.apache.hadoop.fs.FileSystem; public class Setup extends Test { - + private static final int MAX_POOL_SIZE = 8; static String tableName = null; - + @Override public void visit(State state, Environment env, Properties props) throws Exception { Random rand = new Random(); @@ -45,7 +45,7 @@ public class Setup extends Test { String pid = env.getPid(); tableName = String.format("bulk_%s_%s_%d", hostname, pid, System.currentTimeMillis()); log.info("Starting bulk test on " + tableName); - + TableOperations tableOps = env.getConnector().tableOperations(); try { if (!tableOps.exists(getTableName())) { @@ -62,21 +62,21 @@ public class Setup extends Test { state.set("fs", FileSystem.get(CachedConfiguration.getInstance())); state.set("bulkImportSuccess", "true"); BulkPlusOne.counter.set(0l); - + ThreadPoolExecutor e = new SimpleThreadPool(MAX_POOL_SIZE, "bulkImportPool"); state.set("pool", e); } - + public static String getTableName() { return tableName; } - + public static ThreadPoolExecutor getThreadPool(State state) { return (ThreadPoolExecutor) state.get("pool"); } - + public static void run(State state, Runnable r) { getThreadPool(state).submit(r); } - + } http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/test/src/main/java/org/apache/accumulo/test/randomwalk/bulk/Verify.java ---------------------------------------------------------------------- diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/bulk/Verify.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/bulk/Verify.java index f7a727a..f92c31d 100644 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/bulk/Verify.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/bulk/Verify.java @@ -37,9 +37,9 @@ import org.apache.accumulo.test.randomwalk.Test; import org.apache.hadoop.io.Text; public class Verify extends Test { - + static byte[] zero = new byte[] {'0'}; - + @Override public void visit(State state, Environment env, Properties props) throws Exception { ThreadPoolExecutor threadPool = Setup.getThreadPool(state); @@ -57,7 +57,7 @@ public class Verify extends Test { log.info("Not verifying bulk import test due to import failures"); return; } - + String user = env.getConnector().whoami(); Authorizations auths = env.getConnector().securityOperations().getUserAuthorizations(user); Scanner scanner = env.getConnector().createScanner(Setup.getTableName(), auths); @@ -68,18 +68,18 @@ public class Verify extends Test { throw new Exception("Bad key at " + entry); } } - + scanner.clearColumns(); scanner.fetchColumnFamily(BulkPlusOne.MARKER_CF); RowIterator rowIter = new RowIterator(scanner); - + while (rowIter.hasNext()) { Iterator<Entry<Key,Value>> row = rowIter.next(); long prev = 0; Text rowText = null; while (row.hasNext()) { Entry<Key,Value> entry = row.next(); - + if (rowText == null) rowText = entry.getKey().getRow(); @@ -87,13 +87,13 @@ public class Verify extends Test { if (curr - 1 != prev) throw new Exception("Bad marker count " + entry.getKey() + " " + entry.getValue() + " " + prev); - + if (!entry.getValue().toString().equals("1")) throw new Exception("Bad marker value " + entry.getKey() + " " + entry.getValue()); - + prev = curr; } - + if (BulkPlusOne.counter.get() != prev) { throw new Exception("Row " + rowText + " does not have all markers " + BulkPlusOne.counter.get() + " " + prev); } @@ -102,7 +102,7 @@ public class Verify extends Test { log.info("Test successful on table " + Setup.getTableName()); env.getConnector().tableOperations().delete(Setup.getTableName()); } - + public static void main(String args[]) throws Exception { ClientOnRequiredTable opts = new ClientOnRequiredTable(); opts.parseArgs(Verify.class.getName(), args); @@ -139,10 +139,10 @@ public class Verify extends Test { report(startBadRow, lastBadRow, currentBadValue); } } - + private static void report(Text startBadRow, Text lastBadRow, Value value) { System.out.println("Bad value " + new String(value.get(), UTF_8)); System.out.println(" Range [" + startBadRow + " -> " + lastBadRow + "]"); } - + } http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/AddSplits.java ---------------------------------------------------------------------- diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/AddSplits.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/AddSplits.java index 8fc4fb4..2727e62 100644 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/AddSplits.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/AddSplits.java @@ -32,24 +32,24 @@ import org.apache.accumulo.test.randomwalk.Test; import org.apache.hadoop.io.Text; public class AddSplits extends Test { - + @Override public void visit(State state, Environment env, Properties props) throws Exception { Connector conn = env.getConnector(); - + Random rand = (Random) state.get("rand"); - + @SuppressWarnings("unchecked") List<String> tableNames = (List<String>) state.get("tables"); tableNames = new ArrayList<String>(tableNames); tableNames.add(MetadataTable.NAME); String tableName = tableNames.get(rand.nextInt(tableNames.size())); - + TreeSet<Text> splits = new TreeSet<Text>(); - + for (int i = 0; i < rand.nextInt(10) + 1; i++) splits.add(new Text(String.format("%016x", rand.nextLong() & 0x7fffffffffffffffl))); - + try { conn.tableOperations().addSplits(tableName, splits); log.debug("Added " + splits.size() + " splits " + tableName); http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/Apocalypse.java ---------------------------------------------------------------------- diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/Apocalypse.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/Apocalypse.java index 512cb1d..b2d3d50 100644 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/Apocalypse.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/Apocalypse.java @@ -23,12 +23,12 @@ import org.apache.accumulo.test.randomwalk.State; import org.apache.accumulo.test.randomwalk.Test; public class Apocalypse extends Test { - + @Override public void visit(State state, Environment env, Properties props) throws Exception { Process exec = Runtime.getRuntime().exec(new String[] {System.getenv("ACCUMULO_HOME") + "/test/system/randomwalk/bin/apocalypse.sh"}); if (exec.waitFor() != 0) throw new RuntimeException("apocalypse.sh returned a non-zero response: " + exec.exitValue()); } - + } http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/BatchScan.java ---------------------------------------------------------------------- diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/BatchScan.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/BatchScan.java index 6afc7c8..187199f 100644 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/BatchScan.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/BatchScan.java @@ -38,26 +38,26 @@ import org.apache.accumulo.test.randomwalk.State; import org.apache.accumulo.test.randomwalk.Test; public class BatchScan extends Test { - + @Override public void visit(State state, Environment env, Properties props) throws Exception { Connector conn = env.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 { BatchScanner bs = conn.createBatchScanner(tableName, Authorizations.EMPTY, 3); List<Range> ranges = new ArrayList<Range>(); for (int i = 0; i < rand.nextInt(2000) + 1; i++) ranges.add(new Range(String.format("%016x", rand.nextLong() & 0x7fffffffffffffffl))); - + bs.setRanges(ranges); - + try { Iterator<Entry<Key,Value>> iter = bs.iterator(); while (iter.hasNext()) @@ -65,7 +65,7 @@ public class BatchScan extends Test { } finally { bs.close(); } - + log.debug("Wrote to " + tableName); } catch (TableNotFoundException e) { log.debug("BatchScan " + tableName + " failed, doesnt exist"); http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/BatchWrite.java ---------------------------------------------------------------------- diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/BatchWrite.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/BatchWrite.java index 09bf883..76f5cbd 100644 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/BatchWrite.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/BatchWrite.java @@ -36,18 +36,18 @@ import org.apache.accumulo.test.randomwalk.State; import org.apache.accumulo.test.randomwalk.Test; public class BatchWrite extends Test { - + @Override public void visit(State state, Environment env, Properties props) throws Exception { Connector conn = env.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 { BatchWriter bw = conn.createBatchWriter(tableName, new BatchWriterConfig()); try { @@ -58,13 +58,13 @@ public class BatchWrite extends Test { for (int j = 0; j < 10; j++) { m.put("cf", "cq" + j, new Value(String.format("%016x", val).getBytes(UTF_8))); } - + bw.addMutation(m); } } finally { bw.close(); } - + log.debug("Wrote to " + tableName); } catch (TableNotFoundException e) { log.debug("BatchWrite " + tableName + " failed, doesnt exist"); http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/BulkImport.java ---------------------------------------------------------------------- diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/BulkImport.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/BulkImport.java index 0a9d3b9..5af08ec 100644 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/BulkImport.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/BulkImport.java @@ -45,11 +45,11 @@ import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; public class BulkImport extends Test { - + public static class RFileBatchWriter implements BatchWriter { - + RFile.Writer writer; - + public RFileBatchWriter(Configuration conf, FileSystem fs, String file) throws IOException { AccumuloConfiguration aconf = AccumuloConfiguration.getDefaultConfiguration(); CachableBlockFile.Writer cbw = new CachableBlockFile.Writer(fs.create(new Path(file), false, conf.getInt("io.file.buffer.size", 4096), @@ -57,14 +57,14 @@ public class BulkImport extends Test { writer = new RFile.Writer(cbw, 100000); writer.startDefaultLocalityGroup(); } - + @Override public void addMutation(Mutation m) throws MutationsRejectedException { List<ColumnUpdate> updates = m.getUpdates(); for (ColumnUpdate cu : updates) { Key key = new Key(m.getRow(), cu.getColumnFamily(), cu.getColumnQualifier(), cu.getColumnVisibility(), 42, false, false); Value val = new Value(cu.getValue(), false); - + try { writer.append(key, val); } catch (IOException e) { @@ -72,16 +72,16 @@ public class BulkImport extends Test { } } } - + @Override public void addMutations(Iterable<Mutation> iterable) throws MutationsRejectedException { for (Mutation mutation : iterable) addMutation(mutation); } - + @Override public void flush() throws MutationsRejectedException {} - + @Override public void close() throws MutationsRejectedException { try { @@ -90,28 +90,28 @@ public class BulkImport extends Test { throw new RuntimeException(e); } } - + } - + @Override public void visit(State state, Environment env, Properties props) throws Exception { Connector conn = env.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", rand.nextLong() & 0x7fffffffffffffffl); - + fs.mkdirs(new Path(bulkDir)); fs.mkdirs(new Path(bulkDir + "_f")); - + try { BatchWriter bw = new RFileBatchWriter(conf, fs, bulkDir + "/file01.rf"); try { @@ -120,22 +120,22 @@ public class BulkImport extends Test { for (int i = 0; i < numRows; i++) { rows.add(rand.nextLong() & 0x7fffffffffffffffl); } - + for (Long row : rows) { Mutation m = new Mutation(String.format("%016x", row)); long val = rand.nextLong() & 0x7fffffffffffffffl; for (int j = 0; j < 10; j++) { m.put("cf", "cq" + j, new Value(String.format("%016x", val).getBytes(UTF_8))); } - + 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"); @@ -145,6 +145,6 @@ public class BulkImport extends Test { fs.delete(new Path(bulkDir), true); fs.delete(new Path(bulkDir + "_f"), true); } - + } } http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/ChangeAuthorizations.java ---------------------------------------------------------------------- diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/ChangeAuthorizations.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/ChangeAuthorizations.java index 03f2f39..65502c3 100644 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/ChangeAuthorizations.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/ChangeAuthorizations.java @@ -31,20 +31,20 @@ import org.apache.accumulo.test.randomwalk.State; import org.apache.accumulo.test.randomwalk.Test; public class ChangeAuthorizations extends Test { - + @Override public void visit(State state, Environment env, Properties props) throws Exception { Connector conn = env.getConnector(); - + Random rand = (Random) state.get("rand"); - + @SuppressWarnings("unchecked") List<String> userNames = (List<String>) state.get("users"); - + String userName = userNames.get(rand.nextInt(userNames.size())); try { List<byte[]> auths = new ArrayList<byte[]>(conn.securityOperations().getUserAuthorizations(userName).getAuthorizations()); - + if (rand.nextBoolean()) { String authorization = String.format("a%d", rand.nextInt(5000)); log.debug("adding authorization " + authorization); @@ -59,5 +59,5 @@ public class ChangeAuthorizations extends Test { log.debug("Unable to change user authorizations: " + ex.getCause()); } } - + } http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/ChangePermissions.java ---------------------------------------------------------------------- diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/ChangePermissions.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/ChangePermissions.java index 5df1e21..680750a 100644 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/ChangePermissions.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/ChangePermissions.java @@ -27,33 +27,33 @@ import org.apache.accumulo.core.client.AccumuloSecurityException; import org.apache.accumulo.core.client.Connector; import org.apache.accumulo.core.client.impl.thrift.TableOperationExceptionType; import org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException; -import org.apache.accumulo.core.security.SystemPermission; import org.apache.accumulo.core.security.NamespacePermission; +import org.apache.accumulo.core.security.SystemPermission; import org.apache.accumulo.core.security.TablePermission; import org.apache.accumulo.test.randomwalk.Environment; import org.apache.accumulo.test.randomwalk.State; import org.apache.accumulo.test.randomwalk.Test; public class ChangePermissions extends Test { - + @Override public void visit(State state, Environment env, Properties props) throws Exception { Connector conn = env.getConnector(); - + Random rand = (Random) state.get("rand"); - + @SuppressWarnings("unchecked") List<String> userNames = (List<String>) state.get("users"); String userName = userNames.get(rand.nextInt(userNames.size())); - + @SuppressWarnings("unchecked") List<String> tableNames = (List<String>) state.get("tables"); String tableName = tableNames.get(rand.nextInt(tableNames.size())); - + @SuppressWarnings("unchecked") List<String> namespaces = (List<String>) state.get("namespaces"); String namespace = namespaces.get(rand.nextInt(namespaces.size())); - + try { int dice = rand.nextInt(3); if (dice == 0) @@ -67,7 +67,7 @@ public class ChangePermissions extends Test { } catch (AccumuloException ex) { Throwable cause = ex.getCause(); if (cause != null && cause instanceof ThriftTableOperationException) { - ThriftTableOperationException toe = (ThriftTableOperationException)cause.getCause(); + ThriftTableOperationException toe = (ThriftTableOperationException) cause.getCause(); if (toe.type == TableOperationExceptionType.NAMESPACE_NOTFOUND) { log.debug("Unable to change user permissions: " + toe); return; @@ -75,18 +75,18 @@ public class ChangePermissions extends Test { } } } - + private void changeTablePermission(Connector conn, Random rand, String userName, String tableName) throws AccumuloException, AccumuloSecurityException { - + EnumSet<TablePermission> perms = EnumSet.noneOf(TablePermission.class); for (TablePermission p : TablePermission.values()) { if (conn.securityOperations().hasTablePermission(userName, tableName, p)) perms.add(p); } - + EnumSet<TablePermission> more = EnumSet.allOf(TablePermission.class); more.removeAll(perms); - + if (rand.nextBoolean() && more.size() > 0) { List<TablePermission> moreList = new ArrayList<TablePermission>(more); TablePermission choice = moreList.get(rand.nextInt(moreList.size())); @@ -101,18 +101,18 @@ public class ChangePermissions extends Test { } } } - + private void changeSystemPermission(Connector conn, Random rand, String userName) throws AccumuloException, AccumuloSecurityException { EnumSet<SystemPermission> perms = EnumSet.noneOf(SystemPermission.class); for (SystemPermission p : SystemPermission.values()) { if (conn.securityOperations().hasSystemPermission(userName, p)) perms.add(p); } - + EnumSet<SystemPermission> more = EnumSet.allOf(SystemPermission.class); more.removeAll(perms); more.remove(SystemPermission.GRANT); - + if (rand.nextBoolean() && more.size() > 0) { List<SystemPermission> moreList = new ArrayList<SystemPermission>(more); SystemPermission choice = moreList.get(rand.nextInt(moreList.size())); @@ -127,18 +127,18 @@ public class ChangePermissions extends Test { } } } - + private void changeNamespacePermission(Connector conn, Random rand, String userName, String namespace) throws AccumuloException, AccumuloSecurityException { - + EnumSet<NamespacePermission> perms = EnumSet.noneOf(NamespacePermission.class); for (NamespacePermission p : NamespacePermission.values()) { if (conn.securityOperations().hasNamespacePermission(userName, namespace, p)) perms.add(p); } - + EnumSet<NamespacePermission> more = EnumSet.allOf(NamespacePermission.class); more.removeAll(perms); - + if (rand.nextBoolean() && more.size() > 0) { List<NamespacePermission> moreList = new ArrayList<NamespacePermission>(more); NamespacePermission choice = moreList.get(rand.nextInt(moreList.size())); http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CheckBalance.java ---------------------------------------------------------------------- diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CheckBalance.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CheckBalance.java index df246d4..c113091 100644 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CheckBalance.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CheckBalance.java @@ -33,10 +33,10 @@ import org.apache.accumulo.test.randomwalk.State; import org.apache.accumulo.test.randomwalk.Test; /** - * + * */ public class CheckBalance extends Test { - + static final String LAST_UNBALANCED_TIME = "lastUnbalancedTime"; static final String UNBALANCED_COUNT = "unbalancedCount"; @@ -75,7 +75,7 @@ public class CheckBalance extends Test { lastCount = thisCount; } } - + // It is expected that the number of tablets will be uneven for short // periods of time. Don't complain unless we've seen it only unbalanced // over a 15 minute period and it's been at least three checks. @@ -97,7 +97,7 @@ public class CheckBalance extends Test { state.remove(UNBALANCED_COUNT); } } - + private static double stddev(Collection<Long> samples, double avg) { int num = samples.size(); double sqrtotal = 0.0; http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/Compact.java ---------------------------------------------------------------------- diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/Compact.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/Compact.java index 30476a4..d0f1010 100644 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/Compact.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/Compact.java @@ -29,20 +29,20 @@ import org.apache.accumulo.test.randomwalk.Test; import org.apache.hadoop.io.Text; public class Compact extends Test { - + @Override public void visit(State state, Environment env, Properties props) throws Exception { Connector conn = env.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())); - + List<Text> range = ConcurrentFixture.generateRange(rand); - + try { boolean wait = rand.nextBoolean(); conn.tableOperations().compact(tableName, range.get(0), range.get(1), false, wait); @@ -52,6 +52,6 @@ public class Compact extends Test { } catch (TableOfflineException toe) { log.debug("compact " + tableName + " from " + range.get(0) + " to " + range.get(1) + " failed, offline"); } - + } } http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/ConcurrentFixture.java ---------------------------------------------------------------------- diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/ConcurrentFixture.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/ConcurrentFixture.java index 9c51e81..a32e463 100644 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/ConcurrentFixture.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/ConcurrentFixture.java @@ -20,44 +20,42 @@ import java.util.ArrayList; import java.util.List; import java.util.Random; -import org.apache.accumulo.test.randomwalk.Fixture; import org.apache.accumulo.test.randomwalk.Environment; +import org.apache.accumulo.test.randomwalk.Fixture; import org.apache.accumulo.test.randomwalk.State; import org.apache.hadoop.io.Text; /** * When multiple instance of this test suite are run, all instances will operate on the same set of table names. - * - * + * + * */ public class ConcurrentFixture extends Fixture { - + @Override public void setUp(State state, Environment env) throws Exception {} - + @Override public void tearDown(State state, Environment env) throws Exception { state.remove(CheckBalance.LAST_UNBALANCED_TIME); state.remove(CheckBalance.UNBALANCED_COUNT); } - + /** - * + * * @param rand - * A Random to use - * @return - * A two element list with first being smaller than the second, but either value (or both) can be null + * A Random to use + * @return A two element list with first being smaller than the second, but either value (or both) can be null */ public static List<Text> generateRange(Random rand) { ArrayList<Text> toRet = new ArrayList<Text>(2); long firstLong = rand.nextLong(); - - + long secondLong = rand.nextLong(); Text first = null, second = null; - + // Having all negative values = null might be too frequent if (firstLong >= 0) first = new Text(String.format("%016x", firstLong & 0x7fffffffffffffffl)); @@ -69,10 +67,10 @@ public class ConcurrentFixture extends Fixture { first = second; second = swap; } - + toRet.add(first); toRet.add(second); - + return toRet; } } http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CreateTable.java ---------------------------------------------------------------------- diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CreateTable.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CreateTable.java index b9e1ece..30d49f0 100644 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CreateTable.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CreateTable.java @@ -30,18 +30,18 @@ import org.apache.accumulo.test.randomwalk.State; import org.apache.accumulo.test.randomwalk.Test; public class CreateTable extends Test { - + @Override public void visit(State state, Environment env, Properties props) throws Exception { Connector conn = env.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); http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CreateUser.java ---------------------------------------------------------------------- diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CreateUser.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CreateUser.java index 8f265ad..e73e80a 100644 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CreateUser.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/CreateUser.java @@ -31,14 +31,14 @@ public class CreateUser extends Test { @Override public void visit(State state, Environment env, Properties props) throws Exception { Connector conn = env.getConnector(); - + Random rand = (Random) state.get("rand"); - + @SuppressWarnings("unchecked") List<String> userNames = (List<String>) state.get("users"); - + String userName = userNames.get(rand.nextInt(userNames.size())); - + try { log.debug("Creating user " + userName); conn.securityOperations().createLocalUser(userName, new PasswordToken(userName + "pass")); http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/DeleteRange.java ---------------------------------------------------------------------- diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/DeleteRange.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/DeleteRange.java index ced8011..280f620 100644 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/DeleteRange.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/DeleteRange.java @@ -31,18 +31,18 @@ import org.apache.accumulo.test.randomwalk.Test; import org.apache.hadoop.io.Text; public class DeleteRange extends Test { - + @Override public void visit(State state, Environment env, Properties props) throws Exception { Connector conn = env.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())); - + List<Text> range = new ArrayList<Text>(); do { range.add(new Text(String.format("%016x", rand.nextLong() & 0x7fffffffffffffffl))); @@ -53,7 +53,7 @@ public class DeleteRange extends Test { range.set(0, null); if (rand.nextInt(20) == 0) range.set(1, null); - + try { conn.tableOperations().deleteRows(tableName, range.get(0), range.get(1)); log.debug("deleted rows (" + range.get(0) + " -> " + range.get(1) + "] in " + tableName); http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/DeleteTable.java ---------------------------------------------------------------------- diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/DeleteTable.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/DeleteTable.java index 6fb9f7f..4bee7f1 100644 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/DeleteTable.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/DeleteTable.java @@ -27,18 +27,18 @@ import org.apache.accumulo.test.randomwalk.State; import org.apache.accumulo.test.randomwalk.Test; public class DeleteTable extends Test { - + @Override public void visit(State state, Environment env, Properties props) throws Exception { Connector conn = env.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().delete(tableName); log.debug("Deleted table " + tableName); http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/DropUser.java ---------------------------------------------------------------------- diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/DropUser.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/DropUser.java index 13d3c05..a4442c6 100644 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/DropUser.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/DropUser.java @@ -30,14 +30,14 @@ public class DropUser extends Test { @Override public void visit(State state, Environment env, Properties props) throws Exception { Connector conn = env.getConnector(); - + Random rand = (Random) state.get("rand"); - + @SuppressWarnings("unchecked") List<String> userNames = (List<String>) state.get("users"); - + String userName = userNames.get(rand.nextInt(userNames.size())); - + try { log.debug("Dropping user " + userName); conn.securityOperations().dropLocalUser(userName); http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/IsolatedScan.java ---------------------------------------------------------------------- diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/IsolatedScan.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/IsolatedScan.java index 78f73b4..1bb51bb 100644 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/IsolatedScan.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/IsolatedScan.java @@ -36,21 +36,21 @@ import org.apache.accumulo.test.randomwalk.State; import org.apache.accumulo.test.randomwalk.Test; public class IsolatedScan extends Test { - + @Override public void visit(State state, Environment env, Properties props) throws Exception { Connector conn = env.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 { RowIterator iter = new RowIterator(new IsolatedScanner(conn.createScanner(tableName, Authorizations.EMPTY))); - + while (iter.hasNext()) { PeekingIterator<Entry<Key,Value>> row = new PeekingIterator<Entry<Key,Value>>(iter.next()); Entry<Key,Value> kv = null; http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/ListSplits.java ---------------------------------------------------------------------- diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/ListSplits.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/ListSplits.java index 1f82fc0..6944092 100644 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/ListSplits.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/ListSplits.java @@ -30,18 +30,18 @@ import org.apache.accumulo.test.randomwalk.Test; import org.apache.hadoop.io.Text; public class ListSplits extends Test { - + @Override public void visit(State state, Environment env, Properties props) throws Exception { Connector conn = env.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 { Collection<Text> splits = conn.tableOperations().listSplits(tableName); log.debug("Table " + tableName + " had " + splits.size() + " splits"); http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/Merge.java ---------------------------------------------------------------------- diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/Merge.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/Merge.java index 84a4665..a997c2b 100644 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/Merge.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/Merge.java @@ -31,21 +31,21 @@ import org.apache.accumulo.test.randomwalk.Test; import org.apache.hadoop.io.Text; public class Merge extends Test { - + @Override public void visit(State state, Environment env, Properties props) throws Exception { Connector conn = env.getConnector(); - + Random rand = (Random) state.get("rand"); - + @SuppressWarnings("unchecked") List<String> tableNames = (List<String>) state.get("tables"); tableNames = new ArrayList<String>(tableNames); tableNames.add(MetadataTable.NAME); String tableName = tableNames.get(rand.nextInt(tableNames.size())); - + List<Text> range = ConcurrentFixture.generateRange(rand); - + try { conn.tableOperations().merge(tableName, range.get(0), range.get(1)); log.debug("merged " + tableName + " from " + range.get(0) + " to " + range.get(1)); @@ -54,6 +54,6 @@ public class Merge extends Test { } catch (TableNotFoundException tne) { log.debug("merge " + tableName + " from " + range.get(0) + " to " + range.get(1) + " failed, doesnt exist"); } - + } } http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/OfflineTable.java ---------------------------------------------------------------------- diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/OfflineTable.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/OfflineTable.java index 1d725bc..ba6389f 100644 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/OfflineTable.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/OfflineTable.java @@ -28,18 +28,18 @@ import org.apache.accumulo.test.randomwalk.State; import org.apache.accumulo.test.randomwalk.Test; public class OfflineTable extends Test { - + @Override public void visit(State state, Environment env, Properties props) throws Exception { Connector conn = env.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().offline(tableName, rand.nextBoolean()); log.debug("Offlined " + tableName); @@ -49,6 +49,6 @@ public class OfflineTable extends Test { } catch (TableNotFoundException tne) { log.debug("offline or online failed " + tableName + ", doesnt exist"); } - + } } http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/RenameTable.java ---------------------------------------------------------------------- diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/RenameTable.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/RenameTable.java index d468614..57119eb 100644 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/RenameTable.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/RenameTable.java @@ -30,31 +30,31 @@ import org.apache.accumulo.test.randomwalk.State; import org.apache.accumulo.test.randomwalk.Test; public class RenameTable extends Test { - + @Override public void visit(State state, Environment env, Properties props) throws Exception { Connector conn = env.getConnector(); - + Random rand = (Random) state.get("rand"); - + @SuppressWarnings("unchecked") List<String> tableNames = (List<String>) state.get("tables"); - + String srcTableName = tableNames.get(rand.nextInt(tableNames.size())); String newTableName = tableNames.get(rand.nextInt(tableNames.size())); - + String srcNamespace = "", newNamespace = ""; - + int index = srcTableName.indexOf('.'); if (-1 != index) { srcNamespace = srcTableName.substring(0, index); } - + index = newTableName.indexOf('.'); if (-1 != index) { newNamespace = newTableName.substring(0, index); } - + try { conn.tableOperations().rename(srcTableName, newTableName); log.debug("Renamed table " + srcTableName + " " + newTableName); @@ -71,7 +71,7 @@ public class RenameTable extends Test { return; } } - + log.debug("Rename " + srcTableName + " failed, doesnt exist"); } catch (IllegalArgumentException e) { log.debug("Rename: " + e.toString()); @@ -82,7 +82,7 @@ public class RenameTable extends Test { } log.debug("Rename " + srcTableName + " failed.", e); } - + if (!srcNamespace.equals(newNamespace)) { log.error("RenameTable operation should have failed when renaming across namespaces."); } http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/ScanTable.java ---------------------------------------------------------------------- diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/ScanTable.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/ScanTable.java index 8dd24f7..e0bec38 100644 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/ScanTable.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/ScanTable.java @@ -36,18 +36,18 @@ import org.apache.accumulo.test.randomwalk.State; import org.apache.accumulo.test.randomwalk.Test; public class ScanTable extends Test { - + @Override public void visit(State state, Environment env, Properties props) throws Exception { Connector conn = env.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, Authorizations.EMPTY); Iterator<Entry<Key,Value>> iter = scanner.iterator(); http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/Setup.java ---------------------------------------------------------------------- diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/Setup.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/Setup.java index 142287d..c19fcbd 100644 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/Setup.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/Setup.java @@ -26,29 +26,29 @@ import org.apache.accumulo.test.randomwalk.State; import org.apache.accumulo.test.randomwalk.Test; public class Setup extends Test { - + @Override public void visit(State state, Environment env, Properties props) throws Exception { Random rand = new Random(); state.set("rand", rand); - + int numTables = Integer.parseInt(props.getProperty("numTables", "9")); int numNamespaces = Integer.parseInt(props.getProperty("numNamespaces", "2")); log.debug("numTables = " + numTables); log.debug("numNamespaces = " + numNamespaces); List<String> tables = new ArrayList<String>(); List<String> namespaces = new ArrayList<String>(); - + for (int i = 0; i < numNamespaces; i++) { namespaces.add(String.format("nspc_%03d", i)); } - + // Make tables in the default namespace - double tableCeil = Math.ceil((double)numTables / (numNamespaces + 1)); + double tableCeil = Math.ceil((double) numTables / (numNamespaces + 1)); for (int i = 0; i < tableCeil; i++) { tables.add(String.format("ctt_%03d", i)); } - + // Make tables in each namespace double tableFloor = Math.floor(numTables / (numNamespaces + 1)); for (String n : namespaces) { @@ -56,10 +56,10 @@ public class Setup extends Test { tables.add(String.format(n + ".ctt_%03d", i)); } } - + state.set("tables", tables); state.set("namespaces", namespaces); - + int numUsers = Integer.parseInt(props.getProperty("numUsers", "5")); log.debug("numUsers = " + numUsers); List<String> users = new ArrayList<String>(); @@ -67,5 +67,5 @@ public class Setup extends Test { users.add(String.format("user%03d", i)); state.set("users", users); } - + } http://git-wip-us.apache.org/repos/asf/accumulo/blob/6bc67602/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/Shutdown.java ---------------------------------------------------------------------- diff --git a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/Shutdown.java b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/Shutdown.java index 6715edb..6cc8312 100644 --- a/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/Shutdown.java +++ b/test/src/main/java/org/apache/accumulo/test/randomwalk/concurrent/Shutdown.java @@ -32,16 +32,16 @@ import org.apache.accumulo.test.randomwalk.State; import org.apache.accumulo.test.randomwalk.Test; public class Shutdown extends Test { - + @Override public void visit(State state, Environment env, Properties props) throws Exception { log.info("shutting down"); SetGoalState.main(new String[] {MasterGoalState.CLEAN_STOP.name()}); - + while (!env.getConnector().instanceOperations().getTabletServers().isEmpty()) { UtilWaitThread.sleep(1000); } - + while (true) { try { AccumuloServerContext context = new AccumuloServerContext(new ServerConfigurationFactory(HdfsZooInstance.getInstance())); @@ -53,9 +53,9 @@ public class Shutdown extends Test { } UtilWaitThread.sleep(1000); } - + log.info("servers stopped"); UtilWaitThread.sleep(10000); } - + }