Class DigestManager
- java.lang.Object
- 
- org.apache.bookkeeper.proto.checksum.DigestManager
 
- 
- Direct Known Subclasses:
- CRC32CDigestManager,- CRC32DigestManager,- DummyDigestManager,- MacDigestManager
 
 public abstract class DigestManager extends java.lang.ObjectThis class takes an entry, attaches a digest to it and packages it with relevant data so that it can be shipped to the bookie. On the return side, it also gets a packet, checks that the digest matches, and extracts the original entry for the packet. Currently 3 types of digests are supported: MAC (based on SHA-1) and CRC32 and CRC32C.
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classDigestManager.RecoveryDataA representation of RecoveryData.
 - 
Field SummaryFields Modifier and Type Field Description static intLAC_METADATA_LENGTH(package private) longledgerId(package private) intmacCodeLengthstatic intMETADATA_LENGTH(package private) booleanuseV2Protocol
 - 
Constructor SummaryConstructors Constructor Description DigestManager(long ledgerId, boolean useV2Protocol, io.netty.buffer.ByteBufAllocator allocator)
 - 
Method SummaryAll Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (package private) abstract booleanacceptsMemoryAddressBuffer()io.netty.util.ReferenceCountedcomputeDigestAndPackageForSending(long entryId, long lastAddConfirmed, long length, io.netty.buffer.ByteBuf data, byte[] masterKey, int flags)Computes the digest for an entry and put bytes together for sending.ByteBufListcomputeDigestAndPackageForSendingLac(long lac)Computes the digest for writeLac for sending.static byte[]generateMasterKey(byte[] password)(package private) abstract intgetMacCodeLength()static DigestManagerinstantiate(long ledgerId, byte[] passwd, DataFormats.LedgerMetadataFormat.DigestType digestType, io.netty.buffer.ByteBufAllocator allocator, boolean useV2Protocol)(package private) abstract intinternalUpdate(int digest, byte[] buffer, int offset, int len)(package private) abstract intinternalUpdate(int digest, io.netty.buffer.ByteBuf buffer, int offset, int len)(package private) abstract booleanisInt32Digest()(package private) abstract voidpopulateValueAndReset(int digest, io.netty.buffer.ByteBuf buffer)(package private) intupdate(int digest, io.netty.buffer.ByteBuf buffer, int offset, int len)io.netty.buffer.ByteBufverifyDigestAndReturnData(long entryId, io.netty.buffer.ByteBuf dataReceived)Verify that the digest matches and returns the data in the entry.longverifyDigestAndReturnLac(io.netty.buffer.ByteBuf dataReceived)DigestManager.RecoveryDataverifyDigestAndReturnLastConfirmed(io.netty.buffer.ByteBuf dataReceived)
 
- 
- 
- 
Field Detail- 
METADATA_LENGTHpublic static final int METADATA_LENGTH - See Also:
- Constant Field Values
 
 - 
LAC_METADATA_LENGTHpublic static final int LAC_METADATA_LENGTH - See Also:
- Constant Field Values
 
 - 
ledgerIdfinal long ledgerId 
 - 
useV2Protocolfinal boolean useV2Protocol 
 - 
macCodeLengthfinal int macCodeLength 
 
- 
 - 
Method Detail- 
getMacCodeLengthabstract int getMacCodeLength() 
 - 
internalUpdateabstract int internalUpdate(int digest, io.netty.buffer.ByteBuf buffer, int offset, int len)
 - 
internalUpdateabstract int internalUpdate(int digest, byte[] buffer, int offset, int len)
 - 
updatefinal int update(int digest, io.netty.buffer.ByteBuf buffer, int offset, int len)
 - 
populateValueAndResetabstract void populateValueAndReset(int digest, io.netty.buffer.ByteBuf buffer)
 - 
isInt32Digestabstract boolean isInt32Digest() 
 - 
instantiatepublic static DigestManager instantiate(long ledgerId, byte[] passwd, DataFormats.LedgerMetadataFormat.DigestType digestType, io.netty.buffer.ByteBufAllocator allocator, boolean useV2Protocol) throws java.security.GeneralSecurityException - Throws:
- java.security.GeneralSecurityException
 
 - 
generateMasterKeypublic static byte[] generateMasterKey(byte[] password) throws java.security.NoSuchAlgorithmException- Throws:
- java.security.NoSuchAlgorithmException
 
 - 
computeDigestAndPackageForSendingpublic io.netty.util.ReferenceCounted computeDigestAndPackageForSending(long entryId, long lastAddConfirmed, long length, io.netty.buffer.ByteBuf data, byte[] masterKey, int flags)Computes the digest for an entry and put bytes together for sending.- Parameters:
- entryId-
- lastAddConfirmed-
- length-
- data-
- Returns:
 
 - 
computeDigestAndPackageForSendingLacpublic ByteBufList computeDigestAndPackageForSendingLac(long lac) Computes the digest for writeLac for sending.- Parameters:
- lac-
- Returns:
 
 - 
verifyDigestAndReturnLacpublic long verifyDigestAndReturnLac(io.netty.buffer.ByteBuf dataReceived) throws BKException.BKDigestMatchException
 - 
verifyDigestAndReturnDatapublic io.netty.buffer.ByteBuf verifyDigestAndReturnData(long entryId, io.netty.buffer.ByteBuf dataReceived) throws BKException.BKDigestMatchExceptionVerify that the digest matches and returns the data in the entry.- Parameters:
- entryId-
- dataReceived-
- Returns:
- Throws:
- BKException.BKDigestMatchException
 
 - 
verifyDigestAndReturnLastConfirmedpublic DigestManager.RecoveryData verifyDigestAndReturnLastConfirmed(io.netty.buffer.ByteBuf dataReceived) throws BKException.BKDigestMatchException 
 - 
acceptsMemoryAddressBufferabstract boolean acceptsMemoryAddressBuffer() 
 
- 
 
-