Search in sources :

Example 1 with StringMD5KeyCreator

use of com.ms.silverking.cloud.dht.client.serialization.internal.StringMD5KeyCreator in project SilverKing by Morgan-Stanley.

the class FileSegmentUtil method main.

public static void main(String[] args) {
    if (args.length != 4) {
        System.err.println("args: <key> <nsDir> <minSegment> <maxSegment>");
    } else {
        try {
            DHTKey key;
            File nsDir;
            int minSegment;
            int maxSegment;
            if (!args[0].equals("*")) {
                key = new StringMD5KeyCreator().createKey(args[0]);
            } else {
                key = null;
            }
            nsDir = new File(args[1]);
            minSegment = Integer.parseInt(args[2]);
            maxSegment = Integer.parseInt(args[3]);
            debugFiles(key, nsDir, minSegment, maxSegment);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
Also used : StringMD5KeyCreator(com.ms.silverking.cloud.dht.client.serialization.internal.StringMD5KeyCreator) DHTKey(com.ms.silverking.cloud.dht.common.DHTKey) File(java.io.File) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 2 with StringMD5KeyCreator

use of com.ms.silverking.cloud.dht.client.serialization.internal.StringMD5KeyCreator in project SilverKing by Morgan-Stanley.

the class NamespacePerspectiveOptionsImpl method keyCreatorFor.

private static <K> KeyCreator<K> keyCreatorFor(SerializationRegistry serializationRegistry, Class keyClass, KeyDigestType keyDigestType) {
    if (keyClass == String.class) {
        switch(keyDigestType) {
            case MD5:
                return (KeyCreator<K>) new StringMD5KeyCreator();
            default:
                throw new RuntimeException("Unsupported <keyClass, KeyDigestType>");
        }
    } else if (keyClass == Integer.class) {
        switch(keyDigestType) {
            case MD5:
                return (KeyCreator<K>) new IntegerMD5KeyCreator();
            default:
                throw new RuntimeException("Unsupported <keyClass, KeyDigestType>");
        }
    } else if (keyClass == Long.class) {
        switch(keyDigestType) {
            case MD5:
                return (KeyCreator<K>) new LongMD5KeyCreator();
            default:
                throw new RuntimeException("Unsupported <keyClass, KeyDigestType>");
        }
    } else if (keyClass == UUID.class) {
        switch(keyDigestType) {
            case MD5:
                return (KeyCreator<K>) new UUIDMD5KeyCreator();
            default:
                throw new RuntimeException("Unsupported <keyClass, KeyDigestType>");
        }
    } else if (keyClass == byte[].class) {
        switch(keyDigestType) {
            case MD5:
                return (KeyCreator<K>) new ArrayMD5KeyCreator();
            default:
                throw new RuntimeException("Unsupported <keyClass, KeyDigestType>");
        }
    } else {
        BufferDestSerializer<K> s;
        s = serializationRegistry.getSerializer(keyClass);
        if (s != null) {
            return new SerializedMD5KeyCreator(s);
        } else {
            throw new IllegalArgumentException("Unsupported key class. " + "No custom serializer, and no serializer found: " + keyClass);
        }
    }
}
Also used : StringMD5KeyCreator(com.ms.silverking.cloud.dht.client.serialization.internal.StringMD5KeyCreator) IntegerMD5KeyCreator(com.ms.silverking.cloud.dht.client.serialization.internal.IntegerMD5KeyCreator) UUIDMD5KeyCreator(com.ms.silverking.cloud.dht.client.serialization.internal.UUIDMD5KeyCreator) LongMD5KeyCreator(com.ms.silverking.cloud.dht.client.serialization.internal.LongMD5KeyCreator) ArrayMD5KeyCreator(com.ms.silverking.cloud.dht.client.serialization.internal.ArrayMD5KeyCreator) IntegerMD5KeyCreator(com.ms.silverking.cloud.dht.client.serialization.internal.IntegerMD5KeyCreator) SerializedMD5KeyCreator(com.ms.silverking.cloud.dht.client.serialization.internal.SerializedMD5KeyCreator) UUIDMD5KeyCreator(com.ms.silverking.cloud.dht.client.serialization.internal.UUIDMD5KeyCreator) StringMD5KeyCreator(com.ms.silverking.cloud.dht.client.serialization.internal.StringMD5KeyCreator) LongMD5KeyCreator(com.ms.silverking.cloud.dht.client.serialization.internal.LongMD5KeyCreator) ArrayMD5KeyCreator(com.ms.silverking.cloud.dht.client.serialization.internal.ArrayMD5KeyCreator) SerializedMD5KeyCreator(com.ms.silverking.cloud.dht.client.serialization.internal.SerializedMD5KeyCreator) UUID(java.util.UUID)

Aggregations

StringMD5KeyCreator (com.ms.silverking.cloud.dht.client.serialization.internal.StringMD5KeyCreator)2 ArrayMD5KeyCreator (com.ms.silverking.cloud.dht.client.serialization.internal.ArrayMD5KeyCreator)1 IntegerMD5KeyCreator (com.ms.silverking.cloud.dht.client.serialization.internal.IntegerMD5KeyCreator)1 LongMD5KeyCreator (com.ms.silverking.cloud.dht.client.serialization.internal.LongMD5KeyCreator)1 SerializedMD5KeyCreator (com.ms.silverking.cloud.dht.client.serialization.internal.SerializedMD5KeyCreator)1 UUIDMD5KeyCreator (com.ms.silverking.cloud.dht.client.serialization.internal.UUIDMD5KeyCreator)1 DHTKey (com.ms.silverking.cloud.dht.common.DHTKey)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 UUID (java.util.UUID)1