<commit_before>/***********************************************************************************************************************
 *
 * Copyright (C) 2010 by the Stratosphere project (http://stratosphere.eu)
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations under the License.
 *
 **********************************************************************************************************************/

package eu.stratosphere.nephele.checkpointing;

import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.channels.FileChannel;

import eu.stratosphere.nephele.executiongraph.ExecutionVertexID;
import eu.stratosphere.nephele.taskmanager.transferenvelope.CheckpointDeserializer;
import eu.stratosphere.nephele.taskmanager.transferenvelope.TransferEnvelope;
import eu.stratosphere.nephele.taskmanager.transferenvelope.TransferEnvelopeDispatcher;

class CheckpointReplayTask extends Thread {

	private final ReplayFinishedNotifier replayFinishedNotifier;

	private final ExecutionVertexID vertexID;

	private final String checkpointDirectory;

	private final TransferEnvelopeDispatcher transferEnvelopeDispatcher;

	private final boolean isCheckpointComplete;

	private volatile boolean isCanceled = false;

	CheckpointReplayTask(final ReplayFinishedNotifier replayFinishedNotifier, final ExecutionVertexID vertexID,
			final String checkpointDirectory, final TransferEnvelopeDispatcher transferEnvelopeDispatcher,
			final boolean isCheckpointComplete) {

		this.replayFinishedNotifier = replayFinishedNotifier;
		this.vertexID = vertexID;
		this.checkpointDirectory = checkpointDirectory;
		this.transferEnvelopeDispatcher = transferEnvelopeDispatcher;
		this.isCheckpointComplete = isCheckpointComplete;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public void run() {

		try {
			replayCheckpoint();
		} catch (IOException ioe) {
			// TODO: Handle this correctly
			ioe.printStackTrace();
		}

		// Notify the checkpoint replay manager that the replay has been finished
		this.replayFinishedNotifier.replayFinished(this.vertexID);
	}

	void cancelAndWait() {

		this.isCanceled = true;
		interrupt();

		try {<commit_msg>Added names for recovery threads<commit_after>/***********************************************************************************************************************
 *
 * Copyright (C) 2010 by the Stratosphere project (http://stratosphere.eu)
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations under the License.
 *
 **********************************************************************************************************************/

package eu.stratosphere.nephele.checkpointing;

import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.channels.FileChannel;

import eu.stratosphere.nephele.executiongraph.ExecutionVertexID;
import eu.stratosphere.nephele.taskmanager.transferenvelope.CheckpointDeserializer;
import eu.stratosphere.nephele.taskmanager.transferenvelope.TransferEnvelope;
import eu.stratosphere.nephele.taskmanager.transferenvelope.TransferEnvelopeDispatcher;

class CheckpointReplayTask extends Thread {

	private final ReplayFinishedNotifier replayFinishedNotifier;

	private final ExecutionVertexID vertexID;

	private final String checkpointDirectory;

	private final TransferEnvelopeDispatcher transferEnvelopeDispatcher;

	private final boolean isCheckpointComplete;

	private volatile boolean isCanceled = false;

	CheckpointReplayTask(final ReplayFinishedNotifier replayFinishedNotifier, final ExecutionVertexID vertexID,
			final String checkpointDirectory, final TransferEnvelopeDispatcher transferEnvelopeDispatcher,
			final boolean isCheckpointComplete) {

		super("Recovery task for " + vertexID);

		this.replayFinishedNotifier = replayFinishedNotifier;
		this.vertexID = vertexID;
		this.checkpointDirectory = checkpointDirectory;
		this.transferEnvelopeDispatcher = transferEnvelopeDispatcher;
		this.isCheckpointComplete = isCheckpointComplete;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public void run() {

		try {
			replayCheckpoint();
		} catch (IOException ioe) {
			// TODO: Handle this correctly
			ioe.printStackTrace();
		}

		// Notify the checkpoint replay manager that the replay has been finished
		this.replayFinishedNotifier.replayFinished(this.vertexID);
	}

	void cancelAndWait() {

		this.isCanceled = true;
		interrupt();

		try {
{'fraction_non_alphanumeric': 0.1507098653076083, 'fraction_numerical': 0.0029122679286494356, 'mean_word_length': 5.885964912280702, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4903207', 'n_tokens_mistral': 1500, 'n_tokens_neox': 1353, 'n_words': 400}