use of org.apache.hyracks.control.cc.application.CCServiceContext in project asterixdb by apache.
the class JobStartWork method doRun.
@Override
protected void doRun() throws Exception {
IJobManager jobManager = ccs.getJobManager();
try {
final CCServiceContext ccServiceCtx = ccs.getContext();
JobRun run;
if (!predestributed) {
//Need to create the ActivityClusterGraph
IActivityClusterGraphGeneratorFactory acggf = (IActivityClusterGraphGeneratorFactory) DeploymentUtils.deserialize(acggfBytes, deploymentId, ccServiceCtx);
IActivityClusterGraphGenerator acgg = acggf.createActivityClusterGraphGenerator(jobId, ccServiceCtx, jobFlags);
run = new JobRun(ccs, deploymentId, jobId, acggf, acgg, jobFlags);
} else {
//ActivityClusterGraph has already been distributed
run = new JobRun(ccs, deploymentId, jobId, ccs.getPreDistributedJobStore().getDistributedJobDescriptor(jobId));
}
jobManager.add(run);
callback.setValue(jobId);
} catch (Exception e) {
callback.setException(e);
}
}
use of org.apache.hyracks.control.cc.application.CCServiceContext in project asterixdb by apache.
the class JobManager method finalComplete.
@Override
public void finalComplete(JobRun run) throws HyracksException {
checkJob(run);
JobId jobId = run.getJobId();
HyracksException caughtException = null;
CCServiceContext serviceCtx = ccs.getContext();
if (serviceCtx != null) {
try {
serviceCtx.notifyJobFinish(jobId);
} catch (HyracksException e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
caughtException = e;
}
}
run.setStatus(run.getPendingStatus(), run.getPendingExceptions());
run.setEndTime(System.currentTimeMillis());
activeRunMap.remove(jobId);
runMapArchive.put(jobId, run);
runMapHistory.put(jobId, run.getExceptions());
if (run.getActivityClusterGraph().isReportTaskDetails()) {
/**
* log job details when profiling is enabled
*/
try {
ccs.getJobLogFile().log(createJobLogObject(run));
} catch (Exception e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
if (caughtException == null) {
caughtException = new HyracksException(e);
} else {
caughtException.addSuppressed(e);
}
}
}
// Releases cluster capacitys occupied by the job.
JobSpecification job = run.getJobSpecification();
jobCapacityController.release(job);
// Picks the next job to execute.
pickJobsToRun();
// throws caught exceptions if any
if (caughtException != null) {
throw caughtException;
}
}
use of org.apache.hyracks.control.cc.application.CCServiceContext in project asterixdb by apache.
the class JobManagerTest method mockClusterControllerService.
private ClusterControllerService mockClusterControllerService() {
ClusterControllerService ccs = mock(ClusterControllerService.class);
CCServiceContext ccServiceCtx = mock(CCServiceContext.class);
LogFile logFile = mock(LogFile.class);
INodeManager nodeManager = mockNodeManager();
when(ccs.getContext()).thenReturn(ccServiceCtx);
when(ccs.getJobLogFile()).thenReturn(logFile);
when(ccs.getNodeManager()).thenReturn(nodeManager);
when(ccs.getCCConfig()).thenReturn(ccConfig);
return ccs;
}
use of org.apache.hyracks.control.cc.application.CCServiceContext in project asterixdb by apache.
the class JobManager method executeJob.
// Executes a job when the required capacity for the job is met.
private void executeJob(JobRun run) throws HyracksException {
run.setStartTime(System.currentTimeMillis());
JobId jobId = run.getJobId();
activeRunMap.put(jobId, run);
CCServiceContext serviceCtx = ccs.getContext();
JobSpecification spec = run.getJobSpecification();
if (!run.getExecutor().isPredistributed()) {
serviceCtx.notifyJobCreation(jobId, spec);
}
run.setStatus(JobStatus.RUNNING, null);
executeJobInternal(run);
}
use of org.apache.hyracks.control.cc.application.CCServiceContext in project asterixdb by apache.
the class ClusterControllerService method startApplication.
private void startApplication() throws Exception {
serviceCtx = new CCServiceContext(this, serverCtx, ccContext, ccConfig.getAppConfig());
serviceCtx.addJobLifecycleListener(datasetDirectoryService);
executor = Executors.newCachedThreadPool(serviceCtx.getThreadFactory());
application.start(serviceCtx, ccConfig.getAppArgsArray());
IJobCapacityController jobCapacityController = application.getJobCapacityController();
// Job manager is in charge of job lifecycle management.
try {
Constructor<?> jobManagerConstructor = this.getClass().getClassLoader().loadClass(ccConfig.getJobManagerClass()).getConstructor(CCConfig.class, ClusterControllerService.class, IJobCapacityController.class);
jobManager = (IJobManager) jobManagerConstructor.newInstance(ccConfig, this, jobCapacityController);
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
if (LOGGER.isLoggable(Level.WARNING)) {
LOGGER.log(Level.WARNING, "class " + ccConfig.getJobManagerClass() + " could not be used: ", e);
}
// Falls back to the default implementation if the user-provided class name is not valid.
jobManager = new JobManager(ccConfig, this, jobCapacityController);
}
}
Aggregations