Search in sources :

Example 1 with RestoreWork

use of org.voltdb.rejoin.StreamSnapshotSink.RestoreWork in project voltdb by VoltDB.

the class ElasticJoinProducer method runForBlockingDataTransfer.

/**
     * Blocking transfer all partitioned table data and notify the coordinator.
     * @param siteConnection
     */
private void runForBlockingDataTransfer(SiteProcedureConnection siteConnection) {
    boolean sourcesReady = false;
    RestoreWork restoreWork = m_dataSink.poll(m_snapshotBufferAllocator);
    if (restoreWork != null) {
        restoreBlock(restoreWork, siteConnection);
        sourcesReady = true;
    }
    // replicated table in the database, so check for both conditions.
    if (m_dataSink.isEOF() || m_snapshotCompletionMonitor.isDone()) {
        // No more data from this data sink, close and remove it from the list
        m_dataSink.close();
        if (m_streamSnapshotMb != null) {
            VoltDB.instance().getHostMessenger().removeMailbox(m_streamSnapshotMb.getHSId());
        }
        JOINLOG.debug(m_whoami + " data transfer is finished");
        if (m_snapshotCompletionMonitor.isDone()) {
            try {
                SnapshotCompletionEvent event = m_snapshotCompletionMonitor.get();
                siteConnection.setDRProtocolVersion(event.drVersion);
                assert (event != null);
                JOINLOG.debug("P" + m_partitionId + " noticed data transfer completion");
                m_completionAction.setSnapshotTxnId(event.multipartTxnId);
                setJoinComplete(siteConnection, event.exportSequenceNumbers, event.drSequenceNumbers, event.drMixedClusterSizeConsumerState, false, /* requireExistingSequenceNumbers */
                event.clusterCreateTime);
            } catch (InterruptedException e) {
                // isDone() already returned true, this shouldn't happen
                VoltDB.crashLocalVoltDB("Impossible interruption happend", true, e);
            } catch (ExecutionException e) {
                VoltDB.crashLocalVoltDB("Error waiting for snapshot to finish", true, e);
            }
        } else {
            m_taskQueue.offer(this);
        }
    } else {
        // The sources are not set up yet, don't block the site,
        // return here and retry later.
        returnToTaskQueue(sourcesReady);
    }
}
Also used : SnapshotCompletionEvent(org.voltdb.SnapshotCompletionInterest.SnapshotCompletionEvent) RestoreWork(org.voltdb.rejoin.StreamSnapshotSink.RestoreWork) ExecutionException(java.util.concurrent.ExecutionException)

Example 2 with RestoreWork

use of org.voltdb.rejoin.StreamSnapshotSink.RestoreWork in project voltdb by VoltDB.

the class RejoinProducer method runForRejoin.

/**
     * An implementation of run() that does not block the site thread.
     * The Site has responsibility for transactions that occur between
     * schedulings of this task.
     */
@Override
public void runForRejoin(SiteProcedureConnection siteConnection, TaskLog m_taskLog) throws IOException {
    if (!m_schemaHasNoTables) {
        boolean sourcesReady = false;
        RestoreWork rejoinWork = m_rejoinSiteProcessor.poll(m_snapshotBufferAllocator);
        if (rejoinWork != null) {
            restoreBlock(rejoinWork, siteConnection);
            sourcesReady = true;
        }
        if (m_rejoinSiteProcessor.isEOF() == false) {
            returnToTaskQueue(sourcesReady);
        } else {
            REJOINLOG.debug(m_whoami + "Rejoin snapshot transfer is finished");
            m_rejoinSiteProcessor.close();
            if (m_streamSnapshotMb != null) {
                VoltDB.instance().getHostMessenger().removeMailbox(m_streamSnapshotMb.getHSId());
            }
            doFinishingTask(siteConnection);
        }
    } else {
        doFinishingTask(siteConnection);
        // Remove the completion monitor for an empty (zero table) rejoin.
        m_snapshotCompletionMonitor.set(null);
    }
}
Also used : RestoreWork(org.voltdb.rejoin.StreamSnapshotSink.RestoreWork)

Aggregations

RestoreWork (org.voltdb.rejoin.StreamSnapshotSink.RestoreWork)2 ExecutionException (java.util.concurrent.ExecutionException)1 SnapshotCompletionEvent (org.voltdb.SnapshotCompletionInterest.SnapshotCompletionEvent)1