Refine search
protected long readHeader(RandomAccessFile raFile) throws IOException { raFile.seek(0); if (raFile.length() == 0) return -1; String versionHint = raFile.readUTF(); if (!"GH".equals(versionHint)) throw new IllegalArgumentException("Not a GraphHopper file! Expected 'GH' as file marker but was " + versionHint); long bytes = raFile.readLong(); setSegmentSize(raFile.readInt()); for (int i = 0; i < header.length; i++) { header[i] = raFile.readInt(); } return bytes; }
psinfo.seek(8); if(adjust(psinfo.readInt())!=pid) throw new IOException("psinfo PID mismatch"); // sanity check ppid = adjust(psinfo.readInt()); psinfo.seek(236); // offset of pr_argc argc = adjust(psinfo.readInt()); argp = adjustL(psinfo.readLong()); envp = adjustL(psinfo.readLong()); b64 = (psinfo.readByte() == PR_MODEL_LP64); } else { psinfo.seek(188); // offset of pr_argc argc = adjust(psinfo.readInt()); argp = to64(adjust(psinfo.readInt())); envp = to64(adjust(psinfo.readInt())); b64 = (psinfo.readByte() == PR_MODEL_LP64);
private synchronized TreeSet<Long> readRemovedPages() { try { TreeSet<Long> removedPages = new TreeSet<>(); if (chunkMetaData.length() > 8) { chunkMetaData.seek(4); int removedPagesCount = chunkMetaData.readInt(); for (int i = 0; i < removedPagesCount; i++) removedPages.add(chunkMetaData.readLong()); } return removedPages; } catch (IOException e) { throw panic(DataUtils.newIllegalStateException(DataUtils.ERROR_READING_FAILED, "Failed to readRemovedPages", e)); } }
file.seek(sectorNumber * SECTOR_BYTES); int length = file.readInt(); if (length > SECTOR_BYTES * numSectors) { throw new IOException("Invalid length: " + length + " > " + SECTOR_BYTES * numSectors); if (e.getMessage().equals("Not in GZIP format")) { GlowServer.logger.info("Incorrect region version, switching to zlib..."); file.seek((sectorNumber * SECTOR_BYTES) + Integer.BYTES); file.write(VERSION_DEFLATE); return getZlibInputStream(data);
@Override public boolean isPreUpgradableLayout(StorageDirectory sd) throws IOException { File oldF = new File(sd.getRoot(), "storage"); if (!oldF.exists()) { return false; } // check the layout version inside the storage file // Lock and Read old storage file try (RandomAccessFile oldFile = new RandomAccessFile(oldF, "rws"); FileLock oldLock = oldFile.getChannel().tryLock()) { if (null == oldLock) { LOG.error("Unable to acquire file lock on path {}", oldF); throw new OverlappingFileLockException(); } oldFile.seek(0); int oldVersion = oldFile.readInt(); if (oldVersion < LAST_PRE_UPGRADE_LAYOUT_VERSION) { return false; } } return true; }
@Override // Storage public boolean isPreUpgradableLayout(StorageDirectory sd) throws IOException { if (disablePreUpgradableLayoutCheck) { return false; } File oldImageDir = new File(sd.getRoot(), "image"); if (!oldImageDir.exists()) { return false; } // check the layout version inside the image file File oldF = new File(oldImageDir, "fsimage"); RandomAccessFile oldFile = new RandomAccessFile(oldF, "rws"); try { oldFile.seek(0); int oldVersion = oldFile.readInt(); oldFile.close(); oldFile = null; if (oldVersion < LAST_PRE_UPGRADE_LAYOUT_VERSION) { return false; } } finally { IOUtils.cleanupWithLogger(LOG, oldFile); } return true; }
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; }
/** * Initializes this header from the specified file. Looks for the right * version and reads the integer value of {@link #pageSize} from the file. * */ @Override public void readHeader(RandomAccessFile file) throws IOException { file.seek(0); if(file.readInt() != FILE_VERSION) { throw new RuntimeException("File " + file + " is not a PersistentPageFile or wrong version!"); } this.pageSize = file.readInt(); }