Java Code Examples for org.apache.cassandra.config.DatabaseDescriptor#getAllDataFileLocations()

The following examples show how to use org.apache.cassandra.config.DatabaseDescriptor#getAllDataFileLocations() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StorageService.java    From stratio-cassandra with Apache License 2.0 6 votes vote down vote up
/**
 * Remove the snapshot with the given name from the given keyspaces.
 * If no tag is specified we will remove all snapshots.
 */
public void clearSnapshot(String tag, String... keyspaceNames) throws IOException
{
    if(tag == null)
        tag = "";

    Set<String> keyspaces = new HashSet<>();
    for (String dataDir : DatabaseDescriptor.getAllDataFileLocations())
    {
        for(String keyspaceDir : new File(dataDir).list())
        {
            // Only add a ks if it has been specified as a param, assuming params were actually provided.
            if (keyspaceNames.length > 0 && !Arrays.asList(keyspaceNames).contains(keyspaceDir))
                continue;
            keyspaces.add(keyspaceDir);
        }
    }

    for (String keyspace : keyspaces)
        Keyspace.clearSnapshot(tag, keyspace);

    if (logger.isDebugEnabled())
        logger.debug("Cleared out snapshot directories");
}
 
Example 2
Source File: StorageServiceServerTest.java    From stratio-cassandra with Apache License 2.0 6 votes vote down vote up
@Test
public void testRegularMode() throws ConfigurationException
{
    SchemaLoader.mkdirs();
    SchemaLoader.cleanup();
    StorageService.instance.initServer(0);
    for (String path : DatabaseDescriptor.getAllDataFileLocations())
    {
        // verify that storage directories are there.
        assertTrue(new File(path).exists());
    }
    // a proper test would be to call decommission here, but decommission() mixes both shutdown and datatransfer
    // calls.  This test is only interested in the shutdown-related items which a properly handled by just
    // stopping the client.
    //StorageService.instance.decommission();
    StorageService.instance.stopClient();
}
 
Example 3
Source File: StorageService.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
public String[] getAllDataFileLocations()
{
    String[] locations = DatabaseDescriptor.getAllDataFileLocations();
    for (int i = 0; i < locations.length; i++)
        locations[i] = FileUtils.getCanonicalPath(locations[i]);
    return locations;
}
 
Example 4
Source File: StorageServiceClientTest.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
@Test
public void testClientOnlyMode() throws ConfigurationException
{
    SchemaLoader.mkdirs();
    SchemaLoader.cleanup();
    StorageService.instance.initClient(0);

    // verify that no storage directories were created.
    for (String path : DatabaseDescriptor.getAllDataFileLocations())
    {
        assertFalse(new File(path).exists());
    }
    StorageService.instance.stopClient();
}