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));
}
}
});
}
}
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);
}
}
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());
}
}
}
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();
}
}
}
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);
}
}
Aggregations