+
+ @Override
+ public RaftPolicy getRaftPolicy() {
+ return policySupplier.get();
+ }
+
+ @Override
+ public String getTempFileDirectory() {
+ return tempFileDirectory;
+ }
+
+ @Override
+ public int getFileBackedStreamingThreshold() {
+ return fileBackedStreamingThreshold;
+ }
+
+
+ @Override
+ public PeerAddressResolver getPeerAddressResolver() {
+ return peerAddressResolver;
+ }
+
+ public void setPeerAddressResolver(final @NonNull PeerAddressResolver peerAddressResolver) {
+ this.peerAddressResolver = requireNonNull(peerAddressResolver);
+ }
+
+ @Override
+ public long getSyncIndexThreshold() {
+ return syncIndexThreshold;
+ }
+
+ public void setSyncIndexThreshold(final long syncIndexThreshold) {
+ checkArgument(syncIndexThreshold >= 0);
+ this.syncIndexThreshold = syncIndexThreshold;
+ }
+
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ private RaftPolicy getPolicy() {
+ 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).getDeclaredConstructor().newInstance();
+ } catch (ClassCastException | ReflectiveOperationException 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;
+ }