本文整理汇总了Java中org.apache.cassandra.io.util.FileUtils.renameWithConfirm方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtils.renameWithConfirm方法的具体用法?Java FileUtils.renameWithConfirm怎么用?Java FileUtils.renameWithConfirm使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cassandra.io.util.FileUtils
的用法示例。
在下文中一共展示了FileUtils.renameWithConfirm方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: rewriteSSTableMetadata
import org.apache.cassandra.io.util.FileUtils; //导入方法依赖的package包/类
private void rewriteSSTableMetadata(Descriptor descriptor, Map<MetadataType, MetadataComponent> currentComponents) throws IOException
{
String filePath = descriptor.tmpFilenameFor(Component.STATS);
try (DataOutputStreamPlus out = new BufferedDataOutputStreamPlus(new FileOutputStream(filePath)))
{
serialize(currentComponents, out, descriptor.version);
out.flush();
}
// we cant move a file on top of another file in windows:
if (FBUtilities.isWindows)
FileUtils.delete(descriptor.filenameFor(Component.STATS));
FileUtils.renameWithConfirm(filePath, descriptor.filenameFor(Component.STATS));
}
示例2: handleHistoryFiles
import org.apache.cassandra.io.util.FileUtils; //导入方法依赖的package包/类
private static File handleHistoryFiles()
{
File outputDir = FBUtilities.getToolsOutputDirectory();
File historyFile = new File(outputDir, HISTORYFILE);
File oldHistoryFile = new File(System.getProperty("user.home"), OLD_HISTORYFILE);
if(oldHistoryFile.exists())
FileUtils.renameWithConfirm(oldHistoryFile, historyFile);
return historyFile;
}
示例3: CfAssumptions
import org.apache.cassandra.io.util.FileUtils; //导入方法依赖的package包/类
public CfAssumptions()
{
assumptions = new HashMap<String, Map<String, Map<String, String>>>();
assumptionsChanged = false;
assumptionDirectory = FBUtilities.getToolsOutputDirectory();
File oldAssumptionDir = new File(System.getProperty("user.home") + File.separator + ".cassandra-cli");
if (oldAssumptionDir.exists())
{
File oldAssumptionFile = new File(oldAssumptionDir, ASSUMPTIONS_FILENAME);
if (oldAssumptionFile.exists())
FileUtils.renameWithConfirm(oldAssumptionFile, new File(assumptionDirectory, ASSUMPTIONS_FILENAME));
FileUtils.deleteRecursive(oldAssumptionDir);
}
}
示例4: rewriteSSTableMetadata
import org.apache.cassandra.io.util.FileUtils; //导入方法依赖的package包/类
private void rewriteSSTableMetadata(Descriptor descriptor, Map<MetadataType, MetadataComponent> currentComponents) throws IOException
{
Descriptor tmpDescriptor = descriptor.asType(Descriptor.Type.TEMP);
try (DataOutputStreamAndChannel out = new DataOutputStreamAndChannel(new FileOutputStream(tmpDescriptor.filenameFor(Component.STATS))))
{
serialize(currentComponents, out);
out.flush();
}
// we cant move a file on top of another file in windows:
if (FBUtilities.isWindows())
FileUtils.delete(descriptor.filenameFor(Component.STATS));
FileUtils.renameWithConfirm(tmpDescriptor.filenameFor(Component.STATS), descriptor.filenameFor(Component.STATS));
}
示例5: completeSSTable
import org.apache.cassandra.io.util.FileUtils; //导入方法依赖的package包/类
private void completeSSTable(PerSSTableIndexWriter indexWriter, SSTableReader sstable, Collection<ColumnIndex> indexes)
{
indexWriter.complete();
for (ColumnIndex index : indexes)
{
File tmpIndex = new File(index.getPath(indexWriter.getDescriptor()));
if (!tmpIndex.exists()) // no data was inserted into the index for given sstable
continue;
FileUtils.renameWithConfirm(tmpIndex, new File(index.getPath(sstable.descriptor)));
index.update(Collections.<SSTableReader>emptyList(), Collections.singletonList(sstable));
}
}
示例6: rewriteSSTableMetadata
import org.apache.cassandra.io.util.FileUtils; //导入方法依赖的package包/类
private void rewriteSSTableMetadata(Descriptor descriptor, Map<MetadataType, MetadataComponent> currentComponents) throws IOException
{
String filePath = descriptor.tmpFilenameFor(Component.STATS);
try (DataOutputStreamPlus out = new BufferedDataOutputStreamPlus(new FileOutputStream(filePath)))
{
serialize(currentComponents, out, descriptor.version);
out.flush();
}
// we cant move a file on top of another file in windows:
if (FBUtilities.isWindows())
FileUtils.delete(descriptor.filenameFor(Component.STATS));
FileUtils.renameWithConfirm(filePath, descriptor.filenameFor(Component.STATS));
}
示例7: rename
import org.apache.cassandra.io.util.FileUtils; //导入方法依赖的package包/类
public static void rename(Descriptor tmpdesc, Descriptor newdesc, Set<Component> components)
{
for (Component component : Sets.difference(components, Sets.newHashSet(Component.DATA, Component.SUMMARY)))
{
FileUtils.renameWithConfirm(tmpdesc.filenameFor(component), newdesc.filenameFor(component));
}
// do -Data last because -Data present should mean the sstable was completely renamed before crash
FileUtils.renameWithConfirm(tmpdesc.filenameFor(Component.DATA), newdesc.filenameFor(Component.DATA));
// rename it without confirmation because summary can be available for loadNewSSTables but not for closeAndOpenReader
FileUtils.renameWithOutConfirm(tmpdesc.filenameFor(Component.SUMMARY), newdesc.filenameFor(Component.SUMMARY));
}
示例8: mutateLevel
import org.apache.cassandra.io.util.FileUtils; //导入方法依赖的package包/类
/**
* Scary method mutating existing sstable component
*
* Tries to do it safely by moving the new file on top of the old one
*
* Caller needs to reload the sstable metadata (sstableReader.reloadSSTableMetadata())
*
* @see org.apache.cassandra.io.sstable.SSTableReader#reloadSSTableMetadata()
*
* @param oldMetadata
* @param descriptor
* @param filename
* @param level
* @throws IOException
*/
public static synchronized void mutateLevel(Pair<SSTableMetadata, Set<Integer>> oldMetadata, Descriptor descriptor, String filename, int level) throws IOException
{
logger.debug("Mutating {} to level {}", descriptor.filenameFor(Component.STATS), level);
SSTableMetadata metadata = SSTableMetadata.copyWithNewSSTableLevel(oldMetadata.left, level);
DataOutputStream out = new DataOutputStream(new FileOutputStream(filename + "-tmp"));
SSTableMetadata.serializer.legacySerialize(metadata, oldMetadata.right, descriptor, out);
out.flush();
out.close();
FileUtils.renameWithConfirm(filename + "-tmp", filename);
}