try {
LOG.info ("Request " + requestList.size() +
" resources from session: " + handle);
if (!checkResourceRequestType(requestList)) {
LOG.error ("Bad resource type from session: " + handle);
throw new TApplicationException("Bad resource type");
}
if (!checkResourceRequestExcluded(requestList)) {
LOG.error("Bad excluded hosts from session: " + handle);
throw new TApplicationException("Requesting excluded hosts");
}
sessionManager.heartbeat(handle);
List<ResourceRequestInfo> reqInfoList =
new ArrayList<ResourceRequestInfo>(requestList.size());
for (ResourceRequest request : requestList) {
List<String> hosts = request.getHosts();
List<RequestedNode> requestedNodes = null;
if (hosts != null && hosts.size() > 0) {
requestedNodes = new ArrayList<RequestedNode>(hosts.size());
for (String host : hosts) {
requestedNodes.add(nodeManager.resolve(host, request.type));
}
}
ResourceRequestInfo info =
new ResourceRequestInfo(request, requestedNodes);
reqInfoList.add(info);
}
sessionManager.requestResource(handle, reqInfoList);
for (ResourceRequest req : requestList) {
metrics.requestResource(req.type);
}
scheduler.notifyScheduler();
} catch (RuntimeException e) {
e.printStackTrace();
throw new TApplicationException(e.getMessage());
}
}