Example usage for org.apache.cassandra.config ConfigurationLoader loadConfig

List of usage examples for org.apache.cassandra.config ConfigurationLoader loadConfig

Introduction

In this page you can find the example usage for org.apache.cassandra.config ConfigurationLoader loadConfig.

Prototype

Config loadConfig() throws ConfigurationException;

Source Link

Document

Loads a Config object to use to configure a node.

Usage

From source file:com.tuplejump.stargate.cassandra.CassandraUtils.java

License:Apache License

static void loadYaml() throws ConfigurationException, IOException {
    URL url = CassandraUtils.getStorageConfigURL();
    logger.info("Loading settings from " + url);
    String loaderClass = System.getProperty("cassandra.config.loader");
    ConfigurationLoader loader = loaderClass == null ? new YamlConfigurationLoader()
            : FBUtilities.<ConfigurationLoader>construct(loaderClass, "configuration loading");
    conf = loader.loadConfig();
    logger.info("Data files directories: " + Arrays.toString(conf.data_file_directories));
}

From source file:org.jesterj.ingest.logging.Cassandra.java

License:Apache License

public static void start(File cassandraDir) {

    System.out.println("Booting to run cassandra");
    try {//from   ww  w.  j  av  a2  s . c o m
        if (!cassandraDir.exists() && !cassandraDir.mkdirs()) {
            throw new RuntimeException("could not create" + cassandraDir);
        }
        File yaml = new File(cassandraDir, "cassandra.yaml");
        System.setProperty("cassandra.config", yaml.toURI().toString());
        if (!yaml.exists()) {
            CassandraConfig cfg = new CassandraConfig(cassandraDir.getCanonicalPath());
            cfg.guessIp();
            listenAddress = cfg.getListen_address();
            String cfgStr = new Yaml().dumpAsMap(cfg);
            Files.write(yaml.toPath(), cfgStr.getBytes(), StandardOpenOption.CREATE);
        } else {
            ConfigurationLoader cl = new YamlConfigurationLoader();
            Config conf = cl.loadConfig();
            listenAddress = conf.listen_address;
        }
    } catch (IOException | ConfigurationException e) {
        e.printStackTrace();
    }
    cassandra = new CassandraDaemon();
    try {
        // keep cassandra from clobering system.out and sytem.err
        System.setProperty("cassandra-foreground", "true");
        cassandra.activate();
    } catch (Exception e) {
        e.printStackTrace();
    }

    synchronized (finalBootActions) {
        while (finalBootActions.peek() != null) {
            finalBootActions.remove().run();
        }
        booting = false;
    }
    System.out.println("Cassandra booted");
}