Search in sources :

Example 1 with IJobManager

use of org.apache.hyracks.control.cc.job.IJobManager in project asterixdb by apache.

the class WaitForJobCompletionWork method doRun.

@Override
protected void doRun() throws Exception {
    IJobManager jobManager = ccs.getJobManager();
    final IJobStatusConditionVariable cRunningVar = jobManager.get(jobId);
    if (cRunningVar != null) {
        ccs.getExecutor().execute(new Runnable() {

            @Override
            public void run() {
                try {
                    cRunningVar.waitForCompletion();
                    callback.setValue(null);
                } catch (Exception e) {
                    callback.setException(e);
                }
            }
        });
    } else {
        final List<Exception> exceptions = jobManager.getExceptionHistory(jobId);
        ccs.getExecutor().execute(new Runnable() {

            @Override
            public void run() {
                callback.setValue(null);
                if (exceptions != null && !exceptions.isEmpty()) {
                    /**
                         * only report the first exception because IResultCallback will only throw one exception
                         * anyway
                         */
                    callback.setException(exceptions.get(0));
                }
            }
        });
    }
}
Also used : IJobStatusConditionVariable(org.apache.hyracks.control.cc.job.IJobStatusConditionVariable) IJobManager(org.apache.hyracks.control.cc.job.IJobManager)

Example 2 with IJobManager

use of org.apache.hyracks.control.cc.job.IJobManager 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 3 with IJobManager

use of org.apache.hyracks.control.cc.job.IJobManager in project asterixdb by apache.

the class JobletCleanupNotificationWork method runWork.

@Override
public void runWork() {
    IJobManager jobManager = ccs.getJobManager();
    final JobRun run = jobManager.get(jobId);
    Set<String> cleanupPendingNodes = run.getCleanupPendingNodeIds();
    if (!cleanupPendingNodes.remove(nodeId)) {
        if (LOGGER.isLoggable(Level.WARNING)) {
            LOGGER.warning(nodeId + " not in pending cleanup nodes set: " + cleanupPendingNodes + " for Job: " + jobId);
        }
        return;
    }
    INodeManager nodeManager = ccs.getNodeManager();
    NodeControllerState ncs = nodeManager.getNodeControllerState(nodeId);
    if (ncs != null) {
        ncs.getActiveJobIds().remove(jobId);
    }
    if (cleanupPendingNodes.isEmpty()) {
        try {
            jobManager.finalComplete(run);
        } catch (HyracksException e) {
            // Fail the job with the caught exception during final completion.
            run.getExceptions().add(e);
            run.setStatus(JobStatus.FAILURE, run.getExceptions());
        }
    }
}
Also used : INodeManager(org.apache.hyracks.control.cc.cluster.INodeManager) HyracksException(org.apache.hyracks.api.exceptions.HyracksException) IJobManager(org.apache.hyracks.control.cc.job.IJobManager) NodeControllerState(org.apache.hyracks.control.cc.NodeControllerState) JobRun(org.apache.hyracks.control.cc.job.JobRun)

Example 4 with IJobManager

use of org.apache.hyracks.control.cc.job.IJobManager in project asterixdb by apache.

the class RegisterPartitionAvailibilityWork method run.

@Override
public void run() {
    final PartitionId pid = partitionDescriptor.getPartitionId();
    IJobManager jobManager = ccs.getJobManager();
    JobRun run = jobManager.get(pid.getJobId());
    if (run == null) {
        return;
    }
    PartitionMatchMaker pmm = run.getPartitionMatchMaker();
    List<Pair<PartitionDescriptor, PartitionRequest>> matches = pmm.registerPartitionDescriptor(partitionDescriptor);
    for (Pair<PartitionDescriptor, PartitionRequest> match : matches) {
        try {
            PartitionUtils.reportPartitionMatch(ccs, pid, match);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
Also used : PartitionRequest(org.apache.hyracks.control.common.job.PartitionRequest) PartitionDescriptor(org.apache.hyracks.control.common.job.PartitionDescriptor) IJobManager(org.apache.hyracks.control.cc.job.IJobManager) PartitionMatchMaker(org.apache.hyracks.control.cc.partitions.PartitionMatchMaker) PartitionId(org.apache.hyracks.api.partitions.PartitionId) JobRun(org.apache.hyracks.control.cc.job.JobRun) Pair(org.apache.commons.lang3.tuple.Pair)

Example 5 with IJobManager

use of org.apache.hyracks.control.cc.job.IJobManager in project asterixdb by apache.

the class RemoveDeadNodesWork method run.

@Override
public void run() {
    try {
        INodeManager nodeManager = ccs.getNodeManager();
        Pair<Collection<String>, Collection<JobId>> result = nodeManager.removeDeadNodes();
        Collection<String> deadNodes = result.getLeft();
        Collection<JobId> affectedJobIds = result.getRight();
        int size = affectedJobIds.size();
        if (size > 0) {
            if (LOGGER.isLoggable(Level.INFO)) {
                LOGGER.info("Number of affected jobs: " + size);
            }
            IJobManager jobManager = ccs.getJobManager();
            for (JobId jobId : affectedJobIds) {
                JobRun run = jobManager.get(jobId);
                if (run != null) {
                    run.getExecutor().notifyNodeFailures(deadNodes);
                }
            }
        }
        if (!deadNodes.isEmpty()) {
            ccs.getContext().notifyNodeFailure(deadNodes);
        }
    } catch (HyracksException e) {
        LOGGER.log(Level.WARNING, "Uncaught exception on notifyNodeFailure", e);
    }
}
Also used : INodeManager(org.apache.hyracks.control.cc.cluster.INodeManager) Collection(java.util.Collection) HyracksException(org.apache.hyracks.api.exceptions.HyracksException) IJobManager(org.apache.hyracks.control.cc.job.IJobManager) JobId(org.apache.hyracks.api.job.JobId) JobRun(org.apache.hyracks.control.cc.job.JobRun)

Aggregations

IJobManager (org.apache.hyracks.control.cc.job.IJobManager)12 JobRun (org.apache.hyracks.control.cc.job.JobRun)9 HyracksException (org.apache.hyracks.api.exceptions.HyracksException)4 PartitionId (org.apache.hyracks.api.partitions.PartitionId)2 CCServiceContext (org.apache.hyracks.control.cc.application.CCServiceContext)2 INodeManager (org.apache.hyracks.control.cc.cluster.INodeManager)2 PartitionMatchMaker (org.apache.hyracks.control.cc.partitions.PartitionMatchMaker)2 PartitionDescriptor (org.apache.hyracks.control.common.job.PartitionDescriptor)2 PartitionRequest (org.apache.hyracks.control.common.job.PartitionRequest)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Collection (java.util.Collection)1 Pair (org.apache.commons.lang3.tuple.Pair)1 ActivityId (org.apache.hyracks.api.dataflow.ActivityId)1 TaskId (org.apache.hyracks.api.dataflow.TaskId)1 ActivityCluster (org.apache.hyracks.api.job.ActivityCluster)1 IActivityClusterGraphGenerator (org.apache.hyracks.api.job.IActivityClusterGraphGenerator)1 IActivityClusterGraphGeneratorFactory (org.apache.hyracks.api.job.IActivityClusterGraphGeneratorFactory)1 JobId (org.apache.hyracks.api.job.JobId)1 IJobCapacityController (org.apache.hyracks.api.job.resource.IJobCapacityController)1