/** * Returns file md5 checksum provided by {@link org.elasticsearch.index.store.Store} * * @return file checksum */ public String checksum() { return metadata.checksum(); }
public String checksum() { return metaData.checksum(); }
/** * Checks if the checksum for the file is unknown. This only is possible on an empty shard's * segments_N file which was created in older Lucene versions. */ public boolean hasUnknownChecksum() { return metadata.checksum().equals(UNKNOWN_CHECKSUM); }
private void readAndCompareChecksum() throws IOException { actualChecksum = digestToString(getChecksum()); if (!metadata.checksum().equals(actualChecksum)) { throw new CorruptIndexException("checksum failed (hardware problem?) : expected=" + metadata.checksum() + " actual=" + actualChecksum + " (resource=" + metadata.toString() + ")", "VerifyingIndexOutput(" + metadata.name() + ")"); } }
@Override public void verify() throws IOException { String footerDigest = null; if (metadata.checksum().equals(actualChecksum) && writtenBytes == metadata.length()) { ByteArrayIndexInput indexInput = new ByteArrayIndexInput("checksum", this.footerChecksum); footerDigest = digestToString(indexInput.readLong()); if (metadata.checksum().equals(footerDigest)) { return; } } throw new CorruptIndexException("verification failed (hardware problem?) : expected=" + metadata.checksum() + " actual=" + actualChecksum + " footer=" + footerDigest +" writtenLength=" + writtenBytes + " expectedLength=" + metadata.length() + " (resource=" + metadata.toString() + ")", "VerifyingIndexOutput(" + metadata.name() + ")"); }
public static void checkIntegrity(final StoreFileMetaData md, final Directory directory) throws IOException { try (IndexInput input = directory.openInput(md.name(), IOContext.READONCE)) { if (input.length() != md.length()) { // first check the length no matter how old this file is throw new CorruptIndexException("expected length=" + md.length() + " != actual length: " + input.length() + " : file truncated?", input); } // throw exception if the file is corrupt String checksum = Store.digestToString(CodecUtil.checksumEntireFile(input)); // throw exception if metadata is inconsistent if (!checksum.equals(md.checksum())) { throw new CorruptIndexException("inconsistent metadata: lucene checksum=" + checksum + ", metadata checksum=" + md.checksum(), input); } } }
/** * Serializes file info into JSON * * @param file file info * @param builder XContent builder * @param params parameters */ public static void toXContent(FileInfo file, XContentBuilder builder, ToXContent.Params params) throws IOException { builder.startObject(); builder.field(NAME, file.name); builder.field(PHYSICAL_NAME, file.metadata.name()); builder.field(LENGTH, file.metadata.length()); if (file.metadata.checksum().equals(UNKNOWN_CHECKSUM) == false) { builder.field(CHECKSUM, file.metadata.checksum()); } if (file.partSize != null) { builder.field(PART_SIZE, file.partSize.getBytes()); } if (file.metadata.writtenBy() != null) { builder.field(WRITTEN_BY, file.metadata.writtenBy()); } if (file.metadata.hash() != null && file.metadata().hash().length > 0) { BytesRef br = file.metadata.hash(); builder.field(META_HASH, br.bytes, br.offset, br.length); } builder.endObject(); }
/** * Returns file md5 checksum provided by {@link org.elasticsearch.index.store.Store} * * @return file checksum */ public String checksum() { return metadata.checksum(); }
/** * Returns file md5 checksum provided by {@link org.elasticsearch.index.store.Store} * * @return file checksum */ public String checksum() { return metadata.checksum(); }
/** * Returns file md5 checksum provided by {@link org.elasticsearch.index.store.Store} * * @return file checksum */ public String checksum() { return metadata.checksum(); }
if (logger.isTraceEnabled()) { logger.trace("recovery [phase1]: not recovering [{}], exist in local store and has checksum [{}]," + " size [{}]", md.name(), md.checksum(), md.length());
/** * Checks if the checksum for the file is unknown. This only is possible on an empty shard's * segments_N file which was created in older Lucene versions. */ public boolean hasUnknownChecksum() { return metadata.checksum().equals(UNKNOWN_CHECKSUM); }
/** * Checks if the checksum for the file is unknown. This only is possible on an empty shard's * segments_N file which was created in older Lucene versions. */ public boolean hasUnknownChecksum() { return metadata.checksum().equals(UNKNOWN_CHECKSUM); }
/** * Checks if the checksum for the file is unknown. This only is possible on an empty shard's * segments_N file which was created in older Lucene versions. */ public boolean hasUnknownChecksum() { return metadata.checksum().equals(UNKNOWN_CHECKSUM); }
@Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeLong(recoveryId); shardId.writeTo(out); out.writeString(metaData.name()); out.writeVLong(position); out.writeVLong(metaData.length()); out.writeString(metaData.checksum()); out.writeBytesReference(content); out.writeString(metaData.writtenBy().toString()); out.writeBoolean(lastChunk); out.writeVInt(totalTranslogOps); out.writeLong(sourceThrottleTimeInNanos); }
/** * Returns file md5 checksum provided by {@link org.elasticsearch.index.store.Store} * * @return file checksum */ @Nullable public String checksum() { return metadata.checksum(); }
public void add(StoreFileMetaData metaData) throws IOException { if (metaData.hasLegacyChecksum()) { synchronized (this) { // we don't add checksums if they were written by LUCENE_48... now we are using the build in mechanism. legacyChecksums.put(metaData.name(), metaData.checksum()); } } }
private void readAndCompareChecksum() throws IOException { actualChecksum = digestToString(getChecksum()); if (!metadata.checksum().equals(actualChecksum)) { throw new CorruptIndexException("checksum failed (hardware problem?) : expected=" + metadata.checksum() + " actual=" + actualChecksum + " (resource=" + metadata.toString() + ")", "VerifyingIndexOutput(" + metadata.name() + ")"); } }
private void readAndCompareChecksum() throws IOException { actualChecksum = digestToString(getChecksum()); if (!metadata.checksum().equals(actualChecksum)) { throw new CorruptIndexException("checksum failed (hardware problem?) : expected=" + metadata.checksum() + " actual=" + actualChecksum + " (resource=" + metadata.toString() + ")", "VerifyingIndexOutput(" + metadata.name() + ")"); } }
public IndexInput openVerifyingInput(String filename, IOContext context, StoreFileMetaData metadata) throws IOException { if (metadata.hasLegacyChecksum() || metadata.checksum() == null) { logger.debug("open legacy input for {}", filename); return directory().openInput(filename, context); } assert metadata.writtenBy() != null; assert metadata.writtenBy().onOrAfter(Version.LUCENE_4_8_0); return new VerifyingIndexInput(directory().openInput(filename, context)); }