accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubb...@apache.org
Subject [1/2] accumulo git commit: ACCUMULO-3714 Replace PropertyFilter
Date Thu, 09 Apr 2015 19:42:52 GMT
Repository: accumulo
Updated Branches:
  refs/heads/master 8fae3f806 -> 8fbf2dce0


ACCUMULO-3714 Replace PropertyFilter

* Replace internal PropertyFilter with Guava's Predicate.
* Preserve MockConfiguration public API by deprecating PropertyFilter


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/2e9643dc
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/2e9643dc
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/2e9643dc

Branch: refs/heads/master
Commit: 2e9643dcc406df3f1a502f9eaf543d1d9bdee560
Parents: 27f3b30
Author: Christopher Tubbs <ctubbsii@apache.org>
Authored: Wed Apr 8 22:00:52 2015 -0400
Committer: Christopher Tubbs <ctubbsii@apache.org>
Committed: Wed Apr 8 22:00:52 2015 -0400

----------------------------------------------------------------------
 .../apache/accumulo/core/cli/ClientOpts.java    |  7 +++--
 .../core/client/impl/ClientContext.java         | 10 +++---
 .../core/client/mock/MockConfiguration.java     | 23 ++++++++++++--
 .../core/conf/AccumuloConfiguration.java        | 32 +++++++++-----------
 .../accumulo/core/conf/ConfigurationCopy.java   |  6 ++--
 .../core/conf/DefaultConfiguration.java         |  6 ++--
 .../accumulo/core/conf/SiteConfiguration.java   |  7 +++--
 .../core/client/impl/ClientContextTest.java     |  7 +++--
 .../core/conf/DefaultConfigurationTest.java     |  7 +++--
 .../core/conf/ObservableConfigurationTest.java  |  4 ++-
 .../core/conf/SiteConfigurationTest.java        |  7 +++--
 .../server/conf/NamespaceConfiguration.java     | 16 +++++-----
 .../server/conf/TableConfiguration.java         |  4 ++-
 .../server/conf/ZooCachePropertyAccessor.java   |  7 +++--
 .../accumulo/server/conf/ZooConfiguration.java  |  6 ++--
 .../server/fs/PreferredVolumeChooser.java       |  7 +++--
 .../server/conf/NamespaceConfigurationTest.java | 11 ++++---
 .../server/conf/TableConfigurationTest.java     | 11 ++++---
 .../conf/ZooCachePropertyAccessorTest.java      | 24 +++++++++------
 .../accumulo/server/util/FileUtilTest.java      |  4 ++-
 .../apache/accumulo/test/util/CertUtils.java    |  5 +--
 21 files changed, 132 insertions(+), 79 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/2e9643dc/core/src/main/java/org/apache/accumulo/core/cli/ClientOpts.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/cli/ClientOpts.java b/core/src/main/java/org/apache/accumulo/core/cli/ClientOpts.java
index 6185419..0975ec8 100644
--- a/core/src/main/java/org/apache/accumulo/core/cli/ClientOpts.java
+++ b/core/src/main/java/org/apache/accumulo/core/cli/ClientOpts.java
@@ -57,6 +57,7 @@ import org.apache.log4j.Logger;
 import com.beust.jcommander.DynamicParameter;
 import com.beust.jcommander.IStringConverter;
 import com.beust.jcommander.Parameter;
