public FileRef(String metaReference, Path fullReference) { this.metaReference = metaReference; this.fullReference = fullReference; this.suffix = extractSuffix(fullReference); }
@Override public boolean equals(Object obj) { if (obj instanceof FileRef) { return compareTo((FileRef) obj) == 0; } return false; }
@Override public WeightedRandomCollection load(List<String> key) { return new WeightedRandomCollection(key, env, random); } });
public static void finishReplacement(AccumuloConfiguration acuTableConf, VolumeManager fs, Path location, Set<FileRef> oldDatafiles, String compactName) throws IOException { // start deleting files, if we do not finish they will be cleaned // up later for (FileRef ref : oldDatafiles) { Path path = ref.path(); Path deleteFile = new Path(location + "/delete+" + compactName + "+" + path.getName()); if (acuTableConf.getBoolean(Property.GC_TRASH_IGNORE) || !fs.moveToTrash(deleteFile)) fs.deleteRecursively(deleteFile); } }
/** * Given options for tables (across multiple volumes), construct an absolute path using the unique * name within the chosen volume * * @return An absolute, unique path for the imported table */ protected String getClonedTabletDir(Master master, String[] tableDirs, String tabletDir) { // We can try to spread out the tablet dirs across all volumes VolumeChooserEnvironment chooserEnv = new VolumeChooserEnvironment(tableInfo.tableId, master.getContext()); String tableDir = master.getFileSystem().choose(chooserEnv, tableDirs); // Build up a full hdfs://localhost:8020/accumulo/tables/$id/c-XXXXXXX return tableDir + "/" + tableInfo.tableId + "/" + tabletDir; }
protected boolean doesFileExist(Path filePath, ReplicationTarget target) throws IOException { if (!fs.exists(filePath)) { log.warn("Received work request for {} and {}, but the file doesn't exist", filePath, target); return false; } return true; }
String[] getPreferredVolumes(VolumeChooserEnvironment env, String[] options) { switch (env.getScope()) { case INIT: // TODO should be possible to read from SiteConfiguration during init log.warn("Not possible to determine preferred volumes at '{}' scope. Using all volumes.", ChooserScope.INIT); return options; case TABLE: return getPreferredVolumesForTable(env, loadConfFactory(env), options); default: return getPreferredVolumesForScope(env, loadConfFactory(env), options); } }
VolumeChooser getDelegateChooser(VolumeChooserEnvironment env) { switch (env.getScope()) { case INIT: // TODO should be possible to read from SiteConfiguration during init log.warn("Not possible to determine delegate chooser at '{}' scope. Using {}.", ChooserScope.INIT, RandomVolumeChooser.class.getName()); return randomChooser; case TABLE: return getVolumeChooserForTable(env, loadConfFactory(env)); default: return getVolumeChooserForScope(env, loadConfFactory(env)); } }
@Override public String choose(VolumeChooserEnvironment env, String[] options) throws VolumeChooserException { options = getPreferredVolumes(env, options); try { return getCache(env).get(Arrays.asList(options)).next(); } catch (ExecutionException e) { throw new IllegalStateException("Execution exception when attempting to cache choice", e); } }
static void rename(VolumeManager fs, Path src, Path dst) throws IOException { if (!fs.rename(src, dst)) { throw new IOException("Rename " + src + " to " + dst + " returned false "); } }
String getOutputFile() { return outputFile.toString(); }
@Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj == null || !(obj instanceof VolumeChooserEnvironment)) { return false; } VolumeChooserEnvironment other = (VolumeChooserEnvironment) obj; return getScope() == other.getScope() && Objects.equals(getTableId(), other.getTableId()); }
@Override public String choose(VolumeChooserEnvironment env, String[] options) { final String choice; choice = chooser.choose(env, options); if (!(ArrayUtils.contains(options, choice))) { String msg = "The configured volume chooser, '" + chooser.getClass() + "', or one of its delegates returned a volume not in the set of options provided"; throw new VolumeChooserException(msg); } return choice; }
@Override public String choose(VolumeChooserEnvironment env, String[] options) throws VolumeChooserException { log.trace("{}.choose", getClass().getSimpleName()); return getDelegateChooser(env).choose(env, options); }
@Override public String choose(VolumeChooserEnvironment env, String[] options) throws VolumeChooserException { log.trace("{}.choose", getClass().getSimpleName()); // Randomly choose the volume from the preferred volumes String choice = super.choose(env, getPreferredVolumes(env, options)); log.trace("Choice = {}", choice); return choice; }
private static String getTableURI(String rootTabletDir) { Path ret = FileType.TABLE.getVolume(new Path(rootTabletDir)); if (ret == null) return "RELATIVE"; return ret.toString(); }
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; }
void unreserveMergingMinorCompactionFile(FileRef file) { if ((file == null && mergingMinorCompactionFile != null) || (file != null && mergingMinorCompactionFile == null) || (file != null && mergingMinorCompactionFile != null && !file.equals(mergingMinorCompactionFile))) throw new IllegalStateException("Disagreement " + file + " " + mergingMinorCompactionFile); mergingMinorCompactionFile = null; }
private static String getLogURI(String logEntry) { Path ret = FileType.WAL.getVolume(new Path(logEntry)); if (ret == null) return "RELATIVE"; return ret.toString(); }
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; } }