use of com.ms.silverking.cloud.dht.net.MessageGroup in project SilverKing by Morgan-Stanley.
the class MessageGroupTest method receive.
@Override
public void receive(MessageGroup message, MessageGroupConnection connection) {
Log.fine("received: ", message);
switch(mode) {
case client:
semaphore.release();
messagesReceived.incrementAndGet();
break;
case server:
try {
InetSocketAddress other;
MessageGroup msg;
other = new InetSocketAddress(connection.getRemoteSocketAddress().getHostName(), testClientPort);
msg = createMessage(NumConversion.intToBytes(testClientPort));
paServer.send(other, msg, false, Long.MAX_VALUE);
// connection.sendAsynchronous(bufferedData, Long.MAX_VALUE);
} catch (IOException ioe) {
ioe.printStackTrace();
}
break;
default:
throw new RuntimeException("panic");
}
}
use of com.ms.silverking.cloud.dht.net.MessageGroup in project SilverKing by Morgan-Stanley.
the class OpSender method createMessages.
/**
* Given a group of same-typed operations, create and send messages.
* @param asyncOpImpls
* @param startIndex
* @param endIndex
*/
private void createMessages(AsyncOperationImpl[] asyncOpImpls, int startIndex, int endIndex) {
ProtoMessageGroup protoMG;
List<MessageGroup> messageGroups;
MessageEstimate estimate;
estimate = estimateMessage(asyncOpImpls, startIndex, endIndex);
protoMG = asyncOpImpls[startIndex].createProtoMG(estimate);
if (debug) {
System.out.printf("asyncOpImpls.length %d startIndex %d endIndex %d\n", asyncOpImpls.length, startIndex, endIndex);
}
messageGroups = new ArrayList<>();
// then create a new protoMG and add the old to the messageGroups list.
for (int i = startIndex; i <= endIndex; i++) {
if (debug) {
System.out.printf("Calling create with %s\tfor%s\n", protoMG.getUUID(), asyncOpImpls[i].objectToString());
}
protoMG = asyncOpImpls[i].createMessagesForIncomplete(protoMG, messageGroups, estimate);
}
// Add the final protoMG to the list if it is non-empty
protoMG.addToMessageGroupList(messageGroups);
// FUTURE - consider sending sooner, in creation loop
for (MessageGroup messageGroup : messageGroups) {
if (debug) {
System.out.println("OpSender sending:");
System.out.println(messageGroup);
messageGroup.displayForDebug();
}
send(messageGroup);
}
}
use of com.ms.silverking.cloud.dht.net.MessageGroup in project SilverKing by Morgan-Stanley.
the class DHTRingMaster method requestChecksumTree.
public void requestChecksumTree(Triple<Long, Long, Long> nsAndRegion, ConvergencePoint curCP, ConvergencePoint targetCP, IPAndPort owner) {
MessageGroup mg;
UUIDBase uuid;
uuid = UUIDBase.random();
mg = new ProtoChecksumTreeRequestMessageGroup(uuid, nsAndRegion.getV1(), targetCP, curCP, mgBase.getMyID(), new RingRegion(nsAndRegion.getV2(), nsAndRegion.getV3()), mgBase._getIPAndPort(), false).toMessageGroup();
mgBase.send(mg, owner);
}
use of com.ms.silverking.cloud.dht.net.MessageGroup in project SilverKing by Morgan-Stanley.
the class CentralConvergenceController method sendSetState.
private UUIDBase sendSetState(UUIDBase uuid, IPAndPort replica, RingState ringState) {
MessageGroup mg;
mg = new ProtoSetConvergenceStateMessageGroup(uuid, mgBase.getMyID(), setStateDeadlineRelativeMillis, curCP, targetCP, ringState).toMessageGroup();
mgBase.send(mg, replica);
return uuid;
}
use of com.ms.silverking.cloud.dht.net.MessageGroup in project SilverKing by Morgan-Stanley.
the class ConvergenceController2 method sendChecksumTreeRequest.
private void sendChecksumTreeRequest(ChecksumTreeRequest ctr) {
MessageGroup mg;
UUIDBase uuid;
uuid = UUIDBase.random();
outstandingChecksumTreeRequests.put(uuid, ctr);
convergenceControllers.put(uuid, this);
mg = new ProtoChecksumTreeRequestMessageGroup(uuid, ns, ctr.getTargetCP(), ctr.getCurCP(), mgBase.getMyID(), ctr.getRegion(), false).toMessageGroup();
if (verbose || debug) {
Log.warningAsyncf("%x requestChecksumTree: %s\t%s\t%s\t%s", ns, ctr.getReplica(), ctr.getRegion(), ctr.getTargetCP(), ctr.getCurCP());
}
mgBase.send(mg, ctr.getReplica());
ctr.setSent();
}
Aggregations