Java Code Examples for org.apache.commons.configuration2.BaseConfiguration#setProperty()

The following examples show how to use org.apache.commons.configuration2.BaseConfiguration#setProperty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InputOutputHelper.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
public static HadoopGraph getOutputGraph(final Configuration configuration, final GraphComputer.ResultGraph resultGraph, final GraphComputer.Persist persist) {
    final HadoopConfiguration hadoopConfiguration = new HadoopConfiguration(configuration);
    final BaseConfiguration newConfiguration = new BaseConfiguration();
    newConfiguration.copy(hadoopConfiguration);
    if (resultGraph.equals(GraphComputer.ResultGraph.NEW)) {
        newConfiguration.setProperty(Constants.GREMLIN_HADOOP_INPUT_LOCATION, hadoopConfiguration.getOutputLocation());
        if (hadoopConfiguration.containsKey(Constants.GREMLIN_HADOOP_GRAPH_WRITER))
            if (null != InputOutputHelper.getInputFormat(hadoopConfiguration.getGraphWriter()))
                newConfiguration.setProperty(Constants.GREMLIN_HADOOP_GRAPH_READER, InputOutputHelper.getInputFormat(hadoopConfiguration.getGraphWriter()).getCanonicalName());
        newConfiguration.setProperty(Constants.GREMLIN_HADOOP_GRAPH_READER_HAS_EDGES, persist.equals(GraphComputer.Persist.EDGES));
    }
    newConfiguration.setProperty(Constants.GREMLIN_HADOOP_OUTPUT_LOCATION, hadoopConfiguration.getOutputLocation() + "/_");
    return HadoopGraph.open(newConfiguration);
}
 
Example 2
Source File: SystemUtil.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
/**
 * Generate a {@link Configuration} from the {@link System#getProperties}.
 * Only those properties with specified prefix key are aggregated.
 * If the prefix and a . should be removed, then trim prefix.
 *
 * @param prefix     the prefix of the keys to include in the configuration
 * @param trimPrefix whether to trim the prefix + . from the key
 * @return a configuration generated from the System properties
 */
public static Configuration getSystemPropertiesConfiguration(final String prefix, final boolean trimPrefix) {
    final BaseConfiguration apacheConfiguration = new BaseConfiguration();
    for (final Map.Entry<Object, Object> entry : System.getProperties().entrySet()) {
        final String key = entry.getKey().toString();
        final Object value = entry.getValue();
        if (key.startsWith(prefix + "."))
            apacheConfiguration.setProperty(trimPrefix ? key.substring(prefix.length() + 1) : key, value);
    }
    return apacheConfiguration;
}
 
Example 3
Source File: GryoSerializer.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
private static Configuration makeApacheConfiguration(final SparkConf sparkConfiguration) {
    final BaseConfiguration apacheConfiguration = new BaseConfiguration();
    for (final Tuple2<String, String> tuple : sparkConfiguration.getAll()) {
        apacheConfiguration.setProperty(tuple._1(), tuple._2());
    }
    return apacheConfiguration;
}
 
Example 4
Source File: InputOutputHelper.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
public static HadoopGraph getOutputGraph(final Configuration configuration, final GraphComputer.ResultGraph resultGraph, final GraphComputer.Persist persist) {
    final HadoopConfiguration hadoopConfiguration = new HadoopConfiguration(configuration);
    final BaseConfiguration newConfiguration = new BaseConfiguration();
    newConfiguration.copy(org.apache.tinkerpop.gremlin.hadoop.structure.io.InputOutputHelper.getOutputGraph(configuration, resultGraph, persist).configuration());
    if (resultGraph.equals(GraphComputer.ResultGraph.NEW) && hadoopConfiguration.containsKey(Constants.GREMLIN_HADOOP_GRAPH_WRITER)) {
        if (null != InputOutputHelper.getInputFormat(hadoopConfiguration.getGraphWriter()))
            newConfiguration.setProperty(Constants.GREMLIN_HADOOP_GRAPH_READER, InputOutputHelper.getInputFormat(hadoopConfiguration.getGraphWriter()).getCanonicalName());
    }
    return HadoopGraph.open(newConfiguration);
}
 
Example 5
Source File: AbstractSparkTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
protected Configuration getBaseConfiguration() {
    final BaseConfiguration configuration = new BaseConfiguration();
    configuration.setProperty(SparkLauncher.SPARK_MASTER, "local[4]");
    configuration.setProperty(Constants.SPARK_SERIALIZER, GryoSerializer.class.getCanonicalName());
    configuration.setProperty(Constants.SPARK_KRYO_REGISTRATION_REQUIRED, true);
    configuration.setProperty(Graph.GRAPH, HadoopGraph.class.getName());
    configuration.setProperty(Constants.GREMLIN_HADOOP_JARS_IN_DISTRIBUTED_CACHE, false);
    return configuration;
}