-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
810 additions
and
0 deletions.
There are no files selected for viewing
96 changes: 96 additions & 0 deletions
96
.../src/main/java/org/wildfly/extras/creaper/commands/infinispan/cache/AbstractAddCache.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
package org.wildfly.extras.creaper.commands.infinispan.cache; | ||
|
||
import org.wildfly.extras.creaper.core.online.OnlineCommand; | ||
import org.wildfly.extras.creaper.core.online.OnlineCommandContext; | ||
import org.wildfly.extras.creaper.core.online.operations.Address; | ||
import org.wildfly.extras.creaper.core.online.operations.Operations; | ||
import org.wildfly.extras.creaper.core.online.operations.Values; | ||
|
||
abstract class AbstractAddCache implements OnlineCommand { | ||
|
||
private final CacheType cacheType; | ||
private final String cacheContainer; | ||
private final String name; | ||
|
||
// cache properties common to all cache types | ||
private final String jndiName; | ||
private final String module; | ||
private final String start; | ||
private final Boolean statisticsEnabled; | ||
|
||
protected final Address address; | ||
|
||
@Override | ||
public final void apply(OnlineCommandContext ctx) throws Exception { | ||
Values values = Values.empty() | ||
.andOptional("jndi-name", jndiName) | ||
.andOptional("module", module) | ||
.andOptional("start", start) | ||
.andOptional("statistics-enabled", statisticsEnabled); | ||
values = addValuesSpecificForCacheType(values); | ||
|
||
Operations ops = new Operations(ctx.client); | ||
ops.add(address, values); | ||
} | ||
|
||
abstract Values addValuesSpecificForCacheType(Values generalCacheValues); | ||
|
||
AbstractAddCache(Builder builder, CacheType cacheType) { | ||
if (builder.cacheContainer == null) { | ||
throw new NullPointerException("Cache container is required"); | ||
} | ||
this.cacheContainer = builder.cacheContainer; | ||
this.cacheType = cacheType; | ||
this.name = builder.name; | ||
this.jndiName = builder.jndiName; | ||
this.module = builder.module; | ||
this.start = builder.start; | ||
this.statisticsEnabled = builder.statisticsEnabled; | ||
this.address = Address.subsystem("infinispan") | ||
.and("cache-container", cacheContainer) | ||
.and(cacheType.getType(), name); | ||
} | ||
|
||
public abstract static class Builder<THIS extends Builder> { | ||
|
||
protected String name; | ||
protected String cacheContainer; | ||
protected String jndiName; | ||
protected String module; | ||
protected String start; | ||
protected Boolean statisticsEnabled; | ||
|
||
protected Builder(String name) { | ||
if (name == null || name.isEmpty()) { | ||
throw new IllegalArgumentException("Name of the cache must be specified"); | ||
} | ||
this.name = name; | ||
} | ||
|
||
public final THIS cacheContainer(String cacheContainer) { | ||
this.cacheContainer = cacheContainer; | ||
return (THIS) this; | ||
} | ||
|
||
public final THIS jndiName(String jndiName) { | ||
this.jndiName = jndiName; | ||
return (THIS) this; | ||
} | ||
|
||
public final THIS module(String module) { | ||
this.module = module; | ||
return (THIS) this; | ||
} | ||
|
||
public final THIS start(String start) { | ||
this.start = start; | ||
return (THIS) this; | ||
} | ||
|
||
public final THIS statisticsEnabled(Boolean statisticsEnabled) { | ||
this.statisticsEnabled = statisticsEnabled; | ||
return (THIS) this; | ||
} | ||
|
||
} | ||
} |
120 changes: 120 additions & 0 deletions
120
...c/main/java/org/wildfly/extras/creaper/commands/infinispan/cache/AddDistributedCache.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
package org.wildfly.extras.creaper.commands.infinispan.cache; | ||
|
||
import org.wildfly.extras.creaper.core.online.operations.Values; | ||
|
||
public final class AddDistributedCache extends AbstractAddCache { | ||
|
||
private final Boolean asyncMarshalling; | ||
private final CacheMode mode; | ||
private final Long queueFlushInterval; | ||
private final Long remoteTimeout; | ||
private final Double capacityFactor; | ||
private final ConsistentHashStrategy consistentHashStrategy; | ||
private final Long l1lifespan; | ||
private final Integer owners; | ||
private final Integer segments; | ||
|
||
private AddDistributedCache(Builder builder) { | ||
super(builder, CacheType.DISTRIBUTED_CACHE); | ||
this.asyncMarshalling = builder.asyncMarshalling; | ||
this.mode = builder.mode; | ||
this.queueFlushInterval = builder.queueFlushInterval; | ||
this.remoteTimeout = builder.remoteTimeout; | ||
this.capacityFactor = builder.capacityFactor; | ||
this.consistentHashStrategy = builder.consistentHashStrategy; | ||
this.l1lifespan = builder.l1lifespan; | ||
this.owners = builder.owners; | ||
this.segments = builder.segments; | ||
} | ||
|
||
@Override | ||
Values addValuesSpecificForCacheType(Values generalCacheValues) { | ||
return generalCacheValues | ||
.andOptional("async-marshalling", asyncMarshalling) | ||
.andOptional("mode", mode != null ? mode.getMode() : null) | ||
.andOptional("queue-flush-interval", queueFlushInterval) | ||
.andOptional("remote-timeout", remoteTimeout) | ||
.andOptional("capacity-factor", capacityFactor) | ||
.andOptional("consistent-hash-strategy", | ||
consistentHashStrategy != null ? consistentHashStrategy.getType() : null) | ||
.andOptional("l1-lifespan", l1lifespan) | ||
.andOptional("owners", owners) | ||
.andOptional("segments", segments); | ||
} | ||
|
||
public static final class Builder extends AbstractAddCache.Builder<Builder> { | ||
|
||
public Builder(String name) { | ||
super(name); | ||
} | ||
|
||
private Boolean asyncMarshalling; | ||
private CacheMode mode; | ||
private Long queueFlushInterval; | ||
private Long remoteTimeout; | ||
private Double capacityFactor; | ||
private ConsistentHashStrategy consistentHashStrategy; | ||
private Long l1lifespan; | ||
private Integer owners; | ||
private Integer segments; | ||
|
||
public Builder asyncMarshalling(Boolean asyncMarshalling) { | ||
this.asyncMarshalling = asyncMarshalling; | ||
return this; | ||
} | ||
|
||
public Builder mode(CacheMode mode) { | ||
this.mode = mode; | ||
return this; | ||
} | ||
|
||
public Builder queueFlushInterval(Long queueFlushInterval) { | ||
this.queueFlushInterval = queueFlushInterval; | ||
return this; | ||
} | ||
|
||
public Builder remoteTimeout(Long remoteTimeout) { | ||
this.remoteTimeout = remoteTimeout; | ||
return this; | ||
} | ||
|
||
/** | ||
* {@code capacity-factor} is only supported on WildFly 9 and above, | ||
* this setting will be ignored on previous versions. | ||
*/ | ||
public Builder capacityFactor(Double capacityFactor) { | ||
this.capacityFactor = capacityFactor; | ||
return this; | ||
} | ||
|
||
/** | ||
* {@code consistent-hash-strategy} is only supported on WildFly 9 and above, | ||
* this setting will be ignored on previous versions. | ||
*/ | ||
public Builder consistentHashStrategy(ConsistentHashStrategy consistentHashStrategy) { | ||
this.consistentHashStrategy = consistentHashStrategy; | ||
return this; | ||
} | ||
|
||
public Builder l1lifespan(Long l1lifespan) { | ||
this.l1lifespan = l1lifespan; | ||
return this; | ||
} | ||
|
||
public Builder owners(Integer owners) { | ||
this.owners = owners; | ||
return this; | ||
} | ||
|
||
public Builder segments(Integer segments) { | ||
this.segments = segments; | ||
return this; | ||
} | ||
|
||
public AddDistributedCache build() { | ||
return new AddDistributedCache(this); | ||
} | ||
|
||
} | ||
|
||
} |
66 changes: 66 additions & 0 deletions
66
.../main/java/org/wildfly/extras/creaper/commands/infinispan/cache/AddInvalidationCache.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package org.wildfly.extras.creaper.commands.infinispan.cache; | ||
|
||
import org.wildfly.extras.creaper.core.online.operations.Values; | ||
|
||
public final class AddInvalidationCache extends AbstractAddCache { | ||
|
||
private final Boolean asyncMarshalling; | ||
private final CacheMode mode; | ||
private final Long queueFlushInterval; | ||
private final Long remoteTimeout; | ||
|
||
public AddInvalidationCache(Builder builder) { | ||
super(builder, CacheType.INVALIDATION_CACHE); | ||
this.asyncMarshalling = builder.asyncMarshalling; | ||
this.mode = builder.mode; | ||
this.queueFlushInterval = builder.queueFlushInterval; | ||
this.remoteTimeout = builder.remoteTimeout; | ||
} | ||
|
||
@Override | ||
Values addValuesSpecificForCacheType(Values generalCacheValues) { | ||
return generalCacheValues | ||
.andOptional("async-marshalling", asyncMarshalling) | ||
.andOptional("mode", mode != null ? mode.getMode() : null) | ||
.andOptional("queue-flush-interval", queueFlushInterval) | ||
.andOptional("remote-timeout", remoteTimeout); | ||
} | ||
|
||
public static final class Builder extends AbstractAddCache.Builder<Builder> { | ||
|
||
public Builder(String name) { | ||
super(name); | ||
} | ||
|
||
private Boolean asyncMarshalling; | ||
private CacheMode mode; | ||
private Long queueFlushInterval; | ||
private Long remoteTimeout; | ||
|
||
public Builder asyncMarshalling(Boolean asyncMarshalling) { | ||
this.asyncMarshalling = asyncMarshalling; | ||
return this; | ||
} | ||
|
||
public Builder mode(CacheMode mode) { | ||
this.mode = mode; | ||
return this; | ||
} | ||
|
||
public Builder queueFlushInterval(Long queueFlushInterval) { | ||
this.queueFlushInterval = queueFlushInterval; | ||
return this; | ||
} | ||
|
||
public Builder remoteTimeout(Long remoteTimeout) { | ||
this.remoteTimeout = remoteTimeout; | ||
return this; | ||
} | ||
|
||
public AddInvalidationCache build() { | ||
return new AddInvalidationCache(this); | ||
} | ||
|
||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
...nds/src/main/java/org/wildfly/extras/creaper/commands/infinispan/cache/AddLocalCache.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.wildfly.extras.creaper.commands.infinispan.cache; | ||
|
||
import org.wildfly.extras.creaper.core.online.operations.Values; | ||
|
||
public final class AddLocalCache extends AbstractAddCache { | ||
|
||
|
||
public AddLocalCache(Builder builder) { | ||
super(builder, CacheType.LOCAL_CACHE); | ||
} | ||
|
||
@Override | ||
Values addValuesSpecificForCacheType(Values generalCacheValues) { | ||
return generalCacheValues; | ||
} | ||
|
||
public static final class Builder extends AbstractAddCache.Builder<Builder> { | ||
|
||
public Builder(String name) { | ||
super(name); | ||
} | ||
|
||
public AddLocalCache build() { | ||
return new AddLocalCache(this); | ||
} | ||
|
||
} | ||
|
||
} |
66 changes: 66 additions & 0 deletions
66
...rc/main/java/org/wildfly/extras/creaper/commands/infinispan/cache/AddReplicatedCache.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package org.wildfly.extras.creaper.commands.infinispan.cache; | ||
|
||
import org.wildfly.extras.creaper.core.online.operations.Values; | ||
|
||
public final class AddReplicatedCache extends AbstractAddCache { | ||
|
||
private final Boolean asyncMarshalling; | ||
private final CacheMode mode; | ||
private final Long queueFlushInterval; | ||
private final Long remoteTimeout; | ||
|
||
public AddReplicatedCache(Builder builder) { | ||
super(builder, CacheType.REPLICATED_CACHE); | ||
this.asyncMarshalling = builder.asyncMarshalling; | ||
this.mode = builder.mode; | ||
this.queueFlushInterval = builder.queueFlushInterval; | ||
this.remoteTimeout = builder.remoteTimeout; | ||
} | ||
|
||
@Override | ||
Values addValuesSpecificForCacheType(Values generalCacheValues) { | ||
return generalCacheValues | ||
.andOptional("async-marshalling", asyncMarshalling) | ||
.andOptional("mode", mode != null ? mode.getMode() : null) | ||
.andOptional("queue-flush-interval", queueFlushInterval) | ||
.andOptional("remote-timeout", remoteTimeout); | ||
} | ||
|
||
public static final class Builder extends AbstractAddCache.Builder<Builder> { | ||
|
||
public Builder(String name) { | ||
super(name); | ||
} | ||
|
||
private Boolean asyncMarshalling; | ||
private CacheMode mode; | ||
private Long queueFlushInterval; | ||
private Long remoteTimeout; | ||
|
||
public Builder asyncMarshalling(Boolean asyncMarshalling) { | ||
this.asyncMarshalling = asyncMarshalling; | ||
return this; | ||
} | ||
|
||
public Builder mode(CacheMode mode) { | ||
this.mode = mode; | ||
return this; | ||
} | ||
|
||
public Builder queueFlushInterval(Long queueFlushInterval) { | ||
this.queueFlushInterval = queueFlushInterval; | ||
return this; | ||
} | ||
|
||
public Builder remoteTimeout(Long remoteTimeout) { | ||
this.remoteTimeout = remoteTimeout; | ||
return this; | ||
} | ||
|
||
public AddReplicatedCache build() { | ||
return new AddReplicatedCache(this); | ||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.