mirror of https://github.com/apache/cassandra
Refactoring to specialised primitive functional interfaces in AuthCache.java
Closes #131 Patch by Ameya Ketkar; Reviewed by Jeff Jirsa for CASSANDRA-13732
This commit is contained in:
parent
1e7c4b9c05
commit
a5dff2f796
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue