org.apache.flink.runtime.operators.testutils.NirvanaOutputList Java Examples

The following examples show how to use org.apache.flink.runtime.operators.testutils.NirvanaOutputList. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JoinTaskTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testFailingHashFirstMatchTask() {
	int keyCnt1 = 20;
	int valCnt1 = 20;
	
	int keyCnt2 = 20;
	int valCnt2 = 20;
	
	addInput(new UniformRecordGenerator(keyCnt1, valCnt1, false));
	addInput(new UniformRecordGenerator(keyCnt2, valCnt2, false));
	addDriverComparator(this.comparator1);
	addDriverComparator(this.comparator2);
	getTaskConfig().setDriverPairComparator(RecordPairComparatorFactory.get());
	setOutput(new NirvanaOutputList());
	getTaskConfig().setDriverStrategy(DriverStrategy.HYBRIDHASH_BUILD_FIRST);
	getTaskConfig().setRelativeMemoryDriver(hash_frac);
	
	JoinDriver<Record, Record, Record> testTask = new JoinDriver<>();
	
	try {
		testDriver(testTask, MockFailingMatchStub.class);
		Assert.fail("Function exception was not forwarded.");
	} catch (ExpectedTestException etex) {
		// good!
	} catch (Exception e) {
		e.printStackTrace();
		Assert.fail("Test caused an exception.");
	}
}
 
Example #2
Source File: DataSourceTaskTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testFailingDataSourceTask() throws IOException {
	int keyCnt = 20;
	int valCnt = 10;
	
	this.outList = new NirvanaOutputList();
	File tempTestFile = new File(tempFolder.getRoot(), UUID.randomUUID().toString());
	InputFilePreparator.prepareInputFile(new UniformRecordGenerator(keyCnt, valCnt, false),
		tempTestFile, false);

	super.initEnvironment(MEMORY_MANAGER_SIZE, NETWORK_BUFFER_SIZE);
	super.addOutput(this.outList);
	
	DataSourceTask<Record> testTask = new DataSourceTask<>(this.mockEnv);

	super.registerFileInputTask(testTask, MockFailingInputFormat.class, tempTestFile.toURI().toString(), "\n");
	
	boolean stubFailed = false;

	try {
		testTask.invoke();
	} catch (Exception e) {
		stubFailed = true;
	}
	Assert.assertTrue("Function exception was not forwarded.", stubFailed);
	
	// assert that temp file was created
	Assert.assertTrue("Temp output file does not exist",tempTestFile.exists());
	
}
 
Example #3
Source File: JoinTaskTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testFailingHashSecondMatchTask() {
	int keyCnt1 = 20;
	int valCnt1 = 20;
	
	int keyCnt2 = 20;
	int valCnt2 = 20;
	
	addInput(new UniformRecordGenerator(keyCnt1, valCnt1, false));
	addInput(new UniformRecordGenerator(keyCnt2, valCnt2, false));
	addDriverComparator(this.comparator1);
	addDriverComparator(this.comparator2);
	getTaskConfig().setDriverPairComparator(RecordPairComparatorFactory.get());
	setOutput(new NirvanaOutputList());
	getTaskConfig().setDriverStrategy(DriverStrategy.HYBRIDHASH_BUILD_SECOND);
	getTaskConfig().setRelativeMemoryDriver(hash_frac);
	
	JoinDriver<Record, Record, Record> testTask = new JoinDriver<>();
	
	try {
		testDriver(testTask, MockFailingMatchStub.class);
		Assert.fail("Function exception was not forwarded.");
	} catch (ExpectedTestException etex) {
		// good!
	} catch (Exception e) {
		e.printStackTrace();
		Assert.fail("Test caused an exception.");
	}
}
 
Example #4
Source File: JoinTaskTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testFailingHashFirstMatchTask() {
	int keyCnt1 = 20;
	int valCnt1 = 20;
	
	int keyCnt2 = 20;
	int valCnt2 = 20;
	
	addInput(new UniformRecordGenerator(keyCnt1, valCnt1, false));
	addInput(new UniformRecordGenerator(keyCnt2, valCnt2, false));
	addDriverComparator(this.comparator1);
	addDriverComparator(this.comparator2);
	getTaskConfig().setDriverPairComparator(RecordPairComparatorFactory.get());
	setOutput(new NirvanaOutputList());
	getTaskConfig().setDriverStrategy(DriverStrategy.HYBRIDHASH_BUILD_FIRST);
	getTaskConfig().setRelativeMemoryDriver(hash_frac);
	
	JoinDriver<Record, Record, Record> testTask = new JoinDriver<>();
	
	try {
		testDriver(testTask, MockFailingMatchStub.class);
		Assert.fail("Function exception was not forwarded.");
	} catch (ExpectedTestException etex) {
		// good!
	} catch (Exception e) {
		e.printStackTrace();
		Assert.fail("Test caused an exception.");
	}
}
 
Example #5
Source File: CachedMatchTaskTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testFailingHashSecondMatchTask() {
	int keyCnt1 = 20;
	int valCnt1 = 20;
	
	int keyCnt2 = 20;
	int valCnt2 = 20;
	
	addInput(new UniformRecordGenerator(keyCnt1, valCnt1, false));
	addInput(new UniformRecordGenerator(keyCnt2, valCnt2, false));
	addDriverComparator(this.comparator1);
	addDriverComparator(this.comparator2);
	getTaskConfig().setDriverPairComparator(RecordPairComparatorFactory.get());
	setOutput(new NirvanaOutputList());
	getTaskConfig().setDriverStrategy(DriverStrategy.HYBRIDHASH_BUILD_SECOND_CACHED);
	getTaskConfig().setRelativeMemoryDriver(1.0f);
	
	BuildSecondCachedJoinDriver<Record, Record, Record> testTask = new BuildSecondCachedJoinDriver<Record, Record, Record>();
	
	try {
		testResettableDriver(testTask, MockFailingMatchStub.class, 3);
		Assert.fail("Function exception was not forwarded.");
	} catch (ExpectedTestException etex) {
		// good!
	} catch (Exception e) {
		e.printStackTrace();
		Assert.fail("Test caused an exception.");
	}
}
 
Example #6
Source File: CachedMatchTaskTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testFailingHashFirstMatchTask() {
	int keyCnt1 = 20;
	int valCnt1 = 20;
	
	int keyCnt2 = 20;
	int valCnt2 = 20;
	
	addInput(new UniformRecordGenerator(keyCnt1, valCnt1, false));
	addInput(new UniformRecordGenerator(keyCnt2, valCnt2, false));
	addDriverComparator(this.comparator1);
	addDriverComparator(this.comparator2);
	getTaskConfig().setDriverPairComparator(RecordPairComparatorFactory.get());
	setOutput(new NirvanaOutputList());
	getTaskConfig().setDriverStrategy(DriverStrategy.HYBRIDHASH_BUILD_FIRST_CACHED);
	getTaskConfig().setRelativeMemoryDriver(1.0f);
	
	BuildFirstCachedJoinDriver<Record, Record, Record> testTask = new BuildFirstCachedJoinDriver<Record, Record, Record>();
	
	try {
		testResettableDriver(testTask, MockFailingMatchStub.class, 3);
		Assert.fail("Function exception was not forwarded.");
	} catch (ExpectedTestException etex) {
		// good!
	} catch (Exception e) {
		e.printStackTrace();
		Assert.fail("Test caused an exception.");
	}
}
 
Example #7
Source File: DataSourceTaskTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testFailingDataSourceTask() throws IOException {
	int keyCnt = 20;
	int valCnt = 10;
	
	this.outList = new NirvanaOutputList();
	File tempTestFile = new File(tempFolder.getRoot(), UUID.randomUUID().toString());
	InputFilePreparator.prepareInputFile(new UniformRecordGenerator(keyCnt, valCnt, false),
		tempTestFile, false);

	super.initEnvironment(MEMORY_MANAGER_SIZE, NETWORK_BUFFER_SIZE);
	super.addOutput(this.outList);
	
	DataSourceTask<Record> testTask = new DataSourceTask<>(this.mockEnv);

	super.registerFileInputTask(testTask, MockFailingInputFormat.class, tempTestFile.toURI().toString(), "\n");
	
	boolean stubFailed = false;

	try {
		testTask.invoke();
	} catch (Exception e) {
		stubFailed = true;
	}
	Assert.assertTrue("Function exception was not forwarded.", stubFailed);
	
	// assert that temp file was created
	Assert.assertTrue("Temp output file does not exist",tempTestFile.exists());
	
}
 
Example #8
Source File: JoinTaskTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testFailingHashSecondMatchTask() {
	int keyCnt1 = 20;
	int valCnt1 = 20;
	
	int keyCnt2 = 20;
	int valCnt2 = 20;
	
	addInput(new UniformRecordGenerator(keyCnt1, valCnt1, false));
	addInput(new UniformRecordGenerator(keyCnt2, valCnt2, false));
	addDriverComparator(this.comparator1);
	addDriverComparator(this.comparator2);
	getTaskConfig().setDriverPairComparator(RecordPairComparatorFactory.get());
	setOutput(new NirvanaOutputList());
	getTaskConfig().setDriverStrategy(DriverStrategy.HYBRIDHASH_BUILD_SECOND);
	getTaskConfig().setRelativeMemoryDriver(hash_frac);
	
	JoinDriver<Record, Record, Record> testTask = new JoinDriver<>();
	
	try {
		testDriver(testTask, MockFailingMatchStub.class);
		Assert.fail("Function exception was not forwarded.");
	} catch (ExpectedTestException etex) {
		// good!
	} catch (Exception e) {
		e.printStackTrace();
		Assert.fail("Test caused an exception.");
	}
}
 
Example #9
Source File: CachedMatchTaskTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testFailingHashFirstMatchTask() {
	int keyCnt1 = 20;
	int valCnt1 = 20;
	
	int keyCnt2 = 20;
	int valCnt2 = 20;
	
	addInput(new UniformRecordGenerator(keyCnt1, valCnt1, false));
	addInput(new UniformRecordGenerator(keyCnt2, valCnt2, false));
	addDriverComparator(this.comparator1);
	addDriverComparator(this.comparator2);
	getTaskConfig().setDriverPairComparator(RecordPairComparatorFactory.get());
	setOutput(new NirvanaOutputList());
	getTaskConfig().setDriverStrategy(DriverStrategy.HYBRIDHASH_BUILD_FIRST_CACHED);
	getTaskConfig().setRelativeMemoryDriver(1.0f);
	
	BuildFirstCachedJoinDriver<Record, Record, Record> testTask = new BuildFirstCachedJoinDriver<Record, Record, Record>();
	
	try {
		testResettableDriver(testTask, MockFailingMatchStub.class, 3);
		Assert.fail("Function exception was not forwarded.");
	} catch (ExpectedTestException etex) {
		// good!
	} catch (Exception e) {
		e.printStackTrace();
		Assert.fail("Test caused an exception.");
	}
}
 
Example #10
Source File: CachedMatchTaskTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testFailingHashSecondMatchTask() {
	int keyCnt1 = 20;
	int valCnt1 = 20;
	
	int keyCnt2 = 20;
	int valCnt2 = 20;
	
	addInput(new UniformRecordGenerator(keyCnt1, valCnt1, false));
	addInput(new UniformRecordGenerator(keyCnt2, valCnt2, false));
	addDriverComparator(this.comparator1);
	addDriverComparator(this.comparator2);
	getTaskConfig().setDriverPairComparator(RecordPairComparatorFactory.get());
	setOutput(new NirvanaOutputList());
	getTaskConfig().setDriverStrategy(DriverStrategy.HYBRIDHASH_BUILD_SECOND_CACHED);
	getTaskConfig().setRelativeMemoryDriver(1.0f);
	
	BuildSecondCachedJoinDriver<Record, Record, Record> testTask = new BuildSecondCachedJoinDriver<Record, Record, Record>();
	
	try {
		testResettableDriver(testTask, MockFailingMatchStub.class, 3);
		Assert.fail("Function exception was not forwarded.");
	} catch (ExpectedTestException etex) {
		// good!
	} catch (Exception e) {
		e.printStackTrace();
		Assert.fail("Test caused an exception.");
	}
}
 
Example #11
Source File: CachedMatchTaskTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testFailingHashFirstMatchTask() {
	int keyCnt1 = 20;
	int valCnt1 = 20;
	
	int keyCnt2 = 20;
	int valCnt2 = 20;
	
	addInput(new UniformRecordGenerator(keyCnt1, valCnt1, false));
	addInput(new UniformRecordGenerator(keyCnt2, valCnt2, false));
	addDriverComparator(this.comparator1);
	addDriverComparator(this.comparator2);
	getTaskConfig().setDriverPairComparator(RecordPairComparatorFactory.get());
	setOutput(new NirvanaOutputList());
	getTaskConfig().setDriverStrategy(DriverStrategy.HYBRIDHASH_BUILD_FIRST_CACHED);
	getTaskConfig().setRelativeMemoryDriver(1.0f);
	
	BuildFirstCachedJoinDriver<Record, Record, Record> testTask = new BuildFirstCachedJoinDriver<Record, Record, Record>();
	
	try {
		testResettableDriver(testTask, MockFailingMatchStub.class, 3);
		Assert.fail("Function exception was not forwarded.");
	} catch (ExpectedTestException etex) {
		// good!
	} catch (Exception e) {
		e.printStackTrace();
		Assert.fail("Test caused an exception.");
	}
}
 
Example #12
Source File: DataSourceTaskTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testFailingDataSourceTask() throws IOException {
	int keyCnt = 20;
	int valCnt = 10;
	
	this.outList = new NirvanaOutputList();
	File tempTestFile = new File(tempFolder.getRoot(), UUID.randomUUID().toString());
	InputFilePreparator.prepareInputFile(new UniformRecordGenerator(keyCnt, valCnt, false),
		tempTestFile, false);

	super.initEnvironment(MEMORY_MANAGER_SIZE, NETWORK_BUFFER_SIZE);
	super.addOutput(this.outList);
	
	DataSourceTask<Record> testTask = new DataSourceTask<>(this.mockEnv);

	super.registerFileInputTask(testTask, MockFailingInputFormat.class, tempTestFile.toURI().toString(), "\n");
	
	boolean stubFailed = false;

	try {
		testTask.invoke();
	} catch (Exception e) {
		stubFailed = true;
	}
	Assert.assertTrue("Function exception was not forwarded.", stubFailed);
	
	// assert that temp file was created
	Assert.assertTrue("Temp output file does not exist",tempTestFile.exists());
	
}
 
Example #13
Source File: JoinTaskTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testFailingHashSecondMatchTask() {
	int keyCnt1 = 20;
	int valCnt1 = 20;
	
	int keyCnt2 = 20;
	int valCnt2 = 20;
	
	addInput(new UniformRecordGenerator(keyCnt1, valCnt1, false));
	addInput(new UniformRecordGenerator(keyCnt2, valCnt2, false));
	addDriverComparator(this.comparator1);
	addDriverComparator(this.comparator2);
	getTaskConfig().setDriverPairComparator(RecordPairComparatorFactory.get());
	setOutput(new NirvanaOutputList());
	getTaskConfig().setDriverStrategy(DriverStrategy.HYBRIDHASH_BUILD_SECOND);
	getTaskConfig().setRelativeMemoryDriver(hash_frac);
	
	JoinDriver<Record, Record, Record> testTask = new JoinDriver<>();
	
	try {
		testDriver(testTask, MockFailingMatchStub.class);
		Assert.fail("Function exception was not forwarded.");
	} catch (ExpectedTestException etex) {
		// good!
	} catch (Exception e) {
		e.printStackTrace();
		Assert.fail("Test caused an exception.");
	}
}
 
Example #14
Source File: JoinTaskTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testFailingHashFirstMatchTask() {
	int keyCnt1 = 20;
	int valCnt1 = 20;
	
	int keyCnt2 = 20;
	int valCnt2 = 20;
	
	addInput(new UniformRecordGenerator(keyCnt1, valCnt1, false));
	addInput(new UniformRecordGenerator(keyCnt2, valCnt2, false));
	addDriverComparator(this.comparator1);
	addDriverComparator(this.comparator2);
	getTaskConfig().setDriverPairComparator(RecordPairComparatorFactory.get());
	setOutput(new NirvanaOutputList());
	getTaskConfig().setDriverStrategy(DriverStrategy.HYBRIDHASH_BUILD_FIRST);
	getTaskConfig().setRelativeMemoryDriver(hash_frac);
	
	JoinDriver<Record, Record, Record> testTask = new JoinDriver<>();
	
	try {
		testDriver(testTask, MockFailingMatchStub.class);
		Assert.fail("Function exception was not forwarded.");
	} catch (ExpectedTestException etex) {
		// good!
	} catch (Exception e) {
		e.printStackTrace();
		Assert.fail("Test caused an exception.");
	}
}
 
Example #15
Source File: CachedMatchTaskTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testFailingHashSecondMatchTask() {
	int keyCnt1 = 20;
	int valCnt1 = 20;
	
	int keyCnt2 = 20;
	int valCnt2 = 20;
	
	addInput(new UniformRecordGenerator(keyCnt1, valCnt1, false));
	addInput(new UniformRecordGenerator(keyCnt2, valCnt2, false));
	addDriverComparator(this.comparator1);
	addDriverComparator(this.comparator2);
	getTaskConfig().setDriverPairComparator(RecordPairComparatorFactory.get());
	setOutput(new NirvanaOutputList());
	getTaskConfig().setDriverStrategy(DriverStrategy.HYBRIDHASH_BUILD_SECOND_CACHED);
	getTaskConfig().setRelativeMemoryDriver(1.0f);
	
	BuildSecondCachedJoinDriver<Record, Record, Record> testTask = new BuildSecondCachedJoinDriver<Record, Record, Record>();
	
	try {
		testResettableDriver(testTask, MockFailingMatchStub.class, 3);
		Assert.fail("Function exception was not forwarded.");
	} catch (ExpectedTestException etex) {
		// good!
	} catch (Exception e) {
		e.printStackTrace();
		Assert.fail("Test caused an exception.");
	}
}
 
Example #16
Source File: JoinTaskTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Test
public void testCancelMatchTaskWhileMatching() {
	final int keyCnt = 20;
	final int valCnt = 20;
	
	try {
		setOutput(new NirvanaOutputList());
		addDriverComparator(this.comparator1);
		addDriverComparator(this.comparator2);
		getTaskConfig().setDriverPairComparator(RecordPairComparatorFactory.get());
		getTaskConfig().setDriverStrategy(DriverStrategy.INNER_MERGE);
		getTaskConfig().setRelativeMemoryDriver(bnljn_frac);
		setNumFileHandlesForSort(4);
		
		final JoinDriver<Record, Record, Record> testTask = new JoinDriver<>();
		
		addInput(new UniformRecordGenerator(keyCnt, valCnt, true));
		addInput(new UniformRecordGenerator(keyCnt, valCnt, true));
		
		final AtomicReference<Throwable> error = new AtomicReference<>();
		
		Thread taskRunner = new Thread("Task runner for testCancelMatchTaskWhileMatching()") {
			@Override
			public void run() {
				try {
					testDriver(testTask, MockDelayingMatchStub.class);
				}
				catch (Throwable t) {
					error.set(t);
				}
			}
		};
		taskRunner.start();
		
		Thread.sleep(1000);
		
		cancel();
		taskRunner.interrupt();
		
		taskRunner.join(60000);
		
		assertFalse("Task thread did not finish within 60 seconds", taskRunner.isAlive());
		
		Throwable taskError = error.get();
		if (taskError != null) {
			taskError.printStackTrace();
			fail("Error in task while canceling: " + taskError.getMessage());
		}
	}
	catch (Exception e) {
		e.printStackTrace();
		fail(e.getMessage());
	}
}
 
Example #17
Source File: JoinTaskTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Test
public void testCancelMatchTaskWhileMatching() {
	final int keyCnt = 20;
	final int valCnt = 20;
	
	try {
		setOutput(new NirvanaOutputList());
		addDriverComparator(this.comparator1);
		addDriverComparator(this.comparator2);
		getTaskConfig().setDriverPairComparator(RecordPairComparatorFactory.get());
		getTaskConfig().setDriverStrategy(DriverStrategy.INNER_MERGE);
		getTaskConfig().setRelativeMemoryDriver(bnljn_frac);
		setNumFileHandlesForSort(4);
		
		final JoinDriver<Record, Record, Record> testTask = new JoinDriver<>();
		
		addInput(new UniformRecordGenerator(keyCnt, valCnt, true));
		addInput(new UniformRecordGenerator(keyCnt, valCnt, true));
		
		final AtomicReference<Throwable> error = new AtomicReference<>();
		
		Thread taskRunner = new Thread("Task runner for testCancelMatchTaskWhileMatching()") {
			@Override
			public void run() {
				try {
					testDriver(testTask, MockDelayingMatchStub.class);
				}
				catch (Throwable t) {
					error.set(t);
				}
			}
		};
		taskRunner.start();
		
		Thread.sleep(1000);
		
		cancel();
		taskRunner.interrupt();
		
		taskRunner.join(60000);
		
		assertFalse("Task thread did not finish within 60 seconds", taskRunner.isAlive());
		
		Throwable taskError = error.get();
		if (taskError != null) {
			taskError.printStackTrace();
			fail("Error in task while canceling: " + taskError.getMessage());
		}
	}
	catch (Exception e) {
		e.printStackTrace();
		fail(e.getMessage());
	}
}
 
Example #18
Source File: JoinTaskTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Test
public void testCancelMatchTaskWhileMatching() {
	final int keyCnt = 20;
	final int valCnt = 20;
	
	try {
		setOutput(new NirvanaOutputList());
		addDriverComparator(this.comparator1);
		addDriverComparator(this.comparator2);
		getTaskConfig().setDriverPairComparator(RecordPairComparatorFactory.get());
		getTaskConfig().setDriverStrategy(DriverStrategy.INNER_MERGE);
		getTaskConfig().setRelativeMemoryDriver(bnljn_frac);
		setNumFileHandlesForSort(4);
		
		final JoinDriver<Record, Record, Record> testTask = new JoinDriver<>();
		
		addInput(new UniformRecordGenerator(keyCnt, valCnt, true));
		addInput(new UniformRecordGenerator(keyCnt, valCnt, true));
		
		final AtomicReference<Throwable> error = new AtomicReference<>();
		
		Thread taskRunner = new Thread("Task runner for testCancelMatchTaskWhileMatching()") {
			@Override
			public void run() {
				try {
					testDriver(testTask, MockDelayingMatchStub.class);
				}
				catch (Throwable t) {
					error.set(t);
				}
			}
		};
		taskRunner.start();
		
		Thread.sleep(1000);
		
		cancel();
		taskRunner.interrupt();
		
		taskRunner.join(60000);
		
		assertFalse("Task thread did not finish within 60 seconds", taskRunner.isAlive());
		
		Throwable taskError = error.get();
		if (taskError != null) {
			taskError.printStackTrace();
			fail("Error in task while canceling: " + taskError.getMessage());
		}
	}
	catch (Exception e) {
		e.printStackTrace();
		fail(e.getMessage());
	}
}