org.apache.flink.runtime.operators.ResettableDriver Java Examples

The following examples show how to use org.apache.flink.runtime.operators.ResettableDriver. 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: DriverTestBase.java    From flink with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({"unchecked","rawtypes"})
public void testResettableDriver(ResettableDriver driver, Class stubClass, int iterations) throws Exception {

	driver.setup(this);
	
	for(int i = 0; i < iterations; i++) {
		
		if(i == 0) {
			driver.initialize();
		}
		else {
			driver.reset();
		}
		
		testDriver(driver, stubClass);
		
	}
	
	driver.teardown();
}
 
Example #2
Source File: BinaryOperatorTestBase.java    From flink with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({"unchecked", "rawtypes"})
public void testResettableDriver(ResettableDriver driver, Class stubClass, int iterations) throws Exception {
	driver.setup(this);
	
	for (int i = 0; i < iterations; i++) {
		
		if (i == 0) {
			driver.initialize();
		} else {
			driver.reset();
		}
		
		testDriver(driver, stubClass);
		
	}
	
	driver.teardown();
}
 
Example #3
Source File: UnaryOperatorTestBase.java    From flink with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({"unchecked","rawtypes"})
public void testResettableDriver(ResettableDriver driver, Class stubClass, int iterations) throws Exception {
	driver.setup(this);
	
	for (int i = 0; i < iterations; i++) {
		if (i == 0) {
			driver.initialize();
		}
		else {
			driver.reset();
		}
		testDriver(driver, stubClass);
	}
	
	driver.teardown();
}
 
Example #4
Source File: DriverTestBase.java    From flink with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({"unchecked","rawtypes"})
public void testResettableDriver(ResettableDriver driver, Class stubClass, int iterations) throws Exception {

	driver.setup(this);
	
	for(int i = 0; i < iterations; i++) {
		
		if(i == 0) {
			driver.initialize();
		}
		else {
			driver.reset();
		}
		
		testDriver(driver, stubClass);
		
	}
	
	driver.teardown();
}
 
Example #5
Source File: AbstractIterativeTask.java    From flink with Apache License 2.0 6 votes vote down vote up
private void reinstantiateDriver() throws Exception {
	if (this.driver instanceof ResettableDriver) {
		final ResettableDriver<?, ?> resDriver = (ResettableDriver<?, ?>) this.driver;
		resDriver.reset();
	} else {
		Class<? extends Driver<S, OT>> driverClass = this.config.getDriver();
		this.driver = InstantiationUtil.instantiate(driverClass, Driver.class);

		try {
			this.driver.setup(this);
		}
		catch (Throwable t) {
			throw new Exception("The pact driver setup for '" + this.getEnvironment().getTaskInfo().getTaskName() +
					"' , caused an error: " + t.getMessage(), t);
		}
	}
}
 
Example #6
Source File: AbstractIterativeTask.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
protected void closeLocalStrategiesAndCaches() {
	try {
		super.closeLocalStrategiesAndCaches();
	}
	finally {
		if (this.driver instanceof ResettableDriver) {
			final ResettableDriver<?, ?> resDriver = (ResettableDriver<?, ?>) this.driver;
			try {
				resDriver.teardown();
			} catch (Throwable t) {
				log.error("Error while shutting down an iterative operator.", t);
			}
		}
	}
}
 
Example #7
Source File: BinaryOperatorTestBase.java    From flink with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({"unchecked", "rawtypes"})
public void testResettableDriver(ResettableDriver driver, Class stubClass, int iterations) throws Exception {
	driver.setup(this);
	
	for (int i = 0; i < iterations; i++) {
		
		if (i == 0) {
			driver.initialize();
		} else {
			driver.reset();
		}
		
		testDriver(driver, stubClass);
		
	}
	
	driver.teardown();
}
 
