Search in sources :

Example 1 with InputSelection

use of org.apache.flink.streaming.api.operators.InputSelection in project flink by apache.

the class MultipleInputSelectionHandlerTest method testShouldSetAvailableForAnotherInput.

@Test
public void testShouldSetAvailableForAnotherInput() {
    InputSelection secondAndThird = new InputSelection.Builder().select(2).select(3).build();
    MultipleInputSelectionHandler selectionHandler = new MultipleInputSelectionHandler(() -> secondAndThird, 3);
    selectionHandler.nextSelection();
    assertFalse(selectionHandler.shouldSetAvailableForAnotherInput());
    selectionHandler.setUnavailableInput(0);
    assertFalse(selectionHandler.shouldSetAvailableForAnotherInput());
    selectionHandler.setUnavailableInput(2);
    assertTrue(selectionHandler.shouldSetAvailableForAnotherInput());
    selectionHandler.setAvailableInput(0);
    assertTrue(selectionHandler.shouldSetAvailableForAnotherInput());
    selectionHandler.setAvailableInput(2);
    assertFalse(selectionHandler.shouldSetAvailableForAnotherInput());
}
Also used : InputSelection(org.apache.flink.streaming.api.operators.InputSelection) Test(org.junit.Test)

Example 2 with InputSelection

use of org.apache.flink.streaming.api.operators.InputSelection in project flink by apache.

the class MultipleInputSelectionHandlerTest method testLargeInputCount.

@Test
public void testLargeInputCount() {
    int inputCount = MultipleInputSelectionHandler.MAX_SUPPORTED_INPUT_COUNT;
    InputSelection.Builder builder = new InputSelection.Builder();
    for (int i = 1; i <= inputCount; i++) {
        builder.select(i);
    }
    InputSelection allSelected = builder.build();
    MultipleInputSelectionHandler selectionHandler = new MultipleInputSelectionHandler(() -> allSelected, inputCount);
    selectionHandler.nextSelection();
    for (int i = 0; i < inputCount - 1; i++) {
        selectionHandler.setUnavailableInput(i);
    }
    assertTrue(selectionHandler.isAnyInputAvailable());
    selectionHandler.setUnavailableInput(inputCount - 1);
    assertFalse(selectionHandler.isAnyInputAvailable());
}
Also used : InputSelection(org.apache.flink.streaming.api.operators.InputSelection) Test(org.junit.Test)

Aggregations

InputSelection (org.apache.flink.streaming.api.operators.InputSelection)2 Test (org.junit.Test)2