Skip to content

Commit

Permalink
gplazma: make plugin creation caching optional
Browse files Browse the repository at this point in the history
This patch introduces the gplazma.enable.plugin-creation-caching configuration property that
allows the admin to switch off the plugin cache.  This is useful as the cache is arguable a
misfeature and, in its current form, can lead to undesirable behaviour.

A subsequent patch (targeted at master only) will remove this feature.

Target: master
Patch: https://rb.dcache.org/r/7210/
Acked-by: Tigran Mkrtchyan
Request: 2.10
Request: 2.9
Request: 2.8
Request: 2.7
Request: 2.6
Require-notes: true
Require-book: no
  • Loading branch information
paulmillar committed Aug 22, 2014
1 parent 1db22cf commit 17e6de1
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 2 deletions.
Expand Up @@ -46,6 +46,7 @@ public class Gplazma2LoginStrategy
private GPlazma _gplazma;
private Map<String,Object> _environment = Collections.emptyMap();
private PluginFactory _factory;
private boolean _shouldCachePluginCreation;

@Required
public void setConfigurationFile(String configurationFile)
Expand All @@ -66,6 +67,12 @@ public void setNameSpace(NameSpaceProvider namespace)
_factory = new DcacheAwarePluginFactory(namespace);
}

@Required
public void setCachePluginCreation(boolean cache)
{
_shouldCachePluginCreation = cache;
}

public String getConfigurationFile()
{
return _configurationFile;
Expand Down Expand Up @@ -109,6 +116,7 @@ public void init()
new FromFileConfigurationLoadingStrategy(_configurationFile);
_gplazma =
new GPlazma(configuration, getEnvironmentAsProperties(), _factory);
_gplazma.setCachePluginCreation(_shouldCachePluginCreation);
}

static LoginReply
Expand Down
Expand Up @@ -50,6 +50,7 @@
<bean id="login-strategy" class="org.dcache.auth.Gplazma2LoginStrategy" init-method="init">
<description>Interfaces with gPlazma</description>
<property name="configurationFile" value="${gplazma.configuration.file}"/>
<property name="cachePluginCreation" value="${gplazma.enable.plugin-creation-caching}"/>
<property name="nameSpace" ref="namespace"/>
</bean>
</beans>
13 changes: 11 additions & 2 deletions modules/gplazma2/src/main/java/org/dcache/gplazma/GPlazma.java
Expand Up @@ -108,6 +108,8 @@ public boolean apply(Object o)
private ValidationStrategy validationStrategy;
private IdentityStrategy identityStrategy;

private boolean _shouldCachePluginCreation;

/**
* Storage class for failed login attempts. This allows gPlazma to
* refrain from filling up log files should a client attempt multiple
Expand Down Expand Up @@ -231,6 +233,11 @@ public GPlazma(ConfigurationLoadingStrategy configurationLoadingStrategy,
}
}

public void setCachePluginCreation(boolean shouldCache)
{
_shouldCachePluginCreation = shouldCache;
}

public LoginReply login(Subject subject) throws AuthenticationException
{
RecordingLoginMonitor record = new RecordingLoginMonitor();
Expand Down Expand Up @@ -437,8 +444,10 @@ private void loadPlugins() throws GPlazmaInternalException
{
LOGGER.debug("reloading plugins");

pluginLoader = new CachingPluginLoaderDecorator(
XmlResourcePluginLoader.newPluginLoader());
pluginLoader = XmlResourcePluginLoader.newPluginLoader();
if (_shouldCachePluginCreation) {
pluginLoader = new CachingPluginLoaderDecorator(pluginLoader);
}
if(_customPluginFactory != null) {
pluginLoader.setPluginFactory(_customPluginFactory);
}
Expand Down
25 changes: 25 additions & 0 deletions skel/share/defaults/gplazma.properties
Expand Up @@ -48,6 +48,31 @@ gplazma.configuration.file=${dcache.paths.etc}/gplazma.conf
# Cell address of pnfsmanager service
gplazma.service.pnfsmanager=${dcache.service.pnfsmanager}

# Whether to cache gPlazma plugin creation.
#
# Instances of those plugins mentioned in the gPlazma configuration
# file are created when the configuration file is read. This
# property controls whether subsequent plugins with the same name
# will reuse the plugin instance.
#
# Selecting 'true' will result in a single plugin instance for all
# lines in the configuration file with the same plugin name. When a
# configuration file has multiple plugins with the same name, only
# the plugin-specific configuration (if any) of the first plugin (in
# document order) is honoured. All subsequent plugin-specific
# configuration for plugins with the same name is ignored.
#
# Selecting 'false' will result in always creating a new plugin
# instance. All plugin-specific configuration is honoured.
#
# The default value ('true') can lead to broken behaviour but
# maintains backwards-compatibility with earlier dCache releases.
# This property is scheduled to be removed in dCache release 2.11.0,
# with creation caching feature being removed. This is equivalent to
# setting this property to 'false'.
#
(one-of?true|false)gplazma.enable.plugin-creation-caching = true


# -----------------------------------------------------------------------
# Properties for gPlazma plugins
Expand Down
1 change: 1 addition & 0 deletions skel/share/services/gplazma.batch
Expand Up @@ -5,6 +5,7 @@ check -strong gplazma.cell.name
check -strong gplazma.cell.limits.threads
check -strong gplazma.configuration.file
check -strong gplazma.service.pnfsmanager
check -strong gplazma.enable.plugin-creation-caching

create org.dcache.cells.UniversalSpringCell "${gplazma.cell.name}" \
"classpath:org/dcache/services/login/gplazma.xml \
Expand Down

0 comments on commit 17e6de1

Please sign in to comment.