Search in sources :

Example 6 with SSStorageParameters

use of com.ms.silverking.cloud.dht.serverside.SSStorageParameters 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);
}
Also used : StorageParameters(com.ms.silverking.cloud.dht.daemon.storage.StorageParameters) SSStorageParameters(com.ms.silverking.cloud.dht.serverside.SSStorageParameters) SSStorageParameters(com.ms.silverking.cloud.dht.serverside.SSStorageParameters)

Example 7 with SSStorageParameters

use of com.ms.silverking.cloud.dht.serverside.SSStorageParameters 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);
}
Also used : StorageParameters(com.ms.silverking.cloud.dht.daemon.storage.StorageParameters) SSStorageParameters(com.ms.silverking.cloud.dht.serverside.SSStorageParameters) ByteBuffer(java.nio.ByteBuffer)

Aggregations

SSStorageParameters (com.ms.silverking.cloud.dht.serverside.SSStorageParameters)7 StorageParameters (com.ms.silverking.cloud.dht.daemon.storage.StorageParameters)4 ByteBuffer (java.nio.ByteBuffer)3 VersionConstraint (com.ms.silverking.cloud.dht.VersionConstraint)2 DirectoryInPlace (com.ms.silverking.cloud.skfs.dir.DirectoryInPlace)2 Pair (com.ms.silverking.collection.Pair)2 IOException (java.io.IOException)2 File (java.io.File)1 Map (java.util.Map)1 NavigableMap (java.util.NavigableMap)1 TreeMap (java.util.TreeMap)1