[jboss-jira] [JBoss JIRA] (WFLY-12134) Add org.infinispan:infinispan-multimap, org.infinispan:infinispan-clustered-counter, org.infinispan:infinispan-clustered-lock modules
Andreas Weise (Jira)
issues at jboss.org
Tue Apr 28 04:11:00 EDT 2020
[ https://issues.redhat.com/browse/WFLY-12134?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14063080#comment-14063080 ]
Andreas Weise commented on WFLY-12134:
--------------------------------------
Integration of infinispan-clustered-counter via Module also has issues due to CounterModuleLifecycle hooking up to early (https://github.com/infinispan/infinispan/blob/master/counter/src/main/java/org/infinispan/counter/impl/CounterModuleLifecycle.java). It tries to access internal caches, but infinispan subsystem did not load them yet - as not referenced. Seems some piece is missing to coordinate clustered-counter with infinispan subsystem properly.
would be great to see progress here.
however instead of using a module we found a hacky workaround for embedding infinispan-clustered-counter in an application (tested on WFLY19):
{noformat}
@Resource(name = "infinispan/container/my-container")
private EmbeddedCacheManager cacheManager;
public executeCounterStuff() {
// create counter manager from cache manager
final EmbeddedCounterManager counterManager = createCounterManager();
counterManager.defineCounter("c1",
CounterConfiguration
.builder(CounterType.UNBOUNDED_STRONG)
.build());
final StrongCounter c1 = counterManager.getStrongCounter("c1");
c1.addAndGet(...);
// stop the counter manager
counterManager.stop();
}
private EmbeddedCounterManager createCounterManager() {
// initialize CounterMetadataFileFinder and CounterModuleLifecycle SPIs
// manually on org.infinispan.factories.GlobalComponentRegistry
final GlobalComponentRegistry gcr = cacheManager.getGlobalComponentRegistry();
gcr.getComponentMetadataRepo().initialize(
Arrays.asList(new CounterMetadataFileFinder()),
CounterManager.class.getClassLoader());
new CounterModuleLifecycle().cacheManagerStarting(gcr, cacheManager.getCacheManagerConfiguration());
// create and start the counter manager
final EmbeddedCounterManager counterManager = (EmbeddedCounterManager) EmbeddedCounterManagerFactory.asCounterManager(cacheManager);
counterManager.start();
return counterManager;
}
{noformat}
Assuming the custom infinispan cache container (and its default cache) were configured in infinispan subsystem and referenced in web.xml like this
{noformat}
<resource-env-ref>
<resource-env-ref-name>infinispan/container/my-container</resource-env-ref-name>
<resource-env-ref-type>org.infinispan.manager.CacheContainer</resource-env-ref-type>
<lookup-name>java:jboss/infinispan/container/my-container</lookup-name>
</resource-env-ref>
<resource-env-ref>
<resource-env-ref-name>infinispan/cache/my-container/default</resource-env-ref-name>
<resource-env-ref-type>org.infinispan.Cache</resource-env-ref-type>
<lookup-name>java:jboss/infinispan/cache/my-container/default</lookup-name>
</resource-env-ref>
{noformat}
> Add org.infinispan:infinispan-multimap, org.infinispan:infinispan-clustered-counter, org.infinispan:infinispan-clustered-lock modules
> -------------------------------------------------------------------------------------------------------------------------------------
>
> Key: WFLY-12134
> URL: https://issues.redhat.com/browse/WFLY-12134
> Project: WildFly
> Issue Type: Enhancement
> Components: Clustering
> Affects Versions: 17.0.0.Beta1
> Reporter: Sergey Aganin
> Assignee: Paul Ferraro
> Priority: Major
>
> Please add the modules such that users can use the new features of Infinispan.
--
This message was sent by Atlassian Jira
(v7.13.8#713008)
More information about the jboss-jira
mailing list