All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gedi.solutions.geode.functions.JvmExecution Maven / Gradle / Ivy

Go to download

GemFire Enterprise Data Integration - common development extensions powered by Apache Geode

The newest version!
package gedi.solutions.geode.functions;

import java.util.Set;

import org.apache.geode.cache.Region;
import org.apache.geode.cache.execute.Execution;
import org.apache.geode.cache.execute.Function;
import org.apache.geode.cache.execute.FunctionException;
import org.apache.geode.cache.execute.ResultCollector;

import nyla.solutions.core.exception.NotImplementedException;

/**
 * Supports executing functions locally within the JVM
 * 
 * @author Gregory Green
 * @param  the input object for execution
 * @param  the output object for execution 
 * @param  the aggregation
 *
 */
public class JvmExecution implements Execution
{
	
	public JvmExecution(Region region)
	{
		if (region == null)
			throw new IllegalArgumentException("region: required");
		
		
		this.dataSet = region;
	}//-------------------------------------------------------------------
	
	@Override
	public ResultCollector execute(String functionId) throws FunctionException
	{
		throw new NotImplementedException();
	}
	
	@Override
	public Execution withFilter(Set filter)
	{
		this.filter = filter;
		return this;
	}
	
	@Override
	public Execution withCollector(ResultCollector resultcollector)
	{
		throw new NotImplementedException();
	}

	@Override
	public Execution withArgs(Object args)
	{
		return this.setArguments(args);
	}


	public Execution setArguments(Object args)
	{
		 this.arguments = args;
		 return this;
	}
	
	/**
	 * 
	 * @param function the function to exe
	 * @return the result collector
	 * @throws FunctionException when the server side exception occurs
	 */
	@SuppressWarnings({ "unchecked", "rawtypes" })
	public ResultCollector execute(Function function) throws FunctionException
	{
		JvmResultsSender resultSender = new JvmResultsSender();
		JvmResultCollector jmvResultCollector = new JvmResultCollector(resultSender);
		
		JvmRegionFunctionContext rfc = new JvmRegionFunctionContext
				(dataSet, resultSender, arguments, filter);
		
		function.execute(rfc);
		
		
		return jmvResultCollector;
	}//-------------------------------------------------------------------

	private final Region dataSet;
	private Set filter = null;
	
	private Object arguments = null;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy