geode-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bruce Schuchardt (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GEODE-2089) entry-idle-time setting on the client side cache is not working as expected
Date Wed, 09 Nov 2016 21:12:58 GMT

    [ https://issues.apache.org/jira/browse/GEODE-2089?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15652050#comment-15652050
] 

Bruce Schuchardt commented on GEODE-2089:
-----------------------------------------

Here is the unit test:

{code}
  public void testClientDoesNotExpireEntryPrematurely() throws Exception {
    Host host = Host.getHost(0);
    VM vm0 = host.getVM(0);
    VM vm1 = host.getVM(1);
    final String name = this.getUniqueName() + "Region";
    final String key = "testKey";

    int port = createServerRegion(vm0, name, true);
    
    vm0.invoke(new SerializableCallable("create old entry") {
      public Object call() throws Exception {
        LocalRegion r = (LocalRegion)cache.getRegion(name);
        r.put(key, "value");
        AbstractRegionEntry entry = (AbstractRegionEntry)r.basicGetEntry(key);
        // set an old timestamp in the entry - thirty minutes ago
        entry.getVersionStamp().setVersionTimeStamp(System.currentTimeMillis() - 1800000L);
        return null;
      }
    });

    createClientRegion(vm1, name, port, true, ClientRegionShortcut.CACHING_PROXY, false);
    
    vm1.invoke(new SerializableCallable("fetch entry and validate") {
      public Object call() throws Exception {
        final Long[] expirationTimeMillis = new Long[1];
        int expirationSeconds = 15;
        
        LocalRegion r = (LocalRegion)cache.getRegion(name);
        AttributesMutator mutator = r.getAttributesMutator();
        mutator.setEntryIdleTimeout(new ExpirationAttributes(expirationSeconds, ExpirationAction.LOCAL_DESTROY));
        mutator.addCacheListener(new CacheListenerAdapter() {
          @Override
          public void afterDestroy(EntryEvent event) {
            expirationTimeMillis[0] = System.currentTimeMillis();
          }
        });
        
        // fetch the entry from the server and make sure it doesn't expire early
        if (!r.containsKey(key)) {
          r.get(key);
        }

        final long expirationTime = System.currentTimeMillis() + (expirationSeconds * 1000);

        waitForCriterion(new WaitCriterion() {
          public boolean done() {
            return expirationTimeMillis[0] != null;
          }
          public String description() {
            return "waiting for object to expire";
          }
        }, expirationSeconds * 2000, 200, true);

        disconnectFromDS();
        
        assertTrue("entry expired " + (expirationTime - expirationTimeMillis[0]) +
            " milliseconds early", expirationTimeMillis[0] >= expirationTime);
        
        return null;
      }
    });
    
    vm0.invoke(new SerializableRunnable() {
      public void run() {
        disconnectFromDS();
      }
    });
    
  }
{code}

>  entry-idle-time setting on the client side cache is not working as expected
> ----------------------------------------------------------------------------
>
>                 Key: GEODE-2089
>                 URL: https://issues.apache.org/jira/browse/GEODE-2089
>             Project: Geode
>          Issue Type: Bug
>          Components: client/server
>            Reporter: Bruce Schuchardt
>            Assignee: Bruce Schuchardt
>
> I wrote a unit test that sets an entry-idle-time timeout on a client cache with action
local-destroy.  When the client cache pulls an old entry from the server the cache appears
to ignore the entry-idle-time and expires the entry immediately after it is put in the cache.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message