Search in sources :

Example 1 with SnapshotSerializationException

use of org.voltdb.rejoin.StreamSnapshotDataTarget.SnapshotSerializationException in project voltdb by VoltDB.

the class TableStreamer method streamMore.

/**
     * Streams more tuples from the table.
     * @param context          Context
     * @param outputBuffers    Allocated buffers to hold output tuples
     * @param rowCountAccumulator an array of a single int use to accumulate streamed rows count
     * @return A future for all writes to data targets, and a boolean indicating if there's more left in the table.
     * The future could be null if nothing is serialized. If row count is specified it sets the number of rows that
     * is to stream
     * @throws SnapshotSerializationException
     */
@SuppressWarnings("rawtypes")
public Pair<ListenableFuture, Boolean> streamMore(SystemProcedureExecutionContext context, List<DBBPool.BBContainer> outputBuffers, int[] rowCountAccumulator) {
    ListenableFuture writeFuture = null;
    prepareBuffers(outputBuffers);
    Pair<Long, int[]> serializeResult = context.tableStreamSerializeMore(m_tableId, m_type, outputBuffers);
    if (serializeResult.getFirst() == SERIALIZATION_ERROR) {
        // Cancel the snapshot here
        for (DBBPool.BBContainer container : outputBuffers) {
            container.discard();
        }
        SnapshotSerializationException ex = new SnapshotSerializationException("Snapshot of table " + m_tableId + " failed to complete.");
        for (SnapshotTableTask task : m_tableTasks) {
            task.m_target.reportSerializationFailure(ex);
        }
        return Pair.of(null, false);
    }
    if (serializeResult.getSecond()[0] > 0) {
        if (rowCountAccumulator != null && rowCountAccumulator.length == 1) {
            rowCountAccumulator[0] += getTupleDataRowCount(outputBuffers);
        }
        writeFuture = writeBlocksToTargets(outputBuffers, serializeResult.getSecond());
    } else {
        // Return all allocated snapshot output buffers
        for (DBBPool.BBContainer container : outputBuffers) {
            container.discard();
        }
    }
    return Pair.of(writeFuture, serializeResult.getFirst() > 0);
}
Also used : BBContainer(org.voltcore.utils.DBBPool.BBContainer) ListenableFuture(com.google_voltpatches.common.util.concurrent.ListenableFuture) SnapshotSerializationException(org.voltdb.rejoin.StreamSnapshotDataTarget.SnapshotSerializationException) DBBPool(org.voltcore.utils.DBBPool)

Aggregations

ListenableFuture (com.google_voltpatches.common.util.concurrent.ListenableFuture)1 DBBPool (org.voltcore.utils.DBBPool)1 BBContainer (org.voltcore.utils.DBBPool.BBContainer)1 SnapshotSerializationException (org.voltdb.rejoin.StreamSnapshotDataTarget.SnapshotSerializationException)1