org.apache.nifi.util.file.FileUtils.syncWithRestore()方法的使用及代码示例

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

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

FileUtils.syncWithRestore介绍

[英]Syncs a primary copy of a file with the copy in the restore directory. If the restore directory does not have a file and the primary has a file, the the primary's file is copied to the restore directory. Else if the restore directory has a file, but the primary does not, then the restore's file is copied to the primary directory. Else if the primary file is different than the restore file, then an IllegalStateException is thrown. Otherwise, if neither file exists, then no syncing is performed.
[中]将文件的主副本与还原目录中的副本同步。如果还原目录没有文件而主目录有文件,则会将主目录的文件复制到还原目录。否则,如果还原目录有文件,但主目录没有,则还原的文件将复制到主目录。否则,如果主文件与还原文件不同,则会引发IllegalStateException。否则,如果两个文件都不存在,则不执行同步。

代码示例

代码示例来源:origin: apache/nifi

private void syncWithRestoreDirectory() throws IOException {
  // sanity check that restore directory is a directory, creating it if necessary
  FileUtils.ensureDirectoryExistAndCanAccess(restoreDirectory);
  // check that restore directory is not the same as the primary directory
  if (config.getParentFile().getAbsolutePath().equals(restoreDirectory.getAbsolutePath())) {
    throw new IllegalStateException(
        String.format("Cluster firewall configuration file '%s' cannot be in the restore directory '%s' ",
            config.getAbsolutePath(), restoreDirectory.getAbsolutePath()));
  }
  // the restore copy will have same file name, but reside in a different directory
  final File restoreFile = new File(restoreDirectory, config.getName());
  // sync the primary copy with the restore copy
  FileUtils.syncWithRestore(config, restoreFile, logger);
}

代码示例来源:origin: apache/nifi

FileUtils.syncWithRestore(tenantsFile, restoreTenantsFile, logger);
} catch (final IOException | IllegalStateException ioe) {
  throw new AuthorizerCreationException(ioe);

代码示例来源:origin: apache/nifi

FileUtils.syncWithRestore(authorizationsFile, restoreAuthorizationsFile, logger);
} catch (final IOException | IllegalStateException ioe) {
  throw new AuthorizerCreationException(ioe);

相关文章