本文整理汇总了Java中org.apache.hadoop.mapreduce.server.jobtracker.TaskTracker.getAvailableSlots方法的典型用法代码示例。如果您正苦于以下问题:Java TaskTracker.getAvailableSlots方法的具体用法?Java TaskTracker.getAvailableSlots怎么用?Java TaskTracker.getAvailableSlots使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.mapreduce.server.jobtracker.TaskTracker
的用法示例。
在下文中一共展示了TaskTracker.getAvailableSlots方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: assignTasks
import org.apache.hadoop.mapreduce.server.jobtracker.TaskTracker; //导入方法依赖的package包/类
private TaskLookupResult assignTasks(TaskTracker taskTracker)
throws IOException {
TaskTrackerStatus taskTrackerStatus = taskTracker.getStatus();
printQSIs();
// Check if this tasktracker has been reserved for a job...
JobInProgress job = taskTracker.getJobForFallowSlot(type);
if (job != null) {
int availableSlots = taskTracker.getAvailableSlots(type);
if (LOG.isDebugEnabled()) {
LOG.debug(job.getJobID() + ": Checking 'reserved' tasktracker " +
taskTracker.getTrackerName() + " with " + availableSlots +
" '" + type + "' slots");
}
if (availableSlots >= job.getNumSlotsPerTask(type)) {
// Unreserve
taskTracker.unreserveSlots(type, job);
// We found a suitable job. Get task from it.
Task t = obtainNewTask(taskTrackerStatus, job);
//if there is a task return it immediately.
if (t != null) {
if (LOG.isDebugEnabled()) {
LOG.info(job.getJobID() + ": Got " + t.getTaskID() +
" for reserved tasktracker " +
taskTracker.getTrackerName());
}
// we're successful in getting a task
return TaskLookupResult.getTaskFoundResult(t);
}
} else {
// Re-reserve the current tasktracker
taskTracker.reserveSlots(type, job, availableSlots);
if (LOG.isDebugEnabled()) {
LOG.debug(job.getJobID() + ": Re-reserving " +
taskTracker.getTrackerName());
}
return TaskLookupResult.getMemFailedResult();
}
}
for (QueueSchedulingInfo qsi : qsiForAssigningTasks) {
// we may have queues with capacity=0. We shouldn't look at jobs from
// these queues
if (0 == getTSI(qsi).getCapacity()) {
continue;
}
//This call is for optimization if we are already over the
//maximum-capacity we avoid traversing the queues.
if(this.areTasksInQueueOverMaxCapacity(qsi,1)) {
continue;
}
TaskLookupResult tlr = getTaskFromQueue(taskTracker, qsi);
TaskLookupResult.LookUpStatus lookUpStatus = tlr.getLookUpStatus();
if (lookUpStatus == TaskLookupResult.LookUpStatus.NO_TASK_FOUND) {
continue; // Look in other queues.
}
// if we find a task, return
if (lookUpStatus == TaskLookupResult.LookUpStatus.TASK_FOUND) {
return tlr;
}
// if there was a memory mismatch, return
else if (lookUpStatus ==
TaskLookupResult.LookUpStatus.TASK_FAILING_MEMORY_REQUIREMENT) {
return tlr;
}
}
// nothing to give
return TaskLookupResult.getNoTaskFoundResult();
}
示例2: assignTasks
import org.apache.hadoop.mapreduce.server.jobtracker.TaskTracker; //导入方法依赖的package包/类
private TaskLookupResult assignTasks(TaskTracker taskTracker)
throws IOException {
TaskTrackerStatus taskTrackerStatus = taskTracker.getStatus();
printQSCs();
// Check if this tasktracker has been reserved for a job...
JobInProgress job = taskTracker.getJobForFallowSlot(type);
if (job != null) {
int availableSlots = taskTracker.getAvailableSlots(type);
if (LOG.isDebugEnabled()) {
LOG.debug(job.getJobID() + ": Checking 'reserved' tasktracker " +
taskTracker.getTrackerName() + " with " + availableSlots +
" '" + type + "' slots");
}
if (availableSlots >= job.getNumSlotsPerTask(type)) {
// Unreserve
taskTracker.unreserveSlots(type, job);
// We found a suitable job. Get task from it.
Task t = obtainNewTask(taskTrackerStatus, job);
//if there is a task return it immediately.
if (t != null) {
if (LOG.isDebugEnabled()) {
LOG.info(job.getJobID() + ": Got " + t.getTaskID() +
" for reserved tasktracker " +
taskTracker.getTrackerName());
}
// we're successful in getting a task
return TaskLookupResult.getTaskFoundResult(t);
}
} else {
// Re-reserve the current tasktracker
taskTracker.reserveSlots(type, job, availableSlots);
if (LOG.isDebugEnabled()) {
LOG.debug(job.getJobID() + ": Re-reserving " +
taskTracker.getTrackerName());
}
return TaskLookupResult.getMemFailedResult();
}
}
for (AbstractQueue q : getOrderedJobQueues()) {
QueueSchedulingContext qsc = q.getQueueSchedulingContext();
// we may have queues with capacity=0. We shouldn't look at jobs from
// these queues
if (0 == getTSC(qsc).getCapacity()) {
continue;
}
//This call is important for optimization purposes , if we
//have reached the limit already no need for traversing the queue.
if(this.areTasksInQueueOverMaxCapacity(qsc,1)) {
continue;
}
TaskLookupResult tlr = getTaskFromQueue(taskTracker, qsc);
TaskLookupResult.LookUpStatus lookUpStatus = tlr.getLookUpStatus();
if (lookUpStatus == TaskLookupResult.LookUpStatus.NO_TASK_FOUND) {
continue; // Look in other queues.
}
// if we find a task, return
if (lookUpStatus == TaskLookupResult.LookUpStatus.TASK_FOUND) {
return tlr;
}
// if there was a memory mismatch, return
else if (lookUpStatus ==
TaskLookupResult.LookUpStatus.TASK_FAILING_MEMORY_REQUIREMENT) {
return tlr;
}
}
// nothing to give
return TaskLookupResult.getNoTaskFoundResult();
}