You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ratis.apache.org by sz...@apache.org on 2017/06/23 03:32:55 UTC

incubator-ratis git commit: RATIS-92. Move the basic getClassByName methods from RaftProperties to ReflectionUtils.

Repository: incubator-ratis
Updated Branches:
  refs/heads/master 466fc2c3a -> a5b84af2d


RATIS-92. Move the basic getClassByName methods from RaftProperties to ReflectionUtils.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ratis/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ratis/commit/a5b84af2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ratis/tree/a5b84af2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ratis/diff/a5b84af2

Branch: refs/heads/master
Commit: a5b84af2de1e3311e96ebdf81f2a1155976cace4
Parents: 466fc2c
Author: Tsz-Wo Nicholas Sze <sz...@hortonworks.com>
Authored: Fri Jun 23 11:32:22 2017 +0800
Committer: Tsz-Wo Nicholas Sze <sz...@hortonworks.com>
Committed: Fri Jun 23 11:32:22 2017 +0800

----------------------------------------------------------------------
 .../ratis/client/impl/RaftClientImpl.java       |   3 +-
 .../java/org/apache/ratis/RaftConfigKeys.java   |  11 +-
 .../org/apache/ratis/conf/RaftProperties.java   | 117 +------------
 .../main/java/org/apache/ratis/rpc/RpcType.java |  34 +++-
 .../org/apache/ratis/rpc/SupportedRpcType.java  |   4 +-
 .../org/apache/ratis/util/CollectionUtils.java  |  11 +-
 .../org/apache/ratis/util/ReflectionUtils.java  | 165 ++++++++++++++-----
 .../ratis/server/impl/RaftServerProxy.java      |   2 +-
 .../java/org/apache/ratis/MiniRaftCluster.java  |   2 +-
 .../ratis/server/simulation/SimulatedRpc.java   |   3 +-
 10 files changed, 178 insertions(+), 174 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/a5b84af2/ratis-client/src/main/java/org/apache/ratis/client/impl/RaftClientImpl.java
