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:20:43 GMT
Github user ivakegg commented on a diff in the pull request:

    https://github.com/apache/accumulo/pull/253#discussion_r113243125
  
    --- Diff: server/base/src/main/java/org/apache/accumulo/server/fs/PerTableVolumeChooser.java
---
    @@ -18,36 +18,65 @@
     
     import java.util.concurrent.ConcurrentHashMap;
     
    +import org.apache.accumulo.core.client.AccumuloException;
    +import org.apache.accumulo.core.conf.AccumuloConfiguration;
     import org.apache.accumulo.core.conf.Property;
     import org.apache.accumulo.server.client.HdfsZooInstance;
     import org.apache.accumulo.server.conf.ServerConfigurationFactory;
     import org.apache.accumulo.server.conf.TableConfiguration;
    +import org.apache.accumulo.start.classloader.vfs.AccumuloVFSClassLoader;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
     
     /**
      * A {@link VolumeChooser} that delegates to another volume chooser based on the presence
of an experimental table property,
      * {@link Property#TABLE_VOLUME_CHOOSER}. If it isn't found, defaults back to {@link
RandomVolumeChooser}.
      */
     public class PerTableVolumeChooser implements VolumeChooser {
    -
    -  private final VolumeChooser fallbackVolumeChooser = new RandomVolumeChooser();
    +  private static final Logger log = LoggerFactory.getLogger(PerTableVolumeChooser.class);
       // TODO Add hint of expected size to construction, see ACCUMULO-3410
       /* Track VolumeChooser instances so they can keep state. */
       private final ConcurrentHashMap<String,VolumeChooser> tableSpecificChooser =
new ConcurrentHashMap<>();
    +  private final ConcurrentHashMap<String,VolumeChooser> scopeSpecificChooser =
new ConcurrentHashMap<>();
    +  private final RandomVolumeChooser randomChooser = new RandomVolumeChooser();
       // TODO has to be lazily initialized currently because of the reliance on HdfsZooInstance.
see ACCUMULO-3411
       private volatile ServerConfigurationFactory serverConfs;
    +  private volatile VolumeChooser fallbackVolumeChooser = null;
     
       @Override
    -  public String choose(VolumeChooserEnvironment env, String[] options) {
    -    VolumeChooser chooser = null;
    -    if (env.hasTableId()) {
    -      // This local variable is an intentional component of the single-check idiom.
    -      ServerConfigurationFactory localConf = serverConfs;
    -      if (localConf == null) {
    -        // If we're under contention when first getting here we'll throw away some initializations.
    -        localConf = new ServerConfigurationFactory(HdfsZooInstance.getInstance());
    -        serverConfs = localConf;
    -      }
    -      final TableConfiguration tableConf = localConf.getTableConfiguration(env.getTableId());
    +  public String choose(VolumeChooserEnvironment env, String[] options) throws AccumuloException
{
    +    if (log.isTraceEnabled()) {
    +      log.trace("PerTableVolumeChooser.choose");
    +    }
    +    VolumeChooser chooser;
    +    if (!env.hasTableId() && !env.hasScope()) {
    +      // Should only get here during Initialize. Configurations are not yet available.
    +      return randomChooser.choose(env, options);
    +    }
    +
    +    ServerConfigurationFactory localConf = loadConf();
    +    lazilyCreateFallbackChooser();
    +    if (env.hasScope()) {
    --- End diff --
    
    Perhaps ignorance on my part, but shouldn't env.hasTableId() be checked first?  Can env.hasTableId()
&& env.hasScope()?


---
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