gedi-geode-extensions-core/src/main/java/gedi/solutions/geode/operations/functions/ReadExportFunction.java
@Override
	public void execute(FunctionContext<Object> functionContext)
	{

		ResultSender<Object> sender = functionContext.getResultSender();
		Cache cache = CacheFactory.getAnyInstance();
		Logger logWriter = LogManager.getLogger(getClass());
		
		try
		{
			//export data
			
			String[] args = (String[])functionContext.getArguments();
			
			if(args == null || args.length != 2 )
				throw new FunctionException("Required array args: [region,extension]");

			String extensionArg = args[0];
			if(extensionArg == null || extensionArg.length() == 0)
			{
				throw new IllegalArgumentException("File extension required");
			}
			ExportFileType extension =  ExportFileType.valueOf(extensionArg);
			String regionName = args[1]; //TODO: accept multiple regions
			
			
			
			Region<Object,Object> region = cache.getRegion(regionName);
			
			if(region == null)
			{
				sender.lastResult(null);
				return;
			}
			
			//TODO: get file from functions
			File file = new File(new StringBuilder(directoryPath).append("/").append(regionName)
					.append(".").append(extensionArg).toString());
			
			
			//get server name
			String serverName = cache.getDistributedSystem().getDistributedMember().getName();
			
			switch(extension)
			{
				case gfd:
					new GfdExportFunction().exportRegion(region);
				break;
				default:
					throw new IllegalArgumentException("Unsupported extension file type:"+extension);
			}
			
			Serializable content = readContent(file,extension,logWriter);
			
			Serializable[] arrayResults = {serverName,content,file.getAbsolutePath()};
			
			sender.lastResult(arrayResults);
		}
		catch (Exception e)
		{
			String stackTrace = Debugger.stackTrace(e);
			logWriter.error(stackTrace);
			
			throw new FunctionException(stackTrace);
		}
			
	}
@Override
	public void execute(FunctionContext<Object> functionContext)
	{

		ResultSender<Object> sender = functionContext.getResultSender();
		Cache cache = CacheFactory.getAnyInstance();
		Logger logWriter = LogManager.getLogger(getClass());
		
		try
		{
			//export data
			
			String[] args = (String[])functionContext.getArguments();
			
			if(args == null || args.length != 2 )
				throw new FunctionException("Required array args: [region,extension]");

			String extensionArg = args[0];
			if(extensionArg == null || extensionArg.length() == 0)
			{
				throw new IllegalArgumentException("File extension required");
			}
			ExportFileType extension =  ExportFileType.valueOf(extensionArg);
			String regionName = args[1]; //TODO: accept multiple regions
			
			
			
			Region<Object,Object> region = cache.getRegion(regionName);
			
			if(region == null)
			{
				sender.lastResult(null);
				return;
			}
			
			//TODO: get file from functions
			File file = new File(new StringBuilder(directoryPath).append("/").append(regionName)
					.append(".").append(extensionArg).toString());
			
			
			//get server name
			String serverName = cache.getDistributedSystem().getDistributedMember().getName();
			
			switch(extension)
			{
				case gfd:
					new GfdExportFunction().exportRegion(region);
				break;
				default:
					throw new IllegalArgumentException("Unsupported extension file type:"+extension);
			}
			
			Serializable content = readContent(file,extension,logWriter);
			
			Serializable[] arrayResults = {serverName,content,file.getAbsolutePath()};
			
			sender.lastResult(arrayResults);
		}
		catch (Exception e)
		{
			String stackTrace = Debugger.stackTrace(e);
			logWriter.error(stackTrace);
			
			throw new FunctionException(stackTrace);
		}
			
	}
@ Override public void execute ( FunctionContext < Object > functionContext ) { ResultSender < Object > sender = functionContext . getResultSender ( ) ; Cache cache = CacheFactory . getAnyInstance ( ) ; Logger logWriter = LogManager . getLogger ( getClass ( ) ) ; try { //export data
 String [ ] args = ( String [ ] ) functionContext . getArguments ( ) ; if ( args == null || args . length != 2 ) throw new FunctionException ( "Required array args: [region,extension]" ) ; String extensionArg = args [ 0 ] ; if ( extensionArg == null || extensionArg . length ( ) == 0 ) { throw new IllegalArgumentException ( "File extension required" ) ; } ExportFileType extension = ExportFileType . valueOf ( extensionArg ) ; String regionName = args [ 1 ] ; //TODO: accept multiple regions
 Region < Object , Object > region = cache . getRegion ( regionName ) ; if ( region == null ) { sender . lastResult ( null ) ; return ; } //TODO: get file from functions
 File file = new File ( new StringBuilder ( directoryPath ) . append ( "/" ) . append ( regionName ) . append ( "." ) . append ( extensionArg ) . toString ( ) ) ; //get server name
 String serverName = cache . getDistributedSystem ( ) . getDistributedMember ( ) . getName ( ) ; switch ( extension ) { case gfd : new GfdExportFunction ( ) . exportRegion ( region ) ; break ; default : throw new IllegalArgumentException ( "Unsupported extension file type:" + extension ) ; } Serializable content = readContent ( file , extension , logWriter ) ; Serializable [ ] arrayResults = { serverName , content , file . getAbsolutePath ( ) } ; sender . lastResult ( arrayResults ) ; } catch ( Exception e ) { String stackTrace = Debugger . stackTrace ( e ) ; logWriter . error ( stackTrace ) ; throw new FunctionException ( stackTrace ) ; } }
This function will use the JsonExportFunction function
to export json data and read the results to be returned to callers
This function will use the JsonExportFunction function to export json data and read the results to be returned to callers