Examples of Checksum


Examples of java.util.zip.Checksum

        testRecovery(out.toByteArray(), new byte[0]);
    }

    protected void testRecoveryWithBadSizeArgument(int size, int dataSize) throws Exception
    {
        Checksum checksum = new CRC32();
        checksum.update(size);
        testRecoveryWithBadSizeArgument(size, dataSize, checksum.getValue());
    }
View Full Code Here

Examples of java.util.zip.Checksum

  /**
   * Return a {@link Checksum} view of this instance. Modifications to the view
   * will modify this instance too and vice-versa.
   */
  public final Checksum asChecksum() {
    return new Checksum() {

      @Override
      public long getValue() {
        return StreamingXXHash64.this.getValue();
      }
View Full Code Here

Examples of java.util.zip.Checksum

  /**
   * Return a {@link Checksum} view of this instance. Modifications to the view
   * will modify this instance too and vice-versa.
   */
  public final Checksum asChecksum() {
    return new Checksum() {

      @Override
      public long getValue() {
        return StreamingXXHash32.this.getValue() & 0xFFFFFFFL;
      }
View Full Code Here

Examples of java.util.zip.Checksum

      break;
    }
    final LZ4Compressor compressor = randomBoolean()
        ? LZ4Factory.fastestInstance().fastCompressor()
        : LZ4Factory.fastestInstance().highCompressor();
    final Checksum checksum;
    switch (randomInt(2)) {
    case 0:
      checksum = new Adler32();
      break;
    case 1:
View Full Code Here

Examples of java.util.zip.Checksum

    disposed += free(filter("free=false and expires > 0 and (expires) <= " + System.currentTimeMillis() + " limit 1, 100" + limit));
    return disposed;
  }
 
  public static long crc32(byte[] payload) {
    final Checksum checksum = new CRC32();
    checksum.update(payload,0,payload.length);
    return checksum.getValue();
  }
View Full Code Here

Examples of java.util.zip.Checksum

  private static Random rnd = new Random();
  final static Map<String, Byte> test = Maps.newHashMap();
  private static int errors;

  public long crc(String str) {
    final Checksum checksum = new CRC32();

    final byte bytes[] = str.getBytes();
    checksum.update(bytes,0,bytes.length);
    return checksum.getValue();
  }
View Full Code Here

Examples of java.util.zip.Checksum

    @Override
    public byte[] appendChecksum(byte[] data) {
        byte[] output = new byte[data.length+4];
        System.arraycopy(data, 0, output, 0, data.length);
        Checksum crc = new CRC32();
        crc.update(data, 0, data.length);
        byte[] checksum = Fields.intToBytes((int)crc.getValue());
        System.arraycopy(checksum, 0, output, data.length, 4);
        return output;
    }
View Full Code Here

Examples of java.util.zip.Checksum

        return output;
    }

    @Override
    public byte[] generateChecksum(byte[] data, int offset, int length) {
        Checksum crc = new CRC32();
        crc.update(data, offset, length);
        return Fields.intToBytes((int)crc.getValue());
    }
View Full Code Here

Examples of java.util.zip.Checksum

        if (LOG.isDebugEnabled()) {
            LOG.debug(MessageFormat.format(
                    "Computing checksum: {0}",
                    file));
        }
        Checksum checksum = new CRC32();
        byte[] buf = byteBuffers.get();
        FSDataInputStream input = fs.open(file);
        try {
            while (true) {
                int read = input.read(buf);
                if (read < 0) {
                    break;
                }
                checksum.update(buf, 0, read);
            }
        } finally {
            input.close();
        }
        return checksum.getValue();
    }
View Full Code Here

Examples of java.util.zip.Checksum

                    // last CL entry didn't get completely written.  that's ok.
                    break;
                }

                ByteArrayInputStream bufIn = new ByteArrayInputStream(bytes);
                Checksum checksum = new CRC32();
                checksum.update(bytes, 0, bytes.length);
                if (claimedCRC32 != checksum.getValue())
                {
                    // this part of the log must not have been fsynced.  probably the rest is bad too,
                    // but just in case there is no harm in trying them.
                    continue;
                }
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.