List of usage examples for org.apache.cassandra.config DatabaseDescriptor createAllDirectories
public static void createAllDirectories()
From source file:com.btoddb.flume.sinks.cassandra.EmbeddedServerHelper.java
License:Apache License
public static void mkdirs() { try {/*from w w w. j av a2s . c o m*/ DatabaseDescriptor.createAllDirectories(); } catch (IOException e) { throw new RuntimeException(e); } }
From source file:com.stratio.decision.unit.engine.action.CassandraServer.java
License:Apache License
private static void mkdirs() { DatabaseDescriptor.createAllDirectories(); }
From source file:eu.redzoo.article.planetcassandra.reactive.EmbeddedCassandra.java
License:Apache License
@SuppressWarnings("unchecked") protected static int prepare() throws IOException { String cassandraDirName = "target" + File.separator + "cassandra-junit-" + new Random().nextInt(1000000); File cassandraDir = new File(cassandraDirName); if (!cassandraDir.exists()) { boolean isCreated = cassandraDir.mkdirs(); if (!isCreated) { throw new RuntimeException("could not create cassandra dir " + cassandraDir.getAbsolutePath()); }/* ww w .j av a 2s . co m*/ } InputStream cassandraConfigurationInput = null; Writer cassandraConfigurationOutput = null; try { ClassLoader loader = Thread.currentThread().getContextClassLoader(); cassandraConfigurationInput = loader.getResourceAsStream(CASSANDRA_YAML_FILE); Yaml yaml = new Yaml(); Map<String, Object> cassandraConfiguration = (Map<String, Object>) yaml .load(cassandraConfigurationInput); int rpcPort = findUnusedLocalPort(); if (rpcPort == -1) { throw new RuntimeException("Can not start embedded cassandra: no unused local port found!"); } cassandraConfiguration.put("rpc_port", rpcPort); int storagePort = findUnusedLocalPort(); if (storagePort == -1) { throw new RuntimeException("Can not start embedded cassandra: no unused local port found!"); } cassandraConfiguration.put("storage_port", storagePort); int nativeTransportPort = findUnusedLocalPort(); if (nativeTransportPort == -1) { throw new RuntimeException("Can not start embedded cassandra: no unused local port found!"); } cassandraConfiguration.put("native_transport_port", nativeTransportPort); cassandraConfiguration.put("start_native_transport", "true"); cassandraConfigurationOutput = new OutputStreamWriter( new FileOutputStream(cassandraDirName + File.separator + CASSANDRA_YAML_FILE), Charsets.UTF_8); yaml.dump(cassandraConfiguration, cassandraConfigurationOutput); System.setProperty("cassandra.config", new File(cassandraDirName, CASSANDRA_YAML_FILE).toURI().toString()); System.setProperty("cassandra-foreground", "true"); DatabaseDescriptor.createAllDirectories(); return nativeTransportPort; } finally { Closeables.closeQuietly(cassandraConfigurationInput); Closeables.close(cassandraConfigurationOutput, true); } }
From source file:io.datalayer.cassandra.support.AosEmbeddedCassandra.java
License:Apache License
public static void mkdirs() { DatabaseDescriptor.createAllDirectories(); }
From source file:net.oneandone.troilus.CassandraDB.java
License:Apache License
@SuppressWarnings("unchecked") protected static int prepare() { String cassandraDirName = "target" + File.separator + "cassandra-junit-" + new Random().nextInt(1000000); File cassandraDir = new File(cassandraDirName); cassandraDir.mkdirs();//from ww w . ja v a2 s .c o m InputStream cassandraConfigurationInput = null; Writer cassandraConfigurationOutput = null; try { ClassLoader loader = Thread.currentThread().getContextClassLoader(); cassandraConfigurationInput = loader.getResourceAsStream(CASSANDRA_YAML_FILE); Yaml yaml = new Yaml(); Map<String, Object> cassandraConfiguration = (Map<String, Object>) yaml .load(cassandraConfigurationInput); int rpcPort = findUnusedLocalPort(); if (rpcPort == -1) { throw new RuntimeException("Can not start embedded cassandra: no unused local port found!"); } cassandraConfiguration.put("rpc_port", rpcPort); int storagePort = findUnusedLocalPort(); if (storagePort == -1) { throw new RuntimeException("Can not start embedded cassandra: no unused local port found!"); } cassandraConfiguration.put("storage_port", storagePort); int nativeTransportPort = findUnusedLocalPort(); if (nativeTransportPort == -1) { throw new RuntimeException("Can not start embedded cassandra: no unused local port found!"); } cassandraConfiguration.put("native_transport_port", nativeTransportPort); cassandraConfiguration.put("start_native_transport", "true"); Object obj = cassandraConfiguration.get("data_file_directories"); cassandraConfiguration.put("data_file_directories", Lists.newArrayList(new File(cassandraDir, "data").getAbsolutePath())); cassandraConfiguration.put("commitlog_directory", new File(cassandraDir, "commitlog").getAbsolutePath()); cassandraConfiguration.put("saved_caches_directory", new File(cassandraDir, "saved_caches").getAbsolutePath()); // jwestra: 3.x API change: resolve error on start of 'hints_directory' is missing cassandraConfiguration.put("hints_directory", new File(cassandraDir, "hints_directory").getAbsolutePath()); cassandraConfigurationOutput = new OutputStreamWriter( new FileOutputStream(cassandraDirName + File.separator + CASSANDRA_YAML_FILE), Charsets.UTF_8); // jwestra: 3.x API change: resolve error on start of -Dcassandra.storage_dir is not set String storageDir = new File(cassandraDir, "storageDir").getAbsolutePath(); System.setProperty("cassandra.storage_dir", storageDir); // end: 3.x API change yaml.dump(cassandraConfiguration, cassandraConfigurationOutput); System.setProperty("cassandra.config", new File(cassandraDirName, CASSANDRA_YAML_FILE).toURI().toString()); System.setProperty("cassandra-foreground", "true"); DatabaseDescriptor.createAllDirectories(); return nativeTransportPort; } catch (IOException ioe) { throw new RuntimeException(ioe); } finally { Closeables.closeQuietly(cassandraConfigurationInput); try { Closeables.close(cassandraConfigurationOutput, true); } catch (IOException ignore) { } } }
From source file:net.oneandone.troilus.EmbeddedCassandra.java
License:Apache License
@SuppressWarnings("unchecked") protected static int prepare() throws IOException { String cassandraDirName = "target" + File.separator + "cassandra-junit-" + new Random().nextInt(1000000); File cassandraDir = new File(cassandraDirName); cassandraDir.mkdirs();// www. j a v a 2 s .co m InputStream cassandraConfigurationInput = null; Writer cassandraConfigurationOutput = null; try { ClassLoader loader = Thread.currentThread().getContextClassLoader(); cassandraConfigurationInput = loader.getResourceAsStream(CASSANDRA_YAML_FILE); Yaml yaml = new Yaml(); Map<String, Object> cassandraConfiguration = (Map<String, Object>) yaml .load(cassandraConfigurationInput); int rpcPort = findUnusedLocalPort(); if (rpcPort == -1) { throw new RuntimeException("Can not start embedded cassandra: no unused local port found!"); } cassandraConfiguration.put("rpc_port", rpcPort); int storagePort = findUnusedLocalPort(); if (storagePort == -1) { throw new RuntimeException("Can not start embedded cassandra: no unused local port found!"); } cassandraConfiguration.put("storage_port", storagePort); int nativeTransportPort = findUnusedLocalPort(); if (nativeTransportPort == -1) { throw new RuntimeException("Can not start embedded cassandra: no unused local port found!"); } cassandraConfiguration.put("native_transport_port", nativeTransportPort); cassandraConfiguration.put("start_native_transport", "true"); cassandraConfigurationOutput = new OutputStreamWriter( new FileOutputStream(cassandraDirName + File.separator + CASSANDRA_YAML_FILE), Charsets.UTF_8); yaml.dump(cassandraConfiguration, cassandraConfigurationOutput); System.setProperty("cassandra.config", new File(cassandraDirName, CASSANDRA_YAML_FILE).toURI().toString()); System.setProperty("cassandra-foreground", "true"); DatabaseDescriptor.createAllDirectories(); return nativeTransportPort; } finally { Closeables.closeQuietly(cassandraConfigurationInput); Closeables.close(cassandraConfigurationOutput, true); } }
From source file:org.elasticsearch.test.ESSingleNodeTestCase.java
License:Apache License
static void initNode() { System.out.println("cassandra.home=" + System.getProperty("cassandra.home")); System.out.println("cassandra.config.loader=" + System.getProperty("cassandra.config.loader")); System.out.println("cassandra.config=" + System.getProperty("cassandra.config")); System.out.println("cassandra.config.dir=" + System.getProperty("cassandra.config.dir")); System.out.println("cassandra-rackdc.properties=" + System.getProperty("cassandra-rackdc.properties")); System.out.println("cassandra.storagedir=" + System.getProperty("cassandra.storagedir")); DatabaseDescriptor.createAllDirectories(); Settings settings = Settings.builder() .put(ClusterName.SETTING, InternalTestCluster.clusterName("single-node-cluster", 1)) .put("path.home", System.getProperty("cassandra.home")) .put("path.conf", System.getProperty("cassandra.config.dir")) .put("path.data", DatabaseDescriptor.getAllDataFileLocations()[0]) // TODO: use a consistent data path for custom paths // This needs to tie into the ESIntegTestCase#indexSettings() method .put("path.shared_data", DatabaseDescriptor.getAllDataFileLocations()[0]) .put("node.name", nodeName()).put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0).put("script.inline", "on") .put("script.indexed", "on") //.put(EsExecutors.PROCESSORS, 1) // limit the number of threads created .put("http.enabled", true).put(InternalSettingsPreparer.IGNORE_SYSTEM_PROPERTIES_SETTING, true) .build();/*from www. j a v a 2 s .c o m*/ System.out.println("settings=" + settings.getAsMap()); ElassandraDaemon.instance.activate(false, settings, new Environment(settings)); try { Thread.sleep(1000 * 15); } catch (InterruptedException e) { } assertThat(DiscoveryNode.localNode(settings), is(false)); NODE = ElassandraDaemon.instance.node(); ClusterAdminClient clusterAdminClient = client().admin().cluster(); ClusterHealthResponse clusterHealthResponse = clusterAdminClient.prepareHealth().setWaitForGreenStatus() .get(); assertFalse(clusterHealthResponse.isTimedOut()); Settings.Builder settingsBuilder = Settings.builder() .put(InternalCassandraClusterService.SETTING_CLUSTER_DEFAULT_SYNCHRONOUS_REFRESH, true) .put(InternalCassandraClusterService.SETTING_CLUSTER_DEFAULT_DROP_ON_DELETE_INDEX, true); ClusterUpdateSettingsResponse clusterUpdateSettingsResponse = clusterAdminClient.prepareUpdateSettings() .setTransientSettings(settingsBuilder).get(); assertTrue(clusterUpdateSettingsResponse.isAcknowledged()); }
From source file:org.normandra.CassandraTestUtil.java
License:Apache License
private static void clearAndReset() throws IOException { clear(); DatabaseDescriptor.createAllDirectories(); CommitLog.instance.resetUnsafe(true); }
From source file:org.springframework.cassandra.test.integration.EmbeddedCassandraServerHelper.java
License:Apache License
private static void createCassandraDirectories() { DatabaseDescriptor.createAllDirectories(); }