This discussion is archived
1 Reply Latest reply: Mar 29, 2012 7:45 AM by 694204 RSS

Unable to get NamedCacheLifecycleEvent events fired. Coherence 3.6

694204 Newbie
Currently Being Moderated
Hi,

I have a namespace content handler (based on an IndexHandler sample I found on the forums). However in my case rather than a NamedCacheStorageRealizedEvent I want to be notified when a Cache is started and then pass in some information from my extensible XML to a scheduler that will schedule at a fixed rate the class specified (in order to pick up new data from a DB and load into the cache). However I seem unable to set the filter correctly. I can pick up NamedCacheStoredRealizedEvents fine but this is not what I want as I get loads of them for all the coherence common/processing pattern caches.

The code in the Element Handler is (edited for brevity) :-

registerContentHandler("task", new ElementContentHandler()
          {
               public Object onElement(ConfigurationContext configurationContext,
                                             QualifiedName qualifiedName,
                                             XmlElement xmlElement) throws ConfigurationException {
                                   
                    EventDispatcher eventDispatcher = configurationContext.getEnvironment().getResource(EventDispatcher.class);
          eventDispatcher.registerEventProcessor(new NamedCacheLifecycleEventFilter("mars-data-mars-commodity"), new MyTask());
                    return null;
               }

The config of the cache is:-


<caching-scheme-mapping>
<cache-mapping>
<cache-name>mars-data-mars-commodity</cache-name>
<scheme-name>MarsDataScheme</scheme-name>
</cache-mapping>
</caching-scheme-mapping>

<caching-schemes>
<distributed-scheme>
<scheme-name>MarsDataScheme</scheme-name>
<service-name>MarsData</service-name>
<serializer>
<class-name>
com.tangosol.io.pof.ConfigurablePofContext</class-name>
<init-params>
<init-param>
<param-type>java.lang.String</param-type>
<param-value>esl-extensible-pof-config.xml</param-value>
</init-param>
</init-params>
</serializer>
<thread-count>5</thread-count>
<local-storage system-property="mars.localstorage">true</local-storage>
<backing-map-scheme>
<read-write-backing-map-scheme>
<internal-cache-scheme>
<local-scheme>
<unit-calculator>BINARY</unit-calculator>
</local-scheme>
</internal-cache-scheme>
<write-delay>0</write-delay>
<rollback-cachestore-failures>
false</rollback-cachestore-failures>
</read-write-backing-map-scheme>
</backing-map-scheme>
<autostart>true</autostart>
</distributed-scheme>
</caching-schemes>

I have tried also trying the wildcards for the filter:-

eventDispatcher.registerEventProcessor(new NamedCacheLifecycleEventFilter("*"), new MyTask());

This also does not work. Has anyopne managed to get this to work. Or else has a better idea for how to create and schedule tasks for repeatable (fixed period)
execution by specifying them in the extensible environment please let me know !.

My idea was to have the class names specified int he XML with the refresh period and then have them instantiated by reflection and then use
the ScheduleExecutorService.scheduleAtFixedRate() to have the tasks then fired and submitted to the Processing Parttern to have them executed
in the grid. But I cannot prevent the Task Scheduler being invoked mulutiple times from the Extensible Environment !!.

Any help appreciated !.

Regards
Martin

Edited by: jedizippy on Mar 29, 2012 6:01 AM

Edited by: jedizippy on Mar 29, 2012 7:45 AM
  • 1. Re: Unable to get NamedCacheLifecycleEvent events fired. Coherence 3.6
    694204 Newbie
    Currently Being Moderated
    Note I tried using both the following values:-

    eventDispatcher.registerEventProcessor(new NamedCacheLifecycleEventFilter("MarsData"), new MyTask());
    eventDispatcher.registerEventProcessor(new NamedCacheLifecycleEventFilter("mars-data-mars-commodity"), new MyTask());


    I also changed the names to make sure I was not having issues with RegEx etc. But none of these methods works. In the logging from coherence and the processing pattern I can see the LifecycleStartedEvent and NamedCacheStorageRealizedEvent but the one I want NamedCacheLifecycleEvent is never seen in the logs so I can only assume that it is not implemented ?.

    At this point I give up.

    Edited by: jedizippy on Mar 29, 2012 7:44 AM

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points