I think I would use a function to iterate all the local region entries pretty much like Udo suggested.
I attached an example that iterates all the local primary entries and,
based on the last accessed time, removes them. In this example the test is
'< now', so all entries are removed. Of course, you do whatever you want
with that test.
The call to PartitionRegionHelper.getLocalDataForContext returns only
primary entries since optimizeForWrite returns true.
This function currently returns 'true', but it could easily be changed to
return an info object containing the number of entries checked and removed
(or something similar)
Execute it on the region like:
Execution execution = FunctionService.onRegion(this.region);
ResultCollector collector =
execution.execute("CheckLastAccessedTimeFunction");
Object result = collector.getResult();
Thanks,
Barry Oglesby
On Wed, Apr 27, 2016 at 5:36 PM, Eugene Strokin <[email protected]> wrote:
> Udo, thanks a lot. Yes, I do have the same idea to run the process on each
> node, and once it finds that there is not much space left it would kick old
> records out on that server. I'll give your code a try first thing tomorrow.
> Looks like this is exactly what I need.
> Anil, Udo is right, I've managed to set up eviction from heap to overflow
> disk storage. It looks fine now. I'm running a performance test currently
> and it looks stable so far. But my cache is ever growing, and I could run
> out of space. The nature of the data allows me to remove old cached items
> without any problem, and if they are needed again, I could always get them
> from a storage.
> So, Geode evicts from memory to overflow, but I also need to evict the
> items completly off the cache
> On Apr 27, 2016 6:02 PM, "Udo Kohlmeyer" <[email protected]> wrote:
>
>> Anil,
>>
>> Eugene's usecase is such that his memory is low (300Mb) but larger
>> diskspace.
>> He has already configured eviciton to manage the memory aspect. He is
>> just trying to clean up some local disk space. This is a continuation of a
>> previous thread "System Out of Memory".
>>
>> But yes, eviciton could fulfill the same requirement if his memory was
>> larger.
>>
>> --Udo
>>
>> On 28/04/2016 7:41 am, Anilkumar Gingade wrote:
>>
>> Any reason why the supported eviction/expiration does not work for your
>> case...
>>
>> -Anil.
>>
>>
>> On Wed, Apr 27, 2016 at 1:49 PM, Udo Kohlmeyer <[email protected]>
>> wrote:
>>
>>> Hi there Eugene,
>>>
>>> The free space checking code, is that running as a separate process or
>>> as part of each of the server jvms?
>>> I would run the free space checking as part of each server(deployed as
>>> part of the server code). This way each server will monitor it's own free
>>> space.
>>>
>>> I'm not sure how to get the last access time of each item, but if you
>>> can get hold of that information, then you can run some code that will use
>>> the PartitionRegionHelper.getLocalData(Region) or
>>> PartitionRegionHelper.getLocalPrimaryData(Region) to get the local data.
>>>
>>> Then you could remove/invalidate the data entry.
>>>
>>> Also disk store compaction now plays a role. So you might have to
>>> trigger a compaction of the diskstore in order to avoid unnecessary data
>>> being held in the diskstores.
>>>
>>> The simplest way you could do this is by running the following: (as per
>>> the DiskStore API
>>> <http://geode.incubator.apache.org/releases/latest/javadoc/com/gemstone/gemfire/cache/DiskStore.html>
>>> )
>>>
>>> Cache cache = CacheFactory.getAnyInstance();
>>> DiskStore diskstore = cache.findDiskStore("diskStoreName");
>>> diskstore.forceCompaction();
>>>
>>> The forceCompaction method is blocking, so please do not make this code
>>> as part of some critical processing step.
>>>
>>> --Udo
>>>
>>> On 28/04/2016 6:25 am, Eugene Strokin wrote:
>>>
>>> I'm running a periodic check of the free space on each node of my
>>> cluster. The cluster contains a partitioned region.
>>> If some node is getting full, I'd like to remove least recently used
>>> items to free up the space. New items are getting loaded constantly.
>>> I've enabled statistics, so it looks like I can get last access time of
>>> each item, but I'd like to iterate through only "local" items, the items
>>> which are stored on the local node only. I'm trying different things, but
>>> none of them seems right.
>>> Is it even possible? If so, could you please point me to the right
>>> direction?
>>>
>>> Thank you,
>>> Eugene
>>>
>>>
>>>
>>
>>
CheckLastAccessedTimeFunction.java
Description: Binary data
