use of org.apache.hyracks.api.job.IJobletEventListener in project asterixdb by apache.
the class JobEventListenerFactory method createListener.
@Override
public IJobletEventListener createListener(final IHyracksJobletContext jobletContext) {
return new IJobletEventListener() {
@Override
public void jobletFinish(JobStatus jobStatus) {
try {
ITransactionManager txnManager = ((INcApplicationContext) jobletContext.getServiceContext().getApplicationContext()).getTransactionSubsystem().getTransactionManager();
ITransactionContext txnContext = txnManager.getTransactionContext(jobId, false);
txnContext.setWriteTxn(transactionalWrite);
txnManager.completedTransaction(txnContext, DatasetId.NULL, -1, !(jobStatus == JobStatus.FAILURE));
} catch (ACIDException e) {
throw new Error(e);
}
}
@Override
public void jobletStart() {
try {
((INcApplicationContext) jobletContext.getServiceContext().getApplicationContext()).getTransactionSubsystem().getTransactionManager().getTransactionContext(jobId, true);
} catch (ACIDException e) {
throw new Error(e);
}
}
};
}
use of org.apache.hyracks.api.job.IJobletEventListener in project asterixdb by apache.
the class MultiTransactionJobletEventListenerFactory method createListener.
@Override
public IJobletEventListener createListener(final IHyracksJobletContext jobletContext) {
return new IJobletEventListener() {
@Override
public void jobletFinish(JobStatus jobStatus) {
try {
ITransactionManager txnManager = ((INcApplicationContext) jobletContext.getServiceContext().getApplicationContext()).getTransactionSubsystem().getTransactionManager();
for (JobId jobId : jobIds) {
ITransactionContext txnContext = txnManager.getTransactionContext(jobId, false);
txnContext.setWriteTxn(transactionalWrite);
txnManager.completedTransaction(txnContext, DatasetId.NULL, -1, !(jobStatus == JobStatus.FAILURE));
}
} catch (ACIDException e) {
throw new Error(e);
}
}
@Override
public void jobletStart() {
try {
for (JobId jobId : jobIds) {
((INcApplicationContext) jobletContext.getServiceContext().getApplicationContext()).getTransactionSubsystem().getTransactionManager().getTransactionContext(jobId, true);
}
} catch (ACIDException e) {
throw new Error(e);
}
}
};
}
use of org.apache.hyracks.api.job.IJobletEventListener in project asterixdb by apache.
the class Joblet method performCleanup.
private void performCleanup() {
nodeController.getJobletMap().remove(jobId);
IJobletEventListener listener = getJobletEventListener();
if (listener != null) {
listener.jobletFinish(cleanupStatus);
}
close();
cleanupPending = false;
try {
nodeController.getClusterController().notifyJobletCleanup(jobId, nodeController.getId());
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations