public void schedule() throws Exception { try { final int incompleteTaskNum = scheduledRequests.leafTaskNum() + scheduledRequests.nonLeafTaskNum(); if (incompleteTaskNum == 0) { needWakeup.set(true); // all task is done or tasks is not scheduled synchronized (schedulingThread) { schedulingThread.wait(1000); } } else { LinkedList<TaskRequestEvent> taskRequests = createTaskRequest(incompleteTaskNum); if (taskRequests.size() == 0) { synchronized (schedulingThread) { schedulingThread.wait(schedulerDelay); } } else { if (LOG.isDebugEnabled()) { LOG.debug("Get " + taskRequests.size() + " taskRequestEvents "); } if (isLeaf) { scheduledRequests.assignToLeafTasks(taskRequests); } else { scheduledRequests.assignToNonLeafTasks(taskRequests); } } } } catch (TimeoutException e) { LOG.error(e.getMessage()); } }
@Override public void start() { info(LOG, "Start TaskScheduler"); maximumRequestContainer = Math.min(tajoConf.getIntVar(TajoConf.ConfVars.QUERYMASTER_TASK_SCHEDULER_REQUEST_MAX_NUM) , stage.getContext().getWorkerMap().size()); if (isLeaf) { candidateWorkers.addAll(getWorkerIds(getLeafTaskHosts())); } else { //find assigned hosts for Non-Leaf locality in children executionBlock List<ExecutionBlock> executionBlockList = stage.getMasterPlan().getChilds(stage.getBlock()); for (ExecutionBlock executionBlock : executionBlockList) { Stage childStage = stage.getContext().getStage(executionBlock.getId()); candidateWorkers.addAll(childStage.getAssignedWorkerMap().keySet()); } } this.schedulingThread.start(); super.start(); }
public void run() { while (!isStopped && !Thread.currentThread().isInterrupted()) { try { schedule(); } catch (InterruptedException e) { if (isStopped) { break; } else { LOG.fatal(e.getMessage(), e); stage.abort(StageState.ERROR, e); } } catch (Throwable e) { LOG.fatal(e.getMessage(), e); stage.abort(StageState.ERROR, e); break; } } info(LOG, "TaskScheduler schedulingThread stopped"); } };
if (remainingScheduledObjectNum() > 0 && nodes > 0) { tailLimit = Math.max(remainingScheduledObjectNum() / nodes, 1); cancellation += cancel(responseProto.getCancellationTaskList()); info(LOG, "Canceled requests: " + responseProto.getCancellationTaskCount() + " from " + addr); continue; cancellation += cancel(requestProto.getTaskRequestList()); warn(LOG, "Canceled requests: " + requestProto.getTaskRequestCount() + " by " + ExceptionUtils.getFullStackTrace(e)); continue; info(LOG, String.format("Assigned Local/Rack/Total: (%d/%d/%d), " + "Attempted Cancel/Assign/Total: (%d/%d/%d), " + "Locality: %.2f%%, Rack host: %s",
cancellation += cancel(responseProto.getCancellationTaskList()); info(LOG, "Canceled requests: " + responseProto.getCancellationTaskCount() + " from " + addr); continue; cancellation += cancel(requestProto.getTaskRequestList()); warn(LOG, "Canceled requests: " + requestProto.getTaskRequestCount() + " by " + ExceptionUtils.getFullStackTrace(e)); continue;
/** * Increase the count of running tasks and disk loads for a certain task runner. * * @param volumeId Volume identifier * @return the volume load (i.e., how many running tasks use this volume) */ private synchronized int increaseConcurrency(int volumeId) { int concurrency = 1; if (diskVolumeLoads.containsKey(volumeId)) { concurrency = diskVolumeLoads.get(volumeId) + 1; } if (volumeId > -1) { info(LOG, "Assigned host : " + host + ", Volume : " + volumeId + ", Concurrency : " + concurrency); } else if (volumeId == -1) { // this case is disabled namenode block meta or compressed text file or amazon s3 info(LOG, "Assigned host : " + host + ", Unknown Volume : " + volumeId + ", Concurrency : " + concurrency); } else if (volumeId == REMOTE) { // this case has processed all block on host and it will be assigned to remote info(LOG, "Assigned host : " + host + ", Remaining local tasks : " + getRemainingLocalTaskSize() + ", Remote Concurrency : " + concurrency + ", Unassigned volumes: " + unassignedTaskForEachVolume.size()); } diskVolumeLoads.put(volumeId, concurrency); return concurrency; }
protected void cancel(TaskAttempt taskAttempt) { TaskAttemptToSchedulerEvent schedulerEvent = new TaskAttemptToSchedulerEvent( EventType.T_SCHEDULE, taskAttempt.getTask().getId().getExecutionBlockId(), null, taskAttempt); if(taskAttempt.isLeafTask()) { releaseTaskAttempt(taskAttempt); scheduledRequests.addLeafTask(schedulerEvent); } else { scheduledRequests.addNonLeafTask(schedulerEvent); } context.getMasterContext().getEventHandler().handle( new TaskAttemptEvent(taskAttempt.getId(), TaskAttemptEventType.TA_ASSIGN_CANCEL)); }
protected int cancel(List<TaskAllocationProto> tasks) { int canceled = 0; for (TaskAllocationProto proto : tasks) { TaskAttemptId attemptId = new TaskAttemptId(proto.getTaskRequest().getId()); cancel(stage.getTask(attemptId.getTaskId()).getAttempt(attemptId)); canceled++; } return canceled; }
if (remainingScheduledObjectNum() > 0 && nodes > 0) { tailLimit = Math.max(remainingScheduledObjectNum() / nodes, 1); cancellation += cancel(responseProto.getCancellationTaskList()); info(LOG, "Canceled requests: " + responseProto.getCancellationTaskCount() + " from " + addr); continue; cancellation += cancel(requestProto.getTaskRequestList()); warn(LOG, "Canceled requests: " + requestProto.getTaskRequestCount() + " by " + ExceptionUtils.getFullStackTrace(e)); continue; info(LOG, String.format("Assigned Local/Rack/Total: (%d/%d/%d), " + "Attempted Cancel/Assign/Total: (%d/%d/%d), " + "Locality: %.2f%%, Rack host: %s",
cancellation += cancel(responseProto.getCancellationTaskList()); info(LOG, "Canceled requests: " + responseProto.getCancellationTaskCount() + " from " + addr); continue; cancellation += cancel(requestProto.getTaskRequestList()); warn(LOG, "Canceled requests: " + requestProto.getTaskRequestCount() + " by " + ExceptionUtils.getFullStackTrace(e)); continue;
/** * Increase the count of running tasks and disk loads for a certain task runner. * * @param volumeId Volume identifier * @return the volume load (i.e., how many running tasks use this volume) */ private synchronized int increaseConcurrency(int volumeId) { int concurrency = 1; if (diskVolumeLoads.containsKey(volumeId)) { concurrency = diskVolumeLoads.get(volumeId) + 1; } if (volumeId > DataLocation.UNKNOWN_VOLUME_ID) { info(LOG, "Assigned host : " + host + ", Volume : " + volumeId + ", Concurrency : " + concurrency); } else if (volumeId == DataLocation.UNKNOWN_VOLUME_ID) { // this case is disabled namenode block meta or compressed text file or amazon s3 info(LOG, "Assigned host : " + host + ", Unknown Volume : " + volumeId + ", Concurrency : " + concurrency); } else if (volumeId == DataLocation.REMOTE_VOLUME_ID) { // this case has processed all block on host and it will be assigned to remote info(LOG, "Assigned host : " + host + ", Remaining local tasks : " + getRemainingLocalTaskSize() + ", Remote Concurrency : " + concurrency + ", Unassigned volumes: " + unassignedTaskForEachVolume.size()); } diskVolumeLoads.put(volumeId, concurrency); return concurrency; }
protected void cancel(TaskAttempt taskAttempt) { TaskAttemptToSchedulerEvent schedulerEvent = new TaskAttemptToSchedulerEvent( EventType.T_SCHEDULE, taskAttempt.getTask().getId().getExecutionBlockId(), null, taskAttempt); if(taskAttempt.isLeafTask()) { releaseTaskAttempt(taskAttempt); scheduledRequests.addLeafTask(schedulerEvent); } else { scheduledRequests.addNonLeafTask(schedulerEvent); } context.getMasterContext().getEventHandler().handle( new TaskAttemptEvent(taskAttempt.getId(), TaskAttemptEventType.TA_ASSIGN_CANCEL)); }
protected int cancel(List<TaskAllocationProto> tasks) { int canceled = 0; for (TaskAllocationProto proto : tasks) { TaskAttemptId attemptId = new TaskAttemptId(proto.getTaskRequest().getId()); cancel(stage.getTask(attemptId.getTaskId()).getAttempt(attemptId)); canceled++; } return canceled; }
@Override public void start() { info(LOG, "Start TaskScheduler"); maximumRequestContainer = Math.min(tajoConf.getIntVar(TajoConf.ConfVars.QUERYMASTER_TASK_SCHEDULER_REQUEST_MAX_NUM) , stage.getContext().getWorkerMap().size()); if (isLeaf) { candidateWorkers.addAll(getWorkerIds(getLeafTaskHosts())); } else { //find assigned hosts for Non-Leaf locality in children executionBlock List<ExecutionBlock> executionBlockList = stage.getMasterPlan().getChilds(stage.getBlock()); for (ExecutionBlock executionBlock : executionBlockList) { Stage childStage = stage.getContext().getStage(executionBlock.getId()); candidateWorkers.addAll(childStage.getAssignedWorkerMap().keySet()); } } this.schedulingThread.start(); super.start(); }
public void run() { while (!isStopped && !Thread.currentThread().isInterrupted()) { try { schedule(); } catch (InterruptedException e) { if (isStopped) { break; } else { LOG.fatal(e.getMessage(), e); stage.abort(StageState.ERROR, e); } } catch (Throwable e) { LOG.fatal(e.getMessage(), e); stage.abort(StageState.ERROR, e); break; } } info(LOG, "TaskScheduler schedulingThread stopped"); } };
@Override public void stop() { isStopped = true; if (schedulingThread != null) { synchronized (schedulingThread) { schedulingThread.interrupt(); } } candidateWorkers.clear(); scheduledRequests.clear(); info(LOG, "Task Scheduler stopped"); super.stop(); }
public void schedule() throws Exception { try { final int incompleteTaskNum = scheduledRequests.leafTaskNum() + scheduledRequests.nonLeafTaskNum(); if (incompleteTaskNum == 0) { needWakeup.set(true); // all task is done or tasks is not scheduled synchronized (schedulingThread) { schedulingThread.wait(1000); } } else { LinkedList<TaskRequestEvent> taskRequests = createTaskRequest(incompleteTaskNum); if (taskRequests.size() == 0) { synchronized (schedulingThread) { schedulingThread.wait(schedulerDelay); } } else { if (LOG.isDebugEnabled()) { LOG.debug("Get " + taskRequests.size() + " taskRequestEvents "); } if (isLeaf) { scheduledRequests.assignToLeafTasks(taskRequests); } else { scheduledRequests.assignToNonLeafTasks(taskRequests); } } } } catch (TimeoutException e) { LOG.error(e.getMessage()); } }
@Override public void stop() { isStopped = true; if (schedulingThread != null) { synchronized (schedulingThread) { schedulingThread.interrupt(); } } candidateWorkers.clear(); scheduledRequests.clear(); info(LOG, "Task Scheduler stopped"); super.stop(); }