}
// Add the message to the cache
int idSerializerPos = 0;
int workerMessageSize = 0;
byte[] serializedId = null;
WritableRequest writableRequest = null;
for (int i = 0; i < idCounter.length; i++) {
if (idCounter[i] == 1) {
serializedId = idSerializer[i].getByteArray();
idSerializerPos = idSerializer[i].getPos();
// Add the message to the cache
workerMessageSize = addMessage(workerInfoList[i],
firstPartitionMap[i], serializedId, idSerializerPos, message);
if (LOG.isTraceEnabled()) {
LOG.trace("sendMessageToAllRequest: Send bytes (" +
message.toString() + ") to one target in worker " +
workerInfoList[i]);
}
++totalMsgsSentInSuperstep;
if (workerMessageSize >= maxMessagesSizePerWorker) {
PairList<Integer, VertexIdMessages<I, M>>
workerMessages = removeWorkerMessages(workerInfoList[i]);
writableRequest = new SendWorkerMessagesRequest<>(workerMessages);
totalMsgBytesSentInSuperstep += writableRequest.getSerializedSize();
clientProcessor.doRequest(workerInfoList[i], writableRequest);
// Notify sending
getServiceWorker().getGraphTaskManager().notifySentMessages();
}
} else if (idCounter[i] > 1) {
serializedId = idSerializer[i].getByteArray();
idSerializerPos = idSerializer[i].getPos();
workerMessageSize = addOneToManyMessage(
workerInfoList[i], serializedId, idSerializerPos, idCounter[i],
message);
if (LOG.isTraceEnabled()) {
LOG.trace("sendMessageToAllRequest: Send bytes (" +
message.toString() + ") to all targets in worker" +
workerInfoList[i]);
}
totalMsgsSentInSuperstep += idCounter[i];
if (workerMessageSize >= maxMessagesSizePerWorker) {
ByteArrayOneMessageToManyIds<I, M> workerMsgVids =
removeWorkerMsgVids(workerInfoList[i]);
writableRequest = new SendWorkerOneMessageToManyRequest<>(
workerMsgVids, getConf());
totalMsgBytesSentInSuperstep += writableRequest.getSerializedSize();
clientProcessor.doRequest(workerInfoList[i], writableRequest);
// Notify sending
getServiceWorker().getGraphTaskManager().notifySentMessages();
}
}