Search in sources :

Example 41 with DHTKey

use of com.ms.silverking.cloud.dht.common.DHTKey in project SilverKing by Morgan-Stanley.

the class FileSegmentCompactor method compact.

public static HashedSetMap<DHTKey, Triple<Long, Integer, Long>> compact(File nsDir, int segmentNumber, NamespaceOptions nsOptions, EntryRetentionCheck retentionCheck) throws IOException {
    FileSegment compactedSegment;
    File oldFile;
    File trashFile;
    File newFile;
    HashedSetMap<DHTKey, Triple<Long, Integer, Long>> removedEntries;
    removedEntries = new HashedSetMap<>();
    compactedSegment = createCompactedSegment(nsDir, segmentNumber, nsOptions, nsOptions.getSegmentSize(), retentionCheck, removedEntries, nsOptions.getRevisionMode() == RevisionMode.UNRESTRICTED_REVISIONS);
    compactedSegment.persist();
    Log.warning("Swapping to compacted segment: ", segmentNumber);
    oldFile = FileSegment.fileForSegment(nsDir, segmentNumber);
    newFile = getCompactionFile(nsDir, segmentNumber);
    trashFile = getTrashFile(nsDir, segmentNumber);
    // Leave old file around for one cycle in case there are references to it
    rename(oldFile, trashFile);
    rename(newFile, oldFile);
    Log.warning("Done swapping to compacted segment: ", segmentNumber);
    return removedEntries;
}
Also used : Triple(com.ms.silverking.collection.Triple) DHTKey(com.ms.silverking.cloud.dht.common.DHTKey) File(java.io.File)

Example 42 with DHTKey

use of com.ms.silverking.cloud.dht.common.DHTKey in project SilverKing by Morgan-Stanley.

the class ActiveProxyPut method localOp.

protected void localOp(List<? extends DHTKey> _entries, OpCommunicator<MessageGroupKeyEntry, PutResult> comm) {
    boolean useUpdate;
    PutCommunicator pComm;
    pComm = (PutCommunicator) comm;
    useUpdate = _entries.size() > 0 && (_entries.get(0) instanceof MessageGroupKeyOrdinalEntry);
    if (!useUpdate) {
        List<StorageValueAndParameters> values;
        long creationTime;
        creationTime = SystemTimeUtil.systemTimeSource.absTimeNanos();
        values = new ArrayList<>(_entries.size());
        for (DHTKey _entry : _entries) {
            values.add(new StorageValueAndParameters((MessageGroupPutEntry) _entry, (PutOperationContainer) this, creationTime));
            if (debug) {
                System.out.printf("localOp: %s\n", _entry);
            }
        // Log.fine(entry);
        }
        getStorage().put(getContext(), values, getUserData(), pComm);
        if (forwardingMode.forwards()) {
            for (DHTKey _entry : _entries) {
                storageOperation.localUpdate(_entry, StorageProtocolUtil.initialStorageStateOrdinal, OpResult.SUCCEEDED, pComm);
            }
        }
    } else {
        localOp_putupdate(_entries, pComm);
    }
}
Also used : MessageGroupKeyOrdinalEntry(com.ms.silverking.cloud.dht.net.MessageGroupKeyOrdinalEntry) PutCommunicator(com.ms.silverking.cloud.dht.daemon.storage.protocol.PutCommunicator) DHTKey(com.ms.silverking.cloud.dht.common.DHTKey) PutOperationContainer(com.ms.silverking.cloud.dht.daemon.storage.protocol.PutOperationContainer) StorageValueAndParameters(com.ms.silverking.cloud.dht.daemon.storage.StorageValueAndParameters) MessageGroupPutEntry(com.ms.silverking.cloud.dht.net.MessageGroupPutEntry)

Example 43 with DHTKey

use of com.ms.silverking.cloud.dht.common.DHTKey in project SilverKing by Morgan-Stanley.

the class IntegerSHA1KeyCreator method main.

public static void main(String[] args) {
    IntegerSHA1KeyCreator integerSHA1KeyCreator;
    DHTKey key;
    DHTKey[] subKeys;
    int numSubKeys;
    integerSHA1KeyCreator = new IntegerSHA1KeyCreator();
    key = integerSHA1KeyCreator.createKey(12345);
    numSubKeys = 5;
    subKeys = integerSHA1KeyCreator.createSubKeys(key, numSubKeys);
    System.out.println(key);
    for (int i = 0; i < subKeys.length; i++) {
        System.out.printf("%d\t%s\n", i, subKeys[i]);
    }
}
Also used : DHTKey(com.ms.silverking.cloud.dht.common.DHTKey)

Example 44 with DHTKey

use of com.ms.silverking.cloud.dht.common.DHTKey in project SilverKing by Morgan-Stanley.

the class IntegerMD5KeyCreator method main.

public static void main(String[] args) {
    IntegerMD5KeyCreator integerMD5KeyCreator;
    DHTKey key;
    DHTKey[] subKeys;
    int numSubKeys;
    integerMD5KeyCreator = new IntegerMD5KeyCreator();
    key = integerMD5KeyCreator.createKey(12345);
    numSubKeys = 5;
    subKeys = integerMD5KeyCreator.createSubKeys(key, numSubKeys);
    System.out.println(key);
    for (int i = 0; i < subKeys.length; i++) {
        System.out.printf("%d\t%s\n", i, subKeys[i]);
    }
}
Also used : DHTKey(com.ms.silverking.cloud.dht.common.DHTKey)

Example 45 with DHTKey

use of com.ms.silverking.cloud.dht.common.DHTKey in project SilverKing by Morgan-Stanley.

the class SingleKeyToDHTKeyMap method remove.

@Override
public DHTKey remove(Object key) {
    if (this.key != null && key.equals(this.key)) {
        DHTKey _dhtKey;
        _dhtKey = this.dhtKey;
        this.key = null;
        this.dhtKey = null;
        return _dhtKey;
    } else {
        return null;
    }
}
Also used : DHTKey(com.ms.silverking.cloud.dht.common.DHTKey)

Aggregations

DHTKey (com.ms.silverking.cloud.dht.common.DHTKey)47 VersionConstraint (com.ms.silverking.cloud.dht.VersionConstraint)10 OpResult (com.ms.silverking.cloud.dht.common.OpResult)7 ByteBuffer (java.nio.ByteBuffer)7 KeyAndVersionChecksum (com.ms.silverking.cloud.dht.daemon.storage.KeyAndVersionChecksum)5 SimpleKey (com.ms.silverking.cloud.dht.common.SimpleKey)4 MessageGroupKeyOrdinalEntry (com.ms.silverking.cloud.dht.net.MessageGroupKeyOrdinalEntry)4 MessageGroupRetrievalResponseEntry (com.ms.silverking.cloud.dht.net.MessageGroupRetrievalResponseEntry)4 IOException (java.io.IOException)4 WeakReference (java.lang.ref.WeakReference)4 InternalRetrievalOptions (com.ms.silverking.cloud.dht.common.InternalRetrievalOptions)3 ConvergencePoint (com.ms.silverking.cloud.dht.daemon.storage.convergence.ConvergencePoint)3 ProtoRetrievalMessageGroup (com.ms.silverking.cloud.dht.net.ProtoRetrievalMessageGroup)3 Triple (com.ms.silverking.collection.Triple)3 File (java.io.File)3 Map (java.util.Map)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 ConcurrentMap (java.util.concurrent.ConcurrentMap)3 RetrievalOptions (com.ms.silverking.cloud.dht.RetrievalOptions)2 DHTKeyIntEntry (com.ms.silverking.cloud.dht.collection.DHTKeyIntEntry)2