Search in sources :

Example 1 with ValueRetentionPolicy

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

the class DirectoryInMemorySS method reap.

private void reap() {
    if (serializedVersions.size() > reapMinVersions) {
        ValueRetentionPolicy vrp;
        Set<Long> versionsToRemove;
        Log.warningf("Reap DirectoryInMemorySS %s", KeyUtil.keyToString(dirKey));
        versionsToRemove = new HashSet<>();
        vrp = nsOptions.getValueRetentionPolicy();
        if (vrp instanceof TimeAndVersionRetentionPolicy) {
            TimeAndVersionRetentionState rs;
            long curTimeNanos;
            rs = new TimeAndVersionRetentionState();
            curTimeNanos = SystemTimeSource.instance.absTimeNanos();
            for (long version : serializedVersions.descendingKeySet()) {
                if (!vrp.retains(dirKey, version, curTimeNanos, false, rs, curTimeNanos)) {
                    versionsToRemove.add(version);
                }
            }
        } else {
            Log.warning("Unexpected retention policy: " + vrp);
        }
        remove(versionsToRemove);
    }
}
Also used : TimeAndVersionRetentionState(com.ms.silverking.cloud.dht.TimeAndVersionRetentionState) ValueRetentionPolicy(com.ms.silverking.cloud.dht.ValueRetentionPolicy) TimeAndVersionRetentionPolicy(com.ms.silverking.cloud.dht.TimeAndVersionRetentionPolicy)

Example 2 with ValueRetentionPolicy

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

the class NamespaceStore method reap.

// //////////////////
// Retention
public void reap(boolean leaveTrash) {
    ValueRetentionPolicy vrp;
    vrp = nsOptions.getValueRetentionPolicy();
    Log.warningAsyncf("reap ns %x %s %s", ns, vrp, leaveTrash);
    if (vrp != null) {
        if (!leaveTrash) {
            FileSegmentCompactor.emptyTrashAndCompaction(nsDir);
        }
        writeLock.lock();
        metaWriteLock.lock();
        try {
            long curTimeNanos;
            curTimeNanos = systemTimeSource.absTimeNanos();
            switch(vrp.getImplementationType()) {
                case SingleReverseSegmentWalk:
                    singleReverseSegmentWalk(vrp, vrp.createInitialState(), curTimeNanos);
                    break;
                case RetainAll:
                    break;
                default:
                    throw new RuntimeException("Unsupported ValueRetentionPolicy ImplementationType: " + vrp.getImplementationType());
            }
        } finally {
            metaWriteLock.unlock();
            writeLock.unlock();
        }
        if (!leaveTrash) {
            FileSegmentCompactor.emptyTrashAndCompaction(nsDir);
        }
    }
}
Also used : ValueRetentionPolicy(com.ms.silverking.cloud.dht.ValueRetentionPolicy)

Example 3 with ValueRetentionPolicy

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

the class FileSegmentCompactor method main.

public static void main(String[] args) {
    try {
        if (args.length != 3) {
            System.out.println("args: <nsDir> <segmentNumber> <timeSpanSeconds>");
        } else {
            File nsDir;
            int segmentNumber;
            NamespaceOptions nsOptions;
            ValueRetentionPolicy valueRetentionPolicy;
            int timeSpanSeconds;
            nsDir = new File(args[0]);
            segmentNumber = Integer.parseInt(args[1]);
            timeSpanSeconds = Integer.parseInt(args[2]);
            valueRetentionPolicy = new TimeAndVersionRetentionPolicy(TimeAndVersionRetentionPolicy.Mode.wallClock, 1, timeSpanSeconds);
            nsOptions = DHTConstants.defaultNamespaceOptions.valueRetentionPolicy(valueRetentionPolicy);
            compact(nsDir, segmentNumber, nsOptions, new TestRetentionCheck(32768));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : NamespaceOptions(com.ms.silverking.cloud.dht.NamespaceOptions) ValueRetentionPolicy(com.ms.silverking.cloud.dht.ValueRetentionPolicy) File(java.io.File) TimeAndVersionRetentionPolicy(com.ms.silverking.cloud.dht.TimeAndVersionRetentionPolicy) IOException(java.io.IOException)

Aggregations

ValueRetentionPolicy (com.ms.silverking.cloud.dht.ValueRetentionPolicy)3 TimeAndVersionRetentionPolicy (com.ms.silverking.cloud.dht.TimeAndVersionRetentionPolicy)2 NamespaceOptions (com.ms.silverking.cloud.dht.NamespaceOptions)1 TimeAndVersionRetentionState (com.ms.silverking.cloud.dht.TimeAndVersionRetentionState)1 File (java.io.File)1 IOException (java.io.IOException)1