public ChecksumValidator(ChecksumType checksumType, RandomAccessReader reader, String dataFilename) throws IOException { this.checksumType = checksumType; this.reader = reader; this.dataFilename = dataFilename; chunkSize = reader.readInt(); }
public ChecksumValidator(ChecksumType checksumType, RandomAccessReader reader, String dataFilename) throws IOException { this.checksumType = checksumType; this.reader = reader; this.dataFilename = dataFilename; chunkSize = reader.readInt(); }
public ChecksumValidator(ChecksumType checksumType, RandomAccessReader reader, String dataFilename) throws IOException { this.checksumType = checksumType; this.reader = reader; this.dataFilename = dataFilename; chunkSize = reader.readInt(); }
public void validate(byte[] bytes, int start, int end) throws IOException { int current = (int) checksumType.of(bytes, start, end); int actual = reader.readInt(); if (current != actual) throw new IOException("Corrupted File : " + dataFilename); }
public void validate(byte[] bytes, int start, int end) throws IOException { int current = (int) checksumType.of(bytes, start, end); int actual = reader.readInt(); if (current != actual) throw new IOException("Corrupted File : " + dataFilename); }
public void validate(byte[] bytes, int start, int end) throws IOException { int current = (int) checksumType.of(bytes, start, end); int actual = reader.readInt(); if (current != actual) throw new IOException("Corrupted File : " + dataFilename); }
public void validate(byte[] bytes, int start, int end) throws IOException { checksum.update(bytes, start, end); int current = (int) checksum.getValue(); checksum.reset(); int actual = reader.readInt(); if (current != actual) throw new IOException("Corrupted SSTable : " + descriptor.filenameFor(Component.DATA)); }
public ChecksumValidator(Descriptor descriptor) throws IOException { this.descriptor = descriptor; checksum = descriptor.version.hasAllAdlerChecksums ? new Adler32() : new PureJavaCrc32(); reader = RandomAccessReader.open(new File(descriptor.filenameFor(Component.CRC))); chunkSize = reader.readInt(); }
private static boolean shouldSkip(File file) throws IOException, ConfigurationException { CommitLogDescriptor desc = CommitLogDescriptor.fromFileName(file.getName()); if (desc.version < CommitLogDescriptor.VERSION_21) { return false; } try(RandomAccessReader reader = RandomAccessReader.open(file)) { CommitLogDescriptor.readHeader(reader, DatabaseDescriptor.getEncryptionContext()); int end = reader.readInt(); long filecrc = reader.readInt() & 0xffffffffL; return end == 0 && filecrc == 0; } }
private static boolean shouldSkip(File file) throws IOException, ConfigurationException { CommitLogDescriptor desc = CommitLogDescriptor.fromFileName(file.getName()); if (desc.version < CommitLogDescriptor.VERSION_21) { return false; } try(RandomAccessReader reader = RandomAccessReader.open(file)) { CommitLogDescriptor.readHeader(reader, DatabaseDescriptor.getEncryptionContext()); int end = reader.readInt(); long filecrc = reader.readInt() & 0xffffffffL; return end == 0 && filecrc == 0; } }
private static boolean shouldSkip(File file) throws IOException, ConfigurationException { CommitLogDescriptor desc = CommitLogDescriptor.fromFileName(file.getName()); if (desc.version < CommitLogDescriptor.VERSION_21) { return false; } try(RandomAccessReader reader = RandomAccessReader.open(file)) { CommitLogDescriptor.readHeader(reader, DatabaseDescriptor.getEncryptionContext()); int end = reader.readInt(); long filecrc = reader.readInt() & 0xffffffffL; return end == 0 && filecrc == 0; } }
@SuppressWarnings("resource") public SyncSegment nextSegment(int startPosition, int nextSectionStartPosition) throws IOException { int totalPlainTextLength = reader.readInt(); currentSegmentEndPosition = nextSectionStartPosition - 1; nextLogicalStart += SYNC_MARKER_SIZE; FileDataInput input = new EncryptedFileSegmentInputStream(reader.getPath(), nextLogicalStart, 0, totalPlainTextLength, chunkProvider); nextLogicalStart += totalPlainTextLength; return new SyncSegment(input, startPosition, nextSectionStartPosition, (int)nextLogicalStart, tolerateSegmentErrors(nextSectionStartPosition, reader.length())); } }
@SuppressWarnings("resource") public SyncSegment nextSegment(int startPosition, int nextSectionStartPosition) throws IOException { int totalPlainTextLength = reader.readInt(); currentSegmentEndPosition = nextSectionStartPosition - 1; nextLogicalStart += SYNC_MARKER_SIZE; FileDataInput input = new EncryptedFileSegmentInputStream(reader.getPath(), nextLogicalStart, 0, totalPlainTextLength, chunkProvider); nextLogicalStart += totalPlainTextLength; return new SyncSegment(input, startPosition, nextSectionStartPosition, (int)nextLogicalStart, tolerateSegmentErrors(nextSectionStartPosition, reader.length())); } }
@SuppressWarnings("resource") public SyncSegment nextSegment(int startPosition, int nextSectionStartPosition) throws IOException { int totalPlainTextLength = reader.readInt(); currentSegmentEndPosition = nextSectionStartPosition - 1; nextLogicalStart += SYNC_MARKER_SIZE; FileDataInput input = new EncryptedFileSegmentInputStream(reader.getPath(), nextLogicalStart, 0, totalPlainTextLength, chunkProvider); nextLogicalStart += totalPlainTextLength; return new SyncSegment(input, startPosition, nextSectionStartPosition, (int)nextLogicalStart, tolerateSegmentErrors(nextSectionStartPosition, reader.length())); } }
@SuppressWarnings("resource") public SyncSegment nextSegment(final int startPosition, final int nextSectionStartPosition) throws IOException { reader.seek(startPosition); int uncompressedLength = reader.readInt(); int compressedLength = nextSectionStartPosition - (int)reader.getPosition(); if (compressedLength > compressedBuffer.length) compressedBuffer = new byte[(int) (1.2 * compressedLength)]; reader.readFully(compressedBuffer, 0, compressedLength); if (uncompressedLength > uncompressedBuffer.length) uncompressedBuffer = new byte[(int) (1.2 * uncompressedLength)]; int count = compressor.uncompress(compressedBuffer, 0, compressedLength, uncompressedBuffer, 0); nextLogicalStart += SYNC_MARKER_SIZE; FileDataInput input = new FileSegmentInputStream(ByteBuffer.wrap(uncompressedBuffer, 0, count), reader.getPath(), nextLogicalStart); nextLogicalStart += uncompressedLength; return new SyncSegment(input, startPosition, nextSectionStartPosition, (int)nextLogicalStart, tolerateSegmentErrors(nextSectionStartPosition, reader.length())); } }
@SuppressWarnings("resource") public SyncSegment nextSegment(final int startPosition, final int nextSectionStartPosition) throws IOException { reader.seek(startPosition); int uncompressedLength = reader.readInt(); int compressedLength = nextSectionStartPosition - (int)reader.getPosition(); if (compressedLength > compressedBuffer.length) compressedBuffer = new byte[(int) (1.2 * compressedLength)]; reader.readFully(compressedBuffer, 0, compressedLength); if (uncompressedLength > uncompressedBuffer.length) uncompressedBuffer = new byte[(int) (1.2 * uncompressedLength)]; int count = compressor.uncompress(compressedBuffer, 0, compressedLength, uncompressedBuffer, 0); nextLogicalStart += SYNC_MARKER_SIZE; FileDataInput input = new FileSegmentInputStream(ByteBuffer.wrap(uncompressedBuffer, 0, count), reader.getPath(), nextLogicalStart); nextLogicalStart += uncompressedLength; return new SyncSegment(input, startPosition, nextSectionStartPosition, (int)nextLogicalStart, tolerateSegmentErrors(nextSectionStartPosition, reader.length())); } }
@SuppressWarnings("resource") public SyncSegment nextSegment(final int startPosition, final int nextSectionStartPosition) throws IOException { reader.seek(startPosition); int uncompressedLength = reader.readInt(); int compressedLength = nextSectionStartPosition - (int)reader.getPosition(); if (compressedLength > compressedBuffer.length) compressedBuffer = new byte[(int) (1.2 * compressedLength)]; reader.readFully(compressedBuffer, 0, compressedLength); if (uncompressedLength > uncompressedBuffer.length) uncompressedBuffer = new byte[(int) (1.2 * uncompressedLength)]; int count = compressor.uncompress(compressedBuffer, 0, compressedLength, uncompressedBuffer, 0); nextLogicalStart += SYNC_MARKER_SIZE; FileDataInput input = new FileSegmentInputStream(ByteBuffer.wrap(uncompressedBuffer, 0, count), reader.getPath(), nextLogicalStart); nextLogicalStart += uncompressedLength; return new SyncSegment(input, startPosition, nextSectionStartPosition, (int)nextLogicalStart, tolerateSegmentErrors(nextSectionStartPosition, reader.length())); } }