Skip to content

Commit

Permalink
WFLY-5033 Upgrade Infinispan to 8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
pferraro committed Aug 6, 2015
1 parent 3484b1b commit b0c2429
Show file tree
Hide file tree
Showing 19 changed files with 134 additions and 100 deletions.
Expand Up @@ -22,14 +22,14 @@


package org.jboss.as.clustering.infinispan; package org.jboss.as.clustering.infinispan;


import static org.infinispan.factories.KnownComponentNames.ASYNC_TRANSPORT_EXECUTOR;
import static org.infinispan.factories.KnownComponentNames.GLOBAL_MARSHALLER; import static org.infinispan.factories.KnownComponentNames.GLOBAL_MARSHALLER;


import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ScheduledExecutorService;


import org.infinispan.commons.marshall.StreamingMarshaller; import org.infinispan.commons.marshall.StreamingMarshaller;
import org.infinispan.factories.GlobalComponentRegistry; import org.infinispan.factories.GlobalComponentRegistry;
import org.infinispan.factories.KnownComponentNames;
import org.infinispan.factories.annotations.ComponentName; import org.infinispan.factories.annotations.ComponentName;
import org.infinispan.factories.annotations.Inject; import org.infinispan.factories.annotations.Inject;
import org.infinispan.notifications.cachemanagerlistener.CacheManagerNotifier; import org.infinispan.notifications.cachemanagerlistener.CacheManagerNotifier;
Expand All @@ -49,7 +49,8 @@
public class ChannelTransport extends JGroupsTransport { public class ChannelTransport extends JGroupsTransport {


final ChannelFactory factory; final ChannelFactory factory;
private TimeService timeService;
private volatile ScheduledExecutorService timeoutExecutor;


public ChannelTransport(Channel channel, ChannelFactory factory) { public ChannelTransport(Channel channel, ChannelFactory factory) {
super(channel); super(channel);
Expand All @@ -58,17 +59,15 @@ public ChannelTransport(Channel channel, ChannelFactory factory) {


@Override @Override
@Inject @Inject
public void initialize(@ComponentName(GLOBAL_MARSHALLER) StreamingMarshaller marshaller, public void initialize(@ComponentName(GLOBAL_MARSHALLER) StreamingMarshaller marshaller, CacheManagerNotifier notifier, GlobalComponentRegistry gcr, TimeService timeService,
@ComponentName(ASYNC_TRANSPORT_EXECUTOR) ExecutorService asyncExecutor, InboundInvocationHandler globalHandler, @ComponentName(KnownComponentNames.ASYNC_REPLICATION_QUEUE_EXECUTOR) ScheduledExecutorService timeoutExecutor) {
CacheManagerNotifier notifier, GlobalComponentRegistry gcr, super.initialize(marshaller, notifier, gcr, timeService, globalHandler, timeoutExecutor);
TimeService timeService, InboundInvocationHandler globalHandler) { this.timeoutExecutor = timeoutExecutor;
super.initialize(marshaller, asyncExecutor, notifier, gcr, timeService, globalHandler);
this.timeService = timeService;
} }


@Override @Override
protected void initRPCDispatcher() { protected void initRPCDispatcher() {
this.dispatcher = new CommandAwareRpcDispatcher(this.channel, this, this.asyncExecutor, this.timeService, this.globalHandler); this.dispatcher = new CommandAwareRpcDispatcher(this.channel, this, this.globalHandler, this.timeoutExecutor);
MarshallerAdapter adapter = new MarshallerAdapter(this.marshaller) { MarshallerAdapter adapter = new MarshallerAdapter(this.marshaller) {
@Override @Override
public Object objectFromBuffer(byte[] buffer, int offset, int length) throws Exception { public Object objectFromBuffer(byte[] buffer, int offset, int length) throws Exception {
Expand Down
Expand Up @@ -22,10 +22,7 @@


package org.jboss.as.clustering.infinispan.subsystem; package org.jboss.as.clustering.infinispan.subsystem;


import static org.jboss.as.clustering.infinispan.subsystem.ClusteredCacheResourceDefinition.Attribute.ASYNC_MARSHALLING; import static org.jboss.as.clustering.infinispan.subsystem.ClusteredCacheResourceDefinition.Attribute.*;
import static org.jboss.as.clustering.infinispan.subsystem.ClusteredCacheResourceDefinition.Attribute.QUEUE_FLUSH_INTERVAL;
import static org.jboss.as.clustering.infinispan.subsystem.ClusteredCacheResourceDefinition.Attribute.QUEUE_SIZE;
import static org.jboss.as.clustering.infinispan.subsystem.ClusteredCacheResourceDefinition.Attribute.REMOTE_TIMEOUT;


import org.infinispan.configuration.cache.CacheMode; import org.infinispan.configuration.cache.CacheMode;
import org.infinispan.configuration.cache.ClusteringConfiguration; import org.infinispan.configuration.cache.ClusteringConfiguration;
Expand Down Expand Up @@ -64,7 +61,6 @@ public Builder<Configuration> configure(OperationContext context, ModelNode mode
int queueSize = QUEUE_SIZE.getDefinition().resolveModelAttribute(context, model).asInt(); int queueSize = QUEUE_SIZE.getDefinition().resolveModelAttribute(context, model).asInt();


builder.async() builder.async()
.asyncMarshalling(ASYNC_MARSHALLING.getDefinition().resolveModelAttribute(context, model).asBoolean())
.useReplQueue(queueSize > 0) .useReplQueue(queueSize > 0)
.replQueueInterval(QUEUE_FLUSH_INTERVAL.getDefinition().resolveModelAttribute(context, model).asLong()) .replQueueInterval(QUEUE_FLUSH_INTERVAL.getDefinition().resolveModelAttribute(context, model).asLong())
.replQueueMaxElements(queueSize) .replQueueMaxElements(queueSize)
Expand Down
Expand Up @@ -46,7 +46,6 @@
public class ClusteredCacheResourceDefinition extends CacheResourceDefinition { public class ClusteredCacheResourceDefinition extends CacheResourceDefinition {


enum Attribute implements org.jboss.as.clustering.controller.Attribute { enum Attribute implements org.jboss.as.clustering.controller.Attribute {
ASYNC_MARSHALLING("async-marshalling", ModelType.BOOLEAN, new ModelNode(false)),
MODE("mode", ModelType.STRING, null, new EnumValidatorBuilder<>(Mode.class)), MODE("mode", ModelType.STRING, null, new EnumValidatorBuilder<>(Mode.class)),
QUEUE_FLUSH_INTERVAL("queue-flush-interval", ModelType.LONG, new ModelNode(10L)), QUEUE_FLUSH_INTERVAL("queue-flush-interval", ModelType.LONG, new ModelNode(10L)),
QUEUE_SIZE("queue-size", ModelType.INT, new ModelNode(0)), QUEUE_SIZE("queue-size", ModelType.INT, new ModelNode(0)),
Expand All @@ -63,14 +62,20 @@ enum Attribute implements org.jboss.as.clustering.controller.Attribute {
this.definition = builder.setValidator(validator.configure(builder).build()).build(); this.definition = builder.setValidator(validator.configure(builder).build()).build();
} }


private static SimpleAttributeDefinitionBuilder createBuilder(String name, ModelType type, ModelNode defaultValue) { @Override
return new SimpleAttributeDefinitionBuilder(name, type) public AttributeDefinition getDefinition() {
.setAllowExpression(true) return this.definition;
.setAllowNull(defaultValue != null) }
.setDefaultValue(defaultValue) }
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
.setMeasurementUnit((type == ModelType.LONG) ? MeasurementUnit.MILLISECONDS : null) @Deprecated
; enum DeprecatedAttribute implements org.jboss.as.clustering.controller.Attribute {
ASYNC_MARSHALLING("async-marshalling", ModelType.BOOLEAN, new ModelNode(false), InfinispanModel.VERSION_4_0_0),
;
private final AttributeDefinition definition;

DeprecatedAttribute(String name, ModelType type, ModelNode defaultValue, InfinispanModel deprecation) {
this.definition = createBuilder(name, type, defaultValue).setDeprecated(deprecation.getVersion()).build();
} }


@Override @Override
Expand All @@ -79,6 +84,16 @@ public AttributeDefinition getDefinition() {
} }
} }


static SimpleAttributeDefinitionBuilder createBuilder(String name, ModelType type, ModelNode defaultValue) {
return new SimpleAttributeDefinitionBuilder(name, type)
.setAllowExpression(true)
.setAllowNull(defaultValue != null)
.setDefaultValue(defaultValue)
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
.setMeasurementUnit((type == ModelType.LONG) ? MeasurementUnit.MILLISECONDS : null)
;
}

static void buildTransformation(ModelVersion version, ResourceTransformationDescriptionBuilder builder) { static void buildTransformation(ModelVersion version, ResourceTransformationDescriptionBuilder builder) {


CacheResourceDefinition.buildTransformation(version, builder); CacheResourceDefinition.buildTransformation(version, builder);
Expand All @@ -92,6 +107,7 @@ static void buildTransformation(ModelVersion version, ResourceTransformationDesc
public void registerAttributes(ManagementResourceRegistration registration) { public void registerAttributes(ManagementResourceRegistration registration) {
super.registerAttributes(registration); super.registerAttributes(registration);
new ReloadRequiredWriteAttributeHandler(Attribute.class).register(registration); new ReloadRequiredWriteAttributeHandler(Attribute.class).register(registration);
new ReloadRequiredWriteAttributeHandler(DeprecatedAttribute.class).register(registration);


if (this.allowRuntimeOnlyRegistration) { if (this.allowRuntimeOnlyRegistration) {
new MetricHandler<>(new ClusteredCacheMetricExecutor(), ClusteredCacheMetric.class).register(registration); new MetricHandler<>(new ClusteredCacheMetricExecutor(), ClusteredCacheMetric.class).register(registration);
Expand Down
Expand Up @@ -121,7 +121,13 @@ public void registerAttributes(ManagementResourceRegistration registration) {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
public void registerOperations(ManagementResourceRegistration registration) { public void registerOperations(ManagementResourceRegistration registration) {
ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()).addAttributes(Attribute.class).addAttributes(ClusteredCacheResourceDefinition.Attribute.class).addAttributes(CacheResourceDefinition.Attribute.class).addAttributes(CacheResourceDefinition.DeprecatedAttribute.class); ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver())
.addAttributes(Attribute.class)
.addAttributes(ClusteredCacheResourceDefinition.Attribute.class)
.addAttributes(ClusteredCacheResourceDefinition.DeprecatedAttribute.class)
.addAttributes(CacheResourceDefinition.Attribute.class)
.addAttributes(CacheResourceDefinition.DeprecatedAttribute.class)
;
ResourceServiceHandler handler = new DistributedCacheServiceHandler(); ResourceServiceHandler handler = new DistributedCacheServiceHandler();
new AddStepHandler(descriptor, handler).register(registration); new AddStepHandler(descriptor, handler).register(registration);
new RemoveStepHandler(descriptor, handler).register(registration); new RemoveStepHandler(descriptor, handler).register(registration);
Expand Down
Expand Up @@ -528,10 +528,11 @@ private void parseClusteredCacheAttribute(XMLExtendedStreamReader reader, int in
break; break;
} }
case ASYNC_MARSHALLING: { case ASYNC_MARSHALLING: {
if (this.schema.since(InfinispanSchema.VERSION_1_2)) { if (!this.schema.since(InfinispanSchema.VERSION_1_2) && this.schema.since(InfinispanSchema.VERSION_4_0)) {
readAttribute(reader, index, operation, ClusteredCacheResourceDefinition.Attribute.ASYNC_MARSHALLING); throw ParseUtils.unexpectedAttribute(reader, index);
break;
} }
ROOT_LOGGER.attributeDeprecated(attribute.getLocalName(), reader.getLocalName());
break;
} }
default: { default: {
this.parseCacheAttribute(reader, index, address, operations); this.parseCacheAttribute(reader, index, address, operations);
Expand Down Expand Up @@ -655,7 +656,7 @@ private void parseStateTransfer(XMLExtendedStreamReader reader, PathAddress cach
if (this.schema.since(InfinispanSchema.VERSION_1_1)) { if (this.schema.since(InfinispanSchema.VERSION_1_1)) {
throw ParseUtils.unexpectedAttribute(reader, i); throw ParseUtils.unexpectedAttribute(reader, i);
} }
ROOT_LOGGER.attributeDeprecated(XMLAttribute.FLUSH_TIMEOUT.getLocalName(), XMLElement.STATE_TRANSFER.getLocalName()); ROOT_LOGGER.attributeDeprecated(attribute.getLocalName(), reader.getLocalName());
break; break;
} }
case CHUNK_SIZE: { case CHUNK_SIZE: {
Expand Down Expand Up @@ -1414,15 +1415,21 @@ private void parseStoreWriteBehind(XMLExtendedStreamReader reader, PathAddress s
XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i)); XMLAttribute attribute = XMLAttribute.forName(reader.getAttributeLocalName(i));
switch (attribute) { switch (attribute) {
case FLUSH_LOCK_TIMEOUT: { case FLUSH_LOCK_TIMEOUT: {
readAttribute(reader, i, operation, StoreWriteBehindResourceDefinition.Attribute.FLUSH_LOCK_TIMEOUT); if (this.schema.since(InfinispanSchema.VERSION_4_0)) {
throw ParseUtils.unexpectedAttribute(reader, i);
}
ROOT_LOGGER.attributeDeprecated(attribute.getLocalName(), reader.getLocalName());
break; break;
} }
case MODIFICATION_QUEUE_SIZE: { case MODIFICATION_QUEUE_SIZE: {
readAttribute(reader, i, operation, StoreWriteBehindResourceDefinition.Attribute.MODIFICATION_QUEUE_SIZE); readAttribute(reader, i, operation, StoreWriteBehindResourceDefinition.Attribute.MODIFICATION_QUEUE_SIZE);
break; break;
} }
case SHUTDOWN_TIMEOUT: { case SHUTDOWN_TIMEOUT: {
readAttribute(reader, i, operation, StoreWriteBehindResourceDefinition.Attribute.SHUTDOWN_TIMEOUT); if (this.schema.since(InfinispanSchema.VERSION_4_0)) {
throw ParseUtils.unexpectedAttribute(reader, i);
}
ROOT_LOGGER.attributeDeprecated(attribute.getLocalName(), reader.getLocalName());
break; break;
} }
case THREAD_POOL_SIZE: { case THREAD_POOL_SIZE: {
Expand Down
Expand Up @@ -57,7 +57,12 @@ static void buildTransformation(ModelVersion version, ResourceTransformationDesc
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
public void registerOperations(ManagementResourceRegistration registration) { public void registerOperations(ManagementResourceRegistration registration) {
ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()).addAttributes(ClusteredCacheResourceDefinition.Attribute.class).addAttributes(CacheResourceDefinition.Attribute.class).addAttributes(CacheResourceDefinition.DeprecatedAttribute.class); ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver())
.addAttributes(ClusteredCacheResourceDefinition.Attribute.class)
.addAttributes(ClusteredCacheResourceDefinition.DeprecatedAttribute.class)
.addAttributes(CacheResourceDefinition.Attribute.class)
.addAttributes(CacheResourceDefinition.DeprecatedAttribute.class)
;
ResourceServiceHandler handler = new InvalidationCacheServiceHandler(); ResourceServiceHandler handler = new InvalidationCacheServiceHandler();
new AddStepHandler(descriptor, handler).register(registration); new AddStepHandler(descriptor, handler).register(registration);
new RemoveStepHandler(descriptor, handler).register(registration); new RemoveStepHandler(descriptor, handler).register(registration);
Expand Down
Expand Up @@ -57,7 +57,12 @@ static void buildTransformation(ModelVersion version, ResourceTransformationDesc
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
public void registerOperations(ManagementResourceRegistration registration) { public void registerOperations(ManagementResourceRegistration registration) {
ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()).addAttributes(ClusteredCacheResourceDefinition.Attribute.class).addAttributes(CacheResourceDefinition.Attribute.class).addAttributes(CacheResourceDefinition.DeprecatedAttribute.class); ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver())
.addAttributes(ClusteredCacheResourceDefinition.Attribute.class)
.addAttributes(ClusteredCacheResourceDefinition.DeprecatedAttribute.class)
.addAttributes(CacheResourceDefinition.Attribute.class)
.addAttributes(CacheResourceDefinition.DeprecatedAttribute.class)
;
ResourceServiceHandler handler = new ReplicatedCacheServiceHandler(); ResourceServiceHandler handler = new ReplicatedCacheServiceHandler();
new AddStepHandler(descriptor, handler).register(registration); new AddStepHandler(descriptor, handler).register(registration);
new RemoveStepHandler(descriptor, handler).register(registration); new RemoveStepHandler(descriptor, handler).register(registration);
Expand Down
Expand Up @@ -51,9 +51,7 @@ public AsyncStoreConfiguration getValue() throws IllegalStateException, IllegalA


@Override @Override
public Builder<AsyncStoreConfiguration> configure(OperationContext context, ModelNode model) throws OperationFailedException { public Builder<AsyncStoreConfiguration> configure(OperationContext context, ModelNode model) throws OperationFailedException {
this.builder.flushLockTimeout(FLUSH_LOCK_TIMEOUT.getDefinition().resolveModelAttribute(context, model).asLong());
this.builder.modificationQueueSize(MODIFICATION_QUEUE_SIZE.getDefinition().resolveModelAttribute(context, model).asInt()); this.builder.modificationQueueSize(MODIFICATION_QUEUE_SIZE.getDefinition().resolveModelAttribute(context, model).asInt());
this.builder.shutdownTimeout(SHUTDOWN_TIMEOUT.getDefinition().resolveModelAttribute(context, model).asLong());
this.builder.threadPoolSize(THREAD_POOL_SIZE.getDefinition().resolveModelAttribute(context, model).asInt()); this.builder.threadPoolSize(THREAD_POOL_SIZE.getDefinition().resolveModelAttribute(context, model).asInt());
return this; return this;
} }
Expand Down
Expand Up @@ -54,20 +54,13 @@ public class StoreWriteBehindResourceDefinition extends StoreWriteResourceDefini
static final PathElement PATH = pathElement("behind"); static final PathElement PATH = pathElement("behind");


enum Attribute implements org.jboss.as.clustering.controller.Attribute { enum Attribute implements org.jboss.as.clustering.controller.Attribute {
FLUSH_LOCK_TIMEOUT("flush-lock-timeout", ModelType.LONG, new ModelNode(5000L)),
MODIFICATION_QUEUE_SIZE("modification-queue-size", ModelType.INT, new ModelNode(1024)), MODIFICATION_QUEUE_SIZE("modification-queue-size", ModelType.INT, new ModelNode(1024)),
SHUTDOWN_TIMEOUT("shutdown-timeout", ModelType.LONG, new ModelNode(25000L)),
THREAD_POOL_SIZE("thread-pool-size", ModelType.INT, new ModelNode(1)), THREAD_POOL_SIZE("thread-pool-size", ModelType.INT, new ModelNode(1)),
; ;
private final AttributeDefinition definition; private final AttributeDefinition definition;


Attribute(String name, ModelType type, ModelNode defaultValue) { Attribute(String name, ModelType type, ModelNode defaultValue) {
this.definition = new SimpleAttributeDefinitionBuilder(name, type) this.definition = createBuilder(name, type, defaultValue).build();
.setAllowExpression(true)
.setAllowNull(true)
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
.setMeasurementUnit((type == ModelType.LONG) ? MeasurementUnit.MILLISECONDS : null)
.build();
} }


@Override @Override
Expand All @@ -76,11 +69,37 @@ public AttributeDefinition getDefinition() {
} }
} }


@Deprecated
enum DeprecatedAttribute implements org.jboss.as.clustering.controller.Attribute {
FLUSH_LOCK_TIMEOUT("flush-lock-timeout", ModelType.LONG, new ModelNode(5000L), InfinispanModel.VERSION_4_0_0),
SHUTDOWN_TIMEOUT("shutdown-timeout", ModelType.LONG, new ModelNode(25000L), InfinispanModel.VERSION_4_0_0),
;
private final AttributeDefinition definition;

DeprecatedAttribute(String name, ModelType type, ModelNode defaultValue, InfinispanModel deprecation) {
this.definition = createBuilder(name, type, defaultValue).setDeprecated(deprecation.getVersion()).build();
}

@Override
public AttributeDefinition getDefinition() {
return this.definition;
}
}

static SimpleAttributeDefinitionBuilder createBuilder(String name, ModelType type, ModelNode defaultValue) {
return new SimpleAttributeDefinitionBuilder(name, type)
.setAllowExpression(true)
.setAllowNull(true)
.setFlags(AttributeAccess.Flag.RESTART_RESOURCE_SERVICES)
.setMeasurementUnit((type == ModelType.LONG) ? MeasurementUnit.MILLISECONDS : null)
;
}

static void buildTransformation(ModelVersion version, ResourceTransformationDescriptionBuilder parent) { static void buildTransformation(ModelVersion version, ResourceTransformationDescriptionBuilder parent) {
ResourceTransformationDescriptionBuilder builder = InfinispanModel.VERSION_4_0_0.requiresTransformation(version) ? parent.addChildRedirection(PATH, LEGACY_PATH) : parent.addChildResource(PATH); ResourceTransformationDescriptionBuilder builder = InfinispanModel.VERSION_4_0_0.requiresTransformation(version) ? parent.addChildRedirection(PATH, LEGACY_PATH) : parent.addChildResource(PATH);


if (InfinispanModel.VERSION_3_0_0.requiresTransformation(version)) { if (InfinispanModel.VERSION_3_0_0.requiresTransformation(version)) {
builder.getAttributeBuilder().setValueConverter(new DefaultValueAttributeConverter(Attribute.FLUSH_LOCK_TIMEOUT.getDefinition()), Attribute.FLUSH_LOCK_TIMEOUT.getDefinition()); builder.getAttributeBuilder().setValueConverter(new DefaultValueAttributeConverter(DeprecatedAttribute.FLUSH_LOCK_TIMEOUT.getDefinition()), DeprecatedAttribute.FLUSH_LOCK_TIMEOUT.getDefinition());
} }
} }


Expand All @@ -91,11 +110,12 @@ static void buildTransformation(ModelVersion version, ResourceTransformationDesc
@Override @Override
public void registerAttributes(ManagementResourceRegistration registration) { public void registerAttributes(ManagementResourceRegistration registration) {
new ReloadRequiredWriteAttributeHandler(Attribute.class).register(registration); new ReloadRequiredWriteAttributeHandler(Attribute.class).register(registration);
new ReloadRequiredWriteAttributeHandler(DeprecatedAttribute.class).register(registration);
} }


@Override @Override
public void registerOperations(ManagementResourceRegistration registration) { public void registerOperations(ManagementResourceRegistration registration) {
ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()).addAttributes(Attribute.class); ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()).addAttributes(Attribute.class).addAttributes(DeprecatedAttribute.class);
ResourceServiceHandler handler = new SimpleResourceServiceHandler<>(new StoreWriteBehindBuilderFactory()); ResourceServiceHandler handler = new SimpleResourceServiceHandler<>(new StoreWriteBehindBuilderFactory());
new AddStepHandler(descriptor, handler).register(registration); new AddStepHandler(descriptor, handler).register(registration);
new RemoveStepHandler(descriptor, handler).register(registration); new RemoveStepHandler(descriptor, handler).register(registration);
Expand Down

0 comments on commit b0c2429

Please sign in to comment.