Package eu.stratosphere.configuration

Examples of eu.stratosphere.configuration.IllegalConfigurationException


   
    // read number of field configured via configuration
    int numConfigFields = config.getInteger(NUM_FIELDS_PARAMETER, -1);
    if (numConfigFields != -1) {
      if (numConfigFields <= 0) {
        throw new IllegalConfigurationException("The number of fields for the CsvInputFormat is invalid.");
      }
     
      if (getNumberOfNonNullFields() > 0) {
        throw new IllegalConfigurationException("Mixing configuration via instance parameters and config parameters is not possible.");
      }
   
      int[] textPosIdx = new int[numConfigFields];
      boolean anyTextPosSet = false;
      boolean allTextPosSet = true;
      int maxTextPos = -1;
     
      // parse text positions
      for (int i = 0; i < numConfigFields; i++) {
        int pos = config.getInteger(TEXT_POSITION_PARAMETER_PREFIX + i, -1);
        if (pos == -1) {
          allTextPosSet = false;
          textPosIdx[i] = i;
          maxTextPos = i;
        } else {
          anyTextPosSet = true;
          textPosIdx[i] = pos;
          maxTextPos = pos > maxTextPos ? pos : maxTextPos;
        }
      }
      // check if either none or all text positions have been set
      if (anyTextPosSet && !allTextPosSet) {
        throw new IllegalArgumentException("Invalid configuration for CsvInputFormat: " +
            "Not all text positions set");
      }
     
      // init the array of types to be set. unify the types from the config
      // with the types array set on the instance
     
      // make sure we have a sufficiently large types array
      @SuppressWarnings("unchecked")
      Class<? extends Value>[] types = (Class<? extends Value>[]) new Class[maxTextPos+1];
      int[] targetPos = new int[maxTextPos+1];
     
      // set the fields
      for (int i = 0; i < numConfigFields; i++) {
        int pos = textPosIdx[i];
       
        Class<? extends Value> clazz = config.getClass(FIELD_TYPE_PARAMETER_PREFIX + i, null).asSubclass(Value.class);
        if (clazz == null) {
          throw new IllegalConfigurationException("Invalid configuration for CsvInputFormat: " +
            "No field parser class for parameter " + i);
        }
       
        types[pos] = clazz;
        targetPos[pos] = i;
      }
     
      // update the field types
      setFieldTypes(types);
     
      // make a dense target pos array
      this.targetPositions = new int[numConfigFields];
      for (int i = 0, k = 0; i < targetPos.length; i++) {
        if (types[i] != null) {
          this.targetPositions[k++] = targetPos[i];
        }
      }
    }
    else {
      // not configured via config parameters
      if (this.targetPositions.length == 0) {
        this.targetPositions = new int[getNumberOfNonNullFields()];
        for (int i = 0; i < this.targetPositions.length; i++) {
          this.targetPositions[i] = i;
        }
      }
    }
   
    if (getNumberOfNonNullFields() == 0) {
      throw new IllegalConfigurationException("No fields configured in the CsvInputFormat.");
    }

    this.configured = true;
  }
View Full Code Here


    try {
      invokable.checkConfiguration();
    } catch (IllegalConfigurationException icex) {
      throw icex; // simply forward
    } catch (Throwable t) {
      throw new IllegalConfigurationException("Checking the invokable's configuration caused an error: "
        + StringUtils.stringifyException(t));
    }
  }
View Full Code Here

  @Override
  public void checkConfiguration(final AbstractInvokable invokable) throws IllegalConfigurationException {

    // Check if the user has specified a path
    if (this.path == null) {
      throw new IllegalConfigurationException(this.getName() + " does not specify an input path");
    }

    // Check if the path is valid
    try {
      final FileSystem fs = this.path.getFileSystem();
      final FileStatus f = fs.getFileStatus(this.path);
      if (f == null) {
        throw new IOException(this.path.toString() + " led to a null object");
      }
    } catch (IOException e) {
      throw new IllegalConfigurationException("Cannot access file or directory: "
        + StringUtils.stringifyException(e));
    }

    // register the path in the configuration
    invokable.getTaskConfiguration()
View Full Code Here

    }
    catch (IllegalConfigurationException icex) {
      throw icex; // simply forward
    }
    catch (Throwable t) {
      throw new IllegalConfigurationException("Checking the invokable's configuration caused an error: "
        + StringUtils.stringifyException(t));
    }
  }
View Full Code Here

    }
    catch (IllegalConfigurationException icex) {
      throw icex; // simply forward
    }
    catch (Throwable t) {
      throw new IllegalConfigurationException("Checking the invokable's configuration caused an error: "
        + StringUtils.stringifyException(t));
    }
  }
View Full Code Here

  @Override
  public void checkConfiguration(final AbstractInvokable invokable) throws IllegalConfigurationException {

    // Check if the user has specified a path
    if (this.path == null) {
      throw new IllegalConfigurationException(this.getName() + " does not specify an output path");
    }

    super.checkConfiguration(invokable);
  }
View Full Code Here

  @Override
  public void readParametersFromConfig(Configuration config, ClassLoader cl) throws ClassNotFoundException {
    // figure out how many key fields there are
    final int numKeyFields = config.getInteger(NUM_KEYS, -1);
    if (numKeyFields < 0) {
      throw new IllegalConfigurationException("The number of keys for the comparator is invalid: " + numKeyFields);
    }
   
    final int[] positions = new int[numKeyFields];
    final Class<? extends Key<?>>[] types = new Class[numKeyFields];
    final boolean[] direction = new boolean[numKeyFields];
   
    // read the individual key positions and types
    for (int i = 0; i < numKeyFields; i++) {
      // next key position
      final int p = config.getInteger(KEY_POS_PREFIX + i, -1);
      if (p >= 0) {
        positions[i] = p;
      } else {
        throw new IllegalConfigurationException("Contained invalid position for key no positions for keys.");
      }
     
      // next key type
      final String name = config.getString(KEY_CLASS_PREFIX + i, null);
      if (name != null) {
        types[i] = (Class<? extends Key<?>>) Class.forName(name, true, cl).asSubclass(Key.class);
      } else {
        throw new IllegalConfigurationException("The key type (" + i +
          ") for the comparator is null");
      }
     
      // next key sort direction
      direction[i] = config.getBoolean(KEY_SORT_DIRECTION_PREFIX + i, true);
View Full Code Here

TOP

Related Classes of eu.stratosphere.configuration.IllegalConfigurationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.