public static long readCompactionTimestamp(FileSystem fs, Path compactionOutputPath) throws IOException { Path completionFilePath = new Path(compactionOutputPath, COMPACTION_COMPLETE_FILE_NAME); try (FSDataInputStream completionFileStream = fs.open(completionFilePath)) { return completionFileStream.readLong(); } }
long internalId; try (FSDataInputStream inStream = fs.open(openTxFileName)) { internalId = inStream.readLong(); short fileEpoch = inStream.readShort(); if (epoch != fileEpoch) {
/** @throws Exception If failed. */ @Test public void testAppend() throws Exception { Path fsHome = new Path(primaryFsUri); Path file = new Path(fsHome, "someFile"); int cnt = 1024; FSDataOutputStream out = fs.create(file, true, 1024); for (int i = 0; i < cnt; i++) out.writeLong(i); out.close(); out = fs.append(file); for (int i = cnt; i < cnt * 2; i++) out.writeLong(i); out.close(); FSDataInputStream in = fs.open(file, 1024); for (int i = 0; i < cnt * 2; i++) assertEquals(i, in.readLong()); in.close(); }
/** @throws Exception If failed. */ @Test public void testOpen() throws Exception { Path fsHome = new Path(primaryFsUri); Path file = new Path(fsHome, "someFile"); int cnt = 2 * 1024; try (FSDataOutputStream out = fs.create(file, true, 1024)) { for (long i = 0; i < cnt; i++) out.writeLong(i); } assertEquals(getClientFsUser(), fs.getFileStatus(file).getOwner()); try (FSDataInputStream in = fs.open(file, 1024)) { for (long i = 0; i < cnt; i++) assertEquals(i, in.readLong()); } }
long offsetIndexMeta = fin.readLong(); version = new Version(fin); Magic.readAndVerify(fin);
/** @throws Exception If failed. */ @Test public void testAppend() throws Exception { Path fsHome = new Path(primaryFsUri); Path file = new Path(fsHome, "someFile"); int cnt = 1024; FSDataOutputStream out = fs.create(file, EnumSet.noneOf(CreateFlag.class), Options.CreateOpts.perms(FsPermission.getDefault())); for (int i = 0; i < cnt; i++) out.writeLong(i); out.close(); out = fs.create(file, EnumSet.of(CreateFlag.APPEND), Options.CreateOpts.perms(FsPermission.getDefault())); for (int i = cnt; i < cnt * 2; i++) out.writeLong(i); out.close(); FSDataInputStream in = fs.open(file, 1024); for (int i = 0; i < cnt * 2; i++) assertEquals(i, in.readLong()); in.close(); }
/** @throws Exception If failed. */ @Test public void testOpen() throws Exception { Path fsHome = new Path(primaryFsUri); Path file = new Path(fsHome, "someFile"); int cnt = 2 * 1024; try (FSDataOutputStream out = fs.create(file, EnumSet.noneOf(CreateFlag.class), Options.CreateOpts.perms(FsPermission.getDefault()))) { for (long i = 0; i < cnt; i++) out.writeLong(i); } assertEquals(getClientFsUser(), fs.getFileStatus(file).getOwner()); try (FSDataInputStream in = fs.open(file, 1024)) { for (long i = 0; i < cnt; i++) assertEquals(i, in.readLong()); } }
/** * Print the unencrypted parameters that tell the Crypto Service how to decrypt the file. This * information is useful for debugging if and how a file was encrypted. */ private void printCryptoParams(Path path, FileSystem fs) { byte[] noCryptoBytes = new NoFileEncrypter().getDecryptionParameters(); try (FSDataInputStream fsDis = fs.open(path)) { long fileLength = fs.getFileStatus(path).getLen(); fsDis.seek(fileLength - 16 - Utils.Version.size() - (Long.BYTES)); long cryptoParamOffset = fsDis.readLong(); fsDis.seek(cryptoParamOffset); byte[] cryptoParams = CryptoUtils.readParams(fsDis); if (!Arrays.equals(noCryptoBytes, cryptoParams)) { System.out.println("Encrypted with Params: " + Key.toPrintableString(cryptoParams, 0, cryptoParams.length, cryptoParams.length)); } else { System.out.println("No on disk encryption detected."); } } catch (IOException ioe) { log.error("Error reading crypto params", ioe); } } }
/** * @see java.io.DataInput#readLong() */ @Override public long readLong() throws IOException { return this.fis.readLong(); }
/** * @see java.io.DataInput#readLong() */ @Override public long readLong() throws IOException { return this.fis.readLong(); }
public long get(int i) throws IOException { if (i < 0 || i >= size) { throw new ArrayIndexOutOfBoundsException("i = " + i + " size = " + size); } stream.seek(startPos + i * 8); return stream.readLong(); }
public static long readCompactionTimestamp(FileSystem fs, Path compactionOutputPath) throws IOException { Path completionFilePath = new Path(compactionOutputPath, COMPACTION_COMPLETE_FILE_NAME); try (FSDataInputStream completionFileStream = fs.open(completionFilePath)) { return completionFileStream.readLong(); } }
public static long readCleanUpIntervalMillis(FileSystem fs, Path cleanUpIntervalPath) throws IOException{ if (fs.exists(cleanUpIntervalPath)) { FSDataInputStream input = new FSDataInputStream(fs.open(cleanUpIntervalPath)); long intervalDurationMillis = input.readLong(); input.close(); return intervalDurationMillis; } else { return -1l; } }
public static long readCleanUpIntervalMillis(FileSystem fs, Path cleanUpIntervalPath) throws IOException{ if (fs.exists(cleanUpIntervalPath)) { FSDataInputStream input = new FSDataInputStream(fs.open(cleanUpIntervalPath)); long intervalDurationMillis = input.readLong(); input.close(); return intervalDurationMillis; } else { return -1l; } }
public long getLong(int index) throws IOException { if (index >= limit) { throw new ArrayIndexOutOfBoundsException( "Stream out of bounds: startPos = " + startPos + " limit = " + limit + " index = " + index); } long currentPos = stream.getPos(); stream.seek(startPos + index); long returnValue = stream.readLong(); stream.seek(currentPos); return returnValue; }
public long get() throws IOException { if (stream.getPos() >= startPos + limit * 8) { throw new ArrayIndexOutOfBoundsException( "Stream out of bounds: startPos = " + startPos + " limit = " + limit); } return stream.readLong(); }
public long getLong() throws IOException { if (stream.getPos() >= startPos + limit) { throw new ArrayIndexOutOfBoundsException( "Stream out of bounds: startPos = " + startPos + " limit = " + limit); } return stream.readLong(); }
@Override public long readDouble(String filePath, long offset) throws IOException { FSDataInputStream fileChannel = updateCache(filePath); fileChannel.seek(offset); return fileChannel.readLong(); }
@Override public long readLong(String filePath, long offset) throws IOException { FSDataInputStream fileChannel = updateCache(filePath); fileChannel.seek(offset); return fileChannel.readLong(); }
public long get(int index) throws IOException { if (index >= limit) { throw new ArrayIndexOutOfBoundsException( "Stream out of bounds: startPos = " + startPos + " limit = " + limit + " index = " + index); } long currentPos = stream.getPos(); stream.seek(startPos + index * 8); long returnValue = stream.readLong(); stream.seek(currentPos); return returnValue; }