use of com.ms.silverking.cloud.dht.daemon.storage.StorageParameters in project SilverKing by Morgan-Stanley.
the class DirectoryInMemorySS method serializeDir.
/*
public DirectoryInMemorySS(byte[] buf, int offset, int limit, SSStorageParameters storageParams) {
super(buf, offset, limit);
this.storageParams = storageParams;
}
*/
public Pair<SSStorageParameters, byte[]> serializeDir() {
byte[] serializedDir;
StorageParameters sp;
byte[] checksum;
serializedDir = serialize();
checksum = new byte[0];
sp = new StorageParameters(latestUpdateSP.getVersion(), serializedDir.length, serializedDir.length, CCSSUtil.createCCSS(Compression.NONE, ChecksumType.NONE), checksum, latestUpdateSP.getValueCreator(), latestUpdateSP.getCreationTime());
return new Pair<>(sp, serializedDir);
}
use of com.ms.silverking.cloud.dht.daemon.storage.StorageParameters in project SilverKing by Morgan-Stanley.
the class DataMigrationTool method migrateEntry.
private void migrateEntry(DataSegmentWalkEntry entry, File ssDir) throws IOException {
ByteBuffer valueBuf;
byte[] value;
File dirDir;
StorageParameters newSP;
StorageParameters o;
// System.out.printf("\n ------------- \n%s\n", StringUtil.byteBufferToHexString(entry.getStoredFormat()));
valueBuf = entry.getValue();
value = BufferUtil.arrayCopy(valueBuf);
// System.out.printf("\n......... \n%s\n", StringUtil.byteArrayToHexString(value));
File destFile;
dirDir = new File(ssDir, KeyUtil.keyToString(entry.getKey()));
if (!dirDir.exists()) {
if (!dirDir.mkdir()) {
throw new RuntimeException("Unable to create: " + dirDir);
}
}
o = entry.getStorageParameters();
newSP = new StorageParameters(o.getVersion(), value.length, value.length, CCSSUtil.createCCSS(Compression.NONE, o.getChecksumType(), o.getStorageState()), o.getChecksum(), o.getValueCreator(), o.getCreationTime());
destFile = new File(dirDir, Long.toString(entry.getVersion()));
FileUtil.writeToFile(destFile, StorageParameterSerializer.serialize(newSP), value);
if (displayDirs) {
DirectoryInMemorySS dim;
Pair<SSStorageParameters, byte[]> p;
DirectoryInPlace dip;
dim = new DirectoryInMemorySS(entry.getKey(), null, entry.getStorageParameters(), new File(ssDir, KeyUtil.keyToString(entry.getKey())), null, false);
p = dim.readFromDisk(entry.getStorageParameters().getVersion());
System.out.println(p.getV1());
// System.out.println(StringUtil.byteArrayToHexString(p.getV2()));
dip = new DirectoryInPlace(p.getV2(), 0, p.getV2().length);
dip.display();
}
}
use of com.ms.silverking.cloud.dht.daemon.storage.StorageParameters in project SilverKing by Morgan-Stanley.
the class StorageParameterSerializer method main.
public static void main(String[] args) {
StorageParameters p1;
SSStorageParameters p2;
byte[] checksum;
byte[] valueCreator;
byte[] s;
checksum = new byte[ChecksumType.MD5.length()];
valueCreator = new byte[ValueCreator.BYTES];
p1 = new StorageParameters(1, 2, 3, CCSSUtil.createCCSS(Compression.NONE, ChecksumType.MD5, 0), checksum, valueCreator, System.currentTimeMillis());
System.out.println(p1);
s = serialize(p1);
p2 = deserialize(s);
System.out.println(p2);
}
use of com.ms.silverking.cloud.dht.daemon.storage.StorageParameters in project SilverKing by Morgan-Stanley.
the class StorageParameterSerializer method deserialize.
public static SSStorageParameters deserialize(byte[] a) {
ByteBuffer b;
long version;
int uncompressedSize;
int compressedSize;
short ccss;
byte[] checksum;
byte[] valueCreator;
long creationTime;
b = ByteBuffer.wrap(a);
version = b.getLong();
uncompressedSize = b.getInt();
compressedSize = b.getInt();
creationTime = b.getLong();
ccss = b.getShort();
valueCreator = BufferUtil.arrayCopy(b, ValueCreator.BYTES);
checksum = BufferUtil.arrayCopy(b, CCSSUtil.getChecksumType(ccss).length());
return new StorageParameters(version, uncompressedSize, compressedSize, ccss, checksum, valueCreator, creationTime);
}
Aggregations