@Test
  public void testRestoreWithInterrupt() throws Exception {

    Configuration taskConfig = new Configuration();
    StreamConfig cfg = new StreamConfig(taskConfig);
    cfg.setTimeCharacteristic(TimeCharacteristic.ProcessingTime);
    cfg.setStreamOperator(new StreamSource<>(new TestSource()));

    StreamStateHandle lockingHandle = new InterruptLockingStateHandle();

    TaskDeploymentDescriptor tdd = createTaskDeploymentDescriptor(taskConfig, lockingHandle);
    Task task = createTask(tdd);

    // start the task and wait until it is in "restore"
    task.startTaskThread();
    IN_RESTORE_LATCH.await();

    // trigger cancellation and signal to continue
    task.cancelExecution();

    task.getExecutingThread().join(30000);

    if (task.getExecutionState() == ExecutionState.CANCELING) {
      fail("Task is stuck and not canceling");
    }

    assertEquals(ExecutionState.CANCELED, task.getExecutionState());
    assertNull(task.getFailureCause());
  }
Exemplo n.º 2
0
  public StreamTaskTestHarness(AbstractInvokable task, TypeInformation<OUT> outputType) {
    this.task = task;
    this.memorySize = DEFAULT_MEMORY_MANAGER_SIZE;
    this.bufferSize = DEFAULT_NETWORK_BUFFER_SIZE;

    this.jobConfig = new Configuration();
    this.taskConfig = new Configuration();
    this.executionConfig = new ExecutionConfig();

    streamConfig = new StreamConfig(taskConfig);
    streamConfig.setChainStart();
    streamConfig.setBufferTimeout(0);
    streamConfig.setTimeCharacteristic(TimeCharacteristic.EventTime);

    outputSerializer = outputType.createSerializer(executionConfig);
    outputStreamRecordSerializer = new StreamElementSerializer<OUT>(outputSerializer);
  }