Example usage for org.apache.cassandra.config DatabaseDescriptor getCommitLogLocation

List of usage examples for org.apache.cassandra.config DatabaseDescriptor getCommitLogLocation

Introduction

In this page you can find the example usage for org.apache.cassandra.config DatabaseDescriptor getCommitLogLocation.

Prototype

public static String getCommitLogLocation() 

Source Link

Usage

From source file:com.btoddb.flume.sinks.cassandra.EmbeddedServerHelper.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 av  a  2s  . c  o m
    }

    // 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:com.isthari.spring.cloud.config.cassandra.CassandraServiceDataCleaner.java

License:Apache License

/**
 * Collects all data dirs and returns a set of String paths on the file system.
 *
 * @return//w w w.  j a  v a2  s.com
 */
private Set<String> getDataDirs() {
    Set<String> dirs = new HashSet<String>();
    for (String s : DatabaseDescriptor.getAllDataFileLocations()) {
        dirs.add(s);
    }
    dirs.add(DatabaseDescriptor.getCommitLogLocation());
    return dirs;
}

From source file:com.jeklsoft.cassandraclient.EmbeddedCassandra.java

License:Apache License

private void makeDirsIfNotExist() throws IOException {
    for (String s : Arrays.asList(DatabaseDescriptor.getAllDataFileLocations())) {
        forceMkdir(new File(s));
    }/* w  ww . ja va 2  s  . c o  m*/
    forceMkdir(new File(DatabaseDescriptor.getCommitLogLocation()));
}

From source file:com.navercorp.pinpoint.plugin.cassandra.CassandraTestHelper.java

License:Apache License

private static void cleanUpFiles() throws IOException {
    Set<String> fileLocations = new HashSet<String>();
    for (String dataFileLocation : DatabaseDescriptor.getAllDataFileLocations()) {
        fileLocations.add(dataFileLocation);
    }//from  w w  w.ja va  2 s. com
    fileLocations.add(DatabaseDescriptor.getCommitLogLocation());
    fileLocations.add(DatabaseDescriptor.getSavedCachesLocation());
    for (String fileLocation : fileLocations) {
        File location = new File(fileLocation);
        if (location.exists() && location.isDirectory()) {
            FileUtils.deleteDirectory(fileLocation);
        }
    }
}

From source file:com.savoirtech.bundles.cassandra.AbstractCassandraDaemon.java

License:Apache License

/**
 * This is a hook for concrete daemons to initialize themselves suitably.
 * <p/>/*from  w w  w. j a  v a  2 s.c om*/
 * Subclasses should override this to finish the job (listening on ports, etc.)
 *
 * @throws java.io.IOException
 */
