类org.apache.hadoop.fs.FsStatus源码实例Demo

下面列出了怎么用org.apache.hadoop.fs.FsStatus的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: datawave   文件: HdfsBackedSortedSet.java
public boolean isValid() {
    FsStatus fsStatus = null;
    try {
        fsStatus = ivaratorCacheDir.getFs().getStatus();
    } catch (IOException e) {
        log.warn("Unable to determine status of the filesystem: " + ivaratorCacheDir.getFs());
    }
    
    // determine whether this fs is a good candidate
    if (fsStatus != null) {
        long availableStorageMiB = fsStatus.getRemaining() / 0x100000L;
        double availableStoragePercent = (double) fsStatus.getRemaining() / fsStatus.getCapacity();
        
        // if we are using less than our storage limit, the cache dir is valid
        return availableStorageMiB >= ivaratorCacheDir.getConfig().getMinAvailableStorageMiB()
                        && availableStoragePercent >= ivaratorCacheDir.getConfig().getMinAvailableStoragePercent();
    }
    
    return false;
}
 
源代码2 项目: Hue-Ctrip-DI   文件: TestMain.java
public void test() throws IOException {
	Configuration conf = new Configuration();
	conf.addResource("conf/hdfs/test-hdfs-client-conf.xml");

	System.setProperty("HADOOP_USER_NAME", "hdfs");
	DistributedFileSystem fs = (DistributedFileSystem) FileSystem.get(conf);

	DatanodeInfo[] dataNodeStatus = fs.getDataNodeStats();
	for (DatanodeInfo dninfo : dataNodeStatus) {
		System.out.println(dninfo.getHostName() + ", Is Decommission:"
				+ dninfo.isDecommissioned());
		System.out.println(dninfo.getHostName() + ", Dump Data node:"
				+ dninfo.dumpDatanode());
	}
	System.out.println("Default block size:" + fs.getDefaultBlockSize());
	ContentSummary contentSummary = fs.getContentSummary(new Path("/"));
	System.out.println("Content Summary:" + contentSummary);

	FsStatus fsstatus = fs.getStatus();

	System.out.println(fsstatus.getCapacity());
}
 
源代码3 项目: hadoop   文件: FsUsage.java
@Override
protected void processPath(PathData item) throws IOException {
  FsStatus fsStats = item.fs.getStatus(item.path);
  long size = fsStats.getCapacity();
  long used = fsStats.getUsed();
  long free = fsStats.getRemaining();

  usagesTable.addRow(
      item.fs.getUri(),
      formatSize(size),
      formatSize(used),
      formatSize(free),
      StringUtils.formatPercent((double)used/(double)size, 0)
  );
}
 
源代码4 项目: dremio-oss   文件: HadoopFileSystemWrapper.java
@Override
public FsStatus getStatus() throws IOException {
  try (WaitRecorder recorder = OperatorStats.getWaitRecorder(operatorStats)) {
    return underlyingFs.getStatus();
  } catch(FSError e) {
    throw propagateFSError(e);
  }
}
 
源代码5 项目: dremio-oss   文件: HadoopFileSystemWrapper.java
@Override
public FsStatus getStatus(Path p) throws IOException {
  try (WaitRecorder recorder = OperatorStats.getWaitRecorder(operatorStats)) {
    return underlyingFs.getStatus(p);
  } catch(FSError e) {
    throw propagateFSError(e);
  }
}
 
源代码6 项目: big-c   文件: FsUsage.java
@Override
protected void processPath(PathData item) throws IOException {
  FsStatus fsStats = item.fs.getStatus(item.path);
  long size = fsStats.getCapacity();
  long used = fsStats.getUsed();
  long free = fsStats.getRemaining();

  usagesTable.addRow(
      item.fs.getUri(),
      formatSize(size),
      formatSize(used),
      formatSize(free),
      StringUtils.formatPercent((double)used/(double)size, 0)
  );
}
 
