org.apache.hadoop.fs.FsStatus Java Examples

The following examples show how to use org.apache.hadoop.fs.FsStatus. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HdfsBackedSortedSet.java    From datawave with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #2
Source File: TestMain.java    From Hue-Ctrip-DI with MIT License 6 votes vote down vote up
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());
}
 
Example #3
Source File: CephFileSystem.java    From cephfs-hadoop with GNU Lesser General Public License v2.1 5 votes vote down vote up
@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;
}
 
Example #4
Source File: FsUsage.java    From big-c with Apache License 2.0 5 votes vote down vote up
@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)
  );
}
 
Example #5
Source File: FsUsage.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@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)
  );
}
 
Example #6
Source File: HadoopIgfs20FileSystemAbstractSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** @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());
}
 
Example #7
Source File: HadoopFileSystemWrapper.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
@Override
public FsStatus getStatus(Path p) throws IOException {
  try (WaitRecorder recorder = OperatorStats.getWaitRecorder(operatorStats)) {
    return underlyingFs.getStatus(p);
  } catch(FSError e) {
    throw propagateFSError(e);
  }
}
 
Example #8
Source File: HadoopFileSystemWrapper.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
@Override
public FsStatus getStatus() throws IOException {
  try (WaitRecorder recorder = OperatorStats.getWaitRecorder(operatorStats)) {
    return underlyingFs.getStatus();
  } catch(FSError e) {
    throw propagateFSError(e);
  }
}
 
Example #9
Source File: ViewFs.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public FsStatus getFsStatus() throws AccessControlException,
    FileNotFoundException, IOException {
  return new FsStatus(0, 0, 0);
}
 
Example #10
Source File: DistributedFileSystem.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public FsStatus getStatus(Path p) throws IOException {
  statistics.incrementReadOps(1);
  return dfs.getDiskStatus();
}
 
Example #11
Source File: ViewFs.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public FsStatus getFsStatus() {
  return new FsStatus(0, 0, 0);
}
 
Example #12
Source File: HoodieWrapperFileSystem.java    From hudi with Apache License 2.0 4 votes vote down vote up
@Override
public FsStatus getStatus() throws IOException {
  return fileSystem.getStatus();
}
 
Example #13
Source File: HoodieWrapperFileSystem.java    From hudi with Apache License 2.0 4 votes vote down vote up
@Override
public FsStatus getStatus(Path p) throws IOException {
  return fileSystem.getStatus(convertToDefaultPath(p));
}
 
Example #14
Source File: CrailHDFS.java    From crail with Apache License 2.0 4 votes vote down vote up
@Override
public FsStatus getFsStatus() throws AccessControlException, FileNotFoundException, IOException {
	return new FsStatus(1000000000, 1000, 1000000000 - 1000);
}
 
Example #15
Source File: CrailHadoopFileSystem.java    From crail with Apache License 2.0 4 votes vote down vote up
@Override
public FsStatus getStatus(Path p) throws IOException {
	statistics.incrementReadOps(1);
	return new FsStatus(Long.MAX_VALUE, 0, Long.MAX_VALUE);
}
 
Example #16
Source File: IgniteHadoopFileSystem.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override public FsStatus getFsStatus() throws IOException {
    IgfsStatus status = rmtClient.fsStatus();

    return new FsStatus(status.spaceTotal(), status.spaceUsed(), status.spaceTotal() - status.spaceUsed());
}
 
Example #17
Source File: FileSystemDecorator.java    From incubator-gobblin with Apache License 2.0 4 votes vote down vote up
public FsStatus getStatus() throws java.io.IOException {
  return this.underlyingFs.getStatus();
}
 
Example #18
Source File: FileSystemDecorator.java    From incubator-gobblin with Apache License 2.0 4 votes vote down vote up
public FsStatus getStatus(Path p) throws java.io.IOException {
  return this.underlyingFs.getStatus(replaceScheme(p, this.replacementScheme, this.underlyingScheme));
}
 
Example #19
Source File: HadoopFileStore.java    From jsr203-hadoop with Apache License 2.0 4 votes vote down vote up
@Override
public long getUnallocatedSpace() throws IOException {
  FsStatus status = this.system.getHDFS().getStatus();
  return status.getCapacity() - status.getUsed();
}
 
Example #20
Source File: GoogleHadoopFS.java    From hadoop-connectors with Apache License 2.0 4 votes vote down vote up
@Override
public FsStatus getFsStatus() throws IOException {
  logger.atFinest().log("getStatus()");
  return ghfs.getStatus();
}
 
Example #21
Source File: ProxiedFilesystem.java    From spliceengine with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public FsStatus getStatus() throws IOException {
    return delegate.getStatus();
}
 
Example #22
Source File: ChRootedFs.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public FsStatus getFsStatus() throws IOException {
  return myFs.getFsStatus();
}
 
Example #23
Source File: ChRootedFileSystem.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public FsStatus getStatus(Path p) throws IOException {
  return super.getStatus(fullPath(p));
}
 
Example #24
Source File: DrillFileSystem.java    From Bats with Apache License 2.0 4 votes vote down vote up
@Override
public FsStatus getStatus() throws IOException {
  return underlyingFs.getStatus();
}
 
Example #25
Source File: DistributedFileSystem.java    From big-c with Apache License 2.0 4 votes vote down vote up
public DiskStatus(FsStatus stats) {
  super(stats.getCapacity(), stats.getUsed(), stats.getRemaining());
}
 
Example #26
Source File: DFSClient.java    From big-c with Apache License 2.0 4 votes vote down vote up
/**
 * @see ClientProtocol#getStats()
 */
public FsStatus getDiskStatus() throws IOException {
  long rawNums[] = callGetStats();
  return new FsStatus(rawNums[0], rawNums[1], rawNums[2]);
}
 
Example #27
Source File: ViewFs.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
public FsStatus getFsStatus() {
  return new FsStatus(0, 0, 0);
}
 
Example #28
Source File: ViewFs.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
public FsStatus getFsStatus() throws AccessControlException,
    FileNotFoundException, IOException {
  return new FsStatus(0, 0, 0);
}
 
Example #29
Source File: ChRootedFs.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
public FsStatus getFsStatus() throws IOException {
  return myFs.getFsStatus();
}
 
Example #30
Source File: ChRootedFileSystem.java    From hadoop with Apache License 2.0 4 votes vote down vote up
@Override
public FsStatus getStatus(Path p) throws IOException {
  return super.getStatus(fullPath(p));
}