use of com.ms.silverking.cloud.dht.daemon.storage.protocol.PutCommunicator in project SilverKing by Morgan-Stanley.
the class ActiveProxyPut method startOperation.
void startOperation() {
PutCommunicator pComm;
if (debug) {
System.out.println(this + " " + forwardingMode + " " + storageOperation);
}
pComm = new PutCommunicator(this);
if (forwardingMode.forwards()) {
messageModule.addActivePut(uuid, this);
}
super.startOperation(pComm, message.getPutValueKeyIterator(ProtoPutMessageGroup.getChecksumType(message)), new PutForwardCreator());
// super.startOperation() will forward initial puts. Now we need to forward any
// state updates created due to local processing.
forwardGroupedEntries(pComm.takeReplicaUpdateMessageLists(), optionsByteBuffer, new PutUpdateForwardCreator(storageOperation.nextStorageState(storageOperation.initialStorageState())), pComm);
// free payload for GC
message = null;
}
use of com.ms.silverking.cloud.dht.daemon.storage.protocol.PutCommunicator 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.daemon.storage.protocol.PutCommunicator in project SilverKing by Morgan-Stanley.
the class ActiveProxyPut method handlePutResponse.
// ///////////////////
// handle responses
/**
* Process a put response according to the protocol in use by this StorageOperation.
*
* @param message
* @param _connection
* @return
*/
OpResult handlePutResponse(MessageGroup message, MessageGroupConnectionProxy _connection) {
PutCommunicator pComm;
byte storageState;
pComm = new PutCommunicator(this);
if (debug) {
System.out.println("handlePutResponse");
}
storageState = ProtoPutResponseMessageGroup.getStorageState(message);
for (MessageGroupKeyOrdinalEntry entry : message.getKeyOrdinalIterator()) {
IPAndPort replica;
replica = new IPAndPort(message.getOriginator(), DHTNode.getServerPort());
if (debug) {
System.out.println("replica: " + replica);
}
storageOperation.update(entry.getKey(), replica, storageState, EnumValues.opResult[entry.getOrdinal()], pComm);
}
// forward state updates
Map<IPAndPort, List<MessageGroupKeyOrdinalEntry>> rumLists;
rumLists = pComm.takeReplicaUpdateMessageLists();
if (rumLists.size() > 0) {
forwardGroupedEntries(rumLists, optionsByteBuffer, new PutUpdateForwardCreator(storageOperation.nextStorageState(storageState)), pComm);
}
// send responses for completions
messageModule.sendPutResults(message, version, connection, pComm.takeResults(), storageState, message.getDeadlineRelativeMillis());
return storageOperation.getOpResult();
}
Aggregations