use of org.apache.hyracks.api.dataset.DatasetJobRecord in project asterixdb by apache.
the class Waiter method reportJobFailure.
@Override
public synchronized void reportJobFailure(JobId jobId, List<Exception> exceptions) {
DatasetJobRecord djr = getDatasetJobRecord(jobId);
if (djr != null) {
djr.fail(exceptions);
}
final JobResultInfo jobResultInfo = jobResultLocations.get(jobId);
if (jobResultInfo != null) {
jobResultInfo.setException(exceptions.isEmpty() ? null : exceptions.get(0));
}
notifyAll();
}
use of org.apache.hyracks.api.dataset.DatasetJobRecord in project asterixdb by apache.
the class Waiter method registerResultPartitionLocation.
@Override
public synchronized void registerResultPartitionLocation(JobId jobId, ResultSetId rsId, boolean orderedResult, boolean emptyResult, int partition, int nPartitions, NetworkAddress networkAddress) throws HyracksDataException {
DatasetJobRecord djr = getNonNullDatasetJobRecord(jobId);
djr.setResultSetMetaData(rsId, orderedResult, nPartitions);
DatasetDirectoryRecord record = djr.getOrCreateDirectoryRecord(rsId, partition);
record.setNetworkAddress(networkAddress);
record.setEmpty(emptyResult);
record.start();
final JobResultInfo jobResultInfo = jobResultLocations.get(jobId);
Waiter waiter = jobResultInfo.getWaiter(rsId);
if (waiter != null) {
try {
DatasetDirectoryRecord[] updatedRecords = updatedRecords(jobId, rsId, waiter.knownRecords);
if (updatedRecords != null) {
jobResultInfo.removeWaiter(rsId);
waiter.callback.setValue(updatedRecords);
}
} catch (Exception e) {
waiter.callback.setException(e);
}
}
notifyAll();
}
use of org.apache.hyracks.api.dataset.DatasetJobRecord in project asterixdb by apache.
the class Waiter method updatedRecords.
/**
* Compares the records already known by the client for the given job's result set id with the records that the
* dataset directory service knows and if there are any newly discovered records returns a whole array with the
* new records filled in.
*
* @param jobId
* - Id of the job for which the directory records should be retrieved.
* @param rsId
* - Id of the result set for which the directory records should be retrieved.
* @param knownRecords
* - An array of directory records that the client is already aware of.
* @return
* Returns the updated records if new record were discovered, null otherwise
* @throws HyracksDataException
* TODO(madhusudancs): Think about caching (and still be stateless) instead of this ugly O(n) iterations for
* every check. This already looks very expensive.
*/
private DatasetDirectoryRecord[] updatedRecords(JobId jobId, ResultSetId rsId, DatasetDirectoryRecord[] knownRecords) throws HyracksDataException {
DatasetJobRecord djr = getNonNullDatasetJobRecord(jobId);
if (djr.getStatus().getState() == State.FAILED) {
List<Exception> caughtExceptions = djr.getStatus().getExceptions();
if (caughtExceptions != null && !caughtExceptions.isEmpty()) {
final Exception cause = caughtExceptions.get(caughtExceptions.size() - 1);
if (cause instanceof HyracksDataException) {
throw (HyracksDataException) cause;
}
throw HyracksDataException.create(ErrorCode.RESULT_FAILURE_EXCEPTION, cause, rsId, jobId);
} else {
throw HyracksDataException.create(ErrorCode.RESULT_FAILURE_NO_EXCEPTION, rsId, jobId);
}
}
final ResultSetMetaData resultSetMetaData = djr.getResultSetMetaData(rsId);
if (resultSetMetaData == null) {
return null;
}
DatasetDirectoryRecord[] records = resultSetMetaData.getRecords();
return Arrays.equals(records, knownRecords) ? null : records;
}
use of org.apache.hyracks.api.dataset.DatasetJobRecord in project asterixdb by apache.
the class Waiter method reportResultPartitionWriteCompletion.
@Override
public synchronized void reportResultPartitionWriteCompletion(JobId jobId, ResultSetId rsId, int partition) throws HyracksDataException {
DatasetJobRecord djr = getNonNullDatasetJobRecord(jobId);
djr.getDirectoryRecord(rsId, partition).writeEOS();
djr.updateState(rsId);
notifyAll();
}
use of org.apache.hyracks.api.dataset.DatasetJobRecord in project asterixdb by apache.
the class Waiter method reportResultPartitionFailure.
@Override
public synchronized void reportResultPartitionFailure(JobId jobId, ResultSetId rsId, int partition) {
DatasetJobRecord djr = getDatasetJobRecord(jobId);
if (djr != null) {
djr.fail(rsId, partition);
}
jobResultLocations.get(jobId).setException(new Exception());
notifyAll();
}
Aggregations