Search in sources :

Example 1 with AsterixConfiguration

use of org.apache.asterix.common.configuration.AsterixConfiguration in project asterixdb by apache.

the class TestHelper method getConfigurations.

public static AsterixConfiguration getConfigurations(String fileName) throws IOException, JAXBException, AsterixException {
    try (InputStream is = TestHelper.class.getClassLoader().getResourceAsStream(fileName)) {
        if (is != null) {
            JAXBContext ctx = JAXBContext.newInstance(AsterixConfiguration.class);
            Unmarshaller unmarshaller = ctx.createUnmarshaller();
            return (AsterixConfiguration) unmarshaller.unmarshal(is);
        } else {
            throw new AsterixException("Could not find configuration file " + fileName);
        }
    }
}
Also used : AsterixException(org.apache.asterix.common.exceptions.AsterixException) AsterixConfiguration(org.apache.asterix.common.configuration.AsterixConfiguration) InputStream(java.io.InputStream) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller)

Example 2 with AsterixConfiguration

use of org.apache.asterix.common.configuration.AsterixConfiguration in project asterixdb by apache.

the class Utils method loadAsterixConfig.

public static AsterixConfiguration loadAsterixConfig(String path) throws IOException {
    File f = new File(path);
    try {
        JAXBContext configCtx = JAXBContext.newInstance(AsterixConfiguration.class);
        Unmarshaller unmarshaller = configCtx.createUnmarshaller();
        AsterixConfiguration conf = (AsterixConfiguration) unmarshaller.unmarshal(f);
        return conf;
    } catch (JAXBException e) {
        throw new IOException(e);
    }
}
Also used : AsterixConfiguration(org.apache.asterix.common.configuration.AsterixConfiguration) JAXBException(javax.xml.bind.JAXBException) JAXBContext(javax.xml.bind.JAXBContext) IOException(java.io.IOException) Unmarshaller(javax.xml.bind.Unmarshaller) File(java.io.File)

Example 3 with AsterixConfiguration

use of org.apache.asterix.common.configuration.AsterixConfiguration in project asterixdb by apache.

the class AsterixYARNClient method locateConfig.

/**
     * Locate the Asterix parameters file.
     *
     * @return
     * @throws FileNotFoundException
     * @throws IOException
     */
private AsterixConfiguration locateConfig() throws FileNotFoundException, IOException {
    AsterixConfiguration configuration;
    String configPathBase = MERGED_PARAMETERS_PATH;
    if (baseConfig != null) {
        configuration = Utils.loadAsterixConfig(baseConfig);
        configPathBase = new File(baseConfig).getParentFile().getAbsolutePath() + File.separator + PARAMS_DEFAULT_NAME;
        MERGED_PARAMETERS_PATH = configPathBase;
    } else {
        configuration = Utils.loadAsterixConfig(DEFAULT_PARAMETERS_PATH);
    }
    return configuration;
}
Also used : AsterixConfiguration(org.apache.asterix.common.configuration.AsterixConfiguration) File(java.io.File)

Example 4 with AsterixConfiguration

use of org.apache.asterix.common.configuration.AsterixConfiguration in project asterixdb by apache.

the class InstallerUtil method getAsterixConfiguration.

public static AsterixConfiguration getAsterixConfiguration(String asterixConf) throws FileNotFoundException, IOException, JAXBException {
    if (asterixConf == null) {
        asterixConf = InstallerDriver.getManagixHome() + File.separator + DEFAULT_ASTERIX_CONFIGURATION_PATH;
    }
    File file = new File(asterixConf);
    JAXBContext ctx = JAXBContext.newInstance(AsterixConfiguration.class);
    Unmarshaller unmarshaller = ctx.createUnmarshaller();
    AsterixConfiguration asterixConfiguration = (AsterixConfiguration) unmarshaller.unmarshal(file);
    return asterixConfiguration;
}
Also used : AsterixConfiguration(org.apache.asterix.common.configuration.AsterixConfiguration) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller) File(java.io.File)

Example 5 with AsterixConfiguration

use of org.apache.asterix.common.configuration.AsterixConfiguration in project asterixdb by apache.

the class PropertiesAccessor method configure.

private AsterixConfiguration configure(InputStream is, String fileName) throws AsterixException {
    try {
        JAXBContext ctx = JAXBContext.newInstance(AsterixConfiguration.class);
        Unmarshaller unmarshaller = ctx.createUnmarshaller();
        return (AsterixConfiguration) unmarshaller.unmarshal(is);
    } catch (JAXBException e) {
        throw new AsterixException("Failed to read configuration file " + fileName, e);
    }
}
Also used : AsterixException(org.apache.asterix.common.exceptions.AsterixException) AsterixConfiguration(org.apache.asterix.common.configuration.AsterixConfiguration) JAXBException(javax.xml.bind.JAXBException) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller)

Aggregations

AsterixConfiguration (org.apache.asterix.common.configuration.AsterixConfiguration)9 JAXBContext (javax.xml.bind.JAXBContext)6 File (java.io.File)4 Unmarshaller (javax.xml.bind.Unmarshaller)4 JAXBException (javax.xml.bind.JAXBException)3 FileOutputStream (java.io.FileOutputStream)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Marshaller (javax.xml.bind.Marshaller)2 Coredump (org.apache.asterix.common.configuration.Coredump)2 Store (org.apache.asterix.common.configuration.Store)2 TransactionLogDir (org.apache.asterix.common.configuration.TransactionLogDir)2 AsterixException (org.apache.asterix.common.exceptions.AsterixException)2 InputStream (java.io.InputStream)1 Date (java.util.Date)1 JarFile (java.util.jar.JarFile)1 Property (org.apache.asterix.common.configuration.Property)1 AsterixInstance (org.apache.asterix.event.model.AsterixInstance)1 Cluster (org.apache.asterix.event.schema.cluster.Cluster)1 Node (org.apache.asterix.event.schema.cluster.Node)1