@Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj == null || !(obj instanceof VolumeChooserEnvironment)) { return false; } VolumeChooserEnvironment other = (VolumeChooserEnvironment) obj; return getScope() == other.getScope() && Objects.equals(getTableId(), other.getTableId()); }
VolumeChooser getDelegateChooser(VolumeChooserEnvironment env) { switch (env.getScope()) { case INIT: // TODO should be possible to read from SiteConfiguration during init log.warn("Not possible to determine delegate chooser at '{}' scope. Using {}.", ChooserScope.INIT, RandomVolumeChooser.class.getName()); return randomChooser; case TABLE: return getVolumeChooserForTable(env, loadConfFactory(env)); default: return getVolumeChooserForScope(env, loadConfFactory(env)); } }
String[] getPreferredVolumes(VolumeChooserEnvironment env, String[] options) { switch (env.getScope()) { case INIT: // TODO should be possible to read from SiteConfiguration during init log.warn("Not possible to determine preferred volumes at '{}' scope. Using all volumes.", ChooserScope.INIT); return options; case TABLE: return getPreferredVolumesForTable(env, loadConfFactory(env), options); default: return getPreferredVolumesForScope(env, loadConfFactory(env), options); } }
private String[] getPreferredVolumesForScope(VolumeChooserEnvironment env, ServerConfigurationFactory confFactory, String[] options) { ChooserScope scope = env.getScope(); String property = getPropertyNameForScope(scope); log.trace("Looking up property {} for scope: {}", property, scope); AccumuloConfiguration systemConfiguration = confFactory.getSystemConfiguration(); String preferredVolumes = systemConfiguration.get(property); // fall back to global default scope if this scope isn't configured (and not already default // scope) if ((preferredVolumes == null || preferredVolumes.isEmpty()) && scope != ChooserScope.DEFAULT) { log.debug("{} not found; using {}", property, DEFAULT_SCOPED_PREFERRED_VOLUMES); preferredVolumes = systemConfiguration.get(DEFAULT_SCOPED_PREFERRED_VOLUMES); // only if the custom property is not set to we fall back to the default scoped preferred // volumes if (preferredVolumes == null || preferredVolumes.isEmpty()) { String msg = "Property " + property + " or " + DEFAULT_SCOPED_PREFERRED_VOLUMES + " must be a subset of " + Arrays.toString(options) + " to use the " + getClass().getSimpleName(); throw new VolumeChooserException(msg); } property = DEFAULT_SCOPED_PREFERRED_VOLUMES; } return parsePreferred(property, preferredVolumes, options); }
private VolumeChooser getVolumeChooserForScope(VolumeChooserEnvironment env, ServerConfigurationFactory confFactory) { ChooserScope scope = env.getScope(); String property = getPropertyNameForScope(scope); log.trace("Looking up property {} for scope: {}", property, scope); AccumuloConfiguration systemConfiguration = confFactory.getSystemConfiguration(); String clazz = systemConfiguration.get(property); // fall back to global default scope if this scope isn't configured (and not already default // scope) if ((clazz == null || clazz.isEmpty()) && scope != ChooserScope.DEFAULT) { log.debug("{} not found; using {}", property, DEFAULT_SCOPED_VOLUME_CHOOSER); clazz = systemConfiguration.get(DEFAULT_SCOPED_VOLUME_CHOOSER); if (clazz == null || clazz.isEmpty()) { String msg = "Property " + property + " or " + DEFAULT_SCOPED_VOLUME_CHOOSER + " must be a valid " + VolumeChooser.class.getSimpleName() + " to use the " + getClass().getSimpleName(); throw new VolumeChooserException(msg); } property = DEFAULT_SCOPED_VOLUME_CHOOSER; } String context = null; return createVolumeChooser(context, clazz, property, scope, scopeSpecificChooserCache); }