|
@@ -159,22 +159,18 @@ class FsDatasetImpl implements FsDatasetSpi<FsVolumeImpl> {
|
|
public StorageReport[] getStorageReports(String bpid)
|
|
public StorageReport[] getStorageReports(String bpid)
|
|
throws IOException {
|
|
throws IOException {
|
|
List<StorageReport> reports;
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -292,9 +288,6 @@ class FsDatasetImpl implements FsDatasetSpi<FsVolumeImpl> {
|
|
|
|
|
|
private final int smallBufferSize;
|
|
private final int smallBufferSize;
|
|
|
|
|
|
- // Used for synchronizing access to usage stats
|
|
|
|
- private final Object statsLock = new Object();
|
|
|
|
-
|
|
|
|
final LocalFileSystem localFS;
|
|
final LocalFileSystem localFS;
|
|
|
|
|
|
private boolean blockPinningEnabled;
|
|
private boolean blockPinningEnabled;
|
|
@@ -643,9 +636,7 @@ class FsDatasetImpl implements FsDatasetSpi<FsVolumeImpl> {
|
|
*/
|
|
*/
|
|
@Override // FSDatasetMBean
|
|
@Override // FSDatasetMBean
|
|
public long getDfsUsed() throws IOException {
|
|
public long getDfsUsed() throws IOException {
|
|
- synchronized(statsLock) {
|
|
|
|
- return volumes.getDfsUsed();
|
|
|
|
- }
|
|
|
|
|
|
+ return volumes.getDfsUsed();
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -653,9 +644,7 @@ class FsDatasetImpl implements FsDatasetSpi<FsVolumeImpl> {
|
|
*/
|
|
*/
|
|
@Override // FSDatasetMBean
|
|
@Override // FSDatasetMBean
|
|
public long getBlockPoolUsed(String bpid) throws IOException {
|
|
public long getBlockPoolUsed(String bpid) throws IOException {
|
|
- synchronized(statsLock) {
|
|
|
|
- return volumes.getBlockPoolUsed(bpid);
|
|
|
|
- }
|
|
|
|
|
|
+ return volumes.getBlockPoolUsed(bpid);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -677,9 +666,7 @@ class FsDatasetImpl implements FsDatasetSpi<FsVolumeImpl> {
|
|
*/
|
|
*/
|
|
@Override // FSDatasetMBean
|
|
@Override // FSDatasetMBean
|
|
public long getCapacity() {
|
|
public long getCapacity() {
|
|
- synchronized(statsLock) {
|
|
|
|
- return volumes.getCapacity();
|
|
|
|
- }
|
|
|
|
|
|
+ return volumes.getCapacity();
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -687,9 +674,7 @@ class FsDatasetImpl implements FsDatasetSpi<FsVolumeImpl> {
|
|
*/
|
|
*/
|
|
@Override // FSDatasetMBean
|
|
@Override // FSDatasetMBean
|
|
public long getRemaining() throws IOException {
|
|
public long getRemaining() throws IOException {
|
|
- synchronized(statsLock) {
|
|
|
|
- return volumes.getRemaining();
|
|
|
|
- }
|
|
|
|
|
|
+ return volumes.getRemaining();
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|