/** * Dynamically remove volume in the list. * @param storageLocation {@link StorageLocation} of the volume to be removed. * @param clearFailure set true to remove failure info for this volume. */ void removeVolume(StorageLocation storageLocation, boolean clearFailure) { for (FsVolumeImpl fsVolume : volumes) { StorageLocation baseLocation = fsVolume.getStorageLocation(); if (baseLocation.equals(storageLocation)) { removeVolume(fsVolume); } } if (clearFailure) { removeVolumeFailureInfo(storageLocation); } }
/** * Updates the failed volume info in the volumeFailureInfos Map * and calls {@link #removeVolume(FsVolumeImpl)} to remove the volume * from the volume list for each of the failed volumes. * * @param failedVolumes set of volumes marked failed. */ void handleVolumeFailures(Set<FsVolumeSpi> failedVolumes) { try (AutoCloseableLock lock = checkDirsLock.acquire()) { for(FsVolumeSpi vol : failedVolumes) { FsVolumeImpl fsv = (FsVolumeImpl) vol; try (FsVolumeReference ref = fsv.obtainReference()) { addVolumeFailureInfo(fsv); removeVolume(fsv); } catch (ClosedChannelException e) { FsDatasetImpl.LOG.debug("Caught exception when obtaining " + "reference count on closed volume", e); } catch (IOException e) { FsDatasetImpl.LOG.error("Unexpected IOException", e); } } waitVolumeRemoved(5000, checkDirsLockCondition); } }
volumes.removeVolume(sdLocation, clearFailure); volumes.waitVolumeRemoved(5000, datasetLockCondition);
@Override public Object answer(InvocationOnMock invocationOnMock) throws Throwable { volumeList.removeVolume(new File("data4"), false); volumeList.addVolume(newRef); return null; } }).when(blockedVolume).checkDirs();
/** * Dynamically remove volume in the list. * @param volume the volume to be removed. * @param clearFailure set true to remove failure info for this volume. */ void removeVolume(File volume, boolean clearFailure) { // Make a copy of volumes to remove one volume. final FsVolumeImpl[] curVolumes = volumes.get(); final List<FsVolumeImpl> volumeList = Lists.newArrayList(curVolumes); for (Iterator<FsVolumeImpl> it = volumeList.iterator(); it.hasNext(); ) { FsVolumeImpl fsVolume = it.next(); String basePath, targetPath; basePath = new File(fsVolume.getBasePath()).getAbsolutePath(); targetPath = volume.getAbsolutePath(); if (basePath.equals(targetPath)) { // Make sure the removed volume is the one in the curVolumes. removeVolume(fsVolume); } } if (clearFailure) { removeVolumeFailureInfo(volume); } }
removeVolume(fsv); } catch (ClosedChannelException e) { FsDatasetImpl.LOG.debug("Caught exception when obtaining " +
/** * Dynamically remove volume in the list. * @param volume the volume to be removed. * @param clearFailure set true to remove failure info for this volume. */ void removeVolume(File volume, boolean clearFailure) { // Make a copy of volumes to remove one volume. final FsVolumeImpl[] curVolumes = volumes.get(); final List<FsVolumeImpl> volumeList = Lists.newArrayList(curVolumes); for (Iterator<FsVolumeImpl> it = volumeList.iterator(); it.hasNext(); ) { FsVolumeImpl fsVolume = it.next(); String basePath, targetPath; basePath = new File(fsVolume.getBasePath()).getAbsolutePath(); targetPath = volume.getAbsolutePath(); if (basePath.equals(targetPath)) { // Make sure the removed volume is the one in the curVolumes. removeVolume(fsVolume); } } if (clearFailure) { removeVolumeFailureInfo(volume); } }
volumes.removeVolume(absRoot, clearFailure);
removeVolume(fsv); } catch (ClosedChannelException e) { FsDatasetImpl.LOG.debug("Caught exception when obtaining " +
volumes.removeVolume(absRoot, clearFailure);