Repository: cassandra Updated Branches: refs/heads/trunk 1e7c4b9c0 -> a5dff2f79
Refactoring to specialised primitive functional interfaces in AuthCache.java Closes #131 Patch by Ameya Ketkar; Reviewed by Jeff Jirsa for CASSANDRA-13732 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/a5dff2f7 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/a5dff2f7 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/a5dff2f7 Branch: refs/heads/trunk Commit: a5dff2f79621d7527a3837c0028d2e8b61d16e42 Parents: 1e7c4b9 Author: ameya <[email protected]> Authored: Tue Jul 18 20:37:10 2017 -0700 Committer: Jeff Jirsa <[email protected]> Committed: Thu Jul 27 17:00:13 2017 -0700 ---------------------------------------------------------------------- CHANGES.txt | 1 + .../org/apache/cassandra/auth/AuthCache.java | 41 ++++++++++---------- 2 files changed, 22 insertions(+), 20 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/a5dff2f7/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index b08dd83..2ea2526 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 4.0 + * Refactoring to primitive functional interfaces in AuthCache (CASSANDRA-13732) * Update metrics to 3.1.5 (CASSANDRA-13648) * batch_size_warn_threshold_in_kb can now be set at runtime (CASSANDRA-13699) * Avoid always rebuilding secondary indexes at startup (CASSANDRA-13725) http://git-wip-us.apache.org/repos/asf/cassandra/blob/a5dff2f7/src/java/org/apache/cassandra/auth/AuthCache.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/auth/AuthCache.java b/src/java/org/apache/cassandra/auth/AuthCache.java index 9e00a6e..3954230 100644 --- a/src/java/org/apache/cassandra/auth/AuthCache.java +++ b/src/java/org/apache/cassandra/auth/AuthCache.java @@ -20,9 +20,10 @@ package org.apache.cassandra.auth; import java.lang.management.ManagementFactory; import java.util.concurrent.TimeUnit; -import java.util.function.Consumer; +import java.util.function.BooleanSupplier; import java.util.function.Function; -import java.util.function.Supplier; +import java.util.function.IntConsumer; +import java.util.function.IntSupplier; import javax.management.MBeanServer; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; @@ -43,24 +44,24 @@ public class AuthCache<K, V> implements AuthCacheMBean private volatile LoadingCache<K, V> cache; private final String name; - private final Consumer<Integer> setValidityDelegate; - private final Supplier<Integer> getValidityDelegate; - private final Consumer<Integer> setUpdateIntervalDelegate; - private final Supplier<Integer> getUpdateIntervalDelegate; - private final Consumer<Integer> setMaxEntriesDelegate; - private final Supplier<Integer> getMaxEntriesDelegate; + private final IntConsumer setValidityDelegate; + private final IntSupplier getValidityDelegate; + private final IntConsumer setUpdateIntervalDelegate; + private final IntSupplier getUpdateIntervalDelegate; + private final IntConsumer setMaxEntriesDelegate; + private final IntSupplier getMaxEntriesDelegate; private final Function<K, V> loadFunction; - private final Supplier<Boolean> enableCache; + private final BooleanSupplier enableCache; protected AuthCache(String name, - Consumer<Integer> setValidityDelegate, - Supplier<Integer> getValidityDelegate, - Consumer<Integer> setUpdateIntervalDelegate, - Supplier<Integer> getUpdateIntervalDelegate, - Consumer<Integer> setMaxEntriesDelegate, - Supplier<Integer> getMaxEntriesDelegate, + IntConsumer setValidityDelegate, + IntSupplier getValidityDelegate, + IntConsumer setUpdateIntervalDelegate, + IntSupplier getUpdateIntervalDelegate, + IntConsumer setMaxEntriesDelegate, + IntSupplier getMaxEntriesDelegate, Function<K, V> loadFunction, - Supplier<Boolean> enableCache) + BooleanSupplier enableCache) { this.name = name; this.setValidityDelegate = setValidityDelegate; @@ -123,7 +124,7 @@ public class AuthCache<K, V> implements AuthCacheMBean public int getValidity() { - return getValidityDelegate.get(); + return getValidityDelegate.getAsInt(); } public void setUpdateInterval(int updateInterval) @@ -137,7 +138,7 @@ public class AuthCache<K, V> implements AuthCacheMBean public int getUpdateInterval() { - return getUpdateIntervalDelegate.get(); + return getUpdateIntervalDelegate.getAsInt(); } public void setMaxEntries(int maxEntries) @@ -151,12 +152,12 @@ public class AuthCache<K, V> implements AuthCacheMBean public int getMaxEntries() { - return getMaxEntriesDelegate.get(); + return getMaxEntriesDelegate.getAsInt(); } private LoadingCache<K, V> initCache(LoadingCache<K, V> existing) { - if (!enableCache.get()) + if (!enableCache.getAsBoolean()) return null; if (getValidity() <= 0) --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
