List of usage examples for org.apache.cassandra.io.util FileUtils createDirectory
public static void createDirectory(File directory)
From source file:com.btoddb.flume.sinks.cassandra.EmbeddedServerHelper.java
License:Apache License
/** * Creates a directory// w w w. j av a2 s . c o m * * @param dir * @throws IOException */ private static void mkdir(String dir) throws IOException { FileUtils.createDirectory(dir); }
From source file:com.isthari.spring.cloud.config.cassandra.CassandraServiceDataCleaner.java
License:Apache License
/** * Creates a directory//from ww w . ja v a2 s . c om * * @param dir * @throws IOException */ private void mkdir(String dir) throws IOException { FileUtils.createDirectory(dir); }
From source file:com.netflix.priam.backup.IncrementalRestore.java
License:Apache License
@Override public void execute() throws Exception { String prefix = config.getRestorePrefix(); if (Strings.isNullOrEmpty(prefix)) { logger.error(//w w w. j a va2s . c o m "Restore prefix is not set, skipping incremental restore to avoid looping over the incremental backups. Plz check the configurations"); return; // No point in restoring the files which was just backedup. } if (config.isRestoreClosestToken()) { priamServer.getId().getInstance().setToken(restoreToken.toString()); } Date start = tracker.first().time; Iterator<AbstractBackupPath> incrementals = fs.list(prefix, start, Calendar.getInstance().getTime()); FileUtils.createDirectory(restoreDir); // create restore dir. while (incrementals.hasNext()) { AbstractBackupPath temp = incrementals.next(); if (tracker.contains(temp) || start.compareTo(temp.time) >= 0) continue; // ignore the ones which where already downloaded. if (temp.getType() != BackupFileType.SST) continue; // download SST's only. // skip System Keyspace, else you will run into concurrent schema issues. if (temp.getKeyspace().equalsIgnoreCase("System")) continue; /* Cassandra will rebuild Secondary index's after streaming is complete so we can ignore those */ if (SECONDRY_INDEX_PATTERN.matcher(temp.fileName).matches()) // Make this use the constant from 1.1 continue; // Create Directory for Individual Token respective to each incoming file File tokenDir = new File(restoreDir, temp.getToken()); FileUtils.createDirectory(tokenDir); File keyspaceDir = config.getTargetKSName() == null ? new File(tokenDir, temp.keyspace) : new File(tokenDir, config.getTargetKSName()); FileUtils.createDirectory(keyspaceDir); File columnFamilyDir = config.getTargetCFName() == null ? new File(keyspaceDir, temp.columnFamily) : new File(tokenDir, config.getTargetCFName()); FileUtils.createDirectory(columnFamilyDir); logger.debug("*** Keyspace = " + keyspaceDir.getAbsolutePath() + " Column Family = " + columnFamilyDir.getAbsolutePath() + " File = " + temp.getRemotePath()); if (config.getTargetKSName() != null || config.getTargetCFName() != null) temp.fileName = renameIncrementalRestoreFile(temp.fileName); download(temp, new File(columnFamilyDir, temp.fileName)); } // wait for all the downloads in this batch to complete. waitToComplete(); // stream the SST's in the dir for (File tokenDir : restoreDir.listFiles()) { for (File keyspaceDir : tokenDir.listFiles()) { for (File columnFamilyDir : keyspaceDir.listFiles()) { Collection<PendingFile> streamedSSTs = loader.stream(columnFamilyDir); addToStreamedIncrementalRestorePaths(streamedSSTs); if (streamedIncrementalRestorePaths.size() > 0) { logger.debug("streamedIncrementalRestorePaths > 0, hence notifying observers"); notifyStreamedDataObservers(); } // cleanup the dir which where streamed. loader.deleteCompleted(streamedSSTs); } } } }
From source file:org.apache.gora.cassandra.GoraCassandraTestDriver.java
License:Apache License
/** * Starts embedded Cassandra server./* w w w . j av a 2 s. co m*/ * * @throws Exception * if an error occurs */ @Override public void setUpClass() throws Exception { super.setUpClass(); log.info("Starting embedded Cassandra Server..."); try { cleanupDirectoriesFailover(); FileUtils.createDirectory(baseDirectory); System.setProperty("log4j.configuration", "log4j-server.properties"); System.setProperty("cassandra.config", "cassandra.yaml"); cassandraDaemon = new CassandraDaemon(); cassandraDaemon.init(null); cassandraThread = new Thread(new Runnable() { public void run() { try { cassandraDaemon.start(); } catch (Exception e) { log.error("Embedded casandra server run failed!", e); } } }); cassandraThread.setDaemon(true); cassandraThread.start(); } catch (Exception e) { log.error("Embedded casandra server start failed!", e); // cleanup tearDownClass(); } }
From source file:org.springframework.cassandra.test.integration.EmbeddedCassandraServerHelper.java
License:Apache License
/** * Copies a resource from within the jar to a directory. * * @param resource name of the resource/* w w w . j a va 2s . co m*/ * @param targetDirectory name of the target directory * @throws IOException */ private static void copy(String resource, File targetDirectory) throws IOException { FileUtils.createDirectory(targetDirectory); File file = new File(targetDirectory, new File(resource).getName()); InputStream is = EmbeddedCassandraServerHelper.class.getClassLoader().getResourceAsStream(resource); OutputStream out = new FileOutputStream(file); FileCopyUtils.copy(is, out); out.close(); is.close(); }