[
https://issues.jboss.org/browse/ISPN-1500?page=com.atlassian.jira.plugin....
]
William Burns commented on ISPN-1500:
-------------------------------------
So I was trying to do something similar to how you can apply overrides for the default
configuration.
This is similar to what we have now for default and named caches given N number of
infinispan.xml files which works great.
{code}
List<File> files = ...
for (File file : files) {
InfinispanConfiguration readConfig;
Reader reader = null;
try {
reader = new InputStreamReader(
new FileInputStream(file), "UTF-8");
readConfig = InfinispanConfiguration.newInfinispanConfiguration(
reader);
}
catch (IOException e) {
throw new RuntimeException("There was a problem when parsing infispan
configuration files.", e);
}
finally {
if (reader != null) {
try {
reader.close();
}
catch (IOException e) {
_logger.warn("There was a problem closing reader!", e);
}
}
// Apply overrides to default config
cacheManager.getDefaultConfiguration().applyOverrides(readConfig.parseDefaultConfiguration());
// Apply overrides/definitions to all named caches found in xml
for (Entry<String, Configuration> entry :
readConfig.parseNamedConfigurations().entrySet()) {
String name = entry.getKey();
cacheManager.defineConfiguration(name, entry.getValue());
cacheNames.add(name);
}
}
{code}
So with the move to 5.0+ we need to be able to override or add new externalizers. I
checked the available classes and there is no override class for global config, which is
fine. I ended up writing my own override class which is attached
(MocaOverrideGlobalConfiguration). So with that I can just add the below code to my
previous override code and it would allow for further infinispan.xml files to possible
reconfigure global configuration (rack, machine and site are also nice).
{code}
// This should allow overriding global configuration elements
MocaOverrideGlobalConfiguration v1 = new MocaOverrideGlobalConfiguration();
cacheManager.getGlobalConfiguration().accept(v1);
MocaOverrideGlobalConfiguration v2 = new MocaOverrideGlobalConfiguration();
GlobalConfiguration globalConfig = readConfig.parseGlobalConfiguration();
globalConfig.accept(v2);
v1.override(v2);
{code}
SerializationType doesn't visit AdvancedExternalizersType
---------------------------------------------------------
Key: ISPN-1500
URL:
https://issues.jboss.org/browse/ISPN-1500
Project: Infinispan
Issue Type: Bug
Components: Configuration
Affects Versions: 5.0.1.FINAL
Reporter: William Burns
Assignee: Manik Surtani
Fix For: 5.1.0.CR1, 5.1.0.FINAL
Attachments: MocaOverrideGlobalConfiguration.java
Using infinispan, we have multiple infinispan.xml files that are used to configure our
caches. The overrides used on default and cache configurations work great for this. I
noticed there is no override global configuration support. So I was trying to make my own
for the stuff we needed. One of the items we need to "override" is the
serialization configs (it is more additive than override).
When doing this I found that the SerializationType doesn't properly pass off the
vistor to the AdvancedExternalizersType and thus I can't visit the Type or Configs,
which would make doing this much easier.
I was hoping I could keep a List of AdvancedSerializationConfigs that it visits and then
in my override method just add these Configs 1 by 1 to the SerializationType since it has
the public methods to add AdvancedSerializers.
It seems to be just an oversight but I would expect the accept method of
SerializationType to be the following instead (just added the accept to
AdvancedExternalizersType).
{code}
public void accept(ConfigurationBeanVisitor v) {
this.externalizerTypes.accept(v);
v.visitSerializationType(this);
}
{code}
Side note I noticed the AdvancedExternalizersType has addExternalizer as package level.
It would be easier to just call that method instead of having to detect the id myself and
whether an object or class is configured in the AdvancedSerializerConfig to decide what
add to call, since I could just do a straight add of the Config.
Also there is no way to remove or detect what AdvancedSerializers are present on the
SerializationType, which would be very helpful when trying to replace a given
AdvancedSerializers. Or are the AdvancedSerializerConfigs used started at the end of the
list? This would be preferable, because then I wouldn't care if another existed since
the one I just added would take priority.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see:
http://www.atlassian.com/software/jira