accumulo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ivakegg <...@git.apache.org>
Subject [GitHub] accumulo pull request #253: ACCUMULO-4086 Improve volume chooser fallback
Date Tue, 25 Apr 2017 16:23:58 GMT
Github user ivakegg commented on a diff in the pull request:

    https://github.com/apache/accumulo/pull/253#discussion_r113243918
  
    --- Diff: server/base/src/main/java/org/apache/accumulo/server/fs/PerTableVolumeChooser.java
---
    @@ -68,10 +100,107 @@ public String choose(VolumeChooserEnvironment env, String[] options)
{
               chooser = last;
             }
           }
    +    }
    +    return chooser;
    +  }
    +
    +  private VolumeChooser getVolumeChooserForNonTable(VolumeChooserEnvironment env, ServerConfigurationFactory
localConf) {
    +    VolumeChooser chooser;
    +    final String customProperty = Property.GENERAL_ARBITRARY_PROP_PREFIX.getKey() + env.getScope()
+ ".volume.chooser";
    +
    +    if (log.isTraceEnabled()) {
    +      log.trace("Scope: " + env.getScope());
    +      log.trace("Looking up property: " + customProperty);
    +    }
    +
    +    AccumuloConfiguration systemConfiguration = localConf.getConfiguration();
    +    String clazz = systemConfiguration.get(customProperty);
    +    if (null == clazz || clazz.isEmpty()) {
    +      log.debug("Property not found: " + customProperty + " using fallback chooser.");
    +      return fallbackVolumeChooser;
         } else {
    -      chooser = fallbackVolumeChooser;
    +      chooser = scopeSpecificChooser.get(env.getScope());
    +      if (chooser == null) {
    +        VolumeChooser temp;
    +        try {
    +          temp = loadClassForCustomProperty(clazz);
    +        } catch (Exception e) {
    +          log.error("Failed to create instance for " + env.getScope() + " configured
to use " + clazz + " via " + customProperty);
    +          return fallbackVolumeChooser;
    +        }
    +        chooser = scopeSpecificChooser.putIfAbsent(env.getScope(), temp);
    +        if (chooser == null) {
    +          chooser = temp;
    +          // Otherwise, someone else beat us to initializing; use theirs.
    +        }
    +      } else if (!(chooser.getClass().getName().equals(clazz))) {
    +        if (log.isTraceEnabled()) {
    +          log.trace("change detected for scope: " + env.getScope());
    +        }
    +        // the configuration for this scope's chooser has been updated. In the case of
failure to instantiate we'll repeat here next call.
    +        // TODO stricter definition of when the updated property is used, ref ACCUMULO-3412
    +        VolumeChooser temp;
    +        try {
    +          temp = loadClassForCustomProperty(clazz);
    +        } catch (Exception e) {
    +          log.error("Failed to create instance for " + env.getScope() + " configured
to use " + clazz + " via " + customProperty);
    +          return fallbackVolumeChooser;
    --- End diff --
    
    Should we not be failing here instead of using the fallback?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message