Package java.util.zip

Examples of java.util.zip.Checksum.reset()


                        // writeUTF/writeWithShortLength) and 4 bytes for column count.
                        // This prevents CRC by being fooled by special-case garbage in the file; see CASSANDRA-2128
                        if (serializedSize < 10)
                            break;
                        long claimedSizeChecksum = reader.readLong();
                        checksum.reset();
                        checksum.update(serializedSize);
                        if (checksum.getValue() != claimedSizeChecksum)
                            break; // entry wasn't synced correctly/fully.  that's ok.

                        if (serializedSize > bytes.length)
View Full Code Here


                        // writeUTF/writeWithShortLength) and 4 bytes for column count.
                        // This prevents CRC by being fooled by special-case garbage in the file; see CASSANDRA-2128
                        if (serializedSize < 10)
                            break;
                        long claimedSizeChecksum = reader.readLong();
                        checksum.reset();
                        checksum.update(serializedSize);
                        if (checksum.getValue() != claimedSizeChecksum)
                            break; // entry wasn't synced correctly/fully.  that's ok.

                        if (serializedSize > bytes.length)
View Full Code Here

      buf.writeByte(op.opCode.getOpCode());
      buf.writeLong(op.txid);
      op.writeFields(buf);
      int end = buf.getLength();
      Checksum checksum = FSEditLog.getChecksumForWrite();
      checksum.reset();
      checksum.update(buf.getData(), start, end-start);
      int sum = (int)checksum.getValue();
      buf.writeInt(sum);
    }
  }
View Full Code Here

              fos.close();
              break;
            }
            fos.writeInt((int) bytesRead);
            if (useChecksum) {
              checksum.reset();
              checksum.update(buf, 0, (int) bytesRead);
              fos.writeLong(checksum.getValue());
            }
            fos.write(buf, 0, (int) bytesRead);
            fos.flush();
View Full Code Here

              fos.close();
              break;
            }
            fos.writeInt((int) bytesRead);
            if (useChecksum) {
              checksum.reset();
              checksum.update(buf, 0, (int) bytesRead);
              fos.writeLong(checksum.getValue());
            }
            fos.write(buf, 0, (int) bytesRead);
            fos.flush();
View Full Code Here

    public void testReplicateRequest() throws Exception {
       
        // serialize the request
        Checksum csumAlgo = new CRC32();
        ReusableBuffer data = testEntry.serialize(csumAlgo);
        csumAlgo.reset();
       
        client.replicate(testLSN, data).get();
    }

    /* (non-Javadoc)
 
View Full Code Here

  for (int i = 0; i < N_ITERS; i++) {
      int nBytes = rnd.nextInt(65535);
      byte[] b = new byte[nBytes];
      rnd.nextBytes(b);
      javaChecksum.reset();
      jeChecksum.reset();
      javaChecksum.update(b, 0, nBytes);
      jeChecksum.update(b, 0, nBytes);
      assertEquals(javaChecksum.getValue(), jeChecksum.getValue());
  }
    }
View Full Code Here

  Checksum jeChecksum = new com.sleepycat.je.utilint.Adler32();
  Random rnd = new Random();
  for (int i = 0; i < N_ITERS; i++) {
      int nBytes = rnd.nextInt(65535);
      javaChecksum.reset();
      jeChecksum.reset();
      for (int j = 0; j < nBytes; j++) {
    byte b = (byte) (rnd.nextInt(256) & 0xff);
    javaChecksum.update(b);
    jeChecksum.update(b);
      }
View Full Code Here

    int bytesLeft = endOffset - startOffset;
    int chunkNum = 0;

    while (bytesLeft > 0) {
      // generate the checksum for one chunk
      checksum.reset();
      int count = Math.min(bytesLeft, bytesPerChecksum);
      checksum.update(indata, startOffset, count);

      // write the checksum value to the output buffer.
      int cksumValue = (int)checksum.getValue();
View Full Code Here

    ChecksumType cktype = ChecksumType.codeToType(block.getChecksumType());
    if (cktype == ChecksumType.NULL) {
      return true; // No checkums validations needed for this block.
    }
    Checksum checksumObject = cktype.getChecksumObject();
    checksumObject.reset();

    // read in the stored value of the checksum size from the header.
    int bytesPerChecksum = block.getBytesPerChecksum();

    // bytesPerChecksum is always larger than the size of the header
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.