+
+ @Override
+ public RaftPolicy getRaftPolicy() {
+ return policySupplier.get();
+ }
+
+ @Override
+ public String getTempFileDirectory() {
+ return tempFileDirectory;
+ }
+
+ @Override
+ public int getFileBackedStreamingThreshold() {
+ return fileBackedStreamingThreshold;
+ }
+
+ private class PolicySupplier implements Supplier<RaftPolicy> {
+ @Override
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ public RaftPolicy get() {
+ if (Strings.isNullOrEmpty(DefaultConfigParamsImpl.this.customRaftPolicyImplementationClass)) {
+ LOG.debug("No custom RaftPolicy specified. Using DefaultRaftPolicy");
+ return DefaultRaftPolicy.INSTANCE;
+ }
+
+ try {
+ String className = DefaultConfigParamsImpl.this.customRaftPolicyImplementationClass;
+ LOG.info("Trying to use custom RaftPolicy {}", className);
+ return (RaftPolicy)Class.forName(className).newInstance();
+ } catch (Exception e) {
+ if (LOG.isDebugEnabled()) {
+ LOG.error("Could not create custom raft policy, will stick with default", e);
+ } else {
+ LOG.error("Could not create custom raft policy, will stick with default : cause = {}",
+ e.getMessage());
+ }
+ }
+ return DefaultRaftPolicy.INSTANCE;
+ }
+ }
+
+ @Override
+ public PeerAddressResolver getPeerAddressResolver() {
+ return peerAddressResolver;
+ }
+
+ public void setPeerAddressResolver(@Nonnull PeerAddressResolver peerAddressResolver) {
+ this.peerAddressResolver = Preconditions.checkNotNull(peerAddressResolver);
+ }