Saver(FSImageFormatProtobuf.Saver parent, FileSummary.Builder summary) { this.parent = parent; this.summary = summary; this.context = parent.getContext(); this.fsn = context.getSourceNamesystem(); this.numImageErrors = 0; }
/** * @return number of non-fatal errors detected while saving the image. * @throws IOException on fatal error. */ private long saveSnapshots(FileSummary.Builder summary) throws IOException { FSImageFormatPBSnapshot.Saver snapshotSaver = new FSImageFormatPBSnapshot.Saver( this, summary, context, context.getSourceNamesystem()); snapshotSaver.serializeSnapshotSection(sectionOutputStream); // Skip snapshot-related sections when there is no snapshot. if (context.getSourceNamesystem().getSnapshotManager() .getNumSnapshots() > 0) { snapshotSaver.serializeSnapshotDiffSection(sectionOutputStream); } snapshotSaver.serializeINodeReferenceSection(sectionOutputStream); return snapshotSaver.getNumImageErrors(); }
private void saveSecretManagerSection(FileSummary.Builder summary) throws IOException { final FSNamesystem fsn = context.getSourceNamesystem(); DelegationTokenSecretManager.SecretManagerState state = fsn .saveSecretManagerState(); state.section.writeDelimitedTo(sectionOutputStream); for (SecretManagerSection.DelegationKey k : state.keys) k.writeDelimitedTo(sectionOutputStream); for (SecretManagerSection.PersistToken t : state.tokens) t.writeDelimitedTo(sectionOutputStream); commitSection(summary, SectionName.SECRET_MANAGER); }
private void saveErasureCodingSection( FileSummary.Builder summary) throws IOException { final FSNamesystem fsn = context.getSourceNamesystem(); ErasureCodingPolicyInfo[] ecPolicies = fsn.getErasureCodingPolicyManager().getPolicies(); ArrayList<ErasureCodingPolicyProto> ecPolicyProtoes = new ArrayList<ErasureCodingPolicyProto>(); for (ErasureCodingPolicyInfo p : ecPolicies) { ecPolicyProtoes.add(PBHelperClient.convertErasureCodingPolicy(p)); } ErasureCodingSection section = ErasureCodingSection.newBuilder(). addAllPolicies(ecPolicyProtoes).build(); section.writeDelimitedTo(sectionOutputStream); commitSection(summary, SectionName.ERASURE_CODING); }
private void saveCacheManagerSection(FileSummary.Builder summary) throws IOException { final FSNamesystem fsn = context.getSourceNamesystem(); CacheManager.PersistState state = fsn.getCacheManager().saveState(); state.section.writeDelimitedTo(sectionOutputStream); for (CachePoolInfoProto p : state.pools) p.writeDelimitedTo(sectionOutputStream); for (CacheDirectiveInfoProto p : state.directives) p.writeDelimitedTo(sectionOutputStream); commitSection(summary, SectionName.CACHE_MANAGER); }
void save(File newFile, FSImageCompression compression) throws IOException { checkNotSaved(); final FSNamesystem sourceNamesystem = context.getSourceNamesystem(); final INodeDirectory rootDir = sourceNamesystem.dir.rootDir; final long numINodes = rootDir.getDirectoryWithQuotaFeature()
.setOndiskVersion(FSImageUtil.FILE_VERSION) .setLayoutVersion( context.getSourceNamesystem().getEffectiveLayoutVersion());
Saver(FSImageFormatProtobuf.Saver parent, FileSummary.Builder summary) { this.parent = parent; this.summary = summary; this.context = parent.getContext(); this.fsn = context.getSourceNamesystem(); }
Saver(FSImageFormatProtobuf.Saver parent, FileSummary.Builder summary) { this.parent = parent; this.summary = summary; this.context = parent.getContext(); this.fsn = context.getSourceNamesystem(); }
private void saveNameSystemSection(FileSummary.Builder summary) throws IOException { final FSNamesystem fsn = context.getSourceNamesystem(); OutputStream out = sectionOutputStream; BlockIdManager blockIdManager = fsn.getBlockManager().getBlockIdManager(); NameSystemSection.Builder b = NameSystemSection.newBuilder() .setGenstampV1(blockIdManager.getLegacyGenerationStamp()) .setGenstampV1Limit(blockIdManager.getLegacyGenerationStampLimit()) .setGenstampV2(blockIdManager.getGenerationStamp()) .setLastAllocatedBlockId(blockIdManager.getLastAllocatedContiguousBlockId()) .setLastAllocatedStripedBlockId(blockIdManager.getLastAllocatedStripedBlockId()) .setTransactionId(context.getTxId()); // We use the non-locked version of getNamespaceInfo here since // the coordinating thread of saveNamespace already has read-locked // the namespace for us. If we attempt to take another readlock // from the actual saver thread, there's a potential of a // fairness-related deadlock. See the comments on HDFS-2223. b.setNamespaceId(fsn.unprotectedGetNamespaceInfo().getNamespaceID()); if (fsn.isRollingUpgrade()) { b.setRollingUpgradeStartTime(fsn.getRollingUpgradeInfo().getStartTime()); } NameSystemSection s = b.build(); s.writeDelimitedTo(out); commitSection(summary, SectionName.NS_INFO); }
private void saveSnapshots(FileSummary.Builder summary) throws IOException { FSImageFormatPBSnapshot.Saver snapshotSaver = new FSImageFormatPBSnapshot.Saver( this, summary, context, context.getSourceNamesystem()); snapshotSaver.serializeSnapshotSection(sectionOutputStream); // Skip snapshot-related sections when there is no snapshot. if (context.getSourceNamesystem().getSnapshotManager() .getNumSnapshots() > 0) { snapshotSaver.serializeSnapshotDiffSection(sectionOutputStream); } snapshotSaver.serializeINodeReferenceSection(sectionOutputStream); }
private void saveSnapshots(FileSummary.Builder summary) throws IOException { FSImageFormatPBSnapshot.Saver snapshotSaver = new FSImageFormatPBSnapshot.Saver( this, summary, context, context.getSourceNamesystem()); snapshotSaver.serializeSnapshotSection(sectionOutputStream); // Skip snapshot-related sections when there is no snapshot. if (context.getSourceNamesystem().getSnapshotManager() .getNumSnapshots() > 0) { snapshotSaver.serializeSnapshotDiffSection(sectionOutputStream); } snapshotSaver.serializeINodeReferenceSection(sectionOutputStream); }
private void saveSecretManagerSection(FileSummary.Builder summary) throws IOException { final FSNamesystem fsn = context.getSourceNamesystem(); DelegationTokenSecretManager.SecretManagerState state = fsn .saveSecretManagerState(); state.section.writeDelimitedTo(sectionOutputStream); for (SecretManagerSection.DelegationKey k : state.keys) k.writeDelimitedTo(sectionOutputStream); for (SecretManagerSection.PersistToken t : state.tokens) t.writeDelimitedTo(sectionOutputStream); commitSection(summary, SectionName.SECRET_MANAGER); }
private void saveSecretManagerSection(FileSummary.Builder summary) throws IOException { final FSNamesystem fsn = context.getSourceNamesystem(); DelegationTokenSecretManager.SecretManagerState state = fsn .saveSecretManagerState(); state.section.writeDelimitedTo(sectionOutputStream); for (SecretManagerSection.DelegationKey k : state.keys) k.writeDelimitedTo(sectionOutputStream); for (SecretManagerSection.PersistToken t : state.tokens) t.writeDelimitedTo(sectionOutputStream); commitSection(summary, SectionName.SECRET_MANAGER); }
checkNotSaved(); final FSNamesystem sourceNamesystem = context.getSourceNamesystem(); FSDirectory fsDir = sourceNamesystem.dir; long startTime = now();
private void saveCacheManagerSection(FileSummary.Builder summary) throws IOException { final FSNamesystem fsn = context.getSourceNamesystem(); CacheManager.PersistState state = fsn.getCacheManager().saveState(); state.section.writeDelimitedTo(sectionOutputStream); for (CachePoolInfoProto p : state.pools) p.writeDelimitedTo(sectionOutputStream); for (CacheDirectiveInfoProto p : state.directives) p.writeDelimitedTo(sectionOutputStream); commitSection(summary, SectionName.CACHE_MANAGER); }
private void saveCacheManagerSection(FileSummary.Builder summary) throws IOException { final FSNamesystem fsn = context.getSourceNamesystem(); CacheManager.PersistState state = fsn.getCacheManager().saveState(); state.section.writeDelimitedTo(sectionOutputStream); for (CachePoolInfoProto p : state.pools) p.writeDelimitedTo(sectionOutputStream); for (CacheDirectiveInfoProto p : state.directives) p.writeDelimitedTo(sectionOutputStream); commitSection(summary, SectionName.CACHE_MANAGER); }
void save(File newFile, FSImageCompression compression) throws IOException { checkNotSaved(); final FSNamesystem sourceNamesystem = context.getSourceNamesystem(); final INodeDirectory rootDir = sourceNamesystem.dir.rootDir; final long numINodes = rootDir.getDirectoryWithQuotaFeature()
private void saveNameSystemSection(FileSummary.Builder summary) throws IOException { final FSNamesystem fsn = context.getSourceNamesystem(); OutputStream out = sectionOutputStream; BlockIdManager blockIdManager = fsn.getBlockIdManager(); NameSystemSection.Builder b = NameSystemSection.newBuilder() .setGenstampV1(blockIdManager.getGenerationStampV1()) .setGenstampV1Limit(blockIdManager.getGenerationStampV1Limit()) .setGenstampV2(blockIdManager.getGenerationStampV2()) .setLastAllocatedBlockId(blockIdManager.getLastAllocatedBlockId()) .setTransactionId(context.getTxId()); // We use the non-locked version of getNamespaceInfo here since // the coordinating thread of saveNamespace already has read-locked // the namespace for us. If we attempt to take another readlock // from the actual saver thread, there's a potential of a // fairness-related deadlock. See the comments on HDFS-2223. b.setNamespaceId(fsn.unprotectedGetNamespaceInfo().getNamespaceID()); if (fsn.isRollingUpgrade()) { b.setRollingUpgradeStartTime(fsn.getRollingUpgradeInfo().getStartTime()); } NameSystemSection s = b.build(); s.writeDelimitedTo(out); commitSection(summary, SectionName.NS_INFO); }
private void saveNameSystemSection(FileSummary.Builder summary) throws IOException { final FSNamesystem fsn = context.getSourceNamesystem(); OutputStream out = sectionOutputStream; BlockIdManager blockIdManager = fsn.getBlockIdManager(); NameSystemSection.Builder b = NameSystemSection.newBuilder() .setGenstampV1(blockIdManager.getGenerationStampV1()) .setGenstampV1Limit(blockIdManager.getGenerationStampV1Limit()) .setGenstampV2(blockIdManager.getGenerationStampV2()) .setLastAllocatedBlockId(blockIdManager.getLastAllocatedBlockId()) .setTransactionId(context.getTxId()); // We use the non-locked version of getNamespaceInfo here since // the coordinating thread of saveNamespace already has read-locked // the namespace for us. If we attempt to take another readlock // from the actual saver thread, there's a potential of a // fairness-related deadlock. See the comments on HDFS-2223. b.setNamespaceId(fsn.unprotectedGetNamespaceInfo().getNamespaceID()); if (fsn.isRollingUpgrade()) { b.setRollingUpgradeStartTime(fsn.getRollingUpgradeInfo().getStartTime()); } NameSystemSection s = b.build(); s.writeDelimitedTo(out); commitSection(summary, SectionName.NS_INFO); }