An option that I use successfully, and simpler in my opinion, is a function 
that executes GFSH commands. It uses some internal capabilities but the 
simplicity of it makes it worthwhile to me.

I pass the string into my function as “gfshCommand”. This is a programmatic way 
of executing create region via gfsh.

create region --enable-statistics=true --type=PARTITION_REDUNDANT --name=prices

   public CommandResult executeInternal(final String gfshCommand) 
                throws IllegalAccessException, 
                        IllegalArgumentException, 
                        InvocationTargetException,
                        RuntimeException {
      try {
        ParseResult parseResult = gfshParser.parse(gfshCommand);
        logWriter.fine("Executing the GFSH command");
        CommandResult commandResult = (CommandResult) parseResult.getMethod()
          .invoke(parseResult.getInstance(), parseResult.getArguments());
        return commandResult;
      } catch (CommandProcessingException e) {
          throw new RuntimeException("Gfsh could not execute your command.\n"
            + "Carefully check the spelling of your options and verify that the 
option is valid for the command.\n", e);
      }
    }


Wes Williams

> On Apr 8, 2016, at 6:28 AM, Olivier Mallassi <[email protected]> 
> wrote:
> 
> Hello everybody,
> 
> my apologies if the question has already been asked on the ML (I cannot find 
> the answer in the archive). 
> 
> I have a need to programmatically create / delete region. I am not talking 
> about creating / deleting regions every second or minutes. the need is a pure 
> administration need (being able to create regions via an REST API). 
> 
> I have found the sample code in the documentation 
> (http://geode.docs.pivotal.io/docs/developing/region_options/dynamic_region_creation.html
>  
> <http://geode.docs.pivotal.io/docs/developing/region_options/dynamic_region_creation.html>)
>  and was wondering if you can help with the following questions
> - why are we using this "metadataregion"? is it to support elasticity (add / 
> remove nodes)? other reasons? 
> - Can we delete the regions using the same principle (with another callback)? 
> - is it better to use the <dynamic-region-factory> knowing I need 
> partition_redundant regions? it looks not to be a valid option.
> 
> Many thanks for your help. 
> 
> oliv/ 

Reply via email to