org.apache.cassandra.io.util.FileUtils.delete()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(9.9k)|赞(0)|评价(0)|浏览(150)

本文整理了Java中org.apache.cassandra.io.util.FileUtils.delete()方法的一些代码示例,展示了FileUtils.delete()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtils.delete()方法的具体详情如下:
包路径:org.apache.cassandra.io.util.FileUtils
类名称:FileUtils
方法名:delete

FileUtils.delete介绍

[英]Deletes all files and subdirectories under "dir".
[中]删除“dir”下的所有文件和子目录。

代码示例

代码示例来源:origin: com.facebook.presto.cassandra/cassandra-server

public void delete()
{
  FileUtils.delete(lockfile);
}

代码示例来源:origin: org.apache.cassandra/cassandra-all

/**
 * We use a ReferenceQueue to manage deleting files that have been compacted
 * and for which no more SSTable references exist.  But this is not guaranteed
 * to run for each such file because of the semantics of the JVM gc.  So,
 * we write a marker to `compactedFilename` when a file is compacted;
 * if such a marker exists on startup, the file should be removed.
 *
 * This method will also remove SSTables that are marked as temporary.
 *
 * @return true if the file was deleted
 */
public static boolean delete(Descriptor desc, Set<Component> components)
{
  logger.debug("Deleting sstable: {}", desc);
  // remove the DATA component first if it exists
  if (components.contains(Component.DATA))
    FileUtils.deleteWithConfirm(desc.filenameFor(Component.DATA));
  for (Component component : components)
  {
    if (component.equals(Component.DATA) || component.equals(Component.SUMMARY))
      continue;
    FileUtils.deleteWithConfirm(desc.filenameFor(component));
  }
  if (components.contains(Component.SUMMARY))
    FileUtils.delete(desc.filenameFor(Component.SUMMARY));
  return true;
}

代码示例来源:origin: com.facebook.presto.cassandra/cassandra-server

/**
 * We use a ReferenceQueue to manage deleting files that have been compacted
 * and for which no more SSTable references exist.  But this is not guaranteed
 * to run for each such file because of the semantics of the JVM gc.  So,
 * we write a marker to `compactedFilename` when a file is compacted;
 * if such a marker exists on startup, the file should be removed.
 *
 * This method will also remove SSTables that are marked as temporary.
 *
 * @return true if the file was deleted
 */
public static boolean delete(Descriptor desc, Set<Component> components)
{
  // remove the DATA component first if it exists
  if (components.contains(Component.DATA))
    FileUtils.deleteWithConfirm(desc.filenameFor(Component.DATA));
  for (Component component : components)
  {
    if (component.equals(Component.DATA) || component.equals(Component.SUMMARY))
      continue;
    FileUtils.deleteWithConfirm(desc.filenameFor(component));
  }
  FileUtils.delete(desc.filenameFor(Component.SUMMARY));
  logger.debug("Deleted {}", desc);
  return true;
}

代码示例来源:origin: io.zipkin.brave.cassandra/brave-instrumentation-cassandra-tests

private static void cleanupSavedCaches() {
 File cachesDir = new File(DatabaseDescriptor.getSavedCachesLocation());
 if (!cachesDir.exists() || !cachesDir.isDirectory()) return;
 FileUtils.delete(cachesDir.listFiles());
}

代码示例来源:origin: com.strapdata.cassandra/cassandra-all

/**
 * We use a ReferenceQueue to manage deleting files that have been compacted
 * and for which no more SSTable references exist.  But this is not guaranteed
 * to run for each such file because of the semantics of the JVM gc.  So,
 * we write a marker to `compactedFilename` when a file is compacted;
 * if such a marker exists on startup, the file should be removed.
 *
 * This method will also remove SSTables that are marked as temporary.
 *
 * @return true if the file was deleted
 */
public static boolean delete(Descriptor desc, Set<Component> components)
{
  logger.debug("Deleting sstable: {}", desc);
  // remove the DATA component first if it exists
  if (components.contains(Component.DATA))
    FileUtils.deleteWithConfirm(desc.filenameFor(Component.DATA));
  for (Component component : components)
  {
    if (component.equals(Component.DATA) || component.equals(Component.SUMMARY))
      continue;
    FileUtils.deleteWithConfirm(desc.filenameFor(component));
  }
  if (components.contains(Component.SUMMARY))
    FileUtils.delete(desc.filenameFor(Component.SUMMARY));
  return true;
}

