| 44 | import org.slf4j.LoggerFactory; |
| 45 | |
| 46 | public class DBWorkload { |
| 47 | private static final Logger LOG = LoggerFactory.getLogger(DBWorkload.class); |
| 48 | |
| 49 | private static final String SINGLE_LINE = StringUtil.repeat("=", 70); |
| 50 | |
| 51 | private static final String RATE_DISABLED = "disabled"; |
| 52 | private static final String RATE_UNLIMITED = "unlimited"; |
| 53 | |
| 54 | /** |
| 55 | * @param args |
| 56 | * @throws Exception |
| 57 | */ |
| 58 | public static void main(String[] args) throws Exception { |
| 59 | |
| 60 | // create the command line parser |
| 61 | CommandLineParser parser = new DefaultParser(); |
| 62 | |
| 63 | XMLConfiguration pluginConfig = buildConfiguration("config/plugin.xml"); |
| 64 | |
| 65 | Options options = buildOptions(pluginConfig); |
| 66 | |
| 67 | CommandLine argsLine = parser.parse(options, args); |
| 68 | |
| 69 | if (argsLine.hasOption("h")) { |
| 70 | printUsage(options); |
| 71 | return; |
| 72 | } else if (!argsLine.hasOption("c")) { |
| 73 | LOG.error("Missing Configuration file"); |
| 74 | printUsage(options); |
| 75 | return; |
| 76 | } else if (!argsLine.hasOption("b")) { |
| 77 | LOG.error("Missing Benchmark Class to load"); |
| 78 | printUsage(options); |
| 79 | return; |
| 80 | } |
| 81 | |
| 82 | // Monitoring setup. |
| 83 | ImmutableMonitorInfo.Builder builder = ImmutableMonitorInfo.builder(); |
| 84 | if (argsLine.hasOption("im")) { |
| 85 | builder.monitoringInterval(Integer.parseInt(argsLine.getOptionValue("im"))); |
| 86 | } |
| 87 | if (argsLine.hasOption("mt")) { |
| 88 | switch (argsLine.getOptionValue("mt")) { |
| 89 | case "advanced": |
| 90 | builder.monitoringType(MonitorInfo.MonitoringType.ADVANCED); |
| 91 | break; |
| 92 | case "throughput": |
| 93 | builder.monitoringType(MonitorInfo.MonitoringType.THROUGHPUT); |
| 94 | break; |
| 95 | default: |
| 96 | throw new ParseException( |
| 97 | "Monitoring type '" |
| 98 | + argsLine.getOptionValue("mt") |
| 99 | + "' is undefined, allowed values are: advanced/throughput"); |
| 100 | } |
| 101 | } |
| 102 | MonitorInfo monitorInfo = builder.build(); |
| 103 | |