org.neo4j.io.fs.FileUtils.size()方法的使用及代码示例

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

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

FileUtils.size介绍

[英]Calculates the size of a given directory or file given the provided abstract filesystem.
[中]计算给定抽象文件系统的给定目录或文件的大小。

代码示例

代码示例来源:origin: neo4j/neo4j

@Override
public long getTotalStoreSize()
{
  return databaseDirectory == null ? 0 : FileUtils.size( fs, databaseDirectory );
}

代码示例来源:origin: neo4j/neo4j

@Override
  public void visit( File file, long logVersion )
  {
    totalSize += FileUtils.size( fs, file );
  }
}

代码示例来源:origin: neo4j/neo4j

private long sizeOf( File file )
  {
    return databaseDirectory == null ? 0 : FileUtils.size( fs, file );
  }
}

代码示例来源:origin: neo4j/neo4j

private long sizeOf( File file )
{
  return FileUtils.size( fs, file );
}

代码示例来源:origin: neo4j/neo4j

@Override
public long getTotalStoreSize()
{
  return FileUtils.size( fs, databaseLayout.databaseDirectory() );
}

代码示例来源:origin: neo4j/neo4j

@Override
public long getLogicalLogSize()
{
  return logFiles == null ? 0 : FileUtils.size( fs, logFiles.getHighestLogFile() );
}

代码示例来源:origin: neo4j/neo4j

@Override
public long getIndexStoreSize()
{
  long size = 0L;
  // Add explicit indices
  for ( IndexImplementation index : explicitIndexProviderLookup.allIndexProviders() )
  {
    size += FileUtils.size( fs, index.getIndexImplementationDirectory( databaseLayout ) );
  }
  // Add schema index
  MutableLong schemaSize = new MutableLong();
  indexProviderMap.accept( provider ->
  {
    File rootDirectory = provider.directoryStructure().rootDirectory();
    if ( rootDirectory != null )
    {
      schemaSize.add( FileUtils.size( fs, rootDirectory ) );
    }
    // else this provider didn't have any persistent storage
  } );
  size += schemaSize.longValue();
  // Add label index
  size += FileUtils.size( fs, labelScanStore.getLabelScanStoreFile() );
  return size;
}

代码示例来源:origin: neo4j/neo4j

@Test
public void sizeOfDirector() throws Exception
{
  File dir = directory( "dir" );
  File file1 = new File( dir, "file1" );
  File file2 = new File( dir, "file2" );
  try ( FileWriter fileWriter = new FileWriter( file1 ) )
  {
    fileWriter.append( 'a' ).append( 'b' );
  }
  try ( FileWriter fileWriter = new FileWriter( file2 ) )
  {
    fileWriter.append( 'a' );
  }
  assertThat( size( fs, dir ), is( 3L ) );
}

代码示例来源:origin: neo4j/neo4j

/**
   * Calculates the size of a given directory or file given the provided abstract filesystem.
   *
   * @param fs the filesystem abstraction to use
   * @param file to the file or directory.
   * @return the size, in bytes, of the file or the total size of the content in the directory, including
   * subdirectories.
   */
  public static long size( FileSystemAbstraction fs, File file )
  {
    if ( fs.isDirectory( file ) )
    {
      long size = 0L;
      File[] files = fs.listFiles( file );
      if ( files == null )
      {
        return 0L;
      }
      for ( File child : files )
      {
        size += size( fs, child );
      }
      return size;
    }
    else
    {
      return fs.getFileSize( file );
    }
  }
}

代码示例来源:origin: neo4j/neo4j

@Test
public void sizeOfFile() throws Exception
{
  File file = touchFile( "a" );
  try ( FileWriter fileWriter = new FileWriter( file ) )
  {
    fileWriter.append( 'a' );
  }
  assertThat( size( fs, file ), is( 1L )  );
}

代码示例来源:origin: neo4j/neo4j

/**
 * Register store file sizes, sans transaction logs
 */
private void addStoreFileSizes( Map<String,String> udcFields )
{
  if ( neoStoreDataSource == null )
  {
    return;
  }
  DependencyResolver dependencyResolver = neoStoreDataSource.getDependencyResolver();
  FileSystemAbstraction fileSystem = dependencyResolver.resolveDependency( FileSystemAbstraction.class );
  long databaseSize = FileUtils.size( fileSystem, neoStoreDataSource.getDatabaseLayout().databaseDirectory() );
  add( udcFields, STORE_SIZE, databaseSize );
}

代码示例来源:origin: org.neo4j/neo4j-jmx

@Override
  public void visit( File file, long logVersion )
  {
    totalSize += FileUtils.size( fs, file );
  }
}

代码示例来源:origin: org.neo4j/neo4j-jmx

@Override
public long getTotalStoreSize()
{
  return databaseDirectory == null ? 0 : FileUtils.size( fs, databaseDirectory );
}

代码示例来源:origin: org.neo4j/neo4j-jmx

private long sizeOf( File file )
  {
    return databaseDirectory == null ? 0 : FileUtils.size( fs, file );
  }
}

代码示例来源:origin: org.neo4j/neo4j-jmx

private long sizeOf( File file )
{
  return FileUtils.size( fs, file );
}

代码示例来源:origin: org.neo4j/neo4j-jmx

@Override
public long getLogicalLogSize()
{
  return logFiles == null ? 0 : FileUtils.size( fs, logFiles.getHighestLogFile() );
}

代码示例来源:origin: org.neo4j/neo4j-jmx

@Override
public long getTotalStoreSize()
{
  return FileUtils.size( fs, databaseLayout.databaseDirectory() );
}

代码示例来源:origin: org.neo4j/neo4j-causal-clustering

@Override
public long getRaftLogSize()
{
  File raftLogDirectory = new File( clusterStateDirectory.get(), RAFT_LOG_DIRECTORY_NAME );
  return FileUtils.size( fs, raftLogDirectory );
}

代码示例来源:origin: org.neo4j/neo4j-causal-clustering

@Override
  public long getReplicatedStateSize()
  {
    File replicatedStateDirectory = clusterStateDirectory.get();
    File[] files = fs.listFiles( replicatedStateDirectory );
    if ( files == null )
    {
      return 0L;
    }
    long size = 0L;
    for ( File file : files )
    {
      // Exclude raft log that resides in same directory
      if ( fs.isDirectory( file ) && file.getName().equals( RAFT_LOG_DIRECTORY_NAME ) )
      {
        continue;
      }
      size += FileUtils.size( fs, file );
    }
    return size;
  }
}

代码示例来源:origin: org.neo4j/neo4j-udc

/**
 * Register store file sizes, sans transaction logs
 */
private void addStoreFileSizes( Map<String,String> udcFields )
{
  if ( neoStoreDataSource == null )
  {
    return;
  }
  DependencyResolver dependencyResolver = neoStoreDataSource.getDependencyResolver();
  FileSystemAbstraction fileSystem = dependencyResolver.resolveDependency( FileSystemAbstraction.class );
  long databaseSize = FileUtils.size( fileSystem, neoStoreDataSource.getDatabaseLayout().databaseDirectory() );
  add( udcFields, STORE_SIZE, databaseSize );
}

相关文章