You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geode.apache.org by ankit Soni <an...@gmail.com> on 2020/12/17 12:51:25 UTC

create region and clear entries from geode-client

Hello,

I have started using geode (1.12) in recent time and  looking to achieve
the following from a *java based geode-client program.*

 1.* create REPLCIATED and PARTITION regions from the client itself and
while creating it, need to provide a config that deletes the entries at
specified time.*

 2. *clear entries of a region from the client..*

I am exploring geode doc and have come across the following but unable to
understand what code i need to write in the geode-client java program.
https://geode.apache.org/docs/guide/14/developing/region_options/dynamic_region_creation.html

Can some guide me on how to achieve this...?

-Ankit.

Re: create region and clear entries from geode-client

Posted by Anilkumar Gingade <ag...@vmware.com>.
The doc you are pointing; tries to create region using Functions.
You can use the samples given there and modify as per your requirement or create a new one.

Here is reference doc about function execution:
https://geode.apache.org/docs/guide/14/developing/function_exec/function_execution.html

The clear() op is supported on replicated region but not on partitioned region. 
You can create a function to achieve the clear (similar to creating region) either by calling clear or deleting the region entries by iterating over them.

-Anil.


On 12/17/20, 4:51 AM, "ankit Soni" <an...@gmail.com> wrote:

    Hello,

    I have started using geode (1.12) in recent time and  looking to achieve
    the following from a *java based geode-client program.*

     1.* create REPLCIATED and PARTITION regions from the client itself and
    while creating it, need to provide a config that deletes the entries at
    specified time.*

     2. *clear entries of a region from the client..*

    I am exploring geode doc and have come across the following but unable to
    understand what code i need to write in the geode-client java program.
    https://geode.apache.org/docs/guide/14/developing/region_options/dynamic_region_creation.html

    Can some guide me on how to achieve this...?

    -Ankit.


Re: create region and clear entries from geode-client

Posted by Jens Deppe <jd...@vmware.com>.
Hi Ankit!

For function execution, I'd point you to the geode examples repo which has a simple example for functions [1]. Once you see how that works, it should be fairly straight forward to integrate the code you linked. When using functions, there are a couple of things to be aware of:

Your function code needs to be on the classpath of the servers. You can achieve this either by starting the servers with the '--classpath' option and point that at your jar, or you can use the 'gfsh deploy' jar to make your jar available to all the servers once they are running.

'Manual' region creation is somewhat cumbersome in older versions of Geode. Specifically because you will need to execute your function on each server that should host the region. It's easy when you're developing locally, but definitely becomes a little more involved when you have a larger cluster.

Of interest to you may be a new experimental feature which provides an API for the java client to create regions. Here is a short example:

    ClientCacheFactory factory = new ClientCacheFactory()
        .addPoolLocator("localhost", 10334);
    ClientCache cache = factory.create();

    Region regionConfig = new Region();
    regionConfig.setName("REGION1");
    regionConfig.setType(RegionType.REPLICATE_PERSISTENT);

    ClusterManagementService service =
        new GeodeClusterManagementServiceBuilder()
            .setCache(cache)
            .build();

    service.create(regionConfig);

This functionality should be available in Geode 1.13.

Hope this helps.

--Jens

[1] https://github.com/apache/geode-examples/tree/develop/functions

On 12/17/20, 4:51 AM, "ankit Soni" <an...@gmail.com> wrote:

    Hello,

    I have started using geode (1.12) in recent time and  looking to achieve
    the following from a *java based geode-client program.*

     1.* create REPLCIATED and PARTITION regions from the client itself and
    while creating it, need to provide a config that deletes the entries at
    specified time.*

     2. *clear entries of a region from the client..*

    I am exploring geode doc and have come across the following but unable to
    understand what code i need to write in the geode-client java program.
    https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgeode.apache.org%2Fdocs%2Fguide%2F14%2Fdeveloping%2Fregion_options%2Fdynamic_region_creation.html&amp;data=04%7C01%7Cjdeppe%40vmware.com%7C5995825d4e4349282fc408d8a28a858c%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0%7C0%7C637438063154882742%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=Wfl62xoUDg2jL408T6%2BCg3yaYE2yiZh0blWiDYLr%2FaA%3D&amp;reserved=0

    Can some guide me on how to achieve this...?

    -Ankit.