Exemplo n.º 1
0
            /// <exception cref="System.IO.IOException"/>
            public ChecksumFSInputChecker(ChecksumFileSystem fs, Path file, int bufferSize)
                : base(file, fs.GetFileStatus(file).GetReplication())
            {
                this.datas = fs.GetRawFileSystem().Open(file, bufferSize);
                this.fs    = fs;
                Path sumFile = fs.GetChecksumFile(file);

                try
                {
                    int sumBufferSize = fs.GetSumBufferSize(fs.GetBytesPerSum(), bufferSize);
                    sums = fs.GetRawFileSystem().Open(sumFile, sumBufferSize);
                    byte[] version = new byte[ChecksumVersion.Length];
                    sums.ReadFully(version);
                    if (!Arrays.Equals(version, ChecksumVersion))
                    {
                        throw new IOException("Not a checksum file: " + sumFile);
                    }
                    this.bytesPerSum = sums.ReadInt();
                    Set(fs.verifyChecksum, DataChecksum.NewCrc32(), bytesPerSum, 4);
                }
                catch (FileNotFoundException)
                {
                    // quietly ignore
                    Set(fs.verifyChecksum, null, 1, 0);
                }
                catch (IOException e)
                {
                    // loudly ignore
                    Log.Warn("Problem opening checksum file: " + file + ".  Ignoring exception: ", e);
                    Set(fs.verifyChecksum, null, 1, 0);
                }
            }
Exemplo n.º 2
0
            /// <exception cref="System.IO.IOException"/>
            public ChecksumFSOutputSummer(ChecksumFileSystem fs, Path file, bool overwrite, int
                                          bufferSize, short replication, long blockSize, Progressable progress, FsPermission
                                          permission)
                : base(DataChecksum.NewDataChecksum(DataChecksum.Type.Crc32, fs.GetBytesPerSum())
                       )
            {
                int bytesPerSum = fs.GetBytesPerSum();

                this.datas = fs.GetRawFileSystem().Create(file, permission, overwrite, bufferSize
                                                          , replication, blockSize, progress);
                int sumBufferSize = fs.GetSumBufferSize(bytesPerSum, bufferSize);

                this.sums = fs.GetRawFileSystem().Create(fs.GetChecksumFile(file), permission, true
                                                         , sumBufferSize, replication, blockSize, null);
                sums.Write(ChecksumVersion, 0, ChecksumVersion.Length);
                sums.WriteInt(bytesPerSum);
            }
Exemplo n.º 3
0
 public bool Accept(Path file)
 {
     return(!ChecksumFileSystem.IsChecksumFile(file));
 }
Exemplo n.º 4
0
 /// <exception cref="System.IO.IOException"/>
 public ChecksumFSInputChecker(ChecksumFileSystem fs, Path file)
     : this(fs, file, fs.GetConf().GetInt(LocalFileSystemConfigKeys.LocalFsStreamBufferSizeKey
                                          , LocalFileSystemConfigKeys.LocalFsStreamBufferSizeDefault))
 {
 }