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;
}
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);
}
}
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]);
}
}
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]);
}
}
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;
}
}
Aggregations