Package org.apache.hadoop_voltpatches.util

Examples of org.apache.hadoop_voltpatches.util.PureJavaCrc32.update()


        PureJavaCrc32 crc = getCRC ? new PureJavaCrc32() : null;
        for (String chunk : chunks) {
            if (chunk.endsWith("_complete")) continue;
            resultBuffers[ii] = zk.getData(chunk, false, null);
            if (crc != null) {
                crc.update(resultBuffers[ii]);
            }
            ii++;
        }

        return Pair.of(decompressBytes(resultBuffers), crc != null ? (int)crc.getValue() : null);
View Full Code Here


        buf.position(OFFSET_DATA);
        buf.put(m_serData);

        // Finalize the CRC based on the entire buffer and reset the current position.
        final PureJavaCrc32 crc = new PureJavaCrc32();
        crc.update(buf.array());
        buf.putLong(OFFSET_CRC, crc.getValue());
        buf.rewind();
        return buf;
    }
View Full Code Here

        // Get the CRC, zero out its buffer field, and compare to calculated CRC.
        long crcHeader = buf.getLong(OFFSET_CRC);
        buf.putLong(OFFSET_CRC, 0);
        final PureJavaCrc32 crcBuffer = new PureJavaCrc32();
        assert(buf.hasArray());
        crcBuffer.update(buf.array());
        if (crcHeader != crcBuffer.getValue()) {
            throw new IOException("Hashinator snapshot data CRC mismatch.");
        }

        // Slurp the data.
View Full Code Here

            sw.append(stringer.toString());

            final byte tableListBytes[] = sw.getBuffer().toString().getBytes("UTF-8");
            final PureJavaCrc32 crc = new PureJavaCrc32();
            crc.update(tableListBytes);
            ByteBuffer fileBuffer = ByteBuffer.allocate(tableListBytes.length + 4);
            fileBuffer.putInt((int)crc.getValue());
            fileBuffer.put(tableListBytes);
            fileBuffer.flip();
            fos.getChannel().write(fileBuffer);
View Full Code Here

             */
            if (obj == null) {
                String tableList = caw.toString();
                byte tableListBytes[] = tableList.getBytes("UTF-8");
                PureJavaCrc32 tableListCRC = new PureJavaCrc32();
                tableListCRC.update(tableListBytes);
                tableListCRC.update("\n".getBytes("UTF-8"));
                final int calculatedValue = (int)tableListCRC.getValue();
                if (crc != calculatedValue) {
                    logger.warn("CRC of snapshot digest " + f + " did not match digest contents");
                    return null;
View Full Code Here

            if (obj == null) {
                String tableList = caw.toString();
                byte tableListBytes[] = tableList.getBytes("UTF-8");
                PureJavaCrc32 tableListCRC = new PureJavaCrc32();
                tableListCRC.update(tableListBytes);
                tableListCRC.update("\n".getBytes("UTF-8"));
                final int calculatedValue = (int)tableListCRC.getValue();
                if (crc != calculatedValue) {
                    logger.warn("CRC of snapshot digest " + f + " did not match digest contents");
                    return null;
                }
View Full Code Here

                 * Verify the CRC and then return the data as a JSON object.
                 */
                String tableList = caw.toString();
                byte tableListBytes[] = tableList.getBytes("UTF-8");
                PureJavaCrc32 tableListCRC = new PureJavaCrc32();
                tableListCRC.update(tableListBytes);
                final int calculatedValue = (int)tableListCRC.getValue();
                if (crc != calculatedValue) {
                    logger.warn("CRC of snapshot digest " + f + " did not match digest contents");
                    return null;
                }
View Full Code Here

        for (Entry<String, byte[]> e : super.entrySet()) {
            if (e.getKey().equals("buildinfo.txt") || e.getKey().equals("catalog-report.html")) {
                continue;
            }
            crc.update(e.getKey().getBytes("UTF-8"));
            crc.update(e.getValue());
        }

        return crc.getValue();
    }
View Full Code Here

        for (Entry<String, byte[]> e : super.entrySet()) {
            if (e.getKey().equals("buildinfo.txt") || e.getKey().equals("catalog-report.html")) {
                continue;
            }
            crc.update(e.getKey().getBytes("UTF-8"));
            crc.update(e.getValue());
        }

        return crc.getValue();
    }
View Full Code Here

            }
            lengthBuffer.flip();
            final int originalCRC = lengthBuffer.getInt();
            int length = lengthBuffer.getInt();
            crc.update(lengthBuffer.array(), 4, 4);
            secondCRC.update(lengthBuffer.array(), 4, 4);

            if (length < 0) {
                throw new IOException("Corrupted save file has negative header length");
            }
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.