@Override public void run() { try { saveFSImage(context, sd, nnf); } catch (SaveNamespaceCancelledException snce) { LOG.info("Cancelled image saving for " + sd.getRoot() + ": " + snce.getMessage()); // don't report an error on the storage dir! } catch (Throwable t) { LOG.error("Unable to save image for " + sd.getRoot(), t); context.reportErrorOnStorageDirectory(sd); } }
@Override public void run() { try { saveFSImage(context, sd, nnf); } catch (SaveNamespaceCancelledException snce) { LOG.info("Cancelled image saving for " + sd.getRoot() + ": " + snce.getMessage()); // don't report an error on the storage dir! } catch (Throwable t) { LOG.error("Unable to save image for " + sd.getRoot(), t); context.reportErrorOnStorageDirectory(sd); } }
@Override public void run() { try { saveFSImage(context, sd, nnf); } catch (SaveNamespaceCancelledException snce) { LOG.info("Cancelled image saving for " + sd.getRoot() + ": " + snce.getMessage()); // don't report an error on the storage dir! } catch (Throwable t) { LOG.error("Unable to save image for " + sd.getRoot(), t); context.reportErrorOnStorageDirectory(sd); } }
/** * Save the contents of the FS image * and create empty edits. */ public void saveFSImage() throws IOException { editLog.createNewIfMissing(); for (Iterator<StorageDirectory> it = dirIterator(); it.hasNext();) { StorageDirectory sd = it.next(); NameNodeDirType dirType = (NameNodeDirType)sd.getStorageDirType(); if (dirType.isOfType(NameNodeDirType.IMAGE)) saveFSImage(getImageFile(sd, NameNodeFile.IMAGE_NEW)); if (dirType.isOfType(NameNodeDirType.EDITS)) { editLog.createEditLogFile(getImageFile(sd, NameNodeFile.EDITS)); File editsNew = getImageFile(sd, NameNodeFile.EDITS_NEW); if (editsNew.exists()) editLog.createEditLogFile(editsNew); } } ckptState = CheckpointStates.UPLOAD_DONE; rollFSImage(); }
when(spyImage).saveFSImage((File)anyObject()); break; case MOVE_CURRENT:
void loadFSImage(Collection<File> dataDirs, Collection<File> editsDirs, StartupOption startOpt) throws IOException { // format before starting up if requested if (startOpt == StartupOption.FORMAT) { fsImage.setStorageDirectories(dataDirs, editsDirs); fsImage.format(); startOpt = StartupOption.REGULAR; } try { if (fsImage.recoverTransitionRead(dataDirs, editsDirs, startOpt)) { fsImage.saveFSImage(); } FSEditLog editLog = fsImage.getEditLog(); assert editLog != null : "editLog must be initialized"; if (!editLog.isOpen()) editLog.open(); fsImage.setCheckpointDirectories(null, null); } catch(IOException e) { fsImage.close(); throw e; } synchronized (this) { this.ready = true; this.notifyAll(); } }
/** * Load image from a checkpoint directory and save it into the current one. * @throws IOException */ void doImportCheckpoint() throws IOException { FSImage ckptImage = new FSImage(); FSNamesystem fsNamesys = FSNamesystem.getFSNamesystem(); // replace real image with the checkpoint image FSImage realImage = fsNamesys.getFSImage(); assert realImage == this; fsNamesys.dir.fsImage = ckptImage; // load from the checkpoint dirs try { ckptImage.recoverTransitionRead(checkpointDirs, checkpointEditsDirs, StartupOption.REGULAR); } finally { ckptImage.close(); } // return back the real image realImage.setStorageInfo(ckptImage); fsNamesys.dir.fsImage = realImage; // and save it saveFSImage(); }
saveFSImage(getImageFile(sd, NameNodeFile.IMAGE)); editLog.createEditLogFile(getImageFile(sd, NameNodeFile.EDITS));
/** 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."); }
when(spyImage).saveFSImage((File)anyObject());
when(spyImage).saveFSImage( (SaveNamespaceContext)anyObject(), (StorageDirectory)anyObject(), (NameNodeFile) anyObject()); when(spyImage).saveFSImage( (SaveNamespaceContext)anyObject(), (StorageDirectory)anyObject(), (NameNodeFile) anyObject()); when(spyImage).saveFSImage( (SaveNamespaceContext)anyObject(), (StorageDirectory)anyObject(), (NameNodeFile) anyObject());
when(spyImage).saveFSImage( (SaveNamespaceContext)anyObject(), (StorageDirectory)anyObject(), (NameNodeFile) anyObject());