Package java.util.zip

Examples of java.util.zip.Adler32.update()


                buff.reset();
                buff.skip(5+Journal.BATCH_CONTROL_RECORD_MAGIC.length);
                buff.writeInt(sequence.getLength()-Journal.BATCH_CONTROL_RECORD_SIZE);
                if( journal.isChecksum() ) {
                    Checksum checksum = new Adler32();
                    checksum.update(sequence.getData(), sequence.getOffset()+Journal.BATCH_CONTROL_RECORD_SIZE, sequence.getLength()-Journal.BATCH_CONTROL_RECORD_SIZE);
                    buff.writeLong(checksum.getValue());
                }

                // Now do the 1 big write.
                file.seek(wb.offset);
View Full Code Here


        dob.writeInt(0x81A4);                               // mode
        dob.writeInt((int)(System.currentTimeMillis() / 1000)); // mtime
        dob.writeInt(0);                                    // gmtdiff ignored
        dob.writeByte(0);                                   // no filename
        Adler32 headerChecksum = new Adler32();
        headerChecksum.update(dob.getData(), 0, dob.getLength());
        int hc = (int)headerChecksum.getValue();
        dob.writeInt(hc);
        out.write(LZO_MAGIC);
        out.write(dob.getData(), 0, dob.getLength());
      } finally {
View Full Code Here

                // empty transaction
                System.out.println("EOF reached after " + count + " txns.");
                return;
            }
            Checksum crc = new Adler32();
            crc.update(bytes, 0, bytes.length);
            if (crcValue != crc.getValue()) {
                throw new IOException("CRC doesn't match " + crcValue +
                        " vs " + crc.getValue());
            }
            InputArchive iab = BinaryInputArchive
View Full Code Here

                long expectedChecksum = currentBatchBuffer.getLong();
                Checksum actualChecksum = new Adler32();
                Location nextLocation = goToNextLocation(currentBatch, Location.ANY_RECORD_TYPE, true);
                while (nextLocation != null && nextLocation.getType() != Location.BATCH_CONTROL_RECORD_TYPE) {
                    byte data[] = accessor.readLocation(nextLocation, false);
                    actualChecksum.update(data, 0, data.length);
                    nextLocation = goToNextLocation(nextLocation, Location.ANY_RECORD_TYPE, true);
                }
                if (expectedChecksum != actualChecksum.getValue()) {
                    throw new IOException("Bad checksum for location: " + currentBatch);
                }
View Full Code Here

                buffer.putInt(current.location.getPointer());
                buffer.putInt(current.location.getSize());
                buffer.put(current.location.getType());
                buffer.put(current.getData());
                if (checksum) {
                    adler32.update(current.getData(), 0, current.getData().length);
                }
            }

            // Now we can fill in the batch control record properly.
            buffer.position(Journal.HEADER_SIZE);
View Full Code Here

        header.putInt(blkId) ;
        header.flip() ;
        channel.write(header) ;
       
        Adler32 adler = new Adler32() ;
        adler.update(header.array()) ;

        if ( len > 0 )
        {
            // Make buffer include it's full length.
            // [TxDEV:TODO] This is the full buffer, junk and all.
View Full Code Here

            for ( int i = len ; i < bufferCapacity ; i++ )
                buffer.put(i, (byte)0) ;
           
            // Write all bytes
            channel.write(buffer) ;
            adler.update(buffer.array()) ;
           
            buffer.position(bufferPosition) ;
            buffer.limit(bufferLimit) ;
        }
View Full Code Here

        int len     = header.getInt() ;
        int ref     = header.getInt() ;
        int blockId = header.getInt() ;
       
        Adler32 adler = new Adler32() ;
        adler.update(header.array()) ;

        JournalEntryType type = JournalEntryType.type(typeId) ;
        FileRef fileRef = FileRef.get(ref) ;
        ByteBuffer bb = ByteBuffer.allocate(len) ;
        lenRead = channel.read(bb) ;
View Full Code Here

        JournalEntryType type = JournalEntryType.type(typeId) ;
        FileRef fileRef = FileRef.get(ref) ;
        ByteBuffer bb = ByteBuffer.allocate(len) ;
        lenRead = channel.read(bb) ;
        adler.update(bb.array()) ;
        bb.rewind() ;
        // checksum
        crcTrailer.clear() ;
        lenRead = channel.read(crcTrailer) ;
        if ( lenRead != SizeofCRC )
View Full Code Here

    long checkSumD = defl.getAdler();
    defl.end();

    // getting the checkSum value through the Adler32 class
    Adler32 adl = new Adler32();
    adl.update(byteArray);
    long checkSumR = adl.getValue();
    assertEquals(
                "The checksum value returned by getAdler() is not the same as the checksum returned by creating the adler32 instance",
                checkSumD, checkSumR);
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.