----------------------------------------------------------------------
diff --git a/ratis-client/src/main/java/org/apache/ratis/client/impl/RaftClientImpl.java b/ratis-client/src/main/java/org/apache/ratis/client/impl/RaftClientImpl.java
index c6571ae..fbecb90 100644
--- a/ratis-client/src/main/java/org/apache/ratis/client/impl/RaftClientImpl.java
+++ b/ratis-client/src/main/java/org/apache/ratis/client/impl/RaftClientImpl.java
@@ -56,7 +56,8 @@ final class RaftClientImpl implements RaftClient {
     this.clientRpc = clientRpc;
     this.peers = new ArrayList<>(group.getPeers());
     this.groupId = group.getGroupId();
-    this.leaderId = leaderId != null? leaderId : peers.iterator().next().getId();
+    this.leaderId = leaderId != null? leaderId
+        : !peers.isEmpty()? peers.iterator().next().getId(): null;
     this.retryInterval = retryInterval;
 
     clientRpc.addServers(peers);

http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/a5b84af2/ratis-common/src/main/java/org/apache/ratis/RaftConfigKeys.java
----------------------------------------------------------------------
diff --git a/ratis-common/src/main/java/org/apache/ratis/RaftConfigKeys.java b/ratis-common/src/main/java/org/apache/ratis/RaftConfigKeys.java
index 665a7f5..3de95ab 100644
--- a/ratis-common/src/main/java/org/apache/ratis/RaftConfigKeys.java
+++ b/ratis-common/src/main/java/org/apache/ratis/RaftConfigKeys.java
@@ -24,7 +24,6 @@ import static org.apache.ratis.conf.ConfUtils.set;
 import org.apache.ratis.conf.RaftProperties;
 import org.apache.ratis.rpc.RpcType;
 import org.apache.ratis.rpc.SupportedRpcType;
-import org.apache.ratis.util.ReflectionUtils;
 
 public interface RaftConfigKeys {
   String PREFIX = "raft";
@@ -37,15 +36,7 @@ public interface RaftConfigKeys {
 
     static RpcType type(RaftProperties properties) {
       final String t = get(properties::get, TYPE_KEY, TYPE_DEFAULT);
-
-      try { // Try parsing it as a SupportedRpcType
-        return SupportedRpcType.valueOfIgnoreCase(t);
-      } catch(IllegalArgumentException iae) {
-      }
-
-      // Try using it as a class name
-      return ReflectionUtils.newInstance(
-          ReflectionUtils.getClass(t, properties, RpcType.class));
+      return RpcType.valueOf(t);
     }
 
     static void setType(RaftProperties properties, RpcType type) {

http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/a5b84af2/ratis-common/src/main/java/org/apache/ratis/conf/RaftProperties.java
----------------------------------------------------------------------
diff --git a/ratis-common/src/main/java/org/apache/ratis/conf/RaftProperties.java b/ratis-common/src/main/java/org/apache/ratis/conf/RaftProperties.java
index f8d0bdb..a8dbd39 100644
--- a/ratis-common/src/main/java/org/apache/ratis/conf/RaftProperties.java
+++ b/ratis-common/src/main/java/org/apache/ratis/conf/RaftProperties.java
@@ -18,6 +18,7 @@
 
 package org.apache.ratis.conf;
 
+import org.apache.ratis.util.ReflectionUtils;
 import org.apache.ratis.util.SizeInBytes;
 import org.apache.ratis.util.StringUtils;
 import org.apache.ratis.util.TimeDuration;
@@ -35,7 +36,6 @@ import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
 import java.io.*;
-import java.lang.ref.WeakReference;
 import java.net.JarURLConnection;
 import java.net.URL;
 import java.net.URLConnection;
@@ -122,13 +122,6 @@ public class RaftProperties {
 
   private Properties properties;
   private Properties overlay;
-  private ClassLoader classLoader;
-  {
-    classLoader = Thread.currentThread().getContextClassLoader();
-    if (classLoader == null) {
-      classLoader = RaftProperties.class.getClassLoader();
-    }
-  }
 
   /** A new configuration. */
   public RaftProperties() {
@@ -176,7 +169,6 @@ public class RaftProperties {
     synchronized(RaftProperties.class) {
       REGISTRY.put(this, null);
     }
-    this.classLoader = other.classLoader;
     this.loadDefaults = other.loadDefaults;
   }
 
@@ -1034,74 +1026,7 @@ public class RaftProperties {
     return StringUtils.getTrimmedStrings(valueString);
   }
 
-  /**
-   * Load a class by name.
-   *
-   * @param name the class name.
-   * @return the class object.
-   * @throws ClassNotFoundException if the class is not found.
-   */
-  public Class<?> getClassByName(String name) throws ClassNotFoundException {
-    Class<?> ret = getClassByNameOrNull(name);
-    if (ret == null) {
-      throw new ClassNotFoundException("Class " + name + " not found");
-    }
-    return ret;
-  }
-
-  private static final Map<ClassLoader, Map<String, WeakReference<Class<?>>>>
-      CACHE_CLASSES = new WeakHashMap<>();
-
-  /**
-   * Sentinel value to store negative cache results in {@link #CACHE_CLASSES}.
-   */
-  private static final Class<?> NEGATIVE_CACHE_SENTINEL =
-      NegativeCacheSentinel.class;
-
-  /**
-   * Load a class by name, returning null rather than throwing an exception
-   * if it couldn't be loaded. This is to avoid the overhead of creating
-   * an exception.
-   *
-   * @param name the class name
-   * @return the class object, or null if it could not be found.
-   */
-  public Class<?> getClassByNameOrNull(String name) {
-    Map<String, WeakReference<Class<?>>> map;
-
-    synchronized (CACHE_CLASSES) {
-      map = CACHE_CLASSES.get(classLoader);
-      if (map == null) {
-        map = Collections.synchronizedMap(
-          new WeakHashMap<String, WeakReference<Class<?>>>());
-        CACHE_CLASSES.put(classLoader, map);
-      }
-    }
-
-    Class<?> clazz = null;
-    WeakReference<Class<?>> ref = map.get(name);
-    if (ref != null) {
-       clazz = ref.get();
-    }
 
-    if (clazz == null) {
-      try {
-        clazz = Class.forName(name, true, classLoader);
-      } catch (ClassNotFoundException e) {
-        // Leave a marker that the class isn't found
-        map.put(name, new WeakReference<>(NEGATIVE_CACHE_SENTINEL));
-        return null;
-      }
-      // two putters can race here, but they'll put the same class
-      map.put(name, new WeakReference<>(clazz));
-      return clazz;
-    } else if (clazz == NEGATIVE_CACHE_SENTINEL) {
-      return null; // not found
-    } else {
-      // cache hit
-      return clazz;
-    }
-  }
 
   /**
    * Get the value of the <code>name</code> property
@@ -1124,7 +1049,7 @@ public class RaftProperties {
     try {
       Class<?>[] classes = new Class<?>[classnames.length];
       for(int i = 0; i < classnames.length; i++) {
-        classes[i] = getClassByName(classnames[i]);
+        classes[i] = ReflectionUtils.getClassByName(classnames[i]);
       }
       return classes;
     } catch (ClassNotFoundException e) {
@@ -1147,7 +1072,7 @@ public class RaftProperties {
     if (valueString == null)
       return defaultValue;
     try {
-      return getClassByName(valueString);
+      return ReflectionUtils.getClassByName(valueString);
     } catch (ClassNotFoundException e) {
       throw new RuntimeException(e);
     }
@@ -1201,16 +1126,6 @@ public class RaftProperties {
     set(name, theClass.getName());
   }
 
-  /**
-   * Get the {@link URL} for the named resource.
-   *
-   * @param name resource name.
-   * @return the url for the named resource.
-   */
-  public URL getResource(String name) {
-    return classLoader.getResource(name);
-  }
-
   protected synchronized Properties getProps() {
     if (properties == null) {
       properties = new Properties();
@@ -1324,7 +1239,7 @@ public class RaftProperties {
       if (resource instanceof URL) { // an URL resource
         doc = parse(builder, (URL) resource);
       } else if (resource instanceof String) { // a CLASSPATH resource
-        URL url = getResource((String) resource);
+        URL url = ReflectionUtils.getClassLoader().getResource((String)resource);
         doc = parse(builder, url);
       } else if (resource instanceof InputStream) {
         doc = parse(builder, (InputStream) resource, null);
@@ -1526,24 +1441,6 @@ public class RaftProperties {
     return doc;
   }
 
-  /**
-   * Get the {@link ClassLoader} for this job.
-   *
-   * @return the correct class loader.
-   */
-  public ClassLoader getClassLoader() {
-    return classLoader;
-  }
-
-  /**
-   * Set the class loader that will be used to load the various objects.
-   *
-   * @param classLoader the new class loader.
-   */
-  public void setClassLoader(ClassLoader classLoader) {
-    this.classLoader = classLoader;
-  }
-
   @Override
   public String toString() {
     StringBuilder sb = new StringBuilder();
@@ -1590,10 +1487,4 @@ public class RaftProperties {
     }
     return result;
   }
-
-  /**
-   * A unique class which is used as a sentinel value in the caching
-   * for getClassByName. {@link RaftProperties#getClassByNameOrNull(String)}
-   */
-  private static abstract class NegativeCacheSentinel {}
 }

http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/a5b84af2/ratis-common/src/main/java/org/apache/ratis/rpc/RpcType.java
----------------------------------------------------------------------
diff --git a/ratis-common/src/main/java/org/apache/ratis/rpc/RpcType.java b/ratis-common/src/main/java/org/apache/ratis/rpc/RpcType.java
index 701e979..79b08b6 100644
--- a/ratis-common/src/main/java/org/apache/ratis/rpc/RpcType.java
+++ b/ratis-common/src/main/java/org/apache/ratis/rpc/RpcType.java
@@ -18,15 +18,45 @@
 package org.apache.ratis.rpc;
 
 import org.apache.ratis.conf.Parameters;
-import org.apache.ratis.conf.RaftProperties;
+import org.apache.ratis.util.ReflectionUtils;
 
 /** The type of RPC implementations. */
 public interface RpcType {
+  /**
+   * Parse the given string as a {@link SupportedRpcType}
+   * or a user-defined {@link RpcType}.
+   *
+   * @param rpcType The string representation of an {@link RpcType}.
+   * @return a {@link SupportedRpcType} or a user-defined {@link RpcType}.
+   */
+  static RpcType valueOf(String rpcType) {
+    final Throwable fromSupportedRpcType;
+    try { // Try parsing it as a SupportedRpcType
+      return SupportedRpcType.valueOfIgnoreCase(rpcType);
+    } catch (Throwable t) {
+      fromSupportedRpcType = t;
+    }
+
+    try {
+      // Try using it as a class name
+      return ReflectionUtils.newInstance(
+          ReflectionUtils.getClass(rpcType, RpcType.class));
+    } catch(Throwable t) {
+      final IllegalArgumentException iae = new IllegalArgumentException(
+          "Invalid " + RpcType.class.getSimpleName() + ": \"" + rpcType + "\" "
+              + " cannot be used as a user-defined " + RpcType.class.getSimpleName()
+              + " and it is not a " + SupportedRpcType.class.getSimpleName() + ".");
+      iae.addSuppressed(t);
+      iae.addSuppressed(fromSupportedRpcType);
+      throw iae;
+    }
+  }
+
   /** @return the name of the rpc type. */
   String name();
 
   /** @return a new factory created using the given properties and parameters. */
-  RpcFactory newFactory(RaftProperties properties, Parameters parameters);
+  RpcFactory newFactory(Parameters parameters);
 
   /** An interface to get {@link RpcType}. */
   interface Get {

http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/a5b84af2/ratis-common/src/main/java/org/apache/ratis/rpc/SupportedRpcType.java
----------------------------------------------------------------------
diff --git a/ratis-common/src/main/java/org/apache/ratis/rpc/SupportedRpcType.java b/ratis-common/src/main/java/org/apache/ratis/rpc/SupportedRpcType.java
index 92f70f6..bd4a795 100644
--- a/ratis-common/src/main/java/org/apache/ratis/rpc/SupportedRpcType.java
+++ b/ratis-common/src/main/java/org/apache/ratis/rpc/SupportedRpcType.java
@@ -41,9 +41,9 @@ public enum SupportedRpcType implements RpcType {
   }
 
   @Override
-  public RpcFactory newFactory(RaftProperties properties, Parameters parameters) {
+  public RpcFactory newFactory(Parameters parameters) {
     final Class<? extends RpcFactory> clazz = ReflectionUtils.getClass(
-        factoryClassName, properties, RpcFactory.class);
+        factoryClassName, RpcFactory.class);
     return ReflectionUtils.newInstance(clazz, ARG_CLASSES, parameters);
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/a5b84af2/ratis-common/src/main/java/org/apache/ratis/util/CollectionUtils.java
----------------------------------------------------------------------
diff --git a/ratis-common/src/main/java/org/apache/ratis/util/CollectionUtils.java b/ratis-common/src/main/java/org/apache/ratis/util/CollectionUtils.java
index 5f68d47..d50d6ce 100644
--- a/ratis-common/src/main/java/org/apache/ratis/util/CollectionUtils.java
+++ b/ratis-common/src/main/java/org/apache/ratis/util/CollectionUtils.java
@@ -20,11 +20,7 @@
 
 package org.apache.ratis.util;
 
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Objects;
-import java.util.Random;
+import java.util.*;
 import java.util.function.Function;
 
 public interface CollectionUtils {
@@ -84,4 +80,9 @@ public interface CollectionUtils {
       }
     };
   }
+
+  static <INPUT, OUTPUT> Iterable<OUTPUT> as(
+      INPUT[] array, Function<INPUT, OUTPUT> converter) {
+    return as(Arrays.asList(array), converter);
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/a5b84af2/ratis-common/src/main/java/org/apache/ratis/util/ReflectionUtils.java
----------------------------------------------------------------------
diff --git a/ratis-common/src/main/java/org/apache/ratis/util/ReflectionUtils.java b/ratis-common/src/main/java/org/apache/ratis/util/ReflectionUtils.java
index d0762c3..700965f 100644
--- a/ratis-common/src/main/java/org/apache/ratis/util/ReflectionUtils.java
+++ b/ratis-common/src/main/java/org/apache/ratis/util/ReflectionUtils.java
@@ -21,40 +21,141 @@
 package org.apache.ratis.util;
 
 
+import java.lang.ref.WeakReference;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
+import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
 
-import org.apache.ratis.conf.RaftProperties;
-
 /**
  * Reflection related utility methods.
  */
-public class ReflectionUtils {
+public interface ReflectionUtils {
+  final class Constructors {
+    private Constructors() {}
+
+    /**
+     * Cache of constructors for each class. Pins the classes so they
+     * can't be garbage collected until ReflectionUtils can be collected.
+     */
+    private static final Map<List<Class<?>>, Constructor<?>> CONSTRUCTORS
+        = new ConcurrentHashMap<>();
+
+    private static <T> Constructor<T> get(Class<T> clazz, Class<?>[] argClasses)
+        throws NoSuchMethodException {
+      Objects.requireNonNull(clazz, "clazz == null");
+
+      final List<Class<?>> key = new ArrayList<>(argClasses.length + 1);
+      key.add(clazz);
+      key.addAll(Arrays.asList(argClasses));
 
-  private ReflectionUtils() {
-    // Utility class, cannot instantiate
+      @SuppressWarnings("unchecked")
+      Constructor<T> ctor = (Constructor<T>) CONSTRUCTORS.get(key);
+      if (ctor == null) {
+        ctor = clazz.getDeclaredConstructor(argClasses);
+        ctor.setAccessible(true);
+        CONSTRUCTORS.put(key, ctor);
+      }
+      return ctor;
+    }
   }
 
-  private static final Class<?>[] EMPTY_CLASSES = {};
+  final class Classes {
+    private static Class<?>[] EMPTY_ARRAY = {};
+
+    private static final Map<ClassLoader, Map<String, WeakReference<Class<?>>>>
+        CLASSES = new WeakHashMap<>();
+
+    /** Sentinel value to store negative cache results in {@link #CLASSES}. */
+    private static final Class<?> NEGATIVE_CACHE_SENTINEL = NegativeCacheSentinel.class;
+
+    /**
+     * A unique class which is used as a sentinel value in the caching
+     * for getClassByName. {@link #getClassByNameOrNull(String)}
+     */
+    private static final class NegativeCacheSentinel {}
+
+    private static ClassLoader CLASS_LOADER;
+    static {
+      CLASS_LOADER = Thread.currentThread().getContextClassLoader();
+      if (CLASS_LOADER == null) {
+        CLASS_LOADER = ReflectionUtils.class.getClassLoader();
+      }
+    }
+
+    private static Map<String, WeakReference<Class<?>>> getClassMap() {
+      Map<String, WeakReference<Class<?>>> map;
+      synchronized (CLASSES) {
+        map = CLASSES.get(CLASS_LOADER);
+        if (map == null) {
+          map = Collections.synchronizedMap(new WeakHashMap<>());
+          CLASSES.put(CLASS_LOADER, map);
+        }
+      }
+      return map;
+    }
+  }
+
+  static ClassLoader getClassLoader() {
+    return Classes.CLASS_LOADER;
+  }
+
+  /**
+   * Load a class by name, returning null rather than throwing an exception
+   * if it couldn't be loaded. This is to avoid the overhead of creating
+   * an exception.
+   *
+   * @param name the class name
+   * @return the class object, or null if it could not be found.
+   */
+  static Class<?> getClassByNameOrNull(String name) {
+    final Map<String, WeakReference<Class<?>>> map = Classes.getClassMap();
+
+    Class<?> clazz = null;
+    WeakReference<Class<?>> ref = map.get(name);
+    if (ref != null) {
+      clazz = ref.get();
+    }
+
+    if (clazz == null) {
+      try {
+        clazz = Class.forName(name, true, Classes.CLASS_LOADER);
+      } catch (ClassNotFoundException e) {
+        // Leave a marker that the class isn't found
+        map.put(name, new WeakReference<>(Classes.NEGATIVE_CACHE_SENTINEL));
+        return null;
+      }
+      // two putters can race here, but they'll put the same class
+      map.put(name, new WeakReference<>(clazz));
+      return clazz;
+    } else if (clazz == Classes.NEGATIVE_CACHE_SENTINEL) {
+      return null; // not found
+    } else {
+      // cache hit
+      return clazz;
+    }
+  }
 
   /**
-   * Cache of constructors for each class. Pins the classes so they
-   * can't be garbage collected until ReflectionUtils can be collected.
+   * Load a class by name.
+   *
+   * @param name the class name.
+   * @return the class object.
+   * @throws ClassNotFoundException if the class is not found.
    */
-  private static final Map<List<Class<?>>, Constructor<?>> CONSTRUCTOR_CACHE
-      = new ConcurrentHashMap<>();
+  static Class<?> getClassByName(String name) throws ClassNotFoundException {
+    Class<?> ret = getClassByNameOrNull(name);
+    if (ret == null) {
+      throw new ClassNotFoundException("Class " + name + " not found");
+    }
+    return ret;
+  }
 
   /**
    * Create an object for the given class using its default constructor.
    */
-  public static <T> T newInstance(Class<T> clazz) {
-    return newInstance(clazz, EMPTY_CLASSES);
+  static <T> T newInstance(Class<T> clazz) {
+    return newInstance(clazz, Classes.EMPTY_ARRAY);
   }
 
   /**
@@ -66,28 +167,18 @@ public class ReflectionUtils {
    * @param <T> class type of clazz
    * @return a new object
    */
-  public static <T> T newInstance(Class<T> clazz, Class<?>[] argClasses, Object... args) {
-    Objects.requireNonNull(clazz, "clazz == null");
+  static <T> T newInstance(Class<T> clazz, Class<?>[] argClasses, Object... args) {
+    final Constructor<T> ctor;
     try {
-      final List<Class<?>> key = new ArrayList<>();
-      key.add(clazz);
-      key.addAll(Arrays.asList(argClasses));
-
-      @SuppressWarnings("unchecked")
-      Constructor<T> ctor = (Constructor<T>) CONSTRUCTOR_CACHE.get(key);
-      if (ctor == null) {
-        ctor = clazz.getDeclaredConstructor(argClasses);
-        ctor.setAccessible(true);
-        CONSTRUCTOR_CACHE.put(key, ctor);
-      }
-      return instantiate(clazz.getName(), ctor, args);
+      ctor = Constructors.get(clazz, argClasses);
     } catch (NoSuchMethodException e) {
       throw new UnsupportedOperationException(
           "Unable to find suitable constructor for class " + clazz.getName(), e);
     }
+    return instantiate(clazz.getName(), ctor, args);
   }
 
-  private static <T> T instantiate(final String className, Constructor<T> ctor, Object[] ctorArgs) {
+  static <T> T instantiate(final String className, Constructor<T> ctor, Object[] ctorArgs) {
     try {
       ctor.setAccessible(true);
       return ctor.newInstance(ctorArgs);
@@ -104,7 +195,7 @@ public class ReflectionUtils {
   }
 
   /** Is the given object an instance of one of the given classes? */
-  public static boolean isInstance(Object obj, Class<?>... classes) {
+  static boolean isInstance(Object obj, Class<?>... classes) {
     for(Class<?> c : classes) {
       if (c.isInstance(obj)) {
         return true;
@@ -113,17 +204,17 @@ public class ReflectionUtils {
     return false;
   }
 
-  public static <BASE> Class<? extends BASE> getClass(
-      String subClassName, RaftProperties properties, Class<BASE> base) {
+  static <BASE> Class<? extends BASE> getClass(
+      String subClassName, Class<BASE> base) {
     try {
-      return properties.getClassByName(subClassName).asSubclass(base);
+      return getClassByName(subClassName).asSubclass(base);
     } catch (ClassNotFoundException e) {
       throw new IllegalArgumentException("Failed to get class "
           + subClassName + " as a subclass of " + base, e);
     }
   }
 
-  public static Exception instantiateException(Class<? extends Exception> cls,
+  static Exception instantiateException(Class<? extends Exception> cls,
       String message, Exception from) throws Exception {
     Constructor<? extends Exception> cn = cls.getConstructor(String.class);
     cn.setAccessible(true);

http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/a5b84af2/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerProxy.java
----------------------------------------------------------------------
diff --git a/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerProxy.java b/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerProxy.java
index 366a74c..4b3b9f5 100644
--- a/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerProxy.java
+++ b/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerProxy.java
@@ -57,7 +57,7 @@ public class RaftServerProxy implements RaftServer {
     this.stateMachine = stateMachine;
 
     final RpcType rpcType = RaftConfigKeys.Rpc.type(properties);
-    this.factory = ServerFactory.cast(rpcType.newFactory(properties, parameters));
+    this.factory = ServerFactory.cast(rpcType.newFactory(parameters));
 
     this.impl = CompletableFuture.completedFuture(initImpl(group));
     this.serverRpc = initRaftServerRpc(factory, this, group);

http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/a5b84af2/ratis-server/src/test/java/org/apache/ratis/MiniRaftCluster.java
----------------------------------------------------------------------
diff --git a/ratis-server/src/test/java/org/apache/ratis/MiniRaftCluster.java b/ratis-server/src/test/java/org/apache/ratis/MiniRaftCluster.java
index 0ef7439..577ae16 100644
--- a/ratis-server/src/test/java/org/apache/ratis/MiniRaftCluster.java
+++ b/ratis-server/src/test/java/org/apache/ratis/MiniRaftCluster.java
@@ -140,7 +140,7 @@ public abstract class MiniRaftCluster {
 
     final RpcType rpcType = RaftConfigKeys.Rpc.type(properties);
     this.clientFactory = ClientFactory.cast(
-        rpcType.newFactory(properties, parameters));
+        rpcType.newFactory(parameters));
     this.testBaseDir = getBaseDirectory();
 
     ExitUtils.disableSystemExit();

http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/a5b84af2/ratis-server/src/test/java/org/apache/ratis/server/simulation/SimulatedRpc.java
----------------------------------------------------------------------
diff --git a/ratis-server/src/test/java/org/apache/ratis/server/simulation/SimulatedRpc.java b/ratis-server/src/test/java/org/apache/ratis/server/simulation/SimulatedRpc.java
index f8a32d9..abdc8cf 100644
--- a/ratis-server/src/test/java/org/apache/ratis/server/simulation/SimulatedRpc.java
+++ b/ratis-server/src/test/java/org/apache/ratis/server/simulation/SimulatedRpc.java
@@ -19,7 +19,6 @@ package org.apache.ratis.server.simulation;
 
 import org.apache.ratis.client.ClientFactory;
 import org.apache.ratis.conf.Parameters;
-import org.apache.ratis.conf.RaftProperties;
 import org.apache.ratis.rpc.RpcType;
 import org.apache.ratis.server.RaftServer;
 import org.apache.ratis.server.impl.ServerFactory;
@@ -35,7 +34,7 @@ class SimulatedRpc implements RpcType {
   }
 
   @Override
-  public Factory newFactory(RaftProperties properties, Parameters parameters) {
+  public Factory newFactory(Parameters parameters) {
     return new Factory(parameters);
   }