public virtual void ReadFields(BinaryReader reader) { blockSize = @in.ReadLong(); bytesPerChecksum = @in.ReadInt(); writePacketSize = @in.ReadInt(); replication = @in.ReadShort(); fileBufferSize = @in.ReadInt(); checksumType = WritableUtils.ReadEnum <DataChecksum.Type>(@in); }
public static DataChecksum FromProto(DataTransferProtos.ChecksumProto proto) { if (proto == null) { return(null); } int bytesPerChecksum = proto.GetBytesPerChecksum(); DataChecksum.Type type = PBHelper.Convert(proto.GetType()); return(DataChecksum.NewDataChecksum(type, bytesPerChecksum)); }
/// <summary>Convert a Json map to a MD5MD5CRC32FileChecksum.</summary> /// <exception cref="System.IO.IOException"/> public static MD5MD5CRC32FileChecksum ToMD5MD5CRC32FileChecksum <_T0>(IDictionary < _T0> json) { if (json == null) { return(null); } IDictionary <object, object> m = (IDictionary <object, object>)json[typeof(FileChecksum ).Name]; string algorithm = (string)m["algorithm"]; int length = ((Number)m["length"]); byte[] bytes = StringUtils.HexStringToByte((string)m["bytes"]); DataInputStream @in = new DataInputStream(new ByteArrayInputStream(bytes)); DataChecksum.Type crcType = MD5MD5CRC32FileChecksum.GetCrcTypeFromAlgorithmName(algorithm ); MD5MD5CRC32FileChecksum checksum; switch (crcType) { case DataChecksum.Type.Crc32: { // Recreate what DFSClient would have returned. checksum = new MD5MD5CRC32GzipFileChecksum(); break; } case DataChecksum.Type.Crc32c: { checksum = new MD5MD5CRC32CastagnoliFileChecksum(); break; } default: { throw new IOException("Unknown algorithm: " + algorithm); } } checksum.ReadFields(@in); //check algorithm name if (!checksum.GetAlgorithmName().Equals(algorithm)) { throw new IOException("Algorithm not matched. Expected " + algorithm + ", Received " + checksum.GetAlgorithmName()); } //check length if (length != checksum.GetLength()) { throw new IOException("Length not matched: length=" + length + ", checksum.getLength()=" + checksum.GetLength()); } return(checksum); }
public FsServerDefaults(long blockSize, int bytesPerChecksum, int writePacketSize , short replication, int fileBufferSize, bool encryptDataTransfer, long trashInterval , DataChecksum.Type checksumType) { this.blockSize = blockSize; this.bytesPerChecksum = bytesPerChecksum; this.writePacketSize = writePacketSize; this.replication = replication; this.fileBufferSize = fileBufferSize; this.encryptDataTransfer = encryptDataTransfer; this.trashInterval = trashInterval; this.checksumType = checksumType; }
/// <summary>Normal ctor</summary> /// <param name="type">checksum type</param> /// <param name="size">bytes per checksum</param> public ChecksumOpt(DataChecksum.Type type, int size) { checksumType = type; bytesPerChecksum = size; }
private void CheckParams(DataChecksum.Type type, int bpc, Options.ChecksumOpt obtained ) { Assert.Equal(type, obtained.GetChecksumType()); Assert.Equal(bpc, obtained.GetBytesPerChecksum()); }