ServerConfigurationFactory loadConfFactory(VolumeChooserEnvironment env) { // This local variable is an intentional component of the single-check idiom. ServerConfigurationFactory localConf = lazyConfFactory; if (localConf == null) { // If we're under contention when first getting here we'll throw away some initializations. localConf = env.getServerContext().getServerConfFactory(); lazyConfFactory = localConf; } return localConf; }
ServerConfigurationFactory loadConfFactory(VolumeChooserEnvironment env) { // Get the current table's properties, and find the preferred volumes property // This local variable is an intentional component of the single-check idiom. ServerConfigurationFactory localConf = lazyConfFactory; if (localConf == null) { // If we're under contention when first getting here we'll throw away some initializations. localConf = env.getServerContext().getServerConfFactory(); lazyConfFactory = localConf; } return localConf; } }
public WeightedRandomCollection(List<String> options, VolumeChooserEnvironment env, Random random) { this.random = random; if (options.size() < 1) { throw new IllegalStateException("Options was empty! No valid volumes to choose from."); } VolumeManager manager = env.getServerContext().getVolumeManager(); // Compute percentage space available on each volume for (String option : options) { FileSystem pathFs = manager.getVolumeByPath(new Path(option)).getFileSystem(); try { FsStatus optionStatus = pathFs.getStatus(); double percentFree = ((double) optionStatus.getRemaining() / optionStatus.getCapacity()); add(percentFree, option); } catch (IOException e) { log.error("Unable to get file system status for" + option, e); } } if (map.size() < 1) { throw new IllegalStateException( "Weighted options was empty! Could indicate an issue getting file system status or " + "no free space on any volume"); } }