boolean namespaceIdMatches(FSImage si) { return namespaceID == si.getStorage().namespaceID; }
/** * Get the creation time of the file system. * Notice that this time is initialized to NameNode format time, and updated * to upgrade time during upgrades. * @return time in milliseconds. * See {@link org.apache.hadoop.util.Time#now()}. */ @VisibleForTesting long getCTime() { return fsImage == null ? 0 : fsImage.getStorage().getCTime(); }
void validateStorageInfo(FSImage si) throws IOException { if (!isSameCluster(si) || !storageVersionMatches(si.getStorage())) { throw new IOException("Inconsistent checkpoint fields.\n" + "LV = " + layoutVersion + " namespaceID = " + namespaceID + " cTime = " + cTime + " ; clusterId = " + clusterID + " ; blockpoolId = " + blockpoolID + ".\nExpecting respectively: " + si.getStorage().layoutVersion + "; " + si.getStorage().namespaceID + "; " + si.getStorage().cTime + "; " + si.getClusterID() + "; " + si.getBlockPoolID() + "."); } }
boolean isSameCluster(FSImage si) { return namespaceID == si.getStorage().namespaceID && clusterID.equals(si.getClusterID()) && blockpoolID.equals(si.getBlockPoolID()); }
/** * Get registrationID for datanodes based on the namespaceID. * * @see #registerDatanode(DatanodeRegistration) * @return registration ID */ String getRegistrationID() { return Storage.getRegistrationID(getFSImage().getStorage()); }
CheckpointSignature(FSImage fsImage) { super(fsImage.getStorage()); blockpoolID = fsImage.getBlockPoolID(); mostRecentCheckpointTxId = fsImage.getStorage().getMostRecentCheckpointTxId(); curSegmentTxId = fsImage.getEditLog().getCurSegmentTxId(); }
private int getLayoutVersion() { return namesystem.getFSImage().getStorage().getLayoutVersion(); }
boolean shouldCheckpointAtStartup() { FSImage fsImage = getFSImage(); if(isRole(NamenodeRole.CHECKPOINT)) { assert fsImage.getStorage().getNumStorageDirs() > 0; return ! fsImage.getStorage().getStorageDir(0).getVersionFile().exists(); } // BN always checkpoints on startup in order to get in sync with namespace return true; }
@Override // NameNodeMXBean public String getClusterId() { return getFSImage().getStorage().getClusterID(); }
@Override // NameNodeStatusMXBean public String getNameDirSize() { return getFSImage().getStorage().getNNDirectorySize(); }
@Metric({"LastCheckpointTime", "Time in milliseconds since the epoch of the last checkpoint"}) public long getLastCheckpointTime() { return getFSImage().getStorage().getMostRecentCheckpointTime(); }
@Override // NameNodeMXBean public String getNameDirStatuses() { Map<String, Map<File, StorageDirType>> statusMap = new HashMap<String, Map<File, StorageDirType>>(); Map<File, StorageDirType> activeDirs = new HashMap<File, StorageDirType>(); for (Iterator<StorageDirectory> it = getFSImage().getStorage().dirIterator(); it.hasNext();) { StorageDirectory st = it.next(); activeDirs.put(st.getRoot(), st.getStorageDirType()); } statusMap.put("active", activeDirs); List<Storage.StorageDirectory> removedStorageDirs = getFSImage().getStorage().getRemovedStorageDirs(); Map<File, StorageDirType> failedDirs = new HashMap<File, StorageDirType>(); for (StorageDirectory st : removedStorageDirs) { failedDirs.put(st.getRoot(), st.getStorageDirType()); } statusMap.put("failed", failedDirs); return JSON.toString(statusMap); }
private long countUncheckpointedTxns() { FSImage img = namesystem.getFSImage(); return img.getCorrectLastAppliedOrWrittenTxId() - img.getStorage().getMostRecentCheckpointTxId(); }
/** * Version of @see #getNamespaceInfo() that is not protected by a lock. */ NamespaceInfo unprotectedGetNamespaceInfo() { return new NamespaceInfo(getFSImage().getStorage().getNamespaceID(), getClusterId(), getBlockPoolId(), getFSImage().getStorage().getCTime(), getState()); }
/** * Returns the layout version in effect. Under normal operation, this is the * same as the software's current layout version, defined in * {@link NameNodeLayoutVersion#CURRENT_LAYOUT_VERSION}. During a rolling * upgrade, this can retain the layout version that was persisted to metadata * prior to starting the rolling upgrade, back to a lower bound defined in * {@link NameNodeLayoutVersion#MINIMUM_COMPATIBLE_LAYOUT_VERSION}. New * fsimage files and edit log segments will continue to be written with this * older layout version, so that the files are still readable by the old * software version if the admin chooses to downgrade. * * @return layout version in effect */ public int getEffectiveLayoutVersion() { return getEffectiveLayoutVersion(isRollingUpgrade(), fsImage.getStorage().getLayoutVersion(), NameNodeLayoutVersion.MINIMUM_COMPATIBLE_LAYOUT_VERSION, NameNodeLayoutVersion.CURRENT_LAYOUT_VERSION); }
@Override public TransferFsImage.TransferResult call() throws IOException, InterruptedException { CheckpointFaultInjector.getInstance().duringUploadInProgess(); return TransferFsImage.uploadImageFromStorage(activeNNAddress, conf, namesystem .getFSImage().getStorage(), imageType, txid, canceler); } });
@Metric({"TransactionsSinceLastCheckpoint", "Number of transactions since last checkpoint"}) public long getTransactionsSinceLastCheckpoint() { return getFSImage().getLastAppliedOrWrittenTxId() - getFSImage().getStorage().getMostRecentCheckpointTxId(); }
static void rollForwardByApplyingLogs( RemoteEditLogManifest manifest, FSImage dstImage, FSNamesystem dstNamesystem) throws IOException { NNStorage dstStorage = dstImage.getStorage(); List<EditLogInputStream> editsStreams = Lists.newArrayList(); for (RemoteEditLog log : manifest.getLogs()) { if (log.getEndTxId() > dstImage.getLastAppliedTxId()) { File f = dstStorage.findFinalizedEditsFile( log.getStartTxId(), log.getEndTxId()); editsStreams.add(new EditLogFileInputStream(f, log.getStartTxId(), log.getEndTxId(), true)); } } LOG.info("Checkpointer about to load edits from " + editsStreams.size() + " stream(s)."); dstImage.loadEdits(editsStreams, dstNamesystem); } }
NamenodeRegistration setRegistration() { nodeRegistration = new NamenodeRegistration( NetUtils.getHostPortString(getNameNodeAddress()), NetUtils.getHostPortString(getHttpAddress()), getFSImage().getStorage(), getRole()); return nodeRegistration; }
CheckpointSignature rollEditLog(int layoutVersion) throws IOException { getEditLog().rollEditLog(layoutVersion); // Record this log segment ID in all of the storage directories, so // we won't miss this log segment on a restart if the edits directories // go missing. storage.writeTransactionIdFileToStorage(getEditLog().getCurSegmentTxId()); //Update NameDirSize Metric getStorage().updateNameDirSize(); return new CheckpointSignature(this); }