class Task implements Runnable {

	public void onPartitionStateUpdate(
			IntermediateDataSetID resultId,
			IntermediateResultPartitionID partitionId,
			ExecutionState partitionState) throws IOException, InterruptedException {

		if (executionState == ExecutionState.RUNNING) {
			final SingleInputGate inputGate = inputGatesById.get(resultId);

			if (inputGate != null) {
				if (partitionState == ExecutionState.RUNNING) {
					// Retrigger the partition request
					inputGate.retriggerPartitionRequest(partitionId);
				}
				else if (partitionState == ExecutionState.CANCELED
						|| partitionState == ExecutionState.CANCELING
						|| partitionState == ExecutionState.FAILED) {

					cancelExecution();
				}
				else {
					failExternally(new IllegalStateException("Received unexpected partition state "
							+ partitionState + " for partition request. This is a bug."));
				}
			}
			else {
				failExternally(new IllegalStateException("Received partition state for " +
						"unknown input gate " + resultId + ". This is a bug."));
			}
		}
		else {
			LOG.debug("Ignoring partition state notification for not running task.");
		}
	}

	public  Task(TaskDeploymentDescriptor tdd,
				MemoryManager memManager,
				IOManager ioManager,
				NetworkEnvironment networkEnvironment,
				BroadcastVariableManager bcVarManager,
				ActorGateway taskManagerActor,
				ActorGateway jobManagerActor,
				FiniteDuration actorAskTimeout,
				LibraryCacheManager libraryCache,
				FileCache fileCache,
				TaskManagerRuntimeInfo taskManagerConfig);

}