Search in sources :

Example 1 with ConfigurationException

use of org.openkilda.wfm.error.ConfigurationException in project open-kilda by telstra.

the class AbstractTopology method handleLaunchException.

protected static int handleLaunchException(Exception error) {
    final Logger log = LoggerFactory.getLogger(AbstractTopology.class);
    int errorCode;
    try {
        throw error;
    } catch (CmdLineException e) {
        System.err.println(e.getMessage());
        System.err.println();
        System.err.println("Allowed options and arguments:");
        e.getParser().printUsage(System.err);
        errorCode = 2;
    } catch (ConfigurationException e) {
        System.err.println(e.getMessage());
        errorCode = 3;
    } catch (TException e) {
        log.error("Unable to complete topology setup: {}", e.getMessage());
        errorCode = 4;
    } catch (Exception e) {
        log.error("Unhandled exception", e);
        errorCode = 1;
    }
    return errorCode;
}
Also used : TException(org.apache.storm.thrift.TException) ConfigurationException(org.openkilda.wfm.error.ConfigurationException) Logger(org.slf4j.Logger) CmdLineException(org.kohsuke.args4j.CmdLineException) TException(org.apache.storm.thrift.TException) CmdLineException(org.kohsuke.args4j.CmdLineException) NameCollisionException(org.openkilda.wfm.error.NameCollisionException) ConfigurationException(org.openkilda.wfm.error.ConfigurationException)

Example 2 with ConfigurationException

use of org.openkilda.wfm.error.ConfigurationException in project open-kilda by telstra.

the class LaunchEnvironment method loadPropertiesAndOverlayWithExtra.

private Properties loadPropertiesAndOverlayWithExtra(File[] extraConfiguration) throws ConfigurationException {
    Properties result = new Properties();
    try (InputStream resource = this.getClass().getResourceAsStream(Topology.TOPOLOGY_PROPERTIES)) {
        result.load(resource);
    } catch (IOException e) {
        throw new ConfigurationException("Unable to load default properties.", e);
    }
    for (File path : extraConfiguration) {
        Properties override = new Properties(properties);
        try (FileInputStream source = new FileInputStream(path)) {
            override.load(source);
        } catch (IOException e) {
            throw new ConfigurationException(String.format("Unable to load properties from %s", path), e);
        }
        result.putAll(override);
    }
    result.setProperty(CLI_OVERLAY + ".local", cli.getIsLocal() ? "true" : "false");
    if (cli.getLocalExecutionTime() != null) {
        result.setProperty(CLI_OVERLAY + ".local.execution.time", cli.getLocalExecutionTime().toString());
    }
    return result;
}
Also used : ConfigurationException(org.openkilda.wfm.error.ConfigurationException) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) Properties(java.util.Properties) File(java.io.File) FileInputStream(java.io.FileInputStream)

Aggregations

ConfigurationException (org.openkilda.wfm.error.ConfigurationException)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Properties (java.util.Properties)1 TException (org.apache.storm.thrift.TException)1 CmdLineException (org.kohsuke.args4j.CmdLineException)1 NameCollisionException (org.openkilda.wfm.error.NameCollisionException)1 Logger (org.slf4j.Logger)1