use of com.ms.silverking.cloud.dht.client.ChecksumType in project SilverKing by Morgan-Stanley.
the class SegmentationUtil method getChecksum.
static byte[] getChecksum(ByteBuffer buf) {
ChecksumType checksumType;
byte[] checksum;
checksumType = getChecksumType(buf);
checksum = new byte[checksumType.length()];
BufferUtil.get(buf, checksumOffset, checksum, checksumType.length());
return checksum;
}
use of com.ms.silverking.cloud.dht.client.ChecksumType in project SilverKing by Morgan-Stanley.
the class ValueUtil method verifyChecksum.
public static void verifyChecksum(byte[] storedValue, int storedOffset, byte[] value, int valueOffset, int valueLength) throws CorruptValueException {
byte[] expectedChecksum;
byte[] actualChecksum;
ChecksumType checksumType;
Checksum checksum;
if (debugChecksum) {
System.out.println("storedValue: " + StringUtil.byteArrayToHexString(storedValue));
}
checksumType = MetaDataUtil.getChecksumType(storedValue, storedOffset);
if (checksumType != ChecksumType.NONE) {
actualChecksum = MetaDataUtil.getChecksum(storedValue, storedOffset);
checksum = ChecksumProvider.getChecksum(checksumType);
if (!checksum.isEmpty(actualChecksum)) {
expectedChecksum = checksum.checksum(value, valueOffset, valueLength);
if (debugChecksum) {
System.out.println("valueOffset: " + valueOffset);
System.out.println("valueLength: " + valueLength);
System.out.println("value: " + StringUtil.byteArrayToHexString(value, valueOffset, valueLength) + "\t" + valueLength);
System.out.println("value: " + new String(value, valueOffset, valueLength));
System.out.println("expectedChecksum: " + StringUtil.byteArrayToHexString(expectedChecksum));
System.out.println("actualChecksum: " + StringUtil.byteArrayToHexString(actualChecksum));
System.out.flush();
}
if (!Arrays.equals(expectedChecksum, actualChecksum)) {
throw new CorruptValueException(StringUtil.byteArrayToHexString(actualChecksum) + " != " + StringUtil.byteArrayToHexString(expectedChecksum));
}
}
}
}
use of com.ms.silverking.cloud.dht.client.ChecksumType in project SilverKing by Morgan-Stanley.
the class MetaDataUtil method isInvalidated.
public static boolean isInvalidated(byte[] storedValue, int baseOffset) {
ChecksumType checksumType;
checksumType = getChecksumType(storedValue, baseOffset);
if (checksumType == ChecksumType.SYSTEM) {
byte[] actualChecksum;
actualChecksum = getChecksum(storedValue, baseOffset);
return SystemChecksum.isInvalidationChecksum(actualChecksum);
} else {
return false;
}
}
use of com.ms.silverking.cloud.dht.client.ChecksumType in project SilverKing by Morgan-Stanley.
the class MetaDataUtil method getChecksumLength.
private static int getChecksumLength(byte[] storedValue, int baseOffset) {
ChecksumType checksumType;
checksumType = getChecksumType(storedValue, baseOffset);
return checksumType.length();
}
use of com.ms.silverking.cloud.dht.client.ChecksumType in project SilverKing by Morgan-Stanley.
the class MetaDataUtil method isInvalidated.
public static boolean isInvalidated(ByteBuffer storedValue, int baseOffset) {
ChecksumType checksumType;
checksumType = getChecksumType(storedValue, baseOffset);
if (checksumType == ChecksumType.SYSTEM) {
byte[] actualChecksum;
actualChecksum = getChecksum(storedValue, baseOffset);
return SystemChecksum.isInvalidationChecksum(actualChecksum);
} else {
return false;
}
}
Aggregations