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

The following examples show how to use org.apache.flink.runtime.operators.testutils.DelayingIterator. 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: LeftOuterJoinTaskTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testCancelLeftOuterJoinTaskWhileProbing() throws Exception {
	setOutput(new DiscardingOutputCollector<Tuple2<Integer, Integer>>());
	addDriverComparator(this.comparator1);
	addDriverComparator(this.comparator2);
	getTaskConfig().setDriverPairComparator(new RuntimePairComparatorFactory());
	getTaskConfig().setDriverStrategy(DriverStrategy.LEFT_HYBRIDHASH_BUILD_SECOND);
	getTaskConfig().setRelativeMemoryDriver(this.hash_frac);

	final AbstractOuterJoinDriver<Tuple2<Integer, Integer>, Tuple2<Integer, Integer>, Tuple2<Integer, Integer>> testTask = getOuterJoinDriver();

	addInput(new DelayingIterator<>(new InfiniteIntTupleIterator(), 100), this.serializer);
	addInput(new UniformIntTupleGenerator(1, 1, true), this.serializer);

	final AtomicReference<Throwable> error = new AtomicReference<>();

	final Thread taskRunner = new Thread("Task runner for testCancelOuterJoinTaskWhileSort1()") {
		@Override
		public void run() {
			try {
				testDriver(testTask, MockJoinStub.class);
			} catch (Throwable t) {
				error.set(t);
			}
		}
	};
	taskRunner.start();

	Thread.sleep(1000);

	cancel();
	taskRunner.join(60000);

	assertFalse("Task thread did not finish within 60 seconds", taskRunner.isAlive());

	final Throwable taskError = error.get();
	if (taskError != null) {
		fail("Error in task while canceling:\n" + Throwables.getStackTraceAsString(taskError));
	}
}
 
Example #2
Source File: RightOuterJoinTaskTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testCancelRightOuterJoinTaskWhileProbing() throws Exception {
	setOutput(new DiscardingOutputCollector<Tuple2<Integer, Integer>>());
	addDriverComparator(this.comparator1);
	addDriverComparator(this.comparator2);
	getTaskConfig().setDriverPairComparator(new RuntimePairComparatorFactory());
	getTaskConfig().setDriverStrategy(DriverStrategy.RIGHT_HYBRIDHASH_BUILD_FIRST);
	getTaskConfig().setRelativeMemoryDriver(this.hash_frac);

	final AbstractOuterJoinDriver<Tuple2<Integer, Integer>, Tuple2<Integer, Integer>, Tuple2<Integer, Integer>> testTask = getOuterJoinDriver();

	addInput(new UniformIntTupleGenerator(1, 1, true), this.serializer);
	addInput(new DelayingIterator<>(new InfiniteIntTupleIterator(), 100), this.serializer);

	final AtomicReference<Throwable> error = new AtomicReference<>();

	final Thread taskRunner = new Thread("Task runner for testCancelOuterJoinTaskWhileSort1()") {
		@Override
		public void run() {
			try {
				testDriver(testTask, MockJoinStub.class);
			} catch (Throwable t) {
				error.set(t);
			}
		}
	};
	taskRunner.start();

	Thread.sleep(1000);

	cancel();
	taskRunner.join(60000);

	assertFalse("Task thread did not finish within 60 seconds", taskRunner.isAlive());

	final Throwable taskError = error.get();
	if (taskError != null) {
		fail("Error in task while canceling:\n" + Throwables.getStackTraceAsString(taskError));
	}
}
 
Example #3
Source File: RightOuterJoinTaskTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testCancelRightOuterJoinTaskWhileBuilding() throws Exception {
	setOutput(new DiscardingOutputCollector<Tuple2<Integer, Integer>>());
	addDriverComparator(this.comparator1);
	addDriverComparator(this.comparator2);
	getTaskConfig().setDriverPairComparator(new RuntimePairComparatorFactory());
	getTaskConfig().setDriverStrategy(DriverStrategy.RIGHT_HYBRIDHASH_BUILD_FIRST);
	getTaskConfig().setRelativeMemoryDriver(this.hash_frac);

	final AbstractOuterJoinDriver<Tuple2<Integer, Integer>, Tuple2<Integer, Integer>, Tuple2<Integer, Integer>> testTask = getOuterJoinDriver();

	addInput(new DelayingIterator<>(new InfiniteIntTupleIterator(), 100), this.serializer);
	addInput(new UniformIntTupleGenerator(100, 100, true), this.serializer);

	final AtomicReference<Throwable> error = new AtomicReference<>();

	final Thread taskRunner = new Thread("Task runner for testCancelOuterJoinTaskWhileSort1()") {
		@Override
		public void run() {
			try {
				testDriver(testTask, MockJoinStub.class);
			} catch (Throwable t) {
				error.set(t);
			}
		}
	};
	taskRunner.start();

	Thread.sleep(1000);

	cancel();
	taskRunner.join(60000);

	assertFalse("Task thread did not finish within 60 seconds", taskRunner.isAlive());

	final Throwable taskError = error.get();
	if (taskError != null) {
		fail("Error in task while canceling:\n" + Throwables.getStackTraceAsString(taskError));
	}
}
 
Example #4
Source File: LeftOuterJoinTaskTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testCancelLeftOuterJoinTaskWhileProbing() throws Exception {
	setOutput(new DiscardingOutputCollector<Tuple2<Integer, Integer>>());
	addDriverComparator(this.comparator1);
	addDriverComparator(this.comparator2);
	getTaskConfig().setDriverPairComparator(new RuntimePairComparatorFactory());
	getTaskConfig().setDriverStrategy(DriverStrategy.LEFT_HYBRIDHASH_BUILD_SECOND);
	getTaskConfig().setRelativeMemoryDriver(this.hash_frac);

	final AbstractOuterJoinDriver<Tuple2<Integer, Integer>, Tuple2<Integer, Integer>, Tuple2<Integer, Integer>> testTask = getOuterJoinDriver();

	addInput(new DelayingIterator<>(new InfiniteIntTupleIterator(), 100), this.serializer);
	addInput(new UniformIntTupleGenerator(1, 1, true), this.serializer);

	final AtomicReference<Throwable> error = new AtomicReference<>();

	final Thread taskRunner = new Thread("Task runner for testCancelOuterJoinTaskWhileSort1()") {
		@Override
		public void run() {
			try {
				testDriver(testTask, MockJoinStub.class);
			} catch (Throwable t) {
				error.set(t);
			}
		}
	};
	taskRunner.start();

	Thread.sleep(1000);

	cancel();
	taskRunner.join(60000);

	assertFalse("Task thread did not finish within 60 seconds", taskRunner.isAlive());

	final Throwable taskError = error.get();
	if (taskError != null) {
		fail("Error in task while canceling:\n" + Throwables.getStackTraceAsString(taskError));
	}
}
 
Example #5
Source File: LeftOuterJoinTaskTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testCancelLeftOuterJoinTaskWhileBuilding() throws Exception {
	setOutput(new DiscardingOutputCollector<Tuple2<Integer, Integer>>());
	addDriverComparator(this.comparator1);
	addDriverComparator(this.comparator2);
	getTaskConfig().setDriverPairComparator(new RuntimePairComparatorFactory());
	getTaskConfig().setDriverStrategy(DriverStrategy.LEFT_HYBRIDHASH_BUILD_SECOND);
	getTaskConfig().setRelativeMemoryDriver(this.hash_frac);

	final AbstractOuterJoinDriver<Tuple2<Integer, Integer>, Tuple2<Integer, Integer>, Tuple2<Integer, Integer>> testTask = getOuterJoinDriver();

	addInput(new UniformIntTupleGenerator(100, 100, true), this.serializer);
	addInput(new DelayingIterator<>(new InfiniteIntTupleIterator(), 100), this.serializer);

	final AtomicReference<Throwable> error = new AtomicReference<>();

	final Thread taskRunner = new Thread("Task runner for testCancelOuterJoinTaskWhileSort1()") {
		@Override
		public void run() {
			try {
				testDriver(testTask, MockJoinStub.class);
			} catch (Throwable t) {
				error.set(t);
			}
		}
	};
	taskRunner.start();

	Thread.sleep(1000);

	cancel();
	taskRunner.join(60000);

	assertFalse("Task thread did not finish within 60 seconds", taskRunner.isAlive());

	final Throwable taskError = error.get();
	if (taskError != null) {
		fail("Error in task while canceling:\n" + Throwables.getStackTraceAsString(taskError));
	}
}
 
Example #6
Source File: RightOuterJoinTaskTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testCancelRightOuterJoinTaskWhileProbing() throws Exception {
	setOutput(new DiscardingOutputCollector<Tuple2<Integer, Integer>>());
	addDriverComparator(this.comparator1);
	addDriverComparator(this.comparator2);
	getTaskConfig().setDriverPairComparator(new RuntimePairComparatorFactory());
	getTaskConfig().setDriverStrategy(DriverStrategy.RIGHT_HYBRIDHASH_BUILD_FIRST);
	getTaskConfig().setRelativeMemoryDriver(this.hash_frac);

	final AbstractOuterJoinDriver<Tuple2<Integer, Integer>, Tuple2<Integer, Integer>, Tuple2<Integer, Integer>> testTask = getOuterJoinDriver();

	addInput(new UniformIntTupleGenerator(1, 1, true), this.serializer);
	addInput(new DelayingIterator<>(new InfiniteIntTupleIterator(), 100), this.serializer);

	final AtomicReference<Throwable> error = new AtomicReference<>();

	final Thread taskRunner = new Thread("Task runner for testCancelOuterJoinTaskWhileSort1()") {
		@Override
		public void run() {
			try {
				testDriver(testTask, MockJoinStub.class);
			} catch (Throwable t) {
				error.set(t);
			}
		}
	};
	taskRunner.start();

	Thread.sleep(1000);

	cancel();
	taskRunner.join(60000);

	assertFalse("Task thread did not finish within 60 seconds", taskRunner.isAlive());

	final Throwable taskError = error.get();
	if (taskError != null) {
		fail("Error in task while canceling:\n" + Throwables.getStackTraceAsString(taskError));
	}
}
 
Example #7
Source File: RightOuterJoinTaskTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testCancelRightOuterJoinTaskWhileBuilding() throws Exception {
	setOutput(new DiscardingOutputCollector<Tuple2<Integer, Integer>>());
	addDriverComparator(this.comparator1);
	addDriverComparator(this.comparator2);
	getTaskConfig().setDriverPairComparator(new RuntimePairComparatorFactory());
	getTaskConfig().setDriverStrategy(DriverStrategy.RIGHT_HYBRIDHASH_BUILD_FIRST);
	getTaskConfig().setRelativeMemoryDriver(this.hash_frac);

	final AbstractOuterJoinDriver<Tuple2<Integer, Integer>, Tuple2<Integer, Integer>, Tuple2<Integer, Integer>> testTask = getOuterJoinDriver();

	addInput(new DelayingIterator<>(new InfiniteIntTupleIterator(), 100), this.serializer);
	addInput(new UniformIntTupleGenerator(100, 100, true), this.serializer);

	final AtomicReference<Throwable> error = new AtomicReference<>();

	final Thread taskRunner = new Thread("Task runner for testCancelOuterJoinTaskWhileSort1()") {
		@Override
		public void run() {
			try {
				testDriver(testTask, MockJoinStub.class);
			} catch (Throwable t) {
				error.set(t);
			}
		}
	};
	taskRunner.start();

	Thread.sleep(1000);

	cancel();
	taskRunner.join(60000);

	assertFalse("Task thread did not finish within 60 seconds", taskRunner.isAlive());

	final Throwable taskError = error.get();
	if (taskError != null) {
		fail("Error in task while canceling:\n" + Throwables.getStackTraceAsString(taskError));
	}
}
 
Example #8
Source File: LeftOuterJoinTaskTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testCancelLeftOuterJoinTaskWhileProbing() throws Exception {
	setOutput(new DiscardingOutputCollector<Tuple2<Integer, Integer>>());
	addDriverComparator(this.comparator1);
	addDriverComparator(this.comparator2);
	getTaskConfig().setDriverPairComparator(new RuntimePairComparatorFactory());
	getTaskConfig().setDriverStrategy(DriverStrategy.LEFT_HYBRIDHASH_BUILD_SECOND);
	getTaskConfig().setRelativeMemoryDriver(this.hash_frac);

	final AbstractOuterJoinDriver<Tuple2<Integer, Integer>, Tuple2<Integer, Integer>, Tuple2<Integer, Integer>> testTask = getOuterJoinDriver();

	addInput(new DelayingIterator<>(new InfiniteIntTupleIterator(), 100), this.serializer);
	addInput(new UniformIntTupleGenerator(1, 1, true), this.serializer);

	final AtomicReference<Throwable> error = new AtomicReference<>();

	final Thread taskRunner = new Thread("Task runner for testCancelOuterJoinTaskWhileSort1()") {
		@Override
		public void run() {
			try {
				testDriver(testTask, MockJoinStub.class);
			} catch (Throwable t) {
				error.set(t);
			}
		}
	};
	taskRunner.start();

	Thread.sleep(1000);

	cancel();
	taskRunner.join(60000);

	assertFalse("Task thread did not finish within 60 seconds", taskRunner.isAlive());

	final Throwable taskError = error.get();
	if (taskError != null) {
		fail("Error in task while canceling:\n" + Throwables.getStackTraceAsString(taskError));
	}
}
 
Example #9
Source File: LeftOuterJoinTaskTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testCancelLeftOuterJoinTaskWhileBuilding() throws Exception {
	setOutput(new DiscardingOutputCollector<Tuple2<Integer, Integer>>());
	addDriverComparator(this.comparator1);
	addDriverComparator(this.comparator2);
	getTaskConfig().setDriverPairComparator(new RuntimePairComparatorFactory());
	getTaskConfig().setDriverStrategy(DriverStrategy.LEFT_HYBRIDHASH_BUILD_SECOND);
	getTaskConfig().setRelativeMemoryDriver(this.hash_frac);

	final AbstractOuterJoinDriver<Tuple2<Integer, Integer>, Tuple2<Integer, Integer>, Tuple2<Integer, Integer>> testTask = getOuterJoinDriver();

	addInput(new UniformIntTupleGenerator(100, 100, true), this.serializer);
	addInput(new DelayingIterator<>(new InfiniteIntTupleIterator(), 100), this.serializer);

	final AtomicReference<Throwable> error = new AtomicReference<>();

	final Thread taskRunner = new Thread("Task runner for testCancelOuterJoinTaskWhileSort1()") {
		@Override
		public void run() {
			try {
				testDriver(testTask, MockJoinStub.class);
			} catch (Throwable t) {
				error.set(t);
			}
		}
	};
	taskRunner.start();

	Thread.sleep(1000);

	cancel();
	taskRunner.join(60000);

	assertFalse("Task thread did not finish within 60 seconds", taskRunner.isAlive());

	final Throwable taskError = error.get();
	if (taskError != null) {
		fail("Error in task while canceling:\n" + Throwables.getStackTraceAsString(taskError));
	}
}
 
Example #10
Source File: RightOuterJoinTaskTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testCancelRightOuterJoinTaskWhileProbing() throws Exception {
	setOutput(new DiscardingOutputCollector<Tuple2<Integer, Integer>>());
	addDriverComparator(this.comparator1);
	addDriverComparator(this.comparator2);
	getTaskConfig().setDriverPairComparator(new RuntimePairComparatorFactory());
	getTaskConfig().setDriverStrategy(DriverStrategy.RIGHT_HYBRIDHASH_BUILD_FIRST);
	getTaskConfig().setRelativeMemoryDriver(this.hash_frac);

	final AbstractOuterJoinDriver<Tuple2<Integer, Integer>, Tuple2<Integer, Integer>, Tuple2<Integer, Integer>> testTask = getOuterJoinDriver();

	addInput(new UniformIntTupleGenerator(1, 1, true), this.serializer);
	addInput(new DelayingIterator<>(new InfiniteIntTupleIterator(), 100), this.serializer);

	final AtomicReference<Throwable> error = new AtomicReference<>();

	final Thread taskRunner = new Thread("Task runner for testCancelOuterJoinTaskWhileSort1()") {
		@Override
		public void run() {
			try {
				testDriver(testTask, MockJoinStub.class);
			} catch (Throwable t) {
				error.set(t);
			}
		}
	};
	taskRunner.start();

	Thread.sleep(1000);

	cancel();
	taskRunner.join(60000);

	assertFalse("Task thread did not finish within 60 seconds", taskRunner.isAlive());

	final Throwable taskError = error.get();
	if (taskError != null) {
		fail("Error in task while canceling:\n" + Throwables.getStackTraceAsString(taskError));
	}
}
 
Example #11
Source File: RightOuterJoinTaskTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testCancelRightOuterJoinTaskWhileBuilding() throws Exception {
	setOutput(new DiscardingOutputCollector<Tuple2<Integer, Integer>>());
	addDriverComparator(this.comparator1);
	addDriverComparator(this.comparator2);
	getTaskConfig().setDriverPairComparator(new RuntimePairComparatorFactory());
	getTaskConfig().setDriverStrategy(DriverStrategy.RIGHT_HYBRIDHASH_BUILD_FIRST);
	getTaskConfig().setRelativeMemoryDriver(this.hash_frac);

	final AbstractOuterJoinDriver<Tuple2<Integer, Integer>, Tuple2<Integer, Integer>, Tuple2<Integer, Integer>> testTask = getOuterJoinDriver();

	addInput(new DelayingIterator<>(new InfiniteIntTupleIterator(), 100), this.serializer);
	addInput(new UniformIntTupleGenerator(100, 100, true), this.serializer);

	final AtomicReference<Throwable> error = new AtomicReference<>();

	final Thread taskRunner = new Thread("Task runner for testCancelOuterJoinTaskWhileSort1()") {
		@Override
		public void run() {
			try {
				testDriver(testTask, MockJoinStub.class);
			} catch (Throwable t) {
				error.set(t);
			}
		}
	};
	taskRunner.start();

	Thread.sleep(1000);

	cancel();
	taskRunner.join(60000);

	assertFalse("Task thread did not finish within 60 seconds", taskRunner.isAlive());

	final Throwable taskError = error.get();
	if (taskError != null) {
		fail("Error in task while canceling:\n" + Throwables.getStackTraceAsString(taskError));
	}
}
 
Example #12
Source File: LeftOuterJoinTaskTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testCancelLeftOuterJoinTaskWhileBuilding() throws Exception {
	setOutput(new DiscardingOutputCollector<Tuple2<Integer, Integer>>());
	addDriverComparator(this.comparator1);
	addDriverComparator(this.comparator2);
	getTaskConfig().setDriverPairComparator(new RuntimePairComparatorFactory());
	getTaskConfig().setDriverStrategy(DriverStrategy.LEFT_HYBRIDHASH_BUILD_SECOND);
	getTaskConfig().setRelativeMemoryDriver(this.hash_frac);

	final AbstractOuterJoinDriver<Tuple2<Integer, Integer>, Tuple2<Integer, Integer>, Tuple2<Integer, Integer>> testTask = getOuterJoinDriver();

	addInput(new UniformIntTupleGenerator(100, 100, true), this.serializer);
	addInput(new DelayingIterator<>(new InfiniteIntTupleIterator(), 100), this.serializer);

	final AtomicReference<Throwable> error = new AtomicReference<>();

	final Thread taskRunner = new Thread("Task runner for testCancelOuterJoinTaskWhileSort1()") {
		@Override
		public void run() {
			try {
				testDriver(testTask, MockJoinStub.class);
			} catch (Throwable t) {
				error.set(t);
			}
		}
	};
	taskRunner.start();

	Thread.sleep(1000);

	cancel();
	taskRunner.join(60000);

	assertFalse("Task thread did not finish within 60 seconds", taskRunner.isAlive());

	final Throwable taskError = error.get();
	if (taskError != null) {
		fail("Error in task while canceling:\n" + Throwables.getStackTraceAsString(taskError));
	}
}
 
Example #13
Source File: AbstractOuterJoinTaskTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Test
public void testCancelOuterJoinTaskWhileSort1() throws Exception {
	setOutput(new DiscardingOutputCollector<Tuple2<Integer, Integer>>());
	addDriverComparator(this.comparator1);
	addDriverComparator(this.comparator2);
	getTaskConfig().setDriverPairComparator(new RuntimePairComparatorFactory());
	getTaskConfig().setDriverStrategy(this.getSortDriverStrategy());
	getTaskConfig().setRelativeMemoryDriver(this.bnljn_frac);
	setNumFileHandlesForSort(4);
	
	final AbstractOuterJoinDriver<Tuple2<Integer, Integer>, Tuple2<Integer, Integer>, Tuple2<Integer, Integer>> testTask = getOuterJoinDriver();
	
	addInputSorted(new DelayingIterator<>(new InfiniteIntTupleIterator(), 100), this.serializer, this.comparator1.duplicate());
	addInput(new DelayingIterator<>(new InfiniteIntTupleIterator(), 100), this.serializer);
	
	final AtomicReference<Throwable> error = new AtomicReference<>();
	
	final Thread taskRunner = new Thread("Task runner for testCancelOuterJoinTaskWhileSort1()") {
		@Override
		public void run() {
			try {
				testDriver(testTask, MockJoinStub.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());
	
	final Throwable taskError = error.get();
	if (taskError != null) {
		fail("Error in task while canceling:\n" + Throwables.getStackTraceAsString(taskError));
	}
}
 
Example #14
Source File: AbstractOuterJoinTaskTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Test
public void testCancelOuterJoinTaskWhileSort2() throws Exception {
	setOutput(new DiscardingOutputCollector<Tuple2<Integer, Integer>>());
	addDriverComparator(this.comparator1);
	addDriverComparator(this.comparator2);
	getTaskConfig().setDriverPairComparator(new RuntimePairComparatorFactory());
	getTaskConfig().setDriverStrategy(this.getSortDriverStrategy());
	getTaskConfig().setRelativeMemoryDriver(this.bnljn_frac);
	setNumFileHandlesForSort(4);
	
	final AbstractOuterJoinDriver<Tuple2<Integer, Integer>, Tuple2<Integer, Integer>, Tuple2<Integer, Integer>> testTask = getOuterJoinDriver();
	
	addInput(new DelayingIterator<>(new InfiniteIntTupleIterator(), 1), this.serializer);
	addInputSorted(new DelayingIterator<>(new InfiniteIntTupleIterator(), 1), this.serializer, this.comparator2.duplicate());
	
	final AtomicReference<Throwable> error = new AtomicReference<>();
	
	final Thread taskRunner = new Thread("Task runner for testCancelOuterJoinTaskWhileSort2()") {
		@Override
		public void run() {
			try {
				testDriver(testTask, MockJoinStub.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());
	
	final Throwable taskError = error.get();
	if (taskError != null) {
		fail("Error in task while canceling:\n" + Throwables.getStackTraceAsString(taskError));
	}
}
 
Example #15
Source File: AbstractOuterJoinTaskTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Test
public void testCancelOuterJoinTaskWhileRunning() throws Exception {
	setOutput(new DiscardingOutputCollector<Tuple2<Integer, Integer>>());
	addDriverComparator(this.comparator1);
	addDriverComparator(this.comparator2);
	getTaskConfig().setDriverPairComparator(new RuntimePairComparatorFactory());
	getTaskConfig().setDriverStrategy(this.getSortDriverStrategy());
	getTaskConfig().setRelativeMemoryDriver(bnljn_frac);
	setNumFileHandlesForSort(4);
	
	final AbstractOuterJoinDriver<Tuple2<Integer, Integer>, Tuple2<Integer, Integer>, Tuple2<Integer, Integer>> testTask = getOuterJoinDriver();
	
	addInput(new DelayingIterator<>(new InfiniteIntTupleIterator(), 100), this.serializer);
	addInput(new DelayingIterator<>(new InfiniteIntTupleIterator(), 100), this.serializer);
	
	final AtomicReference<Throwable> error = new AtomicReference<>();
	
	final Thread taskRunner = new Thread("Task runner for testCancelOuterJoinTaskWhileRunning()") {
		@Override
		public void run() {
			try {
				testDriver(testTask, MockJoinStub.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());
	
	final Throwable taskError = error.get();
	if (taskError != null) {
		fail("Error in task while canceling:\n" + Throwables.getStackTraceAsString(taskError));
	}
}
 
Example #16
Source File: AbstractOuterJoinTaskTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Test
public void testCancelOuterJoinTaskWhileRunning() throws Exception {
	setOutput(new DiscardingOutputCollector<Tuple2<Integer, Integer>>());
	addDriverComparator(this.comparator1);
	addDriverComparator(this.comparator2);
	getTaskConfig().setDriverPairComparator(new RuntimePairComparatorFactory());
	getTaskConfig().setDriverStrategy(this.getSortDriverStrategy());
	getTaskConfig().setRelativeMemoryDriver(bnljn_frac);
	setNumFileHandlesForSort(4);
	
	final AbstractOuterJoinDriver<Tuple2<Integer, Integer>, Tuple2<Integer, Integer>, Tuple2<Integer, Integer>> testTask = getOuterJoinDriver();
	
	addInput(new DelayingIterator<>(new InfiniteIntTupleIterator(), 100), this.serializer);
	addInput(new DelayingIterator<>(new InfiniteIntTupleIterator(), 100), this.serializer);
	
	final AtomicReference<Throwable> error = new AtomicReference<>();
	
	final Thread taskRunner = new Thread("Task runner for testCancelOuterJoinTaskWhileRunning()") {
		@Override
		public void run() {
			try {
				testDriver(testTask, MockJoinStub.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());
	
	final Throwable taskError = error.get();
	if (taskError != null) {
		fail("Error in task while canceling:\n" + Throwables.getStackTraceAsString(taskError));
	}
}
 
Example #17
Source File: AbstractOuterJoinTaskTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Test
public void testCancelOuterJoinTaskWhileSort2() throws Exception {
	setOutput(new DiscardingOutputCollector<Tuple2<Integer, Integer>>());
	addDriverComparator(this.comparator1);
	addDriverComparator(this.comparator2);
	getTaskConfig().setDriverPairComparator(new RuntimePairComparatorFactory());
	getTaskConfig().setDriverStrategy(this.getSortDriverStrategy());
	getTaskConfig().setRelativeMemoryDriver(this.bnljn_frac);
	setNumFileHandlesForSort(4);
	
	final AbstractOuterJoinDriver<Tuple2<Integer, Integer>, Tuple2<Integer, Integer>, Tuple2<Integer, Integer>> testTask = getOuterJoinDriver();
	
	addInput(new DelayingIterator<>(new InfiniteIntTupleIterator(), 1), this.serializer);
	addInputSorted(new DelayingIterator<>(new InfiniteIntTupleIterator(), 1), this.serializer, this.comparator2.duplicate());
	
	final AtomicReference<Throwable> error = new AtomicReference<>();
	
	final Thread taskRunner = new Thread("Task runner for testCancelOuterJoinTaskWhileSort2()") {
		@Override
		public void run() {
			try {
				testDriver(testTask, MockJoinStub.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());
	
	final Throwable taskError = error.get();
	if (taskError != null) {
		fail("Error in task while canceling:\n" + Throwables.getStackTraceAsString(taskError));
	}
}
 
Example #18
Source File: AbstractOuterJoinTaskTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Test
public void testCancelOuterJoinTaskWhileSort1() throws Exception {
	setOutput(new DiscardingOutputCollector<Tuple2<Integer, Integer>>());
	addDriverComparator(this.comparator1);
	addDriverComparator(this.comparator2);
	getTaskConfig().setDriverPairComparator(new RuntimePairComparatorFactory());
	getTaskConfig().setDriverStrategy(this.getSortDriverStrategy());
	getTaskConfig().setRelativeMemoryDriver(this.bnljn_frac);
	setNumFileHandlesForSort(4);
	
	final AbstractOuterJoinDriver<Tuple2<Integer, Integer>, Tuple2<Integer, Integer>, Tuple2<Integer, Integer>> testTask = getOuterJoinDriver();
	
	addInputSorted(new DelayingIterator<>(new InfiniteIntTupleIterator(), 100), this.serializer, this.comparator1.duplicate());
	addInput(new DelayingIterator<>(new InfiniteIntTupleIterator(), 100), this.serializer);
	
	final AtomicReference<Throwable> error = new AtomicReference<>();
	
	final Thread taskRunner = new Thread("Task runner for testCancelOuterJoinTaskWhileSort1()") {
		@Override
		public void run() {
			try {
				testDriver(testTask, MockJoinStub.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());
	
	final Throwable taskError = error.get();
	if (taskError != null) {
		fail("Error in task while canceling:\n" + Throwables.getStackTraceAsString(taskError));
	}
}
 
Example #19
Source File: AbstractOuterJoinTaskTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Test
public void testCancelOuterJoinTaskWhileSort2() throws Exception {
	setOutput(new DiscardingOutputCollector<Tuple2<Integer, Integer>>());
	addDriverComparator(this.comparator1);
	addDriverComparator(this.comparator2);
	getTaskConfig().setDriverPairComparator(new RuntimePairComparatorFactory());
	getTaskConfig().setDriverStrategy(this.getSortDriverStrategy());
	getTaskConfig().setRelativeMemoryDriver(this.bnljn_frac);
	setNumFileHandlesForSort(4);
	
	final AbstractOuterJoinDriver<Tuple2<Integer, Integer>, Tuple2<Integer, Integer>, Tuple2<Integer, Integer>> testTask = getOuterJoinDriver();
	
	addInput(new DelayingIterator<>(new InfiniteIntTupleIterator(), 1), this.serializer);
	addInputSorted(new DelayingIterator<>(new InfiniteIntTupleIterator(), 1), this.serializer, this.comparator2.duplicate());
	
	final AtomicReference<Throwable> error = new AtomicReference<>();
	
	final Thread taskRunner = new Thread("Task runner for testCancelOuterJoinTaskWhileSort2()") {
		@Override
		public void run() {
			try {
				testDriver(testTask, MockJoinStub.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());
	
	final Throwable taskError = error.get();
	if (taskError != null) {
		fail("Error in task while canceling:\n" + Throwables.getStackTraceAsString(taskError));
	}
}
 
Example #20
Source File: AbstractOuterJoinTaskTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Test
public void testCancelOuterJoinTaskWhileRunning() throws Exception {
	setOutput(new DiscardingOutputCollector<Tuple2<Integer, Integer>>());
	addDriverComparator(this.comparator1);
	addDriverComparator(this.comparator2);
	getTaskConfig().setDriverPairComparator(new RuntimePairComparatorFactory());
	getTaskConfig().setDriverStrategy(this.getSortDriverStrategy());
	getTaskConfig().setRelativeMemoryDriver(bnljn_frac);
	setNumFileHandlesForSort(4);
	
	final AbstractOuterJoinDriver<Tuple2<Integer, Integer>, Tuple2<Integer, Integer>, Tuple2<Integer, Integer>> testTask = getOuterJoinDriver();
	
	addInput(new DelayingIterator<>(new InfiniteIntTupleIterator(), 100), this.serializer);
	addInput(new DelayingIterator<>(new InfiniteIntTupleIterator(), 100), this.serializer);
	
	final AtomicReference<Throwable> error = new AtomicReference<>();
	
	final Thread taskRunner = new Thread("Task runner for testCancelOuterJoinTaskWhileRunning()") {
		@Override
		public void run() {
			try {
				testDriver(testTask, MockJoinStub.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());
	
	final Throwable taskError = error.get();
	if (taskError != null) {
		fail("Error in task while canceling:\n" + Throwables.getStackTraceAsString(taskError));
	}
}
 
Example #21
Source File: AbstractOuterJoinTaskTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Test
public void testCancelOuterJoinTaskWhileSort1() throws Exception {
	setOutput(new DiscardingOutputCollector<Tuple2<Integer, Integer>>());
	addDriverComparator(this.comparator1);
	addDriverComparator(this.comparator2);
	getTaskConfig().setDriverPairComparator(new RuntimePairComparatorFactory());
	getTaskConfig().setDriverStrategy(this.getSortDriverStrategy());
	getTaskConfig().setRelativeMemoryDriver(this.bnljn_frac);
	setNumFileHandlesForSort(4);
	
	final AbstractOuterJoinDriver<Tuple2<Integer, Integer>, Tuple2<Integer, Integer>, Tuple2<Integer, Integer>> testTask = getOuterJoinDriver();
	
	addInputSorted(new DelayingIterator<>(new InfiniteIntTupleIterator(), 100), this.serializer, this.comparator1.duplicate());
	addInput(new DelayingIterator<>(new InfiniteIntTupleIterator(), 100), this.serializer);
	
	final AtomicReference<Throwable> error = new AtomicReference<>();
	
	final Thread taskRunner = new Thread("Task runner for testCancelOuterJoinTaskWhileSort1()") {
		@Override
		public void run() {
			try {
				testDriver(testTask, MockJoinStub.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());
	
	final Throwable taskError = error.get();
	if (taskError != null) {
		fail("Error in task while canceling:\n" + Throwables.getStackTraceAsString(taskError));
	}
}