Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WFLY-16856 Revert default marshaller back to LEGACY #15992

Merged
merged 2 commits into from Sep 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -22,8 +22,6 @@

package org.wildfly.clustering.infinispan.marshall;

import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.function.BiFunction;
Expand All @@ -42,23 +40,14 @@
*/
public enum InfinispanMarshallerFactory implements BiFunction<ModuleLoader, List<Module>, Marshaller> {

DEFAULT() {
@Override
public Marshaller apply(ModuleLoader moduleLoader, List<Module> modules) {
return MarshallerFactory.DEFAULT.apply(moduleLoader, modules);
}
},
LEGACY() {
private final Set<String> protoStreamModules = new HashSet<>(Arrays.asList("org.wildfly.clustering.server", "org.wildfly.clustering.ejb.infinispan", "org.wildfly.clustering.web.infinispan"));
private final Set<String> protoStreamModules = Set.of("org.wildfly.clustering.server", "org.wildfly.clustering.ejb.infinispan", "org.wildfly.clustering.web.infinispan");
private final Predicate<String> protoStreamPredicate = this.protoStreamModules::contains;

@Override
public Marshaller apply(ModuleLoader moduleLoader, List<Module> modules) {
// Choose marshaller based on the associated modules
if (modules.stream().map(Module::getName).anyMatch(this.protoStreamPredicate)) {
return PROTOSTREAM.apply(moduleLoader, modules);
}
return JBOSS.apply(moduleLoader, modules);
return (modules.stream().map(Module::getName).anyMatch(this.protoStreamPredicate) ? PROTOSTREAM : JBOSS).apply(moduleLoader, modules);
}
},
JBOSS() {
Expand Down
Expand Up @@ -112,7 +112,7 @@ public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder b
MARSHALLER("marshaller", ModelType.STRING) {
@Override
public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) {
return builder.setDefaultValue(new ModelNode(InfinispanMarshallerFactory.DEFAULT.name()))
return builder.setDefaultValue(new ModelNode(InfinispanMarshallerFactory.LEGACY.name()))
.setValidator(new EnumValidator<>(InfinispanMarshallerFactory.class) {
@Override
public void validateParameter(String parameterName, ModelNode value) throws OperationFailedException {
Expand Down
Expand Up @@ -29,14 +29,12 @@
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.transform.TransformationContext;
import org.jboss.as.controller.transform.description.AttributeConverter;
import org.jboss.as.controller.transform.description.DiscardAttributeChecker.DiscardAttributeValueChecker;
import org.jboss.as.controller.transform.description.DiscardAttributeChecker;
import org.jboss.as.controller.transform.description.RejectAttributeChecker;
import org.jboss.as.controller.transform.description.RejectAttributeChecker.SimpleRejectAttributeChecker;
import org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder;
import org.jboss.as.clustering.infinispan.subsystem.CacheContainerResourceDefinition.Attribute;
import org.jboss.as.clustering.infinispan.subsystem.CacheContainerResourceDefinition.ListAttribute;
import org.jboss.dmr.ModelNode;
import org.wildfly.clustering.infinispan.marshall.InfinispanMarshallerFactory;

/**
* Transformer for cache container resources.
Expand Down Expand Up @@ -70,13 +68,11 @@ protected void convertAttribute(PathAddress address, String name, ModelNode modu
}
}
}, ListAttribute.MODULES.getDefinition())
.setValueConverter(AttributeConverter.DEFAULT_VALUE, Attribute.MARSHALLER.getDefinition())
.addRejectCheck(new SimpleRejectAttributeChecker(new ModelNode(InfinispanMarshallerFactory.DEFAULT.name())), Attribute.MARSHALLER.getDefinition())
.end();
}
if (InfinispanModel.VERSION_15_0_0.requiresTransformation(version)) {
this.builder.getAttributeBuilder()
.setDiscard(new DiscardAttributeValueChecker(new ModelNode(InfinispanMarshallerFactory.LEGACY.name())), Attribute.MARSHALLER.getDefinition())
.setDiscard(DiscardAttributeChecker.DEFAULT_VALUE, Attribute.MARSHALLER.getDefinition())
.addRejectCheck(new RejectAttributeChecker.SimpleAcceptAttributeChecker(Attribute.MARSHALLER.getDefinition().getDefaultValue()), Attribute.MARSHALLER.getDefinition())
.end();
}
Expand Down
Expand Up @@ -22,7 +22,6 @@

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

import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.function.BiFunction;
Expand All @@ -38,23 +37,14 @@
*/
public enum HotRodMarshallerFactory implements BiFunction<ModuleLoader, List<Module>, Marshaller> {

DEFAULT() {
@Override
public Marshaller apply(ModuleLoader moduleLoader, List<Module> modules) {
return MarshallerFactory.DEFAULT.apply(moduleLoader, modules);
}
},
LEGACY() {
private final Set<String> protoStreamModules = Collections.singleton("org.wildfly.clustering.web.hotrod");
private final Set<String> protoStreamModules = Set.of("org.wildfly.clustering.web.hotrod");
private final Predicate<String> protoStreamPredicate = this.protoStreamModules::contains;

@Override
public Marshaller apply(ModuleLoader moduleLoader, List<Module> modules) {
// Choose marshaller based on the associated modules
if (modules.stream().map(Module::getName).anyMatch(this.protoStreamPredicate)) {
return PROTOSTREAM.apply(moduleLoader, modules);
}
return JBOSS.apply(moduleLoader, modules);
return (modules.stream().map(Module::getName).anyMatch(this.protoStreamPredicate) ? PROTOSTREAM : JBOSS).apply(moduleLoader, modules);
}
},
JBOSS() {
Expand All @@ -64,9 +54,13 @@ public Marshaller apply(ModuleLoader moduleLoader, List<Module> modules) {
}
},
PROTOSTREAM() {
private final Set<String> clientModules = Set.of("org.infinispan.query.client");
private final Predicate<String> infinispanPredicate = this.clientModules::contains;

@Override
public Marshaller apply(ModuleLoader moduleLoader, List<Module> modules) {
return MarshallerFactory.PROTOSTREAM.apply(moduleLoader, modules);
// Use default ProtoStream marshaller if container uses remote query
return (modules.stream().map(Module::getName).anyMatch(this.infinispanPredicate) ? MarshallerFactory.DEFAULT : MarshallerFactory.PROTOSTREAM).apply(moduleLoader, modules);
}
},
;
Expand Down
Expand Up @@ -99,7 +99,7 @@ public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder b
return builder.setAllowExpression(false).setCapabilityReference(new CapabilityReference(Capability.CONFIGURATION, RemoteClusterResourceDefinition.Requirement.REMOTE_CLUSTER, WILDCARD_PATH));
}
},
MARSHALLER("marshaller", ModelType.STRING, new ModelNode(HotRodMarshallerFactory.DEFAULT.name())) {
MARSHALLER("marshaller", ModelType.STRING, new ModelNode(HotRodMarshallerFactory.LEGACY.name())) {
@Override
public SimpleAttributeDefinitionBuilder apply(SimpleAttributeDefinitionBuilder builder) {
return builder.setValidator(new EnumValidator<>(HotRodMarshallerFactory.class) {
Expand Down
Expand Up @@ -31,10 +31,6 @@
import org.jboss.as.controller.transform.description.DiscardAttributeChecker;
import org.jboss.as.controller.transform.description.RejectAttributeChecker;
import org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder;
import org.jboss.as.controller.transform.description.DiscardAttributeChecker.DiscardAttributeValueChecker;
import org.jboss.as.controller.transform.description.RejectAttributeChecker.SimpleRejectAttributeChecker;
import org.jboss.dmr.ModelNode;
import org.wildfly.clustering.infinispan.marshall.InfinispanMarshallerFactory;

/**
* Transformer for remote cache container resources.
Expand All @@ -50,16 +46,10 @@ public RemoteCacheContainerResourceTransformer(ResourceTransformationDescription

@Override
public void accept(ModelVersion version) {
if (InfinispanModel.VERSION_16_0_0.requiresTransformation(version)) {
this.builder.getAttributeBuilder()
.setValueConverter(AttributeConverter.DEFAULT_VALUE, Attribute.MARSHALLER.getDefinition())
.addRejectCheck(new SimpleRejectAttributeChecker(new ModelNode(InfinispanMarshallerFactory.DEFAULT.name())), Attribute.MARSHALLER.getDefinition())
.end();
}
if (InfinispanModel.VERSION_15_0_0.requiresTransformation(version)) {
this.builder.getAttributeBuilder()
.setDiscard(DiscardAttributeChecker.ALWAYS, Attribute.TRANSACTION_TIMEOUT.getDefinition())
.setDiscard(new DiscardAttributeValueChecker(new ModelNode(InfinispanMarshallerFactory.LEGACY.name())), Attribute.MARSHALLER.getDefinition())
.setDiscard(DiscardAttributeChecker.DEFAULT_VALUE, Attribute.MARSHALLER.getDefinition())
.addRejectCheck(new RejectAttributeChecker.SimpleAcceptAttributeChecker(Attribute.MARSHALLER.getDefinition().getDefaultValue()), Attribute.MARSHALLER.getDefinition())
.setValueConverter(AttributeConverter.DEFAULT_VALUE, Attribute.PROTOCOL_VERSION.getName())
.end();
Expand Down
Expand Up @@ -118,7 +118,7 @@
<xs:documentation>Indicates the default cache for this cache container.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="marshaller" type="tns:marshaller" default="DEFAULT">
<xs:attribute name="marshaller" type="tns:marshaller" default="LEGACY">
<xs:annotation>
<xs:documentation>Defines the marshalling implementation used to marshal cache entries.</xs:documentation>
</xs:annotation>
Expand Down Expand Up @@ -1017,13 +1017,6 @@

<xs:simpleType name="marshaller">
<xs:restriction base="xs:token">
<xs:enumeration value="DEFAULT">
<xs:annotation>
<xs:documentation>
Marshals cache entries using Infinispan's default marshaller (based on ProtoStream) configured to use schemas/marshallers loaded modules associated with this container.
</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="LEGACY">
<xs:annotation>
<xs:documentation>Deprecated. Selects the marshaller dynamically based on the associated modules.</xs:documentation>
Expand All @@ -1037,8 +1030,7 @@
<xs:enumeration value="PROTOSTREAM">
<xs:annotation>
<xs:documentation>
Marshals cache entries using an enhanced ProtoStream marshaller configured to use schemas/marshallers loaded from modules associated with this container.
Entries using this marshaller will be completely opaque to Infinispan server.
Marshals cache entries using ProtoStream configured to use schemas/marshallers loaded from modules associated with this container.
</xs:documentation>
</xs:annotation>
</xs:enumeration>
Expand Down Expand Up @@ -1149,7 +1141,7 @@
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="marshaller" type="tns:marshaller" default="DEFAULT">
<xs:attribute name="marshaller" type="tns:marshaller" default="LEGACY">
<xs:annotation>
<xs:documentation>Defines the marshalling implementation used to marshal cache entries.</xs:documentation>
</xs:annotation>
Expand Down
Expand Up @@ -63,7 +63,7 @@ public InfinispanServerSetupTask() {
.setupScript(createScriptBuilder()
.startBatch()
.add("/socket-binding-group=standard-sockets/remote-destination-outbound-socket-binding=infinispan-server:add(port=%d,host=%s)", INFINISPAN_SERVER_PORT, INFINISPAN_SERVER_ADDRESS)
.add("/subsystem=infinispan/remote-cache-container=remote:add(default-remote-cluster=infinispan-server-cluster, properties={infinispan.client.hotrod.auth_username=%s, infinispan.client.hotrod.auth_password=%s})", INFINISPAN_APPLICATION_USER, INFINISPAN_APPLICATION_PASSWORD)
.add("/subsystem=infinispan/remote-cache-container=remote:add(default-remote-cluster=infinispan-server-cluster, marshaller=PROTOSTREAM, properties={infinispan.client.hotrod.auth_username=%s, infinispan.client.hotrod.auth_password=%s})", INFINISPAN_APPLICATION_USER, INFINISPAN_APPLICATION_PASSWORD)
.add("/subsystem=infinispan/remote-cache-container=remote/remote-cluster=infinispan-server-cluster:add(socket-bindings=[infinispan-server])")
.endBatch()
.build())
Expand Down