Search in sources :

Example 1 with CCServiceContext

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);
    }
}
Also used : IActivityClusterGraphGeneratorFactory(org.apache.hyracks.api.job.IActivityClusterGraphGeneratorFactory) IJobManager(org.apache.hyracks.control.cc.job.IJobManager) IActivityClusterGraphGenerator(org.apache.hyracks.api.job.IActivityClusterGraphGenerator) CCServiceContext(org.apache.hyracks.control.cc.application.CCServiceContext) JobRun(org.apache.hyracks.control.cc.job.JobRun)

Example 2 with CCServiceContext

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;
    }
}
Also used : HyracksException(org.apache.hyracks.api.exceptions.HyracksException) JobSpecification(org.apache.hyracks.api.job.JobSpecification) CCServiceContext(org.apache.hyracks.control.cc.application.CCServiceContext) JobId(org.apache.hyracks.api.job.JobId) InvocationTargetException(java.lang.reflect.InvocationTargetException) HyracksException(org.apache.hyracks.api.exceptions.HyracksException)

Example 3 with CCServiceContext

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;
}
Also used : LogFile(org.apache.hyracks.control.common.logs.LogFile) INodeManager(org.apache.hyracks.control.cc.cluster.INodeManager) CCServiceContext(org.apache.hyracks.control.cc.application.CCServiceContext) ClusterControllerService(org.apache.hyracks.control.cc.ClusterControllerService)

Example 4 with CCServiceContext

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);
}
Also used : JobSpecification(org.apache.hyracks.api.job.JobSpecification) CCServiceContext(org.apache.hyracks.control.cc.application.CCServiceContext) JobId(org.apache.hyracks.api.job.JobId)

Example 5 with CCServiceContext

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);
    }
}
Also used : IJobCapacityController(org.apache.hyracks.api.job.resource.IJobCapacityController) IJobManager(org.apache.hyracks.control.cc.job.IJobManager) JobManager(org.apache.hyracks.control.cc.job.JobManager) CCServiceContext(org.apache.hyracks.control.cc.application.CCServiceContext) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

CCServiceContext (org.apache.hyracks.control.cc.application.CCServiceContext)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 IActivityClusterGraphGenerator (org.apache.hyracks.api.job.IActivityClusterGraphGenerator)2 IActivityClusterGraphGeneratorFactory (org.apache.hyracks.api.job.IActivityClusterGraphGeneratorFactory)2 JobId (org.apache.hyracks.api.job.JobId)2 JobSpecification (org.apache.hyracks.api.job.JobSpecification)2 INodeManager (org.apache.hyracks.control.cc.cluster.INodeManager)2 IJobManager (org.apache.hyracks.control.cc.job.IJobManager)2 HyracksException (org.apache.hyracks.api.exceptions.HyracksException)1 ActivityClusterGraph (org.apache.hyracks.api.job.ActivityClusterGraph)1 JobFlag (org.apache.hyracks.api.job.JobFlag)1 IJobCapacityController (org.apache.hyracks.api.job.resource.IJobCapacityController)1 ClusterControllerService (org.apache.hyracks.control.cc.ClusterControllerService)1 NodeControllerState (org.apache.hyracks.control.cc.NodeControllerState)1 JobManager (org.apache.hyracks.control.cc.job.JobManager)1 JobRun (org.apache.hyracks.control.cc.job.JobRun)1 LogFile (org.apache.hyracks.control.common.logs.LogFile)1