Example #8
Source File: UnaryOperatorTestBase.java    From flink with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({"unchecked","rawtypes"})
public void testResettableDriver(ResettableDriver driver, Class stubClass, int iterations) throws Exception {
	driver.setup(this);
	
	for (int i = 0; i < iterations; i++) {
		if (i == 0) {
			driver.initialize();
		}
		else {
			driver.reset();
		}
		testDriver(driver, stubClass);
	}
	
	driver.teardown();
}
 
Example #9
Source File: AbstractIterativeTask.java    From flink with Apache License 2.0 6 votes vote down vote up
private void reinstantiateDriver() throws Exception {
	if (this.driver instanceof ResettableDriver) {
		final ResettableDriver<?, ?> resDriver = (ResettableDriver<?, ?>) this.driver;
		resDriver.reset();
	} else {
		Class<? extends Driver<S, OT>> driverClass = this.config.getDriver();
		this.driver = InstantiationUtil.instantiate(driverClass, Driver.class);

		try {
			this.driver.setup(this);
		}
		catch (Throwable t) {
			throw new Exception("The pact driver setup for '" + this.getEnvironment().getTaskInfo().getTaskName() +
					"' , caused an error: " + t.getMessage(), t);
		}
	}
}
 
Example #10
Source File: AbstractIterativeTask.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
protected void closeLocalStrategiesAndCaches() {
	try {
		super.closeLocalStrategiesAndCaches();
	}
	finally {
		if (this.driver instanceof ResettableDriver) {
			final ResettableDriver<?, ?> resDriver = (ResettableDriver<?, ?>) this.driver;
			try {
				resDriver.teardown();
			} catch (Throwable t) {
				log.error("Error while shutting down an iterative operator.", t);
			}
		}
	}
}
 
Example #11
Source File: BinaryOperatorTestBase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({"unchecked", "rawtypes"})
public void testResettableDriver(ResettableDriver driver, Class stubClass, int iterations) throws Exception {
	driver.setup(this);
	
	for (int i = 0; i < iterations; i++) {
		
		if (i == 0) {
			driver.initialize();
		} else {
			driver.reset();
		}
		
		testDriver(driver, stubClass);
		
	}
	
	driver.teardown();
}
 
Example #12
Source File: UnaryOperatorTestBase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({"unchecked","rawtypes"})
public void testResettableDriver(ResettableDriver driver, Class stubClass, int iterations) throws Exception {
	driver.setup(this);
	
	for (int i = 0; i < iterations; i++) {
		if (i == 0) {
			driver.initialize();
		}
		else {
			driver.reset();
		}
		testDriver(driver, stubClass);
	}
	
	driver.teardown();
}
 
Example #13
Source File: DriverTestBase.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({"unchecked","rawtypes"})
public void testResettableDriver(ResettableDriver driver, Class stubClass, int iterations) throws Exception {

	driver.setup(this);
	
	for(int i = 0; i < iterations; i++) {
		
		if(i == 0) {
			driver.initialize();
		}
		else {
			driver.reset();
		}
		
		testDriver(driver, stubClass);
		
	}
	
	driver.teardown();
}
 
Example #14
Source File: AbstractIterativeTask.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
private void reinstantiateDriver() throws Exception {
	if (this.driver instanceof ResettableDriver) {
		final ResettableDriver<?, ?> resDriver = (ResettableDriver<?, ?>) this.driver;
		resDriver.reset();
	} else {
		Class<? extends Driver<S, OT>> driverClass = this.config.getDriver();
		this.driver = InstantiationUtil.instantiate(driverClass, Driver.class);

		try {
			this.driver.setup(this);
		}
		catch (Throwable t) {
			throw new Exception("The pact driver setup for '" + this.getEnvironment().getTaskInfo().getTaskName() +
					"' , caused an error: " + t.getMessage(), t);
		}
	}
}
 