代码示例来源:origin: org.apache.cassandra/cassandra-all

public void release()
{
  int n = references.decrementAndGet();
  if (n == 0)
  {
    FileUtils.closeQuietly(index);
    sstableRef.release();
    if (obsolete.get() || sstableRef.globalCount() == 0)
      FileUtils.delete(index.getIndexPath());
  }
}

代码示例来源:origin: com.netflix.sstableadaptor/sstable-adaptor-cassandra

/**
 * We use a ReferenceQueue to manage deleting files that have been compacted
 * and for which no more SSTable references exist.  But this is not guaranteed
 * to run for each such file because of the semantics of the JVM gc.  So,
 * we write a marker to `compactedFilename` when a file is compacted;
 * if such a marker exists on startup, the file should be removed.
 *
 * This method will also remove SSTables that are marked as temporary.
 *
 * @return true if the file was deleted
 */
public static boolean delete(Descriptor desc, Set<Component> components)
{
  // remove the DATA component first if it exists
  if (components.contains(Component.DATA))
    FileUtils.deleteWithConfirm(desc.filenameFor(Component.DATA));
  for (Component component : components)
  {
    if (component.equals(Component.DATA) || component.equals(Component.SUMMARY))
      continue;
    FileUtils.deleteWithConfirm(desc.filenameFor(component));
  }
  if (components.contains(Component.SUMMARY))
    FileUtils.delete(desc.filenameFor(Component.SUMMARY));
  logger.trace("Deleted {}", desc);
  return true;
}

代码示例来源:origin: jsevellec/cassandra-unit

public void release()
{
  int n = references.decrementAndGet();
  if (n == 0)
  {
    FileUtils.closeQuietly(index);
    sstableRef.release();
    if (obsolete.get() || sstableRef.globalCount() == 0)
      FileUtils.delete(index.getIndexPath());
  }
}

代码示例来源:origin: jsevellec/cassandra-unit

/**
 * We use a ReferenceQueue to manage deleting files that have been compacted
 * and for which no more SSTable references exist.  But this is not guaranteed
 * to run for each such file because of the semantics of the JVM gc.  So,
 * we write a marker to `compactedFilename` when a file is compacted;
 * if such a marker exists on startup, the file should be removed.
 *
 * This method will also remove SSTables that are marked as temporary.
 *
 * @return true if the file was deleted
 */
public static boolean delete(Descriptor desc, Set<Component> components)
{
  // remove the DATA component first if it exists
  if (components.contains(Component.DATA))
    FileUtils.deleteWithConfirm(desc.filenameFor(Component.DATA));
  for (Component component : components)
  {
    if (component.equals(Component.DATA) || component.equals(Component.SUMMARY))
      continue;
    FileUtils.deleteWithConfirm(desc.filenameFor(component));
  }
  if (components.contains(Component.SUMMARY))
    FileUtils.delete(desc.filenameFor(Component.SUMMARY));
  logger.trace("Deleted {}", desc);
  return true;
}

代码示例来源:origin: com.strapdata.cassandra/cassandra-all

public void release()
{
  int n = references.decrementAndGet();
  if (n == 0)
  {
    FileUtils.closeQuietly(index);
    sstableRef.release();
    if (obsolete.get() || sstableRef.globalCount() == 0)
      FileUtils.delete(index.getIndexPath());
  }
}

代码示例来源:origin: jsevellec/cassandra-unit

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));

  }
}

代码示例来源:origin: com.netflix.sstableadaptor/sstable-adaptor-cassandra

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));

  }
}

代码示例来源:origin: org.apache.cassandra/cassandra-all

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));

  }
}

代码示例来源:origin: com.strapdata.cassandra/cassandra-all

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));

  }
}

代码示例来源:origin: org.apache.cassandra/cassandra-all

FileUtils.delete(outputFile);
    FileUtils.closeQuietly(part);
  FileUtils.delete(outputFile + "_" + segment);

代码示例来源:origin: com.strapdata.cassandra/cassandra-all

FileUtils.delete(outputFile);
    FileUtils.closeQuietly(part);
  FileUtils.delete(outputFile + "_" + segment);

代码示例来源:origin: jsevellec/cassandra-unit

FileUtils.delete(outputFile);
    FileUtils.closeQuietly(part);
  FileUtils.delete(outputFile + "_" + segment);

代码示例来源:origin: com.facebook.presto.cassandra/cassandra-server

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));

  }
}

相关文章