protected void setup() {
    logger.info("JVM vendor/version: {}/{}", System.getProperty("java.vm.name"),
            System.getProperty("java.version"));
    logger.info("Heap size: {}/{}", Runtime.getRuntime().totalMemory(), Runtime.getRuntime().maxMemory());
    logger.info("Classpath: {}", System.getProperty("java.class.path"));
    CLibrary.tryMlockall();

    listenPort = DatabaseDescriptor.getRpcPort();
    listenAddr = DatabaseDescriptor.getRpcAddress();

    Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
        public void uncaughtException(Thread t, Throwable e) {
            exceptions.incrementAndGet();
            logger.error("Exception in thread " + t, e);
            for (Throwable e2 = e; e2 != null; e2 = e2.getCause()) {
                // some code, like FileChannel.map, will wrap an OutOfMemoryError in another exception
                if (e2 instanceof OutOfMemoryError) {
                    System.exit(100);
                }
            }
        }
    });

    // check all directories(data, commitlog, saved cache) for existence and permission
    Iterable<String> dirs = Iterables.concat(Arrays.asList(DatabaseDescriptor.getAllDataFileLocations()),
            Arrays.asList(new String[] { DatabaseDescriptor.getCommitLogLocation(),
                    DatabaseDescriptor.getSavedCachesLocation() }));
    for (String dataDir : dirs) {
        logger.debug("Checking directory {}", dataDir);
        File dir = new File(dataDir);
        if (dir.exists()) {
            assert dir.isDirectory() && dir.canRead() && dir.canWrite() && dir.canExecute() : String
                    .format("Directory %s is not accessible.", dataDir);
        }
    }

    // Migrate sstables from pre-#2749 to the correct location
    if (Directories.sstablesNeedsMigration()) {
        Directories.migrateSSTables();
    }

    if (CacheService.instance == null) // should never happen
    {
        throw new RuntimeException("Failed to initialize Cache Service.");
    }

    // check the system table to keep user from shooting self in foot by changing partitioner, cluster name, etc.
    // we do a one-off scrub of the system table first; we can't load the list of the rest of the tables,
    // until system table is opened.
    for (CFMetaData cfm : Schema.instance.getTableMetaData(Table.SYSTEM_KS).values()) {
        ColumnFamilyStore.scrubDataDirectories(Table.SYSTEM_KS, cfm.cfName);
    }
    try {
        SystemTable.checkHealth();
    } catch (ConfigurationException e) {
        logger.error("Fatal exception during initialization", e);
        System.exit(100);
    }

    // load keyspace descriptions.
    try {
        DatabaseDescriptor.loadSchemas();
    } catch (IOException e) {
        logger.error("Fatal exception during initialization", e);
        System.exit(100);
    }

    // clean up debris in the rest of the tables
    for (String table : Schema.instance.getTables()) {
        for (CFMetaData cfm : Schema.instance.getTableMetaData(table).values()) {
            ColumnFamilyStore.scrubDataDirectories(table, cfm.cfName);
        }
    }

    // initialize keyspaces
    for (String table : Schema.instance.getTables()) {
        if (logger.isDebugEnabled()) {
            logger.debug("opening keyspace " + table);
        }
        Table.open(table);
    }

    if (CacheService.instance.keyCache.size() > 0) {
        logger.info("completed pre-loading ({} keys) key cache.", CacheService.instance.keyCache.size());
    }

    if (CacheService.instance.rowCache.size() > 0) {
        logger.info("completed pre-loading ({} keys) row cache.", CacheService.instance.rowCache.size());
    }

    try {
        GCInspector.instance.start();
    } catch (Throwable t) {
        logger.warn("Unable to start GCInspector (currently only supported on the Sun JVM)");
    }

    // replay the log if necessary
    try {
        CommitLog.instance.recover();
    } catch (IOException e) {
        logger.error("Fatal configuration error", e);
        System.err.println(e.getMessage()
                + "\nFatal configuration error; unable to start server.  See log for stacktrace.");
        System.exit(1);
    }

    SystemTable.finishStartup();

    // start server internals
    StorageService.instance.registerDaemon(this);
    try {
        StorageService.instance.initServer();
    } catch (ConfigurationException e) {
        logger.error("Fatal configuration error", e);
        System.err.println(e.getMessage()
                + "\nFatal configuration error; unable to start server.  See log for stacktrace.");
        System.exit(1);
    }

    Mx4jTool.maybeLoad();
}

From source file:com.springsource.insight.plugin.cassandra.embeded.EmbeddedCassandraService.java

License:Open Source License

/**
 * Collects all data dirs and returns a set of String paths on the file system.
 *
 * @return/*from   w w w .j  a va  2s .com*/
 */
private Set<String> getDataDirs() {
    Set<String> dirs = new HashSet<String>();
    for (String s : DatabaseDescriptor.getAllDataFileLocations()) {
        dirs.add(s);
    }
    dirs.add(DatabaseDescriptor.getCommitLogLocation());
    dirs.add(DatabaseDescriptor.getSavedCachesLocation());
    return dirs;
}

From source file:com.stratio.decision.unit.engine.action.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()) {
            log.error("No such directory: " + dir.getAbsolutePath());
            throw new RuntimeException("No such directory: " + dir.getAbsolutePath());
        }/* w w w .j  a v a  2s.  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()) {
            log.error("No such directory: " + dir.getAbsolutePath());
            throw new RuntimeException("No such directory: " + dir.getAbsolutePath());
        }
        FileUtils.deleteRecursive(dir);
    }
}

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   ww w  .  j  av a  2 s . c  o 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   www  . j  a  v a2 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 w w w .  j  a  va 2 s .  co 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);
    }
}