private void doMapReduce() { try { Job job = Job.getInstance(); job.getConfiguration().set(OutputFormat.NAMESPACE, "/"); job.getConfiguration().set(OutputFormat.TABLE, "LoadTest"); job.getConfiguration().setInt(OutputFormat.MUTATOR_FLAGS, MutatorFlag.NO_LOG_SYNC.getValue()); job.getConfiguration().setInt(OutputFormat.MUTATOR_FLUSH_INTERVAL, 0); job.getConfiguration().setInt("LoadSplit.TOTAL_ROWS", this.totalRows); job.getConfiguration().setInt("LoadSplit.CLIENTS", this.clients); job.setJarByClass(LoadTest.class); job.setJobName("Hypertable MapReduce connector LoadTest"); job.setInputFormatClass(LoadInputFormat.class); job.setOutputFormatClass(OutputFormat.class); job.setMapOutputKeyClass(KeyWritable.class); job.setMapOutputValueClass(BytesWritable.class); job.setMapperClass(LoadMapper.class); job.setReducerClass(LoadReducer.class); job.setNumReduceTasks(this.clients); job.waitForCompletion(true); } catch (Exception e) { e.printStackTrace(); } }
private int run(String[] args) { String rows = "--rows="; String clients = "--clients="; try { for (int ii = 0; ii < args.length; ++ii) { String cmd = args[ii]; if (cmd.startsWith(rows)) { this.totalRows = Integer.parseInt(cmd.substring(rows.length())); } else if (cmd.startsWith(clients)) { this.clients = Integer.parseInt(cmd.substring(clients.length())); } else { printUsage(); return -1; } } doMapReduce(); } catch (Exception e) { e.printStackTrace(); } return 0; }