+import com.google.common.base.Predicate;
 
 public class ClientOpts extends Help {
 
@@ -342,12 +343,12 @@ public class ClientOpts extends Help {
         }
 
         @Override
-        public void getProperties(Map<String,String> props, PropertyFilter filter)
{
+        public void getProperties(Map<String,String> props, Predicate<String>
filter) {
           for (Entry<String,String> prop : DefaultConfiguration.getInstance())
-            if (filter.accept(prop.getKey()))
+            if (filter.apply(prop.getKey()))
               props.put(prop.getKey(), prop.getValue());
           for (Entry<String,String> prop : xml)
-            if (filter.accept(prop.getKey()))
+            if (filter.apply(prop.getKey()))
               props.put(prop.getKey(), prop.getValue());
         }
 

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2e9643dc/core/src/main/java/org/apache/accumulo/core/client/impl/ClientContext.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/ClientContext.java b/core/src/main/java/org/apache/accumulo/core/client/impl/ClientContext.java
index 9257a1f..9def3ab 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/ClientContext.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/ClientContext.java
@@ -42,6 +42,8 @@ import org.apache.commons.configuration.Configuration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.base.Predicate;
+
 /**
  * This class represents any essential configuration and credentials needed to initiate RPC
operations throughout the code. It is intended to represent a shared
  * object that contains these things from when the client was first constructed. It is not
public API, and is only an internal representation of the context in
@@ -212,13 +214,13 @@ public class ClientContext {
       }
 
       @Override
-      public void getProperties(Map<String,String> props, PropertyFilter filter) {
+      public void getProperties(Map<String,String> props, Predicate<String> filter)
{
         defaults.getProperties(props, filter);
 
         Iterator<?> keyIter = config.getKeys();
         while (keyIter.hasNext()) {
           String key = keyIter.next().toString();
-          if (filter.accept(key))
+          if (filter.apply(key))
             props.put(key, config.getString(key));
         }
 
@@ -226,7 +228,7 @@ public class ClientContext {
         // Automatically reconstruct the server property when converting a client config.
         if (props.containsKey(ClientProperty.KERBEROS_SERVER_PRIMARY.getKey())) {
           final String serverPrimary = props.remove(ClientProperty.KERBEROS_SERVER_PRIMARY.getKey());
-          if (filter.accept(Property.GENERAL_KERBEROS_PRINCIPAL.getKey())) {
+          if (filter.apply(Property.GENERAL_KERBEROS_PRINCIPAL.getKey())) {
             // Use the _HOST expansion. It should be unnecessary in "client land".
             props.put(Property.GENERAL_KERBEROS_PRINCIPAL.getKey(), serverPrimary + "/_HOST@"
+ SaslConnectionParams.getDefaultRealm());
           }
@@ -241,7 +243,7 @@ public class ClientContext {
                 continue;
               }
 
-              if (filter.accept(key)) {
+              if (filter.apply(key)) {
                 char[] value = CredentialProviderFactoryShim.getValueFromCredentialProvider(hadoopConf,
key);
                 if (null != value) {
                   props.put(key, new String(value));

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2e9643dc/core/src/main/java/org/apache/accumulo/core/client/mock/MockConfiguration.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/client/mock/MockConfiguration.java
b/core/src/main/java/org/apache/accumulo/core/client/mock/MockConfiguration.java
index 8c57c5e..410105b 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/mock/MockConfiguration.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/mock/MockConfiguration.java
@@ -22,6 +22,8 @@ import java.util.Map.Entry;
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
 import org.apache.accumulo.core.conf.Property;
 
+import com.google.common.base.Predicate;
+
 class MockConfiguration extends AccumuloConfiguration {
   Map<String,String> map;
 
@@ -38,10 +40,27 @@ class MockConfiguration extends AccumuloConfiguration {
     return map.get(property.getKey());
   }
 
+  /**
+   * Don't use this method. It has been deprecated. Its parameters are not public API and
subject to change.
+   *
+   * @deprecated since 1.7.0; use {@link #getProperties(Map, Predicate)} instead.
+   */
+  @Deprecated
+  public void getProperties(Map<String,String> props, final PropertyFilter filter)
{
+    // convert PropertyFilter to Predicate
+    getProperties(props, new Predicate<String>() {
+
+      @Override
+      public boolean apply(String input) {
+        return filter.accept(input);
+      }
+    });
+  }
+
   @Override
-  public void getProperties(Map<String,String> props, PropertyFilter filter) {
+  public void getProperties(Map<String,String> props, Predicate<String> filter)
{
     for (Entry<String,String> entry : map.entrySet()) {
-      if (filter.accept(entry.getKey())) {
+      if (filter.apply(entry.getKey())) {
         props.put(entry.getKey(), entry.getValue());
       }
     }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2e9643dc/core/src/main/java/org/apache/accumulo/core/conf/AccumuloConfiguration.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/conf/AccumuloConfiguration.java b/core/src/main/java/org/apache/accumulo/core/conf/AccumuloConfiguration.java
index 14d68c2..9ff4185 100644
--- a/core/src/main/java/org/apache/accumulo/core/conf/AccumuloConfiguration.java
+++ b/core/src/main/java/org/apache/accumulo/core/conf/AccumuloConfiguration.java
@@ -33,6 +33,9 @@ import org.apache.accumulo.start.classloader.vfs.AccumuloVFSClassLoader;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+
 /**
  * A configuration object.
  */
@@ -40,7 +43,10 @@ public abstract class AccumuloConfiguration implements Iterable<Entry<String,Str
 
   /**
    * A filter for properties, based on key.
+   *
+   * @deprecated since 1.7.0; use {@link Predicate} instead.
    */
+  @Deprecated
   public interface PropertyFilter {
     /**
      * Determines whether to accept a property based on its key.
@@ -53,19 +59,9 @@ public abstract class AccumuloConfiguration implements Iterable<Entry<String,Str
   }
 
   /**
-   * A filter that accepts all properties.
-   */
-  public static class AllFilter implements PropertyFilter {
-    @Override
-    public boolean accept(String key) {
-      return true;
-    }
-  }
-
-  /**
    * A filter that accepts properties whose keys are an exact match.
    */
-  public static class MatchFilter implements PropertyFilter {
+  public static class MatchFilter implements Predicate<String> {
 
     private String match;
 
@@ -80,7 +76,7 @@ public abstract class AccumuloConfiguration implements Iterable<Entry<String,Str
     }
 
     @Override
-    public boolean accept(String key) {
+    public boolean apply(String key) {
       return Objects.equals(match, key);
     }
   }
@@ -88,7 +84,7 @@ public abstract class AccumuloConfiguration implements Iterable<Entry<String,Str
   /**
    * A filter that accepts properties whose keys begin with a prefix.
    */
-  public static class PrefixFilter implements PropertyFilter {
+  public static class PrefixFilter implements Predicate<String> {
 
     private String prefix;
 
@@ -103,7 +99,7 @@ public abstract class AccumuloConfiguration implements Iterable<Entry<String,Str
     }
 
     @Override
-    public boolean accept(String key) {
+    public boolean apply(String key) {
       return key.startsWith(prefix);
     }
   }
@@ -114,8 +110,7 @@ public abstract class AccumuloConfiguration implements Iterable<Entry<String,Str
    * Gets a property value from this configuration.
    *
    * <p>
-   * Note: this is inefficient, but convenient on occasion. For retrieving multiple properties,
use {@link #getProperties(Map, PropertyFilter)} with a custom
-   * filter.
+   * Note: this is inefficient, but convenient on occasion. For retrieving multiple properties,
use {@link #getProperties(Map, Predicate)} with a custom filter.
    *
    * @param property
    *          property to get
@@ -145,7 +140,7 @@ public abstract class AccumuloConfiguration implements Iterable<Entry<String,Str
    * @param filter
    *          filter for accepting properties from this configuration
    */
-  public abstract void getProperties(Map<String,String> props, PropertyFilter filter);
+  public abstract void getProperties(Map<String,String> props, Predicate<String>
filter);
 
   /**
    * Returns an iterator over property key/value pairs in this configuration. Some implementations
may elect to omit properties.
@@ -154,8 +149,9 @@ public abstract class AccumuloConfiguration implements Iterable<Entry<String,Str
    */
   @Override
   public Iterator<Entry<String,String>> iterator() {
+    Predicate<String> all = Predicates.alwaysTrue();
     TreeMap<String,String> entries = new TreeMap<String,String>();
-    getProperties(entries, new AllFilter());
+    getProperties(entries, all);
     return entries.entrySet().iterator();
   }
 

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2e9643dc/core/src/main/java/org/apache/accumulo/core/conf/ConfigurationCopy.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/conf/ConfigurationCopy.java b/core/src/main/java/org/apache/accumulo/core/conf/ConfigurationCopy.java
index 8326725..28b188f 100644
--- a/core/src/main/java/org/apache/accumulo/core/conf/ConfigurationCopy.java
+++ b/core/src/main/java/org/apache/accumulo/core/conf/ConfigurationCopy.java
@@ -21,6 +21,8 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Map.Entry;
 
+import com.google.common.base.Predicate;
+
 /**
  * An {@link AccumuloConfiguration} which holds a flat copy of properties defined in another
configuration
  */
@@ -62,9 +64,9 @@ public class ConfigurationCopy extends AccumuloConfiguration {
   }
 
   @Override
-  public void getProperties(Map<String,String> props, PropertyFilter filter) {
+  public void getProperties(Map<String,String> props, Predicate<String> filter)
{
     for (Entry<String,String> entry : copy.entrySet()) {
-      if (filter.accept(entry.getKey())) {
+      if (filter.apply(entry.getKey())) {
         props.put(entry.getKey(), entry.getValue());
       }
     }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2e9643dc/core/src/main/java/org/apache/accumulo/core/conf/DefaultConfiguration.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/conf/DefaultConfiguration.java b/core/src/main/java/org/apache/accumulo/core/conf/DefaultConfiguration.java
index 17364a7..34d7fd2 100644
--- a/core/src/main/java/org/apache/accumulo/core/conf/DefaultConfiguration.java
+++ b/core/src/main/java/org/apache/accumulo/core/conf/DefaultConfiguration.java
@@ -21,6 +21,8 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Map.Entry;
 
+import com.google.common.base.Predicate;
+
 /**
  * An {@link AccumuloConfiguration} that contains only default values for properties. This
class is a singleton.
  */
@@ -51,9 +53,9 @@ public class DefaultConfiguration extends AccumuloConfiguration {
   }
 
   @Override
-  public void getProperties(Map<String,String> props, PropertyFilter filter) {
+  public void getProperties(Map<String,String> props, Predicate<String> filter)
{
     for (Entry<String,String> entry : resolvedProps.entrySet())
-      if (filter.accept(entry.getKey()))
+      if (filter.apply(entry.getKey()))
         props.put(entry.getKey(), entry.getValue());
   }
 }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2e9643dc/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java b/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java
index b410cf7..e8c49b4 100644
--- a/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java
+++ b/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java
@@ -25,6 +25,7 @@ import org.apache.hadoop.conf.Configuration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.base.Predicate;
 
 /**
  * An {@link AccumuloConfiguration} which loads properties from an XML file, usually accumulo-site.xml.
This implementation supports defaulting undefined
@@ -116,11 +117,11 @@ public class SiteConfiguration extends AccumuloConfiguration {
   }
 
   @Override
-  public void getProperties(Map<String,String> props, PropertyFilter filter) {
+  public void getProperties(Map<String,String> props, Predicate<String> filter)
{
     parent.getProperties(props, filter);
 
     for (Entry<String,String> entry : getXmlConfig())
-      if (filter.accept(entry.getKey()))
+      if (filter.apply(entry.getKey()))
         props.put(entry.getKey(), entry.getValue());
 
     // CredentialProvider should take precedence over site
@@ -132,7 +133,7 @@ public class SiteConfiguration extends AccumuloConfiguration {
             continue;
           }
 
-          if (filter.accept(key)) {
+          if (filter.apply(key)) {
             char[] value = CredentialProviderFactoryShim.getValueFromCredentialProvider(hadoopConf,
key);
             if (null != value) {
               props.put(key, new String(value));

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2e9643dc/core/src/test/java/org/apache/accumulo/core/client/impl/ClientContextTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/client/impl/ClientContextTest.java
b/core/src/test/java/org/apache/accumulo/core/client/impl/ClientContextTest.java
index 494eb50..ff9863c 100644
--- a/core/src/test/java/org/apache/accumulo/core/client/impl/ClientContextTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/client/impl/ClientContextTest.java
@@ -23,13 +23,15 @@ import java.util.Map;
 
 import org.apache.accumulo.core.client.ClientConfiguration;
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
-import org.apache.accumulo.core.conf.AccumuloConfiguration.AllFilter;
 import org.apache.accumulo.core.conf.CredentialProviderFactoryShim;
 import org.apache.accumulo.core.conf.Property;
 import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+
 public class ClientContextTest {
 
   private static boolean isCredentialProviderAvailable = false;
@@ -98,7 +100,8 @@ public class ClientContextTest {
 
     AccumuloConfiguration accClientConf = ClientContext.convertClientConfig(clientConf);
     Map<String,String> props = new HashMap<String,String>();
-    accClientConf.getProperties(props, new AllFilter());
+    Predicate<String> all = Predicates.alwaysTrue();
+    accClientConf.getProperties(props, all);
 
     // Only sensitive properties are added
     Assert.assertEquals(Property.GENERAL_RPC_TIMEOUT.getDefaultValue(), props.get(Property.GENERAL_RPC_TIMEOUT.getKey()));

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2e9643dc/core/src/test/java/org/apache/accumulo/core/conf/DefaultConfigurationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/conf/DefaultConfigurationTest.java
b/core/src/test/java/org/apache/accumulo/core/conf/DefaultConfigurationTest.java
index e21db3d..9566f2e 100644
--- a/core/src/test/java/org/apache/accumulo/core/conf/DefaultConfigurationTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/conf/DefaultConfigurationTest.java
@@ -20,10 +20,12 @@ import static org.junit.Assert.assertEquals;
 
 import java.util.Map;
 
-import org.apache.accumulo.core.conf.AccumuloConfiguration.AllFilter;
 import org.junit.Before;
 import org.junit.Test;
 
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+
 public class DefaultConfigurationTest {
   private DefaultConfiguration c;
 
@@ -39,8 +41,9 @@ public class DefaultConfigurationTest {
 
   @Test
   public void testGetProperties() {
+    Predicate<String> all = Predicates.alwaysTrue();
     Map<String,String> p = new java.util.HashMap<String,String>();
-    c.getProperties(p, new AllFilter());
+    c.getProperties(p, all);
     assertEquals(Property.MASTER_CLIENTPORT.getDefaultValue(), p.get(Property.MASTER_CLIENTPORT.getKey()));
   }
 

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2e9643dc/core/src/test/java/org/apache/accumulo/core/conf/ObservableConfigurationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/conf/ObservableConfigurationTest.java
b/core/src/test/java/org/apache/accumulo/core/conf/ObservableConfigurationTest.java
index b92fac6..8f73907 100644
--- a/core/src/test/java/org/apache/accumulo/core/conf/ObservableConfigurationTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/conf/ObservableConfigurationTest.java
@@ -28,6 +28,8 @@ import java.util.Map;
 import org.junit.Before;
 import org.junit.Test;
 
+import com.google.common.base.Predicate;
+
 public class ObservableConfigurationTest {
   private static class TestObservableConfig extends ObservableConfiguration {
     @Override
@@ -36,7 +38,7 @@ public class ObservableConfigurationTest {
     }
 
     @Override
-    public void getProperties(Map<String,String> props, PropertyFilter filter) {}
+    public void getProperties(Map<String,String> props, Predicate<String> filter)
{}
   }
 
   private ObservableConfiguration c;

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2e9643dc/core/src/test/java/org/apache/accumulo/core/conf/SiteConfigurationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/conf/SiteConfigurationTest.java b/core/src/test/java/org/apache/accumulo/core/conf/SiteConfigurationTest.java
index f54adb1..a0d48b9 100644
--- a/core/src/test/java/org/apache/accumulo/core/conf/SiteConfigurationTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/conf/SiteConfigurationTest.java
@@ -21,13 +21,15 @@ import java.net.URL;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.accumulo.core.conf.AccumuloConfiguration.AllFilter;
 import org.apache.hadoop.conf.Configuration;
 import org.easymock.EasyMock;
 import org.junit.Assert;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+
 public class SiteConfigurationTest {
   private static boolean isCredentialProviderAvailable;
 
@@ -65,7 +67,8 @@ public class SiteConfigurationTest {
     EasyMock.replay(siteCfg);
 
     Map<String,String> props = new HashMap<String,String>();
-    siteCfg.getProperties(props, new AllFilter());
+    Predicate<String> all = Predicates.alwaysTrue();
+    siteCfg.getProperties(props, all);
 
     Assert.assertEquals("mysecret", props.get(Property.INSTANCE_SECRET.getKey()));
     Assert.assertEquals(null, props.get("ignored.property"));

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2e9643dc/server/base/src/main/java/org/apache/accumulo/server/conf/NamespaceConfiguration.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/conf/NamespaceConfiguration.java
b/server/base/src/main/java/org/apache/accumulo/server/conf/NamespaceConfiguration.java
index bae694b..3d19723 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/conf/NamespaceConfiguration.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/conf/NamespaceConfiguration.java
@@ -33,6 +33,8 @@ import org.apache.accumulo.server.conf.ZooCachePropertyAccessor.PropCacheKey;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.base.Predicate;
+
 public class NamespaceConfiguration extends ObservableConfiguration {
   private static final Logger log = LoggerFactory.getLogger(NamespaceConfiguration.class);
 
@@ -99,26 +101,26 @@ public class NamespaceConfiguration extends ObservableConfiguration {
     return getPropCacheAccessor().get(property, getPath(), getParent);
   }
 
-  private class SystemNamespaceFilter implements PropertyFilter {
+  private class SystemNamespaceFilter implements Predicate<String> {
 
-    private PropertyFilter userFilter;
+    private Predicate<String> userFilter;
 
-    SystemNamespaceFilter(PropertyFilter userFilter) {
+    SystemNamespaceFilter(Predicate<String> userFilter) {
       this.userFilter = userFilter;
     }
 
     @Override
-    public boolean accept(String key) {
+    public boolean apply(String key) {
       if (isIteratorOrConstraint(key))
         return false;
-      return userFilter.accept(key);
+      return userFilter.apply(key);
     }
 
   }
 
   @Override
-  public void getProperties(Map<String,String> props, PropertyFilter filter) {
-    PropertyFilter parentFilter = filter;
+  public void getProperties(Map<String,String> props, Predicate<String> filter)
{
+    Predicate<String> parentFilter = filter;
     // exclude system iterators/constraints from the system namespace
     // so they don't affect the metadata or root tables.
     if (getNamespaceId().equals(Namespaces.ACCUMULO_NAMESPACE_ID))

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2e9643dc/server/base/src/main/java/org/apache/accumulo/server/conf/TableConfiguration.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/conf/TableConfiguration.java
b/server/base/src/main/java/org/apache/accumulo/server/conf/TableConfiguration.java
index 259f2a2..915122b 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/conf/TableConfiguration.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/conf/TableConfiguration.java
@@ -30,6 +30,8 @@ import org.apache.accumulo.server.conf.ZooCachePropertyAccessor.PropCacheKey;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.base.Predicate;
+
 public class TableConfiguration extends ObservableConfiguration {
   private static final Logger log = LoggerFactory.getLogger(TableConfiguration.class);
 
@@ -98,7 +100,7 @@ public class TableConfiguration extends ObservableConfiguration {
   }
 
   @Override
-  public void getProperties(Map<String,String> props, PropertyFilter filter) {
+  public void getProperties(Map<String,String> props, Predicate<String> filter)
{
     getPropCacheAccessor().getProperties(props, getPath(), filter, parent, null);
   }
 

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2e9643dc/server/base/src/main/java/org/apache/accumulo/server/conf/ZooCachePropertyAccessor.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/conf/ZooCachePropertyAccessor.java
b/server/base/src/main/java/org/apache/accumulo/server/conf/ZooCachePropertyAccessor.java
index bec30d2..79f9a59 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/conf/ZooCachePropertyAccessor.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/conf/ZooCachePropertyAccessor.java
@@ -22,12 +22,13 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
-import org.apache.accumulo.core.conf.AccumuloConfiguration.PropertyFilter;
 import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.fate.zookeeper.ZooCache;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.base.Predicate;
+
 /**
  * A helper object for accessing properties in a {@link ZooCache}.
  */
@@ -136,13 +137,13 @@ public class ZooCachePropertyAccessor {
    * @param parentFilter
    *          separate filter for parent properties (optional)
    */
-  void getProperties(Map<String,String> props, String path, PropertyFilter filter,
AccumuloConfiguration parent, PropertyFilter parentFilter) {
+  void getProperties(Map<String,String> props, String path, Predicate<String>
filter, AccumuloConfiguration parent, Predicate<String> parentFilter) {
     parent.getProperties(props, parentFilter != null ? parentFilter : filter);
 
     List<String> children = propCache.getChildren(path);
     if (children != null) {
       for (String child : children) {
-        if (child != null && filter.accept(child)) {
+        if (child != null && filter.apply(child)) {
           String value = get(path + "/" + child);
           if (value != null) {
             props.put(child, value);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2e9643dc/server/base/src/main/java/org/apache/accumulo/server/conf/ZooConfiguration.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/conf/ZooConfiguration.java
b/server/base/src/main/java/org/apache/accumulo/server/conf/ZooConfiguration.java
index a53350b..f178ff1 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/conf/ZooConfiguration.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/conf/ZooConfiguration.java
@@ -31,6 +31,8 @@ import org.apache.accumulo.fate.zookeeper.ZooCache;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.base.Predicate;
+
 public class ZooConfiguration extends AccumuloConfiguration {
   private static final Logger log = LoggerFactory.getLogger(ZooConfiguration.class);
 
@@ -104,13 +106,13 @@ public class ZooConfiguration extends AccumuloConfiguration {
   }
 
   @Override
-  public void getProperties(Map<String,String> props, PropertyFilter filter) {
+  public void getProperties(Map<String,String> props, Predicate<String> filter)
{
     parent.getProperties(props, filter);
 
     List<String> children = propCache.getChildren(ZooUtil.getRoot(instanceId) + Constants.ZCONFIG);
     if (children != null) {
       for (String child : children) {
-        if (child != null && filter.accept(child)) {
+        if (child != null && filter.apply(child)) {
           String value = getRaw(child);
           if (value != null)
             props.put(child, value);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2e9643dc/server/base/src/main/java/org/apache/accumulo/server/fs/PreferredVolumeChooser.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/fs/PreferredVolumeChooser.java
b/server/base/src/main/java/org/apache/accumulo/server/fs/PreferredVolumeChooser.java
index 77026e6..04242a9 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/fs/PreferredVolumeChooser.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/fs/PreferredVolumeChooser.java
@@ -26,7 +26,6 @@ import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.accumulo.core.conf.AccumuloConfiguration.PropertyFilter;
 import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.core.volume.Volume;
 import org.apache.accumulo.server.client.HdfsZooInstance;
@@ -37,6 +36,8 @@ import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.base.Predicate;
+
 /**
  * A {@link RandomVolumeChooser} that limits its choices from a given set of options to the
subset of those options preferred for a particular table. Defaults
  * to selecting from all of the options presented. Can be customized via the table property
{@value #PREFERRED_VOLUMES_CUSTOM_KEY}, which should contain a comma
@@ -47,9 +48,9 @@ public class PreferredVolumeChooser extends RandomVolumeChooser implements
Volum
 
   public static final String PREFERRED_VOLUMES_CUSTOM_KEY = Property.TABLE_ARBITRARY_PROP_PREFIX.getKey()
+ "preferredVolumes";
   // TODO ACCUMULO-3417 replace this with the ability to retrieve by String key.
-  private static final PropertyFilter PREFERRED_VOLUMES_FILTER = new PropertyFilter() {
+  private static final Predicate<String> PREFERRED_VOLUMES_FILTER = new Predicate<String>()
{
     @Override
-    public boolean accept(String key) {
+    public boolean apply(String key) {
       return PREFERRED_VOLUMES_CUSTOM_KEY.equals(key);
     }
   };

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2e9643dc/server/base/src/test/java/org/apache/accumulo/server/conf/NamespaceConfigurationTest.java
----------------------------------------------------------------------
diff --git a/server/base/src/test/java/org/apache/accumulo/server/conf/NamespaceConfigurationTest.java
b/server/base/src/test/java/org/apache/accumulo/server/conf/NamespaceConfigurationTest.java
index 6bd6424..742ebb2 100644
--- a/server/base/src/test/java/org/apache/accumulo/server/conf/NamespaceConfigurationTest.java
+++ b/server/base/src/test/java/org/apache/accumulo/server/conf/NamespaceConfigurationTest.java
@@ -37,8 +37,6 @@ import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.Instance;
 import org.apache.accumulo.core.client.impl.Namespaces;
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
-import org.apache.accumulo.core.conf.AccumuloConfiguration.AllFilter;
-import org.apache.accumulo.core.conf.AccumuloConfiguration.PropertyFilter;
 import org.apache.accumulo.core.conf.ConfigurationObserver;
 import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.core.zookeeper.ZooUtil;
@@ -47,6 +45,9 @@ import org.apache.accumulo.fate.zookeeper.ZooCacheFactory;
 import org.junit.Before;
 import org.junit.Test;
 
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+
 public class NamespaceConfigurationTest {
   private static final String NSID = "namespace";
   private static final String ZOOKEEPERS = "localhost";
@@ -116,9 +117,9 @@ public class NamespaceConfigurationTest {
 
   @Test
   public void testGetProperties() {
-    PropertyFilter filter = new AllFilter();
+    Predicate<String> all = Predicates.alwaysTrue();
     Map<String,String> props = new java.util.HashMap<String,String>();
-    parent.getProperties(props, filter);
+    parent.getProperties(props, all);
     replay(parent);
     List<String> children = new java.util.ArrayList<String>();
     children.add("foo");
@@ -127,7 +128,7 @@ public class NamespaceConfigurationTest {
     expect(zc.get(ZooUtil.getRoot(iid) + Constants.ZNAMESPACES + "/" + NSID + Constants.ZNAMESPACE_CONF
+ "/" + "foo")).andReturn("bar".getBytes(UTF_8));
     expect(zc.get(ZooUtil.getRoot(iid) + Constants.ZNAMESPACES + "/" + NSID + Constants.ZNAMESPACE_CONF
+ "/" + "ding")).andReturn("dong".getBytes(UTF_8));
     replay(zc);
-    c.getProperties(props, filter);
+    c.getProperties(props, all);
     assertEquals(2, props.size());
     assertEquals("bar", props.get("foo"));
     assertEquals("dong", props.get("ding"));

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2e9643dc/server/base/src/test/java/org/apache/accumulo/server/conf/TableConfigurationTest.java
----------------------------------------------------------------------
diff --git a/server/base/src/test/java/org/apache/accumulo/server/conf/TableConfigurationTest.java
b/server/base/src/test/java/org/apache/accumulo/server/conf/TableConfigurationTest.java
index 68ee2b9..1eb933a 100644
--- a/server/base/src/test/java/org/apache/accumulo/server/conf/TableConfigurationTest.java
+++ b/server/base/src/test/java/org/apache/accumulo/server/conf/TableConfigurationTest.java
@@ -33,8 +33,6 @@ import java.util.UUID;
 
 import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.Instance;
-import org.apache.accumulo.core.conf.AccumuloConfiguration.AllFilter;
-import org.apache.accumulo.core.conf.AccumuloConfiguration.PropertyFilter;
 import org.apache.accumulo.core.conf.ConfigurationObserver;
 import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.core.zookeeper.ZooUtil;
@@ -43,6 +41,9 @@ import org.apache.accumulo.fate.zookeeper.ZooCacheFactory;
 import org.junit.Before;
 import org.junit.Test;
 
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+
 public class TableConfigurationTest {
   private static final String TID = "table";
   private static final String ZOOKEEPERS = "localhost";
@@ -100,9 +101,9 @@ public class TableConfigurationTest {
 
   @Test
   public void testGetProperties() {
-    PropertyFilter filter = new AllFilter();
+    Predicate<String> all = Predicates.alwaysTrue();
     Map<String,String> props = new java.util.HashMap<String,String>();
-    parent.getProperties(props, filter);
+    parent.getProperties(props, all);
     replay(parent);
     List<String> children = new java.util.ArrayList<String>();
     children.add("foo");
@@ -111,7 +112,7 @@ public class TableConfigurationTest {
     expect(zc.get(ZooUtil.getRoot(iid) + Constants.ZTABLES + "/" + TID + Constants.ZTABLE_CONF
+ "/" + "foo")).andReturn("bar".getBytes(UTF_8));
     expect(zc.get(ZooUtil.getRoot(iid) + Constants.ZTABLES + "/" + TID + Constants.ZTABLE_CONF
+ "/" + "ding")).andReturn("dong".getBytes(UTF_8));
     replay(zc);
-    c.getProperties(props, filter);
+    c.getProperties(props, all);
     assertEquals(2, props.size());
     assertEquals("bar", props.get("foo"));
     assertEquals("dong", props.get("ding"));

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2e9643dc/server/base/src/test/java/org/apache/accumulo/server/conf/ZooCachePropertyAccessorTest.java
----------------------------------------------------------------------
diff --git a/server/base/src/test/java/org/apache/accumulo/server/conf/ZooCachePropertyAccessorTest.java
b/server/base/src/test/java/org/apache/accumulo/server/conf/ZooCachePropertyAccessorTest.java
index 210d240..e90e921 100644
--- a/server/base/src/test/java/org/apache/accumulo/server/conf/ZooCachePropertyAccessorTest.java
+++ b/server/base/src/test/java/org/apache/accumulo/server/conf/ZooCachePropertyAccessorTest.java
@@ -29,12 +29,13 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
-import org.apache.accumulo.core.conf.AccumuloConfiguration.PropertyFilter;
 import org.apache.accumulo.core.conf.Property;
 import org.apache.accumulo.fate.zookeeper.ZooCache;
 import org.junit.Before;
 import org.junit.Test;
 
+import com.google.common.base.Predicate;
+
 public class ZooCachePropertyAccessorTest {
   private static final String PATH = "/root/path/to/props";
   private static final Property PROP = Property.INSTANCE_SECRET;
@@ -106,7 +107,8 @@ public class ZooCachePropertyAccessorTest {
   public void testGetProperties() {
     Map<String,String> props = new java.util.HashMap<String,String>();
     AccumuloConfiguration parent = createMock(AccumuloConfiguration.class);
-    PropertyFilter filter = createMock(PropertyFilter.class);
+    @SuppressWarnings("unchecked")
+    Predicate<String> filter = createMock(Predicate.class);
     parent.getProperties(props, filter);
     replay(parent);
     String child1 = "child1";
@@ -118,8 +120,8 @@ public class ZooCachePropertyAccessorTest {
     expect(zc.get(PATH + "/" + child1)).andReturn(VALUE_BYTES);
     expect(zc.get(PATH + "/" + child2)).andReturn(null);
     replay(zc);
-    expect(filter.accept(child1)).andReturn(true);
-    expect(filter.accept(child2)).andReturn(true);
+    expect(filter.apply(child1)).andReturn(true);
+    expect(filter.apply(child2)).andReturn(true);
     replay(filter);
 
     a.getProperties(props, PATH, filter, parent, null);
@@ -132,7 +134,8 @@ public class ZooCachePropertyAccessorTest {
   public void testGetProperties_NoChildren() {
     Map<String,String> props = new java.util.HashMap<String,String>();
     AccumuloConfiguration parent = createMock(AccumuloConfiguration.class);
-    PropertyFilter filter = createMock(PropertyFilter.class);
+    @SuppressWarnings("unchecked")
+    Predicate<String> filter = createMock(Predicate.class);
     parent.getProperties(props, filter);
     replay(parent);
     expect(zc.getChildren(PATH)).andReturn(null);
@@ -146,7 +149,8 @@ public class ZooCachePropertyAccessorTest {
   public void testGetProperties_Filter() {
     Map<String,String> props = new java.util.HashMap<String,String>();
     AccumuloConfiguration parent = createMock(AccumuloConfiguration.class);
-    PropertyFilter filter = createMock(PropertyFilter.class);
+    @SuppressWarnings("unchecked")
+    Predicate<String> filter = createMock(Predicate.class);
     parent.getProperties(props, filter);
     replay(parent);
     String child1 = "child1";
@@ -154,7 +158,7 @@ public class ZooCachePropertyAccessorTest {
     children.add(child1);
     expect(zc.getChildren(PATH)).andReturn(children);
     replay(zc);
-    expect(filter.accept(child1)).andReturn(false);
+    expect(filter.apply(child1)).andReturn(false);
     replay(filter);
 
     a.getProperties(props, PATH, filter, parent, null);
@@ -165,8 +169,10 @@ public class ZooCachePropertyAccessorTest {
   public void testGetProperties_ParentFilter() {
     Map<String,String> props = new java.util.HashMap<String,String>();
     AccumuloConfiguration parent = createMock(AccumuloConfiguration.class);
-    PropertyFilter filter = createMock(PropertyFilter.class);
-    PropertyFilter parentFilter = createMock(PropertyFilter.class);
+    @SuppressWarnings("unchecked")
+    Predicate<String> filter = createMock(Predicate.class);
+    @SuppressWarnings("unchecked")
+    Predicate<String> parentFilter = createMock(Predicate.class);
     parent.getProperties(props, parentFilter);
     replay(parent);
     expect(zc.getChildren(PATH)).andReturn(null);

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2e9643dc/server/base/src/test/java/org/apache/accumulo/server/util/FileUtilTest.java
----------------------------------------------------------------------
diff --git a/server/base/src/test/java/org/apache/accumulo/server/util/FileUtilTest.java b/server/base/src/test/java/org/apache/accumulo/server/util/FileUtilTest.java
index 5fe35f9..7bded1a 100644
--- a/server/base/src/test/java/org/apache/accumulo/server/util/FileUtilTest.java
+++ b/server/base/src/test/java/org/apache/accumulo/server/util/FileUtilTest.java
@@ -44,6 +44,8 @@ import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
 import org.junit.rules.TestName;
 
+import com.google.common.base.Predicate;
+
 /**
  *
  */
@@ -238,7 +240,7 @@ public class FileUtilTest {
     }
 
     @Override
-    public void getProperties(Map<String,String> props, PropertyFilter filter) {
+    public void getProperties(Map<String,String> props, Predicate<String> filter)
{
       throw new UnsupportedOperationException();
     }
   }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/2e9643dc/test/src/test/java/org/apache/accumulo/test/util/CertUtils.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/accumulo/test/util/CertUtils.java b/test/src/test/java/org/apache/accumulo/test/util/CertUtils.java
index 3bbd737..2345ea7 100644
--- a/test/src/test/java/org/apache/accumulo/test/util/CertUtils.java
+++ b/test/src/test/java/org/apache/accumulo/test/util/CertUtils.java
@@ -70,6 +70,7 @@ import org.slf4j.LoggerFactory;
 
 import com.beust.jcommander.JCommander;
 import com.beust.jcommander.Parameter;
+import com.google.common.base.Predicate;
 
 public class CertUtils {
   private static final Logger log = LoggerFactory.getLogger(CertUtils.class);
@@ -151,9 +152,9 @@ public class CertUtils {
           }
 
           @Override
-          public void getProperties(Map<String,String> props, PropertyFilter filter)
{
+          public void getProperties(Map<String,String> props, Predicate<String>
filter) {
             for (Entry<String,String> entry : this)
-              if (filter.accept(entry.getKey()))
+              if (filter.apply(entry.getKey()))
                 props.put(entry.getKey(), entry.getValue());
           }
         };


Mime
View raw message