/** @throws Exception If failed. */
@Test
public void testStatus() throws Exception {
    Path file1 = new Path("/file1");

    try (FSDataOutputStream file = fs.create(file1, EnumSet.noneOf(CreateFlag.class),
        Options.CreateOpts.perms(FsPermission.getDefault()))) {
        file.write(new byte[1024 * 1024]);
    }

    FsStatus status = fs.getFsStatus();

    assertEquals(getClientFsUser(), fs.getFileStatus(file1).getOwner());

    assertEquals(4, grid(0).cluster().nodes().size());

    long used = 0, max = 0;

    for (int i = 0; i < 4; i++) {
        IgniteFileSystem igfs = grid(i).fileSystem("igfs");

        IgfsMetrics metrics = igfs.metrics();

        used += metrics.localSpaceSize();
        max += metrics.maxSpaceSize();
    }

    assertEquals(used, status.getUsed());
    assertEquals(max, status.getCapacity());
}
 
源代码8 项目: cephfs-hadoop   文件: CephFileSystem.java
@Override
public FsStatus getStatus(Path p) throws IOException {
 CephStatVFS stat = new CephStatVFS();
 ceph.statfs(p, stat);

 FsStatus status = new FsStatus(stat.bsize * stat.blocks, 
	  	stat.bsize * (stat.blocks - stat.bavail),
	  	stat.bsize * stat.bavail);
 return status;
}
 
源代码9 项目: Bats   文件: DrillFileSystem.java
@Override
public FsStatus getStatus() throws IOException {
  return underlyingFs.getStatus();
}
 
源代码10 项目: Bats   文件: DrillFileSystem.java
@Override
public FsStatus getStatus(Path p) throws IOException {
  return underlyingFs.getStatus(p);
}
 
源代码11 项目: datawave   文件: HdfsBackedSortedSetTest.java
@Test
public void persistReloadTest() throws Exception {
    File tempDir = Files.createTempDir();
    tempDir.deleteOnExit();
    
    File smallDir = new File(tempDir, "small");
    Assert.assertTrue(smallDir.mkdirs());
    
    File largeDir = new File(tempDir, "large");
    Assert.assertTrue(largeDir.mkdirs());
    
    LocalFileSystem fs = new LocalFileSystem();
    fs.initialize(tempDir.toURI(), new Configuration());
    
    FsStatus fsStatus = fs.getStatus();
    
    // set the min remaining MB to something which will cause the 'small' directiory to be skipped
    long minRemainingMB = (fsStatus.getRemaining() / 0x100000L) + 4096l;
    
    List<IvaratorCacheDir> ivaratorCacheDirs = new ArrayList<>();
    ivaratorCacheDirs
                    .add(new IvaratorCacheDir(new IvaratorCacheDirConfig(smallDir.toURI().toString(), 0, minRemainingMB), fs, smallDir.toURI().toString()));
    ivaratorCacheDirs.add(new IvaratorCacheDir(new IvaratorCacheDirConfig(largeDir.toURI().toString()), fs, largeDir.toURI().toString()));
    
    String uniquePath = "blah";
    
    HdfsBackedSortedSet<String> sortedSet = new HdfsBackedSortedSet<>(ivaratorCacheDirs, uniquePath, 9999, 2, new FileSortedSet.PersistOptions());
    
    // Add an entry to the sorted set
    String someTestString = "some test string";
    sortedSet.add(someTestString);
    
    // persist the sorted set
    sortedSet.persist();
    
    Path smallPath = new Path(smallDir.toURI().toString());
    Path smallSubPath = new Path(smallPath, uniquePath);
    Path largePath = new Path(largeDir.toURI().toString());
    Path largeSubPath = new Path(largePath, uniquePath);
    
    // ensure that data was written to the large folder, not the small folder
    Assert.assertFalse(fs.exists(smallSubPath));
    Assert.assertEquals(0, fs.listStatus(smallPath).length);
    Assert.assertTrue(fs.exists(largeSubPath));
    
    FileStatus[] fileStatuses = fs.listStatus(largeSubPath);
    Assert.assertEquals(1, fileStatuses.length);
    Assert.assertTrue(fileStatuses[0].getPath().getName().startsWith("SortedSet"));
    
    // Now make sure reloading an ivarator cache dir works
    HdfsBackedSortedSet<String> reloadedSortedSet = new HdfsBackedSortedSet<>(ivaratorCacheDirs, uniquePath, 9999, 2, new FileSortedSet.PersistOptions());
    
    Assert.assertEquals(1, reloadedSortedSet.size());
    Assert.assertEquals(someTestString, reloadedSortedSet.first());
}
 
源代码12 项目: incubator-crail   文件: CrailHDFS.java
@Override
public FsStatus getFsStatus() throws AccessControlException, FileNotFoundException, IOException {
	return dfs.getStatus();
}
 
源代码13 项目: incubator-crail   文件: CrailHadoopFileSystem.java
@Override
public FsStatus getStatus(Path p) throws IOException {
	statistics.incrementReadOps(1);
	return new FsStatus(Long.MAX_VALUE, 0, Long.MAX_VALUE);
}
 
源代码14 项目: hadoop   文件: DFSClient.java
/**
 * @see ClientProtocol#getStats()
 */
public FsStatus getDiskStatus() throws IOException {
  long rawNums[] = callGetStats();
  return new FsStatus(rawNums[0], rawNums[1], rawNums[2]);
}
 
源代码15 项目: hadoop   文件: DistributedFileSystem.java
public DiskStatus(FsStatus stats) {
  super(stats.getCapacity(), stats.getUsed(), stats.getRemaining());
}
 
源代码16 项目: hadoop   文件: DistributedFileSystem.java
@Override
public FsStatus getStatus(Path p) throws IOException {
  statistics.incrementReadOps(1);
  return dfs.getDiskStatus();
}
 
源代码17 项目: hadoop   文件: ChRootedFileSystem.java
@Override
public FsStatus getStatus(Path p) throws IOException {
  return super.getStatus(fullPath(p));
}
 
源代码18 项目: hadoop   文件: ChRootedFs.java
@Override
public FsStatus getFsStatus() throws IOException {
  return myFs.getFsStatus();
}
 
源代码19 项目: hadoop   文件: ViewFs.java
@Override
public FsStatus getFsStatus() throws AccessControlException,
    FileNotFoundException, IOException {
  return new FsStatus(0, 0, 0);
}
 
源代码20 项目: hadoop   文件: ViewFs.java
@Override
public FsStatus getFsStatus() {
  return new FsStatus(0, 0, 0);
}
 
源代码21 项目: big-c   文件: DFSClient.java
/**
 * @see ClientProtocol#getStats()
 */
public FsStatus getDiskStatus() throws IOException {
  long rawNums[] = callGetStats();
  return new FsStatus(rawNums[0], rawNums[1], rawNums[2]);
}
 
源代码22 项目: big-c   文件: DistributedFileSystem.java
public DiskStatus(FsStatus stats) {
  super(stats.getCapacity(), stats.getUsed(), stats.getRemaining());
}
 
源代码23 项目: big-c   文件: DistributedFileSystem.java
@Override
public FsStatus getStatus(Path p) throws IOException {
  statistics.incrementReadOps(1);
  return dfs.getDiskStatus();
}
 
源代码24 项目: big-c   文件: ChRootedFileSystem.java
@Override
public FsStatus getStatus(Path p) throws IOException {
  return super.getStatus(fullPath(p));
}
 
源代码25 项目: big-c   文件: ChRootedFs.java
@Override
public FsStatus getFsStatus() throws IOException {
  return myFs.getFsStatus();
}
 
源代码26 项目: big-c   文件: ViewFs.java
@Override
public FsStatus getFsStatus() throws AccessControlException,
    FileNotFoundException, IOException {
  return new FsStatus(0, 0, 0);
}
 
源代码27 项目: big-c   文件: ViewFs.java
@Override
public FsStatus getFsStatus() {
  return new FsStatus(0, 0, 0);
}
 
源代码28 项目: hudi   文件: HoodieWrapperFileSystem.java
@Override
public FsStatus getStatus() throws IOException {
  return fileSystem.getStatus();
}
 
源代码29 项目: hudi   文件: HoodieWrapperFileSystem.java
@Override
public FsStatus getStatus(Path p) throws IOException {
  return fileSystem.getStatus(convertToDefaultPath(p));
}
 
源代码30 项目: crail   文件: CrailHDFS.java
@Override
public FsStatus getFsStatus() throws AccessControlException, FileNotFoundException, IOException {
	return new FsStatus(1000000000, 1000, 1000000000 - 1000);
}
 
 类所在包
 同包方法