public ShortCircuitReplica(ExtendedBlockId key, FileInputStream dataStream, FileInputStream metaStream, ShortCircuitCache cache, long creationTimeMs, Slot slot) throws IOException { this.key = key; this.dataStream = dataStream; this.metaStream = metaStream; this.metaHeader = BlockMetadataHeader.preadHeader(metaStream.getChannel()); if (metaHeader.getVersion() != 1) { throw new IOException("invalid metadata header version " + metaHeader.getVersion() + ". Can only handle version 1."); } this.cache = cache; this.creationTimeMs = creationTimeMs; this.slot = slot; }
public ShortCircuitReplica(ExtendedBlockId key, FileInputStream dataStream, FileInputStream metaStream, ShortCircuitCache cache, long creationTimeMs, Slot slot) throws IOException { this.key = key; this.dataStream = dataStream; this.metaStream = metaStream; this.metaHeader = BlockMetadataHeader.preadHeader(metaStream.getChannel()); if (metaHeader.getVersion() != 1) { throw new IOException("invalid metadata header version " + metaHeader.getVersion() + ". Can only handle version 1."); } this.cache = cache; this.creationTimeMs = creationTimeMs; this.slot = slot; }
public ShortCircuitReplica(ExtendedBlockId key, FileInputStream dataStream, FileInputStream metaStream, ShortCircuitCache cache, long creationTimeMs, Slot slot) throws IOException { this.key = key; this.dataStream = dataStream; this.metaStream = metaStream; this.metaHeader = BlockMetadataHeader.preadHeader(metaStream.getChannel()); if (metaHeader.getVersion() != 1) { throw new IOException("invalid metadata header version " + metaHeader.getVersion() + ". Can only handle version 1."); } this.cache = cache; this.creationTimeMs = creationTimeMs; this.slot = slot; }
/** * Convert the replica to a string for debugging purposes. * Note that we can't take the lock here. */ @Override public String toString() { return "ShortCircuitReplica{" + "key=" + key + ", metaHeader.version=" + metaHeader.getVersion() + ", metaHeader.checksum=" + metaHeader.getChecksum() + ", ident=" + "0x" + Integer.toHexString(System.identityHashCode(this)) + ", creationTimeMs=" + creationTimeMs + "}"; } }
/** * Read the checksum header from the meta input stream. * @return the data checksum obtained from the header. */ public static DataChecksum readDataChecksum(final DataInputStream metaIn, final Object name) throws IOException { // read and handle the common header here. For now just a version final BlockMetadataHeader header = readHeader(metaIn); if (header.getVersion() != VERSION) { LOG.warn("Unexpected meta-file version for " + name + ": version in file is " + header.getVersion() + " but expected version is " + VERSION); } return header.getChecksum(); }
/** * Read the checksum header from the meta input stream. * @return the data checksum obtained from the header. */ public static DataChecksum readDataChecksum(final DataInputStream metaIn, final Object name) throws IOException { // read and handle the common header here. For now just a version final BlockMetadataHeader header = readHeader(metaIn); if (header.getVersion() != VERSION) { LOG.warn("Unexpected meta-file version for " + name + ": version in file is " + header.getVersion() + " but expected version is " + VERSION); } return header.getChecksum(); }
/** * Convert the replica to a string for debugging purposes. * Note that we can't take the lock here. */ @Override public String toString() { return new StringBuilder().append("ShortCircuitReplica{"). append("key=").append(key). append(", metaHeader.version=").append(metaHeader.getVersion()). append(", metaHeader.checksum=").append(metaHeader.getChecksum()). append(", ident=").append("0x"). append(Integer.toHexString(System.identityHashCode(this))). append(", creationTimeMs=").append(creationTimeMs). append("}").toString(); } }
/** * Convert the replica to a string for debugging purposes. * Note that we can't take the lock here. */ @Override public String toString() { return new StringBuilder().append("ShortCircuitReplica{"). append("key=").append(key). append(", metaHeader.version=").append(metaHeader.getVersion()). append(", metaHeader.checksum=").append(metaHeader.getChecksum()). append(", ident=").append("0x"). append(Integer.toHexString(System.identityHashCode(this))). append(", creationTimeMs=").append(creationTimeMs). append("}").toString(); } }
/** * This writes all the fields till the beginning of checksum. * @param out DataOutputStream * @throws IOException */ @VisibleForTesting public static void writeHeader(DataOutputStream out, BlockMetadataHeader header) throws IOException { out.writeShort(header.getVersion()); header.getChecksum().writeHeader(out); }
/** * This writes all the fields till the beginning of checksum. * @param out DataOutputStream * @throws IOException */ @VisibleForTesting public static void writeHeader(DataOutputStream out, BlockMetadataHeader header) throws IOException { out.writeShort(header.getVersion()); header.getChecksum().writeHeader(out); }
/** * This writes all the fields till the beginning of checksum. * @param out DataOutputStream * @param header * @return * @throws IOException */ private static void writeHeader(DataOutputStream out, BlockMetadataHeader header) throws IOException { out.writeShort(header.getVersion()); header.getChecksum().writeHeader(out); }
/** * This writes all the fields till the beginning of checksum. * @param out DataOutputStream * @param header * @return * @throws IOException */ private static void writeHeader(DataOutputStream out, BlockMetadataHeader header) throws IOException { out.writeShort(header.getVersion()); header.getChecksum().writeHeader(out); }
/** * Read the checksum header from the meta input stream. * @return the data checksum obtained from the header. */ public static DataChecksum readDataChecksum(final DataInputStream metaIn, final Object name) throws IOException { // read and handle the common header here. For now just a version final BlockMetadataHeader header = readHeader(metaIn); if (header.getVersion() != VERSION) { LOG.warn("Unexpected meta-file version for " + name + ": version in file is " + header.getVersion() + " but expected version is " + VERSION); } return header.getChecksum(); }
/** * This writes all the fields till the beginning of checksum. * @param out DataOutputStream * @throws IOException */ @VisibleForTesting public static void writeHeader(DataOutputStream out, BlockMetadataHeader header) throws IOException { out.writeShort(header.getVersion()); header.getChecksum().writeHeader(out); }
short version = header.getVersion();
short version = header.getVersion();
short version = header.getVersion();