Skip to content
This repository has been archived by the owner on Jun 7, 2021. It is now read-only.

Commit

Permalink
Only create subsystem-specific cache containers if the fractions are …
Browse files Browse the repository at this point in the history
…available [SWARM-198]
  • Loading branch information
tobias committed Dec 18, 2015
1 parent df78829 commit 7c4eaea
Showing 1 changed file with 90 additions and 78 deletions.
Expand Up @@ -46,9 +46,9 @@ public static InfinispanFraction createDefaultFraction() {
public void postInitialize(Container.PostInitContext initContext) {
if (this.defaultFraction) {
if (initContext.hasFraction("jgroups")) {
clusteredDefaultFraction();
clusteredDefaultFraction(initContext);
} else {
localDefaultFraction();
localDefaultFraction(initContext);
}
}
}
Expand All @@ -68,7 +68,7 @@ protected InfinispanFraction markDefaultFraction() {
return this;
}

private InfinispanFraction clusteredDefaultFraction() {
private InfinispanFraction clusteredDefaultFraction(Container.PostInitContext initContext) {
cacheContainer("server",
cc -> cc.defaultCache("default")
.alias("singleton")
Expand All @@ -77,90 +77,102 @@ private InfinispanFraction clusteredDefaultFraction() {
.replicatedCache("default",
c -> c.mode(Mode.SYNC)
.transactionComponent(t -> t.mode(TransactionComponent.Mode.BATCH))));

cacheContainer("web",
cc -> cc.defaultCache("dist")
.jgroupsTransport(t -> t.lockTimeout(60000L))
.distributedCache("dist",
c -> c.mode(Mode.ASYNC)
.l1Lifespan(0L)
.owners(2)
.lockingComponent(lc -> lc.isolation(LockingComponent.Isolation.REPEATABLE_READ))
.transactionComponent(tc -> tc.mode(TransactionComponent.Mode.BATCH))
.fileStore()));

cacheContainer("ejb",
cc -> cc.defaultCache("dist")
.alias("sfsb")
.jgroupsTransport(t -> t.lockTimeout(60000L))
.distributedCache("dist",
c -> c.mode(Mode.ASYNC)
.l1Lifespan(0L)
.owners(2)
.lockingComponent(lc -> lc.isolation(LockingComponent.Isolation.REPEATABLE_READ))
.transactionComponent(t -> t.mode(TransactionComponent.Mode.BATCH))
.fileStore()));

cacheContainer("hibernate",
cc -> cc.defaultCache("local-query")
.jgroupsTransport(t -> t.lockTimeout(60000L))
.localCache("local-query",
c -> c.evictionComponent(ec -> ec.maxEntries(10000L).strategy(EvictionComponent.Strategy.LRU))
.expirationComponent(ec -> ec.maxIdle(100000L)))
.invalidationCache("entity",
c -> c.mode(Mode.SYNC)
.transactionComponent(tc -> tc.mode(TransactionComponent.Mode.NON_XA))
.evictionComponent(ec -> ec.maxEntries(10000L).strategy(EvictionComponent.Strategy.LRU))
.expirationComponent(ec -> ec.maxIdle(100000L)))
.replicatedCache("timestamps", c -> c.mode(Mode.ASYNC)));
if (initContext.hasFraction("undertow")) {
cacheContainer("web",
cc -> cc.defaultCache("dist")
.jgroupsTransport(t -> t.lockTimeout(60000L))
.distributedCache("dist",
c -> c.mode(Mode.ASYNC)
.l1Lifespan(0L)
.owners(2)
.lockingComponent(lc -> lc.isolation(LockingComponent.Isolation.REPEATABLE_READ))
.transactionComponent(tc -> tc.mode(TransactionComponent.Mode.BATCH))
.fileStore()));
}

if (initContext.hasFraction("ejb")) {
cacheContainer("ejb",
cc -> cc.defaultCache("dist")
.alias("sfsb")
.jgroupsTransport(t -> t.lockTimeout(60000L))
.distributedCache("dist",
c -> c.mode(Mode.ASYNC)
.l1Lifespan(0L)
.owners(2)
.lockingComponent(lc -> lc.isolation(LockingComponent.Isolation.REPEATABLE_READ))
.transactionComponent(t -> t.mode(TransactionComponent.Mode.BATCH))
.fileStore()));

}

if (initContext.hasFraction("jpa")) {
cacheContainer("hibernate",
cc -> cc.defaultCache("local-query")
.jgroupsTransport(t -> t.lockTimeout(60000L))
.localCache("local-query",
c -> c.evictionComponent(ec -> ec.maxEntries(10000L).strategy(EvictionComponent.Strategy.LRU))
.expirationComponent(ec -> ec.maxIdle(100000L)))
.invalidationCache("entity",
c -> c.mode(Mode.SYNC)
.transactionComponent(tc -> tc.mode(TransactionComponent.Mode.NON_XA))
.evictionComponent(ec -> ec.maxEntries(10000L).strategy(EvictionComponent.Strategy.LRU))
.expirationComponent(ec -> ec.maxIdle(100000L)))
.replicatedCache("timestamps", c -> c.mode(Mode.ASYNC)));
}

return this;
}

private InfinispanFraction localDefaultFraction() {
private InfinispanFraction localDefaultFraction(Container.PostInitContext initContext) {
cacheContainer("server",
cc -> cc.defaultCache("default")
.localCache("default", c -> c.transactionComponent(t -> t.mode(TransactionComponent.Mode.BATCH)))
.remoteCommandThreadPool());

cacheContainer("web",
cc -> cc.defaultCache("passivation")
.localCache("passivation",
c -> c.lockingComponent(lc -> lc.isolation(LockingComponent.Isolation.REPEATABLE_READ))
.transactionComponent(tc -> tc.mode(TransactionComponent.Mode.BATCH))
.fileStore(fs -> fs.passivation(true).purge(false)))
.localCache("persistent",
c -> c.lockingComponent(lc -> lc.isolation(LockingComponent.Isolation.REPEATABLE_READ))
.transactionComponent(tc -> tc.mode(TransactionComponent.Mode.BATCH))
.fileStore(fs -> fs.passivation(false).purge(false))));

cacheContainer("ejb",
cc -> cc.alias("sfsb")
.defaultCache("passivation")
.localCache("passivation",
c -> c.lockingComponent(lc -> lc.isolation(LockingComponent.Isolation.REPEATABLE_READ))
.transactionComponent(tc -> tc.mode(TransactionComponent.Mode.BATCH))
.fileStore(fs -> fs.passivation(true).purge(false)))
.localCache("persistent",
c -> c.lockingComponent(lc -> lc.isolation(LockingComponent.Isolation.REPEATABLE_READ))
.transactionComponent(tc -> tc.mode(TransactionComponent.Mode.BATCH))
.fileStore(fs -> fs.passivation(false).purge(false))));

cacheContainer("hibernate",
cc -> cc.defaultCache("local-query")
.localCache("entity",
c -> c.transactionComponent(t -> t.mode(TransactionComponent.Mode.NON_XA))
.evictionComponent(e -> e.strategy(EvictionComponent.Strategy.LRU).maxEntries(10000L))
.expirationComponent(e -> e.maxIdle(100000L)))
.localCache("immutable-entity",
c -> c.transactionComponent(t -> t.mode(TransactionComponent.Mode.NON_XA))
.evictionComponent(e -> e.strategy(EvictionComponent.Strategy.LRU).maxEntries(10000L))
.expirationComponent(e -> e.maxIdle(100000L)))
.localCache("local-query",
c -> c.transactionComponent(t -> t.mode(TransactionComponent.Mode.NON_XA))
.evictionComponent(e -> e.strategy(EvictionComponent.Strategy.LRU).maxEntries(10000L))
.expirationComponent(e -> e.maxIdle(100000L)))
.localCache("timestamps"));
if (initContext.hasFraction("undertow")) {
cacheContainer("web",
cc -> cc.defaultCache("passivation")
.localCache("passivation",
c -> c.lockingComponent(lc -> lc.isolation(LockingComponent.Isolation.REPEATABLE_READ))
.transactionComponent(tc -> tc.mode(TransactionComponent.Mode.BATCH))
.fileStore(fs -> fs.passivation(true).purge(false)))
.localCache("persistent",
c -> c.lockingComponent(lc -> lc.isolation(LockingComponent.Isolation.REPEATABLE_READ))
.transactionComponent(tc -> tc.mode(TransactionComponent.Mode.BATCH))
.fileStore(fs -> fs.passivation(false).purge(false))));
}

if (initContext.hasFraction("ejb")) {
cacheContainer("ejb",
cc -> cc.alias("sfsb")
.defaultCache("passivation")
.localCache("passivation",
c -> c.lockingComponent(lc -> lc.isolation(LockingComponent.Isolation.REPEATABLE_READ))
.transactionComponent(tc -> tc.mode(TransactionComponent.Mode.BATCH))
.fileStore(fs -> fs.passivation(true).purge(false)))
.localCache("persistent",
c -> c.lockingComponent(lc -> lc.isolation(LockingComponent.Isolation.REPEATABLE_READ))
.transactionComponent(tc -> tc.mode(TransactionComponent.Mode.BATCH))
.fileStore(fs -> fs.passivation(false).purge(false))));
}

if (initContext.hasFraction("jpa")) {
cacheContainer("hibernate",
cc -> cc.defaultCache("local-query")
.localCache("entity",
c -> c.transactionComponent(t -> t.mode(TransactionComponent.Mode.NON_XA))
.evictionComponent(e -> e.strategy(EvictionComponent.Strategy.LRU).maxEntries(10000L))
.expirationComponent(e -> e.maxIdle(100000L)))
.localCache("immutable-entity",
c -> c.transactionComponent(t -> t.mode(TransactionComponent.Mode.NON_XA))
.evictionComponent(e -> e.strategy(EvictionComponent.Strategy.LRU).maxEntries(10000L))
.expirationComponent(e -> e.maxIdle(100000L)))
.localCache("local-query",
c -> c.transactionComponent(t -> t.mode(TransactionComponent.Mode.NON_XA))
.evictionComponent(e -> e.strategy(EvictionComponent.Strategy.LRU).maxEntries(10000L))
.expirationComponent(e -> e.maxIdle(100000L)))
.localCache("timestamps"));
}

return this;
}
Expand Down

0 comments on commit 7c4eaea

Please sign in to comment.