Example #1
0
  /**
   * Start the benchmark and go to the chosen one.
   *
   * @param args
   */
  public void start(String[] args) throws InterruptedException, Exception {
    // Process command line parameters
    if (args.length != 1) {
      System.out.print(getHelp(args));
      System.exit(-1);
    }

    ParameterEnum benchmarkEnum = null;
    try {
      benchmarkEnum = ParameterEnum.valueOf(args[0].replace("-", "").toUpperCase());
    } catch (IllegalArgumentException iae) {
      System.out.print(getHelp(args));
      logger.error("Program called with invalid parameter. Shutting down.");
      System.exit(-1);
    }

    logger.info("Starting up {}.", NeddyBenchmark.class.getSimpleName());

    // Registers a shutdown hook to free resources of this class.
    Runtime.getRuntime()
        .addShutdownHook(new ShutdownThread(this, "NettyBenchmark Shutdown Thread"));

    // Gets the proper benchmark class.
    Benchmark benchmark = BenchmarkFactory.getBenchmark(benchmarkEnum);

    // Setup the proper event pipeline factory for the benchmark.
    ChannelPipelineFactory pipelineFactory = benchmark.getPipeline();
    getBootstrap().setPipelineFactory(pipelineFactory);

    // Set some necessary or convenient socket options in the bootstrap.
    benchmark.configureBootstrap(getBootstrap());

    // Execute the requested benchmark.
    benchmark.execute();
  }
 private static final void setParameter(
     final Configuration config,
     final Class<?> scope,
     final Object val,
     final ParameterEnum configItem) {
   if (val != null) {
     if (val instanceof Long) {
       config.setLong(
           GeoWaveConfiguratorBase.enumToConfKey(scope, configItem.self()), ((Long) val));
     } else if (val instanceof Double) {
       config.setDouble(
           GeoWaveConfiguratorBase.enumToConfKey(scope, configItem.self()), ((Double) val));
     } else if (val instanceof Boolean) {
       config.setBoolean(
           GeoWaveConfiguratorBase.enumToConfKey(scope, configItem.self()), ((Boolean) val));
     } else if (val instanceof Integer) {
       config.setInt(
           GeoWaveConfiguratorBase.enumToConfKey(scope, configItem.self()), ((Integer) val));
     } else if (val instanceof Class) {
       config.setClass(
           GeoWaveConfiguratorBase.enumToConfKey(scope, configItem.self()),
           ((Class) val),
           ((Class) val));
     } else if (val instanceof byte[]) {
       config.set(
           GeoWaveConfiguratorBase.enumToConfKey(scope, configItem.self()),
           ByteArrayUtils.byteArrayToString((byte[]) val));
     } else {
       config.set(GeoWaveConfiguratorBase.enumToConfKey(scope, configItem.self()), val.toString());
     }
   }
 }
 @Override
 public Object getValue(final PropertyManagement propertyManagement) {
   try {
     return propertyManagement.getProperty(parent);
   } catch (final Exception e) {
     LOGGER.error("Unable to deserialize property '" + parent.toString() + "'", e);
     return null;
   }
 }
 @Override
 public Object getValue(
     final JobContext context, final Class<?> scope, final Object defaultValue) {
   final ScopedJobConfiguration scopedConfig =
       new ScopedJobConfiguration(context.getConfiguration(), scope);
   if (baseClass.isAssignableFrom(Integer.class)) {
     return Integer.valueOf(
         scopedConfig.getInt(parent.self(), ((Integer) defaultValue).intValue()));
   } else if (baseClass.isAssignableFrom(String.class)) {
     return scopedConfig.getString(parent.self(), defaultValue.toString());
   } else if (baseClass.isAssignableFrom(Double.class)) {
     return scopedConfig.getDouble(parent.self(), (Double) defaultValue);
   } else if (baseClass.isAssignableFrom(byte[].class)) {
     return scopedConfig.getBytes(parent.self());
   } else if ((defaultValue == null) || (defaultValue instanceof Class)) {
     try {
       return scopedConfig.getInstance(parent.self(), baseClass, (Class) defaultValue);
     } catch (InstantiationException | IllegalAccessException e) {
       LOGGER.error("Unable to get instance from job context", e);
     }
   }
   return null;
 }