Example #15
Source File: AbstractIterativeTask.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
protected void closeLocalStrategiesAndCaches() {
	try {
		super.closeLocalStrategiesAndCaches();
	}
	finally {
		if (this.driver instanceof ResettableDriver) {
			final ResettableDriver<?, ?> resDriver = (ResettableDriver<?, ?>) this.driver;
			try {
				resDriver.teardown();
			} catch (Throwable t) {
				log.error("Error while shutting down an iterative operator.", t);
			}
		}
	}
}
 
Example #16
Source File: AbstractIterativeTask.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
protected void initialize() throws Exception {
	super.initialize();

	// check if the driver is resettable
	if (this.driver instanceof ResettableDriver) {
		final ResettableDriver<?, ?> resDriver = (ResettableDriver<?, ?>) this.driver;
		// make sure that the according inputs are not reset
		for (int i = 0; i < resDriver.getNumberOfInputs(); i++) {
			if (resDriver.isInputResettable(i)) {
				excludeFromReset(i);
			}
		}
	}

	TaskConfig config = getLastTasksConfig();
	isWorksetIteration = config.getIsWorksetIteration();
	isWorksetUpdate = config.getIsWorksetUpdate();
	isSolutionSetUpdate = config.getIsSolutionSetUpdate();

	if (isWorksetUpdate) {
		worksetBackChannel = BlockingBackChannelBroker.instance().getAndRemove(brokerKey());

		if (isWorksetIteration) {
			worksetAggregator = getIterationAggregators().getAggregator(WorksetEmptyConvergenceCriterion.AGGREGATOR_NAME);

			if (worksetAggregator == null) {
				throw new RuntimeException("Missing workset elements count aggregator.");
			}
		}
	}
}
 
Example #17
Source File: AbstractIterativeTask.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
protected void initialize() throws Exception {
	super.initialize();

	// check if the driver is resettable
	if (this.driver instanceof ResettableDriver) {
		final ResettableDriver<?, ?> resDriver = (ResettableDriver<?, ?>) this.driver;
		// make sure that the according inputs are not reset
		for (int i = 0; i < resDriver.getNumberOfInputs(); i++) {
			if (resDriver.isInputResettable(i)) {
				excludeFromReset(i);
			}
		}
	}

	TaskConfig config = getLastTasksConfig();
	isWorksetIteration = config.getIsWorksetIteration();
	isWorksetUpdate = config.getIsWorksetUpdate();
	isSolutionSetUpdate = config.getIsSolutionSetUpdate();

	if (isWorksetUpdate) {
		worksetBackChannel = BlockingBackChannelBroker.instance().getAndRemove(brokerKey());

		if (isWorksetIteration) {
			worksetAggregator = getIterationAggregators().getAggregator(WorksetEmptyConvergenceCriterion.AGGREGATOR_NAME);

			if (worksetAggregator == null) {
				throw new RuntimeException("Missing workset elements count aggregator.");
			}
		}
	}
}
 
Example #18
Source File: AbstractIterativeTask.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
protected void initialize() throws Exception {
	super.initialize();

	// check if the driver is resettable
	if (this.driver instanceof ResettableDriver) {
		final ResettableDriver<?, ?> resDriver = (ResettableDriver<?, ?>) this.driver;
		// make sure that the according inputs are not reset
		for (int i = 0; i < resDriver.getNumberOfInputs(); i++) {
			if (resDriver.isInputResettable(i)) {
				excludeFromReset(i);
			}
		}
	}

	TaskConfig config = getLastTasksConfig();
	isWorksetIteration = config.getIsWorksetIteration();
	isWorksetUpdate = config.getIsWorksetUpdate();
	isSolutionSetUpdate = config.getIsSolutionSetUpdate();

	if (isWorksetUpdate) {
		worksetBackChannel = BlockingBackChannelBroker.instance().getAndRemove(brokerKey());

		if (isWorksetIteration) {
			worksetAggregator = getIterationAggregators().getAggregator(WorksetEmptyConvergenceCriterion.AGGREGATOR_NAME);

			if (worksetAggregator == null) {
				throw new RuntimeException("Missing workset elements count aggregator.");
			}
		}
	}
}