FsVolumeReference (Apache Hadoop HDFS 3.5.0 API)
Description: declaration: package: org.apache.hadoop.hdfs.server.datanode.fsdataset, interface: FsVolumeReference

Package org.apache.hadoop.hdfs.server.datanode.fsdataset

# Interface FsVolumeReference

All Superinterfaces:
  `AutoCloseable`, `Closeable`

public interface FsVolumeReference extends Closeable
This holds volume reference count as AutoClosable resource. It increases the reference count by one in the constructor, and decreases the reference count by one in `close()`.

        try (FsVolumeReference ref = volume.obtainReference()) {
          // Do IOs on the volume
          volume.createRwb(...);
          ...
        }

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `close()`
  Decrease the reference count of the volume.
  `FsVolumeSpi`
  `getVolume()`
  Returns the underlying volume object.

- ## Method Details

  - ### close

    void close() throws IOException
    Decrease the reference count of the volume.
    Specified by:
      `close` in interface `AutoCloseable`
    Specified by:
      `close` in interface `Closeable`
    Throws:
      `IOException` - it never throws IOException.

  - ### getVolume

    FsVolumeSpi getVolume()
    Returns the underlying volume object. Return null if the reference was released.