/** * Write all data storage files. * @throws IOException */ public void writeAll() throws IOException { this.layoutVersion = FSConstants.LAYOUT_VERSION; for (Iterator<StorageDirectory> it = storageDirs.iterator(); it.hasNext();) { it.next().write(); } }
/** * Write all data storage files. * @throws IOException */ public void writeAll() throws IOException { this.layoutVersion = FSConstants.LAYOUT_VERSION; for (Iterator<StorageDirectory> it = storageDirs.iterator(); it.hasNext();) { it.next().write(); } }
/** * Format a namespace slice storage. * @param sd the namespace storage * @param nsInfo the name space info * @throws IOException Signals that an I/O exception has occurred. */ private void format(StorageDirectory nsSdir, NamespaceInfo nsInfo) throws IOException { LOG.info("Formatting namespace " + namespaceID + " directory " + nsSdir.getCurrentDir()); nsSdir.clearDirectory(); // create directory File rbwDir = new File(nsSdir.getCurrentDir(), STORAGE_DIR_RBW); File finalizedDir = new File(nsSdir.getCurrentDir(), STORAGE_DIR_FINALIZED); LOG.info("Creating Directories : " + rbwDir + ", " + finalizedDir); if (!rbwDir.mkdirs() || !finalizedDir.mkdirs()) { throw new IOException("Cannot create directories : " + rbwDir + ", " + finalizedDir); } this.layoutVersion = FSConstants.LAYOUT_VERSION; this.cTime = nsInfo.getCTime(); this.namespaceID = nsInfo.getNamespaceID(); this.storageType = NodeType.DATA_NODE; nsSdir.write(); }
try { sd.write();
sd.write(); } catch (IOException e) { LOG.error("Cannot write file " + sd.getRoot(), e);
sd.write(); } catch (IOException e) { LOG.error("Cannot write file " + sd.getRoot(), e);
editLog.createEditLogFile(getImageFile(sd, NameNodeFile.EDITS)); sd.write();
this.cTime = nsInfo.getCTime(); for (StorageDirectory sd :sds) { sd.write(); File prevDir = sd.getPreviousDir(); File tmpDir = sd.getPreviousTmp();
this.cTime = nsInfo.getCTime(); for (StorageDirectory sd :sds) { sd.write(); File prevDir = sd.getPreviousDir(); File tmpDir = sd.getPreviousTmp();
"Data-node and name-node layout versions must be the same."; this.cTime = nsInfo.getCTime(); sd.write();
sd.write(versionFile); versionFiles[i] = versionFile;
synchronized Collection<StorageDirectory> recoverTransitionAdditionalRead(NamespaceInfo nsInfo, Collection<File> dataDirs, StartupOption startOpt ) throws IOException{ assert FSConstants.LAYOUT_VERSION == nsInfo.getLayoutVersion() : "Data-node and name-node layout versions must be the same."; // 1. For each data directory calculate its state and // check whether all is consistent before transitioning. // Format and recover. ArrayList<StorageDirectory> newDirs = analyzeStorageDirs(nsInfo, dataDirs, startOpt); // 2. Do transitions // Each storage directory is treated individually. // During startup some of them can upgrade or rollback // while others could be uptodate for the regular startup. doTransition(newDirs, nsInfo, startOpt); assert this.getLayoutVersion() == nsInfo.getLayoutVersion() : "Data-node and name-node layout versions must be the same."; assert this.getCTime() == nsInfo.getCTime() : "Data-node and name-node CTimes must be the same."; // 3. Update all storages. Some of them might have just been formatted. if (this.layoutVersion == 0) { layoutVersion = FSConstants.LAYOUT_VERSION; } for (StorageDirectory sd : newDirs) { sd.write(); } return newDirs; }
/** * Save current image and empty journal into {@code current} directory. */ protected void saveCurrent(SaveNamespaceContext ctx, StorageDirectory sd, boolean forceUncompressed) throws IOException { File curDir = sd.getCurrentDir(); LOG.info("Saving image to: " + sd.getRoot().getAbsolutePath()); NameNodeDirType dirType = (NameNodeDirType) sd.getStorageDirType(); // save new image or new edits if (!curDir.exists() && !curDir.mkdir()) throw new IOException("Cannot create directory " + curDir); if (dirType.isOfType(NameNodeDirType.IMAGE)) { FSImageFormat.Saver saver = new FSImageFormat.Saver(ctx); FSImageCompression compression = FSImageCompression.createCompression(namesystem.getConf(), forceUncompressed); saver.save(getImageFile(sd, NameNodeFile.IMAGE), compression); this.setImageDigest(saver.getSavedDigest()); } if (dirType.isOfType(NameNodeDirType.EDITS)) editLog.createEditLogFile(getImageFile(sd, NameNodeFile.EDITS)); // write version and time files sd.write(); }
/** Create new dfs name directory. Caution: this destroys all files * in this filesystem. */ void format(StorageDirectory sd) throws IOException { sd.clearDirectory(); // create currrent dir sd.lock(); try { NameNodeDirType dirType = (NameNodeDirType)sd.getStorageDirType(); if (dirType.isOfType(NameNodeDirType.IMAGE)) saveFSImage(getImageFile(sd, NameNodeFile.IMAGE)); if (dirType.isOfType(NameNodeDirType.EDITS)) editLog.createEditLogFile(getImageFile(sd, NameNodeFile.EDITS)); sd.write(); } finally { sd.unlock(); } LOG.info("Storage directory " + sd.getRoot() + " has been successfully formatted."); }
/** * Write version file. * * @throws IOException */ public void write() throws IOException { corruptPreUpgradeStorage(root); write(getVersionFile()); }
/** * Write version file. * * @throws IOException */ public void write() throws IOException { corruptPreUpgradeStorage(root); write(getVersionFile()); }
void format(StorageDirectory sd, NamespaceInfo nsInfo) throws IOException { sd.clearDirectory(); // create directory this.layoutVersion = FSConstants.LAYOUT_VERSION; this.namespaceID = nsInfo.getNamespaceID(); // mother namespaceid this.cTime = 0; // store storageID as it currently is sd.write(); }
void format(StorageDirectory sd, NamespaceInfo nsInfo) throws IOException { sd.clearDirectory(); // create directory this.layoutVersion = FSConstants.LAYOUT_VERSION; this.namespaceID = nsInfo.getNamespaceID(); this.cTime = 0; // store storageID as it currently is sd.write(); }