コード例 #1
0
ファイル: ChecksumFs.cs プロジェクト: orf53975/hadoop.net
            /// <exception cref="System.IO.IOException"/>
            /// <exception cref="Org.Apache.Hadoop.FS.UnresolvedLinkException"/>
            public ChecksumFSInputChecker(ChecksumFs fs, Path file, int bufferSize)
                : base(file, fs.GetFileStatus(file).GetReplication())
            {
                this.datas = fs.GetRawFs().Open(file, bufferSize);
                this.fs    = fs;
                Path sumFile = fs.GetChecksumFile(file);

                try
                {
                    int sumBufferSize = fs.GetSumBufferSize(fs.GetBytesPerSum(), bufferSize);
                    sums = fs.GetRawFs().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);
                }
            }
コード例 #2
0
ファイル: ChecksumFs.cs プロジェクト: orf53975/hadoop.net
            /// <exception cref="System.IO.IOException"/>
            public ChecksumFSOutputSummer(ChecksumFs fs, Path file, EnumSet <CreateFlag> createFlag
                                          , FsPermission absolutePermission, int bufferSize, short replication, long blockSize
                                          , Progressable progress, Options.ChecksumOpt checksumOpt, bool createParent)
                : base(DataChecksum.NewDataChecksum(DataChecksum.Type.Crc32, fs.GetBytesPerSum())
                       )
            {
                // checksumOpt is passed down to the raw fs. Unless it implements
                // checksum impelemts internally, checksumOpt will be ignored.
                // If the raw fs does checksum internally, we will end up with
                // two layers of checksumming. i.e. checksumming checksum file.
                this.datas = fs.GetRawFs().CreateInternal(file, createFlag, absolutePermission, bufferSize
                                                          , replication, blockSize, progress, checksumOpt, createParent);
                // Now create the chekcsumfile; adjust the buffsize
                int bytesPerSum   = fs.GetBytesPerSum();
                int sumBufferSize = fs.GetSumBufferSize(bytesPerSum, bufferSize);

                this.sums = fs.GetRawFs().CreateInternal(fs.GetChecksumFile(file), EnumSet.Of(CreateFlag
                                                                                              .Create, CreateFlag.Overwrite), absolutePermission, sumBufferSize, replication,
                                                         blockSize, progress, checksumOpt, createParent);
                sums.Write(ChecksumVersion, 0, ChecksumVersion.Length);
                sums.WriteInt(bytesPerSum);
            }