public static FileSummary loadSummary(RandomAccessFile file) throws IOException { final int FILE_LENGTH_FIELD_SIZE = 4; long fileLength = file.length(); file.seek(fileLength - FILE_LENGTH_FIELD_SIZE); int summaryLength = file.readInt(); if (summaryLength <= 0) { throw new IOException("Negative length of the file"); } file.seek(fileLength - FILE_LENGTH_FIELD_SIZE - summaryLength); byte[] summaryBytes = new byte[summaryLength]; file.readFully(summaryBytes); FileSummary summary = FileSummary .parseDelimitedFrom(new ByteArrayInputStream(summaryBytes)); if (summary.getOndiskVersion() != FILE_VERSION) { throw new IOException("Unsupported file version " + summary.getOndiskVersion()); } if (!NameNodeLayoutVersion.supports(Feature.PROTOBUF_FORMAT, summary.getLayoutVersion())) { throw new IOException("Unsupported layout version " + summary.getLayoutVersion()); } return summary; }
public static FileSummary loadSummary(RandomAccessFile file) throws IOException { final int FILE_LENGTH_FIELD_SIZE = 4; long fileLength = file.length(); file.seek(fileLength - FILE_LENGTH_FIELD_SIZE); int summaryLength = file.readInt(); if (summaryLength <= 0) { throw new IOException("Negative length of the file"); } file.seek(fileLength - FILE_LENGTH_FIELD_SIZE - summaryLength); byte[] summaryBytes = new byte[summaryLength]; file.readFully(summaryBytes); FileSummary summary = FileSummary .parseDelimitedFrom(new ByteArrayInputStream(summaryBytes)); if (summary.getOndiskVersion() != FILE_VERSION) { throw new IOException("Unsupported file version " + summary.getOndiskVersion()); } if (!NameNodeLayoutVersion.supports(Feature.PROTOBUF_FORMAT, summary.getLayoutVersion())) { throw new IOException("Unsupported layout version " + summary.getLayoutVersion()); } return summary; }
public static FileSummary loadSummary(RandomAccessFile file) throws IOException { final int FILE_LENGTH_FIELD_SIZE = 4; long fileLength = file.length(); file.seek(fileLength - FILE_LENGTH_FIELD_SIZE); int summaryLength = file.readInt(); if (summaryLength <= 0) { throw new IOException("Negative length of the file"); } file.seek(fileLength - FILE_LENGTH_FIELD_SIZE - summaryLength); byte[] summaryBytes = new byte[summaryLength]; file.readFully(summaryBytes); FileSummary summary = FileSummary .parseDelimitedFrom(new ByteArrayInputStream(summaryBytes)); if (summary.getOndiskVersion() != FILE_VERSION) { throw new IOException("Unsupported file version " + summary.getOndiskVersion()); } if (!NameNodeLayoutVersion.supports(Feature.PROTOBUF_FORMAT, summary.getLayoutVersion())) { throw new IOException("Unsupported layout version " + summary.getLayoutVersion()); } return summary; }