long getCapacity() { long capacity = 0L; for (FsVolumeImpl v : volumes) { try (FsVolumeReference ref = v.obtainReference()) { capacity += v.getCapacity(); } catch (IOException e) { // ignore. } } return capacity; }
private void addVolumeFailureInfo(FsVolumeImpl vol) { addVolumeFailureInfo(new VolumeFailureInfo( vol.getStorageLocation(), Time.now(), vol.getCapacity())); }
@Override // FsDatasetSpi public StorageReport[] getStorageReports(String bpid) throws IOException { List<StorageReport> reports; // 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; } } return reports.toArray(new StorageReport[reports.size()]); }
@Override public long getAvailable() throws IOException { long remaining = getCapacity() - getDfsUsed() - getReservedForReplicas(); long available = usage.getAvailable() - getRemainingReserved() - getReservedForReplicas(); if (remaining > available) { remaining = available; } return (remaining > 0) ? remaining : 0; }
long getCapacity() { long capacity = 0L; for (FsVolumeImpl v : volumes.get()) { try (FsVolumeReference ref = v.obtainReference()) { capacity += v.getCapacity(); } catch (IOException e) { // ignore. } } return capacity; }
long getCapacity() { long capacity = 0L; for (FsVolumeImpl v : volumes.get()) { try (FsVolumeReference ref = v.obtainReference()) { capacity += v.getCapacity(); } catch (IOException e) { // ignore. } } return capacity; }
private void addVolumeFailureInfo(FsVolumeImpl vol) { addVolumeFailureInfo(new VolumeFailureInfo( new File(vol.getBasePath()).getAbsolutePath(), Time.now(), vol.getCapacity())); }
private void addVolumeFailureInfo(FsVolumeImpl vol) { addVolumeFailureInfo(new VolumeFailureInfo( new File(vol.getBasePath()).getAbsolutePath(), Time.now(), vol.getCapacity())); }
@Override // FsDatasetSpi public StorageReport[] getStorageReports(String bpid) throws IOException { List<StorageReport> reports; synchronized (statsLock) { List<FsVolumeImpl> curVolumes = 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; } } } return reports.toArray(new StorageReport[reports.size()]); }
@Override // FsDatasetSpi public StorageReport[] getStorageReports(String bpid) throws IOException { List<StorageReport> reports; synchronized (statsLock) { List<FsVolumeImpl> curVolumes = 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; } } } return reports.toArray(new StorageReport[reports.size()]); }
@Override public long getAvailable() throws IOException { long remaining = getCapacity() - getDfsUsed() - getReservedForRbw(); long available = usage.getAvailable() - getRemainingReserved() - getReservedForRbw(); if (remaining > available) { remaining = available; } return (remaining > 0) ? remaining : 0; }
@Override public long getAvailable() throws IOException { long remaining = getCapacity() - getDfsUsed() - getReservedForRbw(); long available = usage.getAvailable() - getRemainingReserved() - getReservedForRbw(); if (remaining > available) { remaining = available; } return (remaining > 0) ? remaining : 0; }
private boolean transientFreeSpaceBelowThreshold() throws IOException { long free = 0; long capacity = 0; float percentFree = 0.0f; // Don't worry about fragmentation for now. We don't expect more than one // transient volume per DN. for (FsVolumeImpl v : getVolumes()) { try (FsVolumeReference ref = v.obtainReference()) { if (v.isTransientStorage()) { capacity += v.getCapacity(); free += v.getAvailable(); } } catch (ClosedChannelException e) { // ignore. } } if (capacity == 0) { return false; } percentFree = (float) ((double)free * 100 / capacity); return (percentFree < lowWatermarkFreeSpacePercentage) || (free < lowWatermarkFreeSpaceBytes); }
private boolean transientFreeSpaceBelowThreshold() throws IOException { long free = 0; long capacity = 0; float percentFree = 0.0f; // Don't worry about fragmentation for now. We don't expect more than one // transient volume per DN. for (FsVolumeImpl v : getVolumes()) { try (FsVolumeReference ref = v.obtainReference()) { if (v.isTransientStorage()) { capacity += v.getCapacity(); free += v.getAvailable(); } } catch (ClosedChannelException e) { // ignore. } } if (capacity == 0) { return false; } percentFree = (float) ((double)free * 100 / capacity); return (percentFree < lowWatermarkFreeSpacePercentage) || (free < lowWatermarkFreeSpaceBytes); }
/** * Test metrics associated with volume failures. */ @Test public void testVolumeFailures() throws Exception { assertGauge("VolumeFailuresTotal", 0, getMetrics(NS_METRICS)); assertGauge("EstimatedCapacityLostTotal", 0L, getMetrics(NS_METRICS)); DataNode dn = cluster.getDataNodes().get(0); FsVolumeSpi fsVolume = DataNodeTestUtils.getFSDataset(dn).getVolumes().get(0); File dataDir = new File(fsVolume.getBasePath()); long capacity = ((FsVolumeImpl) fsVolume).getCapacity(); DataNodeTestUtils.injectDataDirFailure(dataDir); long lastDiskErrorCheck = dn.getLastDiskErrorCheck(); dn.checkDiskErrorAsync(); while (dn.getLastDiskErrorCheck() == lastDiskErrorCheck) { Thread.sleep(100); } DataNodeTestUtils.triggerHeartbeat(dn); BlockManagerTestUtil.checkHeartbeat(bm); assertGauge("VolumeFailuresTotal", 1, getMetrics(NS_METRICS)); assertGauge("EstimatedCapacityLostTotal", capacity, getMetrics(NS_METRICS)); }
final FsVolumeImpl v = (FsVolumeImpl)dataSet.volumeMap.get( bpid, blocks[FINALIZED].getLocalBlock()).getVolume(); long available = v.getCapacity()-v.getDfsUsed(); long expectedLen = blocks[FINALIZED].getNumBytes(); try {