Code formatted according to checkstyle rules

pull/1923/head
Nikita Koksharov 6 years ago
parent 901a5a797b
commit 016d3395f1

@ -72,7 +72,7 @@
<!-- Checks for Naming Conventions. -->
<!-- See http://checkstyle.sf.net/config_naming.html -->
<module name="ConstantName">
<property name="format" value="^([A-Z_][A-Z0-9]*(_[A-Z0-9]+)*|_log)$"/>
<property name="format" value="^log(ger)?|[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"/>
</module>
<module name="LocalFinalVariableName"/>
<module name="LocalVariableName"/>
@ -169,7 +169,9 @@
<module name="SimplifyBooleanExpression"/>
<module name="SimplifyBooleanReturn"/>
<module name="StringLiteralEquality"/>
<module name="NestedIfDepth"/>
<module name="NestedIfDepth">
<property name="max" value="2"/>
</module>
<module name="NestedTryDepth"/>
<module name="SuperClone"/>
<module name="IllegalCatch">
@ -186,8 +188,9 @@
<module name="FinalClass"/>
<!--module name="HideUtilityClassConstructor"/-->
<module name="InterfaceIsType"/>
<module name="VisibilityModifier"/>
<module name="VisibilityModifier">
<property name="packageAllowed" value="true"/>
</module>
<!-- Miscellaneous other checks. -->
<!-- See http://checkstyle.sf.net/config_misc.html -->

@ -360,7 +360,7 @@
</execution>
</executions>
<configuration>
<includes>**/org/redisson/api/**/*.java</includes>
<includes>**/org/redisson/api/**/*.java,**/org/redisson/cache/**/*.java</includes>
<consoleOutput>true</consoleOutput>
<enableRSS>false</enableRSS>
<configLocation>/checkstyle.xml</configLocation>

@ -300,7 +300,7 @@ public abstract class AbstractCacheMap<K, V> implements Cache<K, V> {
abstract class MapIterator<M> implements Iterator<M> {
final Iterator<Map.Entry<K, CachedValue<K, V>>> keyIterator = map.entrySet().iterator();
private final Iterator<Map.Entry<K, CachedValue<K, V>>> keyIterator = map.entrySet().iterator();
Map.Entry<K, CachedValue<K, V>> mapEntry;
@ -418,7 +418,7 @@ public abstract class AbstractCacheMap<K, V> implements Cache<K, V> {
final class EntrySet extends AbstractSet<Map.Entry<K, V>> {
public final Iterator<Map.Entry<K,V>> iterator() {
public Iterator<Map.Entry<K, V>> iterator() {
return new MapIterator<Map.Entry<K, V>>() {
@Override
public Map.Entry<K, V> next() {
@ -442,7 +442,7 @@ public abstract class AbstractCacheMap<K, V> implements Cache<K, V> {
};
}
public final boolean contains(Object o) {
public boolean contains(Object o) {
if (!(o instanceof Map.Entry))
return false;
Map.Entry<?, ?> e = (Map.Entry<?, ?>) o;
@ -451,7 +451,7 @@ public abstract class AbstractCacheMap<K, V> implements Cache<K, V> {
return value != null && value.equals(e);
}
public final boolean remove(Object o) {
public boolean remove(Object o) {
if (o instanceof Map.Entry) {
Map.Entry<?, ?> e = (Map.Entry<?, ?>) o;
Object key = e.getKey();
@ -461,11 +461,11 @@ public abstract class AbstractCacheMap<K, V> implements Cache<K, V> {
return false;
}
public final int size() {
public int size() {
return AbstractCacheMap.this.size();
}
public final void clear() {
public void clear() {
AbstractCacheMap.this.clear();
}

@ -59,8 +59,8 @@ public class LFUCacheMap<K, V> extends AbstractCacheMap<K, V> {
public static class LFUCachedValue extends StdCachedValue {
Long id;
long accessCount;
private final Long id;
private long accessCount;
public LFUCachedValue(long id, Object key, Object value, long ttl, long maxIdleTime) {
super(key, value, ttl, maxIdleTime);

@ -22,7 +22,6 @@ import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicLong;
/**

@ -111,38 +111,7 @@ public abstract class LocalCacheListener {
// check if instance has already been used
&& lastInvalidate > 0) {
if (System.currentTimeMillis() - lastInvalidate > cacheUpdateLogTime) {
cache.clear();
return;
}
object.isExistsAsync().onComplete((res, e) -> {
if (e != null) {
log.error("Can't check existance", e);
return;
}
if (!res) {
cache.clear();
return;
}
RScoredSortedSet<byte[]> logs = new RedissonScoredSortedSet<byte[]>(ByteArrayCodec.INSTANCE, commandExecutor, getUpdatesLogName(), null);
logs.valueRangeAsync(lastInvalidate, true, Double.POSITIVE_INFINITY, true)
.onComplete((r, ex) -> {
if (ex != null) {
log.error("Can't load update log", ex);
return;
}
for (byte[] entry : r) {
byte[] keyHash = Arrays.copyOf(entry, 16);
CacheKey key = new CacheKey(keyHash);
cache.remove(key);
}
});
});
loadAfterReconnection();
}
}
});
@ -282,4 +251,38 @@ public abstract class LocalCacheListener {
return RedissonObject.prefixName("redisson__cache_updates_log", name);
}
private void loadAfterReconnection() {
if (System.currentTimeMillis() - lastInvalidate > cacheUpdateLogTime) {
cache.clear();
return;
}
object.isExistsAsync().onComplete((res, e) -> {
if (e != null) {
log.error("Can't check existance", e);
return;
}
if (!res) {
cache.clear();
return;
}
RScoredSortedSet<byte[]> logs = new RedissonScoredSortedSet<byte[]>(ByteArrayCodec.INSTANCE, commandExecutor, getUpdatesLogName(), null);
logs.valueRangeAsync(lastInvalidate, true, Double.POSITIVE_INFINITY, true)
.onComplete((r, ex) -> {
if (ex != null) {
log.error("Can't load update log", ex);
return;
}
for (byte[] entry : r) {
byte[] keyHash = Arrays.copyOf(entry, 16);
CacheKey key = new CacheKey(keyHash);
cache.remove(key);
}
});
});
}
}

@ -55,7 +55,9 @@ public class LocalCacheView<K, V> {
@Override
public Iterator<K> iterator() {
return new Iterator<K>() {
Iterator<CacheValue> iter = cache.values().iterator();
private Iterator<CacheValue> iter = cache.values().iterator();
@Override
public boolean hasNext() {
return iter.hasNext();
@ -106,7 +108,9 @@ public class LocalCacheView<K, V> {
@Override
public Iterator<V> iterator() {
return new Iterator<V>() {
Iterator<CacheValue> iter = cache.values().iterator();
private Iterator<CacheValue> iter = cache.values().iterator();
@Override
public boolean hasNext() {
return iter.hasNext();
@ -151,7 +155,9 @@ public class LocalCacheView<K, V> {
@Override
public Iterator<Map.Entry<K, V>> iterator() {
return new Iterator<Map.Entry<K, V>>() {
Iterator<CacheValue> iter = cache.values().iterator();
private Iterator<CacheValue> iter = cache.values().iterator();
@Override
public boolean hasNext() {
return iter.hasNext();

@ -21,14 +21,14 @@ package org.redisson.cache;
public class StdCachedValue<K, V> implements CachedValue<K, V> {
protected final K key;
protected final V value;
private final K key;
private final V value;
long ttl;
long maxIdleTime;
private long ttl;
private long maxIdleTime;
long creationTime;
long lastAccess;
private long creationTime;
private long lastAccess;
public StdCachedValue(K key, V value, long ttl, long maxIdleTime) {
this.value = value;

Loading…
Cancel
Save