public void doRequest(ServerData serverData) {
UnsafeByteArrayOutputStream reusedOut = new UnsafeByteArrayOutputStream();
UnsafeReusableByteArrayInput reusedIn = new UnsafeReusableByteArrayInput();
DataInput input = getDataInput();
AllAggregatorServerData aggregatorData = serverData.getAllAggregatorData();
try {
int num = input.readInt();
for (int i = 0; i < num; i++) {
String name = input.readUTF();
GlobalCommType type = GlobalCommType.values()[input.readByte()];
Writable value = WritableUtils.readWritableObject(input, conf);
if (type == GlobalCommType.SPECIAL_COUNT) {
aggregatorData.receivedRequestCountFromMaster(
((LongWritable) value).get(),
getSenderTaskId());
} else {
aggregatorData.receiveValueFromMaster(name, type, value);
if (type == GlobalCommType.REDUCE_OPERATIONS) {
ReduceOperation<Object, Writable> reduceOpCopy =
(ReduceOperation<Object, Writable>)
WritableUtils.createCopy(reusedOut, reusedIn, value, conf);
serverData.getOwnerAggregatorData().registerReducer(
name, reduceOpCopy);
}
}
}
} catch (IOException e) {
throw new IllegalStateException("doRequest: " +
"IOException occurred while processing request", e);
}
aggregatorData.receivedRequestFromMaster(getData());
}