List of usage examples for org.apache.cassandra.config DatabaseDescriptor getAllDataFileLocations
public static String[] getAllDataFileLocations()
From source file:com.stratio.deep.cassandra.embedded.CassandraServer.java
License:Apache License
private static void cleanup() throws IOException { // clean up commitlog String[] directoryNames = { DatabaseDescriptor.getCommitLogLocation(), }; for (String dirName : directoryNames) { File dir = new File(dirName); if (!dir.exists()) { logger.error("No such directory: " + dir.getAbsolutePath()); throw new RuntimeException("No such directory: " + dir.getAbsolutePath()); }/*from w w w.j ava2 s . co m*/ FileUtils.deleteRecursive(dir); } // clean up data directory which are stored as data directory/table/data // files for (String dirName : DatabaseDescriptor.getAllDataFileLocations()) { File dir = new File(dirName); if (!dir.exists()) { logger.error("No such directory: " + dir.getAbsolutePath()); throw new RuntimeException("No such directory: " + dir.getAbsolutePath()); } FileUtils.deleteRecursive(dir); } }
From source file:io.datalayer.cassandra.support.AosEmbeddedCassandra.java
License:Apache License
public static void cleanup() throws IOException { // clean up commitlog String[] directoryNames = { DatabaseDescriptor.getCommitLogLocation(), }; for (String dirName : directoryNames) { File dir = new File(dirName); if (!dir.exists()) throw new RuntimeException("No such directory: " + dir.getAbsolutePath()); FileUtils.deleteRecursive(dir);//from w w w . j a va 2 s .com } // clean up data directory which are stored as data directory/table/data // files for (String dirName : DatabaseDescriptor.getAllDataFileLocations()) { File dir = new File(dirName); if (!dir.exists()) throw new RuntimeException("No such directory: " + dir.getAbsolutePath()); FileUtils.deleteRecursive(dir); } }
From source file:me.tango.cassandra.bench.SchemaLoader.java
License:Apache License
public static void cleanup() { // clean up commitlog String[] directoryNames = { DatabaseDescriptor.getCommitLogLocation(), }; for (String dirName : directoryNames) { File dir = new File(dirName); if (!dir.exists()) throw new RuntimeException("No such directory: " + dir.getAbsolutePath()); FileUtils.deleteRecursive(dir);/*from ww w .j a v a2 s. c o m*/ } cleanupSavedCaches(); // clean up data directory which are stored as data directory/keyspace/data files for (String dirName : DatabaseDescriptor.getAllDataFileLocations()) { File dir = new File(dirName); if (!dir.exists()) throw new RuntimeException("No such directory: " + dir.getAbsolutePath()); FileUtils.deleteRecursive(dir); } }
From source file:org.ebayopensource.turmeric.manager.cassandra.server.CassandraTestManager.java
License:Open Source License
private static void cleanupData() throws IOException { String[] allDataFileLocations = DatabaseDescriptor.getAllDataFileLocations(); for (String s : allDataFileLocations) { File dirFile = new File(s + "/rl"); if (dirFile.exists() && dirFile.isDirectory()) { FileUtils.delete(dirFile.listFiles()); }//from www . ja va2s .co m } }
From source file:org.ebayopensource.turmeric.monitoring.aggregation.util.CassandraTestManager.java
License:Open Source License
private static void cleanupData() throws IOException { String[] allDataFileLocations = DatabaseDescriptor.getAllDataFileLocations(); for (String s : allDataFileLocations) { File dirFile = new File(s); if (dirFile.exists() && dirFile.isDirectory()) { FileUtils.delete(dirFile.listFiles()); }//from ww w .j a v a 2 s .c om } }
From source file:org.ebayopensource.turmeric.rateLimiterproviderImpl.RateLimiterProviderImplTest.java
License:Open Source License
private void cleanupData() throws IOException { String[] allDataFileLocations = DatabaseDescriptor.getAllDataFileLocations(); for (String s : allDataFileLocations) { File dirFile = new File(s); if (dirFile.exists() && dirFile.isDirectory()) { FileUtils.delete(dirFile.listFiles()); }/*from w ww . j a va 2 s .c o m*/ } }
From source file:org.ebayopensource.turmeric.utils.cassandra.server.CassandraTestManager.java
License:Open Source License
private static Set<String> getDataDirs() { Set<String> dirs = new HashSet<String>(); for (String s : DatabaseDescriptor.getAllDataFileLocations()) { dirs.add(s);// w ww. jav a 2 s .c o m } return dirs; }
From source file:org.elassandra.SnapshotTests.java
License:Apache License
@Test public void basicSnapshotTest() throws Exception { process(ConsistencyLevel.ONE,//from w w w . j av a2 s. c o m String.format(Locale.ROOT, "CREATE KEYSPACE ks WITH replication = {'class': 'NetworkTopologyStrategy', '%s': '1'}", DatabaseDescriptor.getLocalDataCenter())); process(ConsistencyLevel.ONE, "CREATE TABLE ks.t1 ( name text, age int, primary key (name))"); XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("t1") .field("discover", ".*").endObject().endObject(); createIndex("ks", Settings.builder().put("index.snapshot_with_sstable", true).build(), "t1", mapping); ensureGreen("ks"); for (long i = 0; i < 1000; i++) process(ConsistencyLevel.ONE, String.format(Locale.ROOT, "INSERT INTO ks.t1 (name, age) VALUES ('name%d', %d)", i, i)); assertThat( client().prepareSearch().setIndices("ks").setTypes("t1") .setQuery(QueryBuilders.queryStringQuery("*:*")).get().getHits().getTotalHits(), equalTo(1000L)); // take snaphot StorageService.instance.takeSnapshot("snap1", "ks"); // drop all process(ConsistencyLevel.ONE, "TRUNCATE ks.t1"); assertThat( client().prepareSearch().setIndices("ks").setTypes("t1") .setQuery(QueryBuilders.queryStringQuery("*:*")).get().getHits().getTotalHits(), equalTo(0L)); // close index and restore SSTable+Lucene files assertAcked(client().admin().indices().prepareClose("ks").get()); String dataLocation = DatabaseDescriptor.getAllDataFileLocations()[0]; restoreSSTable(dataLocation, "ks", "t1", Schema.instance.getCFMetaData("ks", "t1").cfId, "snap1"); restoreLucenceFiles(dataLocation, "ks", "snap1"); // refresh SSTables and repopen index StorageService.instance.loadNewSSTables("ks", "t1"); assertAcked(client().admin().indices().prepareOpen("ks").get()); ensureGreen("ks"); assertThat( client().prepareSearch().setIndices("ks").setTypes("t1") .setQuery(QueryBuilders.queryStringQuery("*:*")).get().getHits().getTotalHits(), equalTo(1000L)); }
From source file:org.elassandra.SnapshotTests.java
License:Apache License
@Test //mvn test -Pdev -pl com.strapdata.elasticsearch:elasticsearch -Dtests.seed=622A2B0618CE4676 -Dtests.class=org.elassandra.SnapshotTests -Dtests.method="onDropSnapshotTest" -Des.logger.level=ERROR -Dtests.assertion.disabled=false -Dtests.security.manager=false -Dtests.heap.size=1024m -Dtests.locale=ro-RO -Dtests.timezone=America/Toronto public void onDropSnapshotTest() throws Exception { process(ConsistencyLevel.ONE,// w w w . j a v a2s .c o m String.format(Locale.ROOT, "CREATE KEYSPACE ks WITH replication = {'class': 'NetworkTopologyStrategy', '%s': '1'}", DatabaseDescriptor.getLocalDataCenter())); process(ConsistencyLevel.ONE, "CREATE TABLE ks.t1 ( name text, age int, primary key (name))"); XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("t1") .field("discover", ".*").endObject().endObject(); createIndex("ks", Settings.builder().put("index.snapshot_with_sstable", true).build(), "t1", mapping); ensureGreen("ks"); for (long i = 0; i < 1000; i++) process(ConsistencyLevel.ONE, String.format(Locale.ROOT, "INSERT INTO ks.t1 (name, age) VALUES ('name%d', %d)", i, i)); assertThat( client().prepareSearch().setIndices("ks").setTypes("t1") .setQuery(QueryBuilders.queryStringQuery("*:*")).get().getHits().getTotalHits(), equalTo(1000L)); UUID cfId = Schema.instance.getCFMetaData("ks", "t1").cfId; String id = cfId.toString().replaceAll("\\-", ""); if (!DatabaseDescriptor.isAutoSnapshot()) StorageService.instance.takeTableSnapshot("ks", "t1", Long.toString(new Date().getTime())); // drop index + keyspace (C* snapshot before drop => flush before snapshot => ES flush before delete) assertAcked(client().admin().indices().prepareDelete("ks").get()); // recreate schema and mapping process(ConsistencyLevel.ONE, String.format(Locale.ROOT, "CREATE KEYSPACE ks WITH replication = {'class': 'NetworkTopologyStrategy', '%s': '1'}", DatabaseDescriptor.getLocalDataCenter())); process(ConsistencyLevel.ONE, "CREATE TABLE ks.t1 ( name text, age int, primary key (name))"); createIndex("ks", Settings.builder().put("index.snapshot_with_sstable", true).build(), "t1", mapping); ensureGreen("ks"); assertThat( client().prepareSearch().setIndices("ks").setTypes("t1") .setQuery(QueryBuilders.queryStringQuery("*:*")).get().getHits().getTotalHits(), equalTo(0L)); // close index and restore SSTable+Lucene files assertAcked(client().admin().indices().prepareClose("ks").get()); String dataLocation = DatabaseDescriptor.getAllDataFileLocations()[0]; DirectoryStream<Path> stream = Files .newDirectoryStream(PathUtils.get(dataLocation + "/ks/t1-" + id + "/snapshots/")); Path snapshot = stream.iterator().next(); String snap = snapshot.getFileName().toString(); System.out.println("snapshot name=" + snap); stream.close(); restoreSSTable(dataLocation, "ks", "t1", cfId, snap); restoreLucenceFiles(dataLocation, "ks", snap); // refresh SSTables and repopen index StorageService.instance.loadNewSSTables("ks", "t1"); assertAcked(client().admin().indices().prepareOpen("ks").get()); ensureGreen("ks"); assertThat( client().prepareSearch().setIndices("ks").setTypes("t1") .setQuery(QueryBuilders.queryStringQuery("*:*")).get().getHits().getTotalHits(), equalTo(1000L)); }
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 w w w . j a v a2 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()); }