/** * Writes all the fields till the beginning of checksum. * @param out * @param checksum * @throws IOException */ static void writeHeader(DataOutputStream out, DataChecksum checksum) throws IOException { writeHeader(out, new BlockMetadataHeader(METADATA_VERSION, checksum)); }
/** * Writes all the fields till the beginning of checksum. * @throws IOException on error */ public static void writeHeader(DataOutputStream out, DataChecksum checksum) throws IOException { writeHeader(out, new BlockMetadataHeader(VERSION, checksum)); }
private static BlockMetadataHeader readHeader(short version, DataInputStream in) throws IOException { DataChecksum checksum = DataChecksum.newDataChecksum(in); return new BlockMetadataHeader(version, checksum); }
private static BlockMetadataHeader readHeader(short version, DataInputStream in) throws IOException { DataChecksum checksum = DataChecksum.newDataChecksum(in); return new BlockMetadataHeader(version, checksum); }
private static BlockMetadataHeader readHeader(short version, DataInputStream in) throws IOException { DataChecksum checksum = DataChecksum.newDataChecksum(in); return new BlockMetadataHeader(version, checksum); }
private static BlockMetadataHeader readHeader(short version, DataInputStream in) throws IOException { DataChecksum checksum = DataChecksum.newDataChecksum(in); return new BlockMetadataHeader(version, checksum); }
private static BlockMetadataHeader readHeader(short version, DataInputStream in) throws IOException { DataChecksum checksum = DataChecksum.newDataChecksum(in); return new BlockMetadataHeader(version, checksum); }
/** * Writes all the fields till the beginning of checksum. * @throws IOException on error */ public static void writeHeader(DataOutputStream out, DataChecksum checksum) throws IOException { writeHeader(out, new BlockMetadataHeader(VERSION, checksum)); }
private static BlockMetadataHeader readHeader(short version, DataInputStream in, Checksum checksumImpl) throws IOException { DataChecksum checksum = DataChecksum.newDataChecksum(in, checksumImpl); return new BlockMetadataHeader(version, checksum); }
/** * Writes all the fields till the beginning of checksum. * @throws IOException on error */ public static void writeHeader(DataOutputStream out, DataChecksum checksum) throws IOException { writeHeader(out, new BlockMetadataHeader(VERSION, checksum)); }
/** * Writes all the fields till the beginning of checksum. * @param out * @param checksum * @throws IOException */ static void writeHeader(DataOutputStream out, DataChecksum checksum) throws IOException { writeHeader(out, new BlockMetadataHeader(METADATA_VERSION, checksum)); }
/** * Read the header without changing the position of the FileChannel. * * @param fc The FileChannel to read. * @return the Metadata Header. * @throws IOException on error. */ public static BlockMetadataHeader preadHeader(FileChannel fc) throws IOException { final byte arr[] = new byte[getHeaderSize()]; ByteBuffer buf = ByteBuffer.wrap(arr); while (buf.hasRemaining()) { if (fc.read(buf, 0) <= 0) { throw new EOFException("unexpected EOF while reading " + "metadata file header"); } } short version = (short)((arr[0] << 8) | (arr[1] & 0xff)); DataChecksum dataChecksum = DataChecksum.newDataChecksum(arr, 2); return new BlockMetadataHeader(version, dataChecksum); }
/** * Read the header without changing the position of the FileChannel. * This is used by the client for short-circuit reads. * * @param fc The FileChannel to read. * @return the Metadata Header. * @throws IOException on error. */ public static BlockMetadataHeader preadHeader(FileChannel fc) throws IOException { final byte arr[] = new byte[getHeaderSize()]; ByteBuffer buf = ByteBuffer.wrap(arr); while (buf.hasRemaining()) { if (fc.read(buf, 0) <= 0) { throw new EOFException("unexpected EOF while reading " + "metadata file header"); } } short version = (short)((arr[0] << 8) | (arr[1] & 0xff)); DataChecksum dataChecksum = DataChecksum.newDataChecksum(arr, 2); return new BlockMetadataHeader(version, dataChecksum); }
/** * Read the header without changing the position of the FileChannel. * * @param fc The FileChannel to read. * @return the Metadata Header. * @throws IOException on error. */ public static BlockMetadataHeader preadHeader(FileChannel fc) throws IOException { final byte arr[] = new byte[getHeaderSize()]; ByteBuffer buf = ByteBuffer.wrap(arr); while (buf.hasRemaining()) { if (fc.read(buf, 0) <= 0) { throw new EOFException("unexpected EOF while reading " + "metadata file header"); } } short version = (short)((arr[0] << 8) | (arr[1] & 0xff)); DataChecksum dataChecksum = DataChecksum.newDataChecksum(arr, 2); return new BlockMetadataHeader(version, dataChecksum); }
public TestFileDescriptorPair() throws IOException { fis = new FileInputStream[2]; for (int i = 0; i < 2; i++) { String name = dir.getDir() + "/file" + i; FileOutputStream fos = new FileOutputStream(name); if (i == 0) { // write 'data' file fos.write(1); } else { // write 'metadata' file BlockMetadataHeader header = new BlockMetadataHeader((short)1, DataChecksum.newDataChecksum(DataChecksum.Type.NULL, 4)); DataOutputStream dos = new DataOutputStream(fos); BlockMetadataHeader.writeHeader(dos, header); dos.close(); } fos.close(); fis[i] = new FileInputStream(name); } }