|
@@ -153,22 +153,22 @@ class FsDatasetImpl implements FsDatasetSpi<FsVolumeImpl> {
|
|
|
public StorageReport[] getStorageReports(String bpid)
|
|
|
throws IOException {
|
|
|
List<StorageReport> reports;
|
|
|
- synchronized (statsLock) {
|
|
|
- List<FsVolumeImpl> curVolumes = volumes.getVolumes();
|
|
|
- reports = new ArrayList<>(curVolumes.size());
|
|
|
- for (FsVolumeImpl volume : curVolumes) {
|
|
|
- try (FsVolumeReference ref = volume.obtainReference()) {
|
|
|
- StorageReport sr = new StorageReport(volume.toDatanodeStorage(),
|
|
|
- false,
|
|
|
- volume.getCapacity(),
|
|
|
- volume.getDfsUsed(),
|
|
|
- volume.getAvailable(),
|
|
|
- volume.getBlockPoolUsed(bpid),
|
|
|
- volume.getNonDfsUsed());
|
|
|
- reports.add(sr);
|
|
|
- } catch (ClosedChannelException e) {
|
|
|
- continue;
|
|
|
- }
|
|
|
+ // Volumes are the references from a copy-on-write snapshot, so the
|
|
|
+ // access on the volume metrics doesn't require an additional lock.
|
|
|
+ List<FsVolumeImpl> curVolumes = volumes.getVolumes();
|
|
|
+ reports = new ArrayList<>(curVolumes.size());
|
|
|
+ for (FsVolumeImpl volume : curVolumes) {
|
|
|
+ try (FsVolumeReference ref = volume.obtainReference()) {
|
|
|
+ StorageReport sr = new StorageReport(volume.toDatanodeStorage(),
|
|
|
+ false,
|
|
|
+ volume.getCapacity(),
|
|
|
+ volume.getDfsUsed(),
|
|
|
+ volume.getAvailable(),
|
|
|
+ volume.getBlockPoolUsed(bpid),
|
|
|
+ volume.getNonDfsUsed());
|
|
|
+ reports.add(sr);
|
|
|
+ } catch (ClosedChannelException e) {
|
|
|
+ continue;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -247,9 +247,6 @@ class FsDatasetImpl implements FsDatasetSpi<FsVolumeImpl> {
|
|
|
|
|
|
private final int smallBufferSize;
|
|
|
|
|
|
- // Used for synchronizing access to usage stats
|
|
|
- private final Object statsLock = new Object();
|
|
|
-
|
|
|
final LocalFileSystem localFS;
|
|
|
|
|
|
private boolean blockPinningEnabled;
|
|
@@ -583,9 +580,7 @@ class FsDatasetImpl implements FsDatasetSpi<FsVolumeImpl> {
|
|
|
*/
|
|
|
@Override // FSDatasetMBean
|
|
|
public long getDfsUsed() throws IOException {
|
|
|
- synchronized(statsLock) {
|
|
|
- return volumes.getDfsUsed();
|
|
|
- }
|
|
|
+ return volumes.getDfsUsed();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -593,9 +588,7 @@ class FsDatasetImpl implements FsDatasetSpi<FsVolumeImpl> {
|
|
|
*/
|
|
|
@Override // FSDatasetMBean
|
|
|
public long getBlockPoolUsed(String bpid) throws IOException {
|
|
|
- synchronized(statsLock) {
|
|
|
- return volumes.getBlockPoolUsed(bpid);
|
|
|
- }
|
|
|
+ return volumes.getBlockPoolUsed(bpid);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -611,9 +604,7 @@ class FsDatasetImpl implements FsDatasetSpi<FsVolumeImpl> {
|
|
|
*/
|
|
|
@Override // FSDatasetMBean
|
|
|
public long getCapacity() throws IOException {
|
|
|
- synchronized(statsLock) {
|
|
|
- return volumes.getCapacity();
|
|
|
- }
|
|
|
+ return volumes.getCapacity();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -621,9 +612,7 @@ class FsDatasetImpl implements FsDatasetSpi<FsVolumeImpl> {
|
|
|
*/
|
|
|
@Override // FSDatasetMBean
|
|
|
public long getRemaining() throws IOException {
|
|
|
- synchronized(statsLock) {
|
|
|
- return volumes.getRemaining();
|
|
|
- }
|
|
|
+ return volumes.getRemaining();
|
|
|
}
|
|
|
|
|
|
/**
|