Search in sources :

Example 26 with PropertiesConfiguration

use of org.apache.commons.configuration2.PropertiesConfiguration in project janusgraph by JanusGraph.

the class CQLInputFormatIT method getGraphConfiguration.

private PropertiesConfiguration getGraphConfiguration(final String filename) throws ConfigurationException, IOException {
    final PropertiesConfiguration config = ConfigurationUtil.loadPropertiesConfig(filename, false);
    Path baseOutDir = Paths.get((String) config.getProperty("gremlin.hadoop.outputLocation"));
    baseOutDir.toFile().mkdirs();
    String outDir = Files.createTempDirectory(baseOutDir, null).toAbsolutePath().toString();
    config.setProperty("gremlin.hadoop.outputLocation", outDir);
    config.setProperty("janusgraphmr.ioformat.conf.storage.port", String.valueOf(cql.getMappedCQLPort()));
    return config;
}
Also used : Path(java.nio.file.Path) PropertiesConfiguration(org.apache.commons.configuration2.PropertiesConfiguration)

Example 27 with PropertiesConfiguration

use of org.apache.commons.configuration2.PropertiesConfiguration in project accumulo by apache.

the class MiniAccumuloClusterTest method testRandomPorts.

@Test
public void testRandomPorts() throws Exception {
    File confDir = new File(testDir, "conf");
    File accumuloProps = new File(confDir, "accumulo.properties");
    var config = new PropertiesConfiguration();
    try (var reader = new FileReader(accumuloProps, UTF_8)) {
        config.read(reader);
    }
    for (Property randomPortProp : new Property[] { Property.TSERV_CLIENTPORT, Property.MONITOR_PORT, Property.MANAGER_CLIENTPORT, Property.GC_PORT }) {
        String value = config.getString(randomPortProp.getKey());
        assertNotNull("Found no value for " + randomPortProp, value);
        assertEquals("0", value);
    }
}
Also used : FileReader(java.io.FileReader) File(java.io.File) PropertiesConfiguration(org.apache.commons.configuration2.PropertiesConfiguration) Property(org.apache.accumulo.core.conf.Property) Test(org.junit.Test)

Example 28 with PropertiesConfiguration

use of org.apache.commons.configuration2.PropertiesConfiguration in project accumulo by apache.

the class ClientConfiguration method serialize.

public String serialize() {
    var propConfig = new PropertiesConfiguration();
    propConfig.copy(compositeConfig);
    StringWriter writer = new StringWriter();
    try {
        propConfig.write(writer);
    } catch (ConfigurationException | IOException e) {
        // this should never happen
        throw new IllegalStateException(e);
    }
    return writer.toString();
}
Also used : StringWriter(java.io.StringWriter) ConfigurationException(org.apache.commons.configuration2.ex.ConfigurationException) IOException(java.io.IOException) PropertiesConfiguration(org.apache.commons.configuration2.PropertiesConfiguration)

Example 29 with PropertiesConfiguration

use of org.apache.commons.configuration2.PropertiesConfiguration in project accumulo by apache.

the class VolumeIT method updateConfig.

@SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "paths provided by test")
private void updateConfig(Consumer<PropertiesConfiguration> updater) throws Exception {
    var file = new File(cluster.getAccumuloPropertiesPath());
    var config = new PropertiesConfiguration();
    try (FileReader out = new FileReader(file, UTF_8)) {
        config.read(out);
    }
    updater.accept(config);
    try (FileWriter out = new FileWriter(file, UTF_8)) {
        config.write(out);
    }
}
Also used : FileWriter(java.io.FileWriter) FileReader(java.io.FileReader) StoredTabletFile(org.apache.accumulo.core.metadata.StoredTabletFile) File(java.io.File) PropertiesConfiguration(org.apache.commons.configuration2.PropertiesConfiguration) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Aggregations

PropertiesConfiguration (org.apache.commons.configuration2.PropertiesConfiguration)28 ConfigurationException (org.apache.commons.configuration2.ex.ConfigurationException)10 File (java.io.File)7 IOException (java.io.IOException)6 Path (java.nio.file.Path)6 Parameters (org.apache.commons.configuration2.builder.fluent.Parameters)5 Configuration (org.apache.commons.configuration2.Configuration)4 Configurations (org.apache.commons.configuration2.builder.fluent.Configurations)4 FileReader (java.io.FileReader)3 FileBasedConfigurationBuilder (org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder)3 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)2 StringWriter (java.io.StringWriter)2 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)2 BaseConfiguration (org.apache.commons.configuration2.BaseConfiguration)2 PropertiesBuilderParameters (org.apache.commons.configuration2.builder.fluent.PropertiesBuilderParameters)2 DefaultListDelimiterHandler (org.apache.commons.configuration2.convert.DefaultListDelimiterHandler)2 Preconditions (com.google.common.base.Preconditions)1 BufferedReader (java.io.BufferedReader)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 FileInputStream (java.io.FileInputStream)1