Java Code Examples for org.apache.hadoop.conf.Configuration.getRaw()

The following are Jave code examples for showing how to use getRaw() of the org.apache.hadoop.conf.Configuration class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: ditb   File: CheckConfigurationConstraint.java   View Source Code Vote up 6 votes
@Override
public void setConf(Configuration conf) {
  super.setConf(conf);
  if (conf != null) {
    String val = conf.get(key);
    if (val == null || !val.equals(value))
      throw new IllegalArgumentException(
          "Configuration was not passed correctly");
    // and then check to make sure we got a fresh config by checking for a
    // hadoop-based config value, and if we don't find it, its fine
    if (conf.getRaw("fs.file.impl") != null)
      throw new IllegalArgumentException(
          "Configuration was created using 'new Configuration()', should be "
              + "done via 'new Configuration(false) to exclude defaut hadoop "
              + "configurations values.");
  }
}
 
Example 2
Project: aliyun-maxcompute-data-collectors   File: HsqldbJobStorage.java   View Source Code Vote up 4 votes
/**
 * Actually insert/update the resources for this job.
 */
private void createInternal(String jobName, JobData data)
    throws IOException {
  try {
    LOG.debug("Creating job: " + jobName);

    // Save the name of the Sqoop tool.
    setV0Property(jobName, PROPERTY_CLASS_SCHEMA, SQOOP_TOOL_KEY,
        data.getSqoopTool().getToolName());

    // Save the property set id.
    setV0Property(jobName, PROPERTY_CLASS_SCHEMA, PROPERTY_SET_KEY,
        CUR_PROPERTY_SET_ID);

    // Save all properties of the SqoopOptions.
    Properties props = data.getSqoopOptions().writeProperties();
    setV0Properties(jobName, PROPERTY_CLASS_SQOOP_OPTIONS, props);

    // And save all unique properties of the configuration.
    Configuration saveConf = data.getSqoopOptions().getConf();
    Configuration baseConf = new Configuration();

    for (Map.Entry<String, String> entry : saveConf) {
      String key = entry.getKey();
      String rawVal = saveConf.getRaw(key);
      String baseVal = baseConf.getRaw(key);
      if (baseVal != null && rawVal.equals(baseVal)) {
        continue; // Don't save this; it's set in the base configuration.
      }

      LOG.debug("Saving " + key + " => " + rawVal + " / " + baseVal);
      setV0Property(jobName, PROPERTY_CLASS_CONFIG, key, rawVal);
    }

    connection.commit();
  } catch (SQLException sqlE) {
    try {
      connection.rollback();
    } catch (SQLException sqlE2) {
      LOG.warn("Exception rolling back transaction during error handling: "
          + sqlE2);
    }
    throw new IOException("Error communicating with database", sqlE);
  }
}