Search in sources :

Example 1 with DatasetJobRecord

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();
}
Also used : DatasetJobRecord(org.apache.hyracks.api.dataset.DatasetJobRecord)

Example 2 with DatasetJobRecord

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();
}
Also used : DatasetJobRecord(org.apache.hyracks.api.dataset.DatasetJobRecord) DatasetDirectoryRecord(org.apache.hyracks.api.dataset.DatasetDirectoryRecord) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) HyracksException(org.apache.hyracks.api.exceptions.HyracksException)

Example 3 with DatasetJobRecord

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;
}
Also used : ResultSetMetaData(org.apache.hyracks.api.dataset.ResultSetMetaData) DatasetJobRecord(org.apache.hyracks.api.dataset.DatasetJobRecord) DatasetDirectoryRecord(org.apache.hyracks.api.dataset.DatasetDirectoryRecord) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) HyracksException(org.apache.hyracks.api.exceptions.HyracksException) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException)

Example 4 with DatasetJobRecord

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();
}
Also used : DatasetJobRecord(org.apache.hyracks.api.dataset.DatasetJobRecord)

Example 5 with DatasetJobRecord

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();
}
Also used : DatasetJobRecord(org.apache.hyracks.api.dataset.DatasetJobRecord) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) HyracksException(org.apache.hyracks.api.exceptions.HyracksException)

Aggregations

DatasetJobRecord (org.apache.hyracks.api.dataset.DatasetJobRecord)5 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)3 HyracksException (org.apache.hyracks.api.exceptions.HyracksException)3 DatasetDirectoryRecord (org.apache.hyracks.api.dataset.DatasetDirectoryRecord)2 ResultSetMetaData (org.apache.hyracks.api.dataset.ResultSetMetaData)1