private static LocalRecoverable deserializeV1(byte[] serialized) throws IOException { final ByteBuffer bb = ByteBuffer.wrap(serialized).order(ByteOrder.LITTLE_ENDIAN); if (bb.getInt() != MAGIC_NUMBER) { throw new IOException("Corrupt data: Unexpected magic number."); } final long offset = bb.getLong(); final byte[] targetFileBytes = new byte[bb.getInt()]; final byte[] tempFileBytes = new byte[bb.getInt()]; bb.get(targetFileBytes); bb.get(tempFileBytes); final String targetPath = new String(targetFileBytes, CHARSET); final String tempPath = new String(tempFileBytes, CHARSET); return new LocalRecoverable(new File(targetPath), new File(tempPath), offset); } }
@Override public Committer closeForCommit() throws IOException { final long pos = getPos(); close(); return new LocalCommitter(new LocalRecoverable(targetFile, tempFile, pos)); }
@Override public ResumeRecoverable persist() throws IOException { // we call both flush and sync in order to ensure persistence on mounted // file systems, like NFS, EBS, EFS, ... flush(); sync(); return new LocalRecoverable(targetFile, tempFile, getPos()); }
private static LocalRecoverable deserializeV1(byte[] serialized) throws IOException { final ByteBuffer bb = ByteBuffer.wrap(serialized).order(ByteOrder.LITTLE_ENDIAN); if (bb.getInt() != MAGIC_NUMBER) { throw new IOException("Corrupt data: Unexpected magic number."); } final long offset = bb.getLong(); final byte[] targetFileBytes = new byte[bb.getInt()]; final byte[] tempFileBytes = new byte[bb.getInt()]; bb.get(targetFileBytes); bb.get(tempFileBytes); final String targetPath = new String(targetFileBytes, CHARSET); final String tempPath = new String(tempFileBytes, CHARSET); return new LocalRecoverable(new File(targetPath), new File(tempPath), offset); } }
@Override public Committer closeForCommit() throws IOException { final long pos = getPos(); close(); return new LocalCommitter(new LocalRecoverable(targetFile, tempFile, pos)); }
@Override public ResumeRecoverable persist() throws IOException { // we call both flush and sync in order to ensure persistence on mounted // file systems, like NFS, EBS, EFS, ... flush(); sync(); return new LocalRecoverable(targetFile, tempFile, getPos()); }