void benchmarkOne() throws IOException { for (int idx = 0; idx < opsPerThread; idx++) { if ((localNumOpsExecuted + 1) % statsOp.ugcRefreshCount == 0) nameNode.refreshUserToGroupsMappings(); long stat = statsOp.executeOp(daemonId, idx, arg1); localNumOpsExecuted++; localCumulativeTime += stat; } }
public void run() { localNumOpsExecuted = 0; localCumulativeTime = 0; arg1 = statsOp.getExecutionArgument(daemonId); try { benchmarkOne(); } catch (IOException ex) { LOG.error("StatsDaemon " + daemonId + " failed: \n" + StringUtils.stringifyException(ex)); } }
/** * Main method of the benchmark. * * @param args command line parameters */ public static void runBenchmark(Configuration conf, List<String> args) throws Exception { if (args.size() < 2 || !args.get(0).startsWith("-op")) printUsage(); String type = args.get(1); boolean runAll = OperationStatsBase.OP_ALL_NAME.equals(type); NNThroughputBenchmark bench = null; List<OperationStatsBase> ops = new ArrayList<OperationStatsBase>(); OperationStatsBase opStat = null; try { bench = new NNThroughputBenchmark(conf); if (runAll || CreateFileStats.OP_CREATE_NAME.equals(type)) { opStat = bench.new CreateFileStats(args); ops.add(opStat); } if (runAll || OpenFileStats.OP_OPEN_NAME.equals(type)) { opStat = bench.new OpenFileStats(args); ops.add(opStat); } if (runAll || DeleteFileStats.OP_DELETE_NAME.equals(type)) { opStat = bench.new DeleteFileStats(args); ops.add(opStat); } if (runAll || RenameFileStats.OP_RENAME_NAME.equals(type)) { opStat = bench.new RenameFileStats(args); ops.add(opStat); } if (runAll || BlockReportStats.OP_BLOCK_REPORT_NAME.equals(type)) { opStat = bench.new BlockReportStats(args); ops.add(opStat); } if (runAll || ReplicationStats.OP_REPLICATION_NAME.equals(type)) { opStat = bench.new ReplicationStats(args); ops.add(opStat); } if (runAll || CleanAllStats.OP_CLEAN_NAME.equals(type)) { opStat = bench.new CleanAllStats(args); ops.add(opStat); } if (ops.size() == 0) printUsage(); // run each benchmark for (OperationStatsBase op : ops) { LOG.info("Starting benchmark: " + op.getOpName()); op.benchmark(); op.cleanUp(); } // print statistics for (OperationStatsBase op : ops) { LOG.info(""); op.printResults(); } } catch (Exception e) { LOG.error(StringUtils.stringifyException(e)); throw e; } finally { if (bench != null) bench.close(); } }