Code formatted according to checkstyle rules

pull/1923/head
Nikita Koksharov 6 years ago
parent 7126b0bef0
commit a5862933dc

@ -366,7 +366,11 @@
**/org/redisson/client/**/*.java,
**/org/redisson/cluster/**/*.java,
**/org/redisson/codec/**/*.java,
**/org/redisson/command/**/*.java
**/org/redisson/command/**/*.java,
**/org/redisson/config/**/*.java,
**/org/redisson/connection/**/*.java,
**/org/redisson/eviction/**/*.java,
**/org/redisson/executor/**/*.java,
</includes>
<consoleOutput>true</consoleOutput>
<enableRSS>false</enableRSS>

@ -102,7 +102,7 @@ public class BaseMasterSlaveServersConfig<T extends BaseMasterSlaveServersConfig
*/
public T setSlaveConnectionPoolSize(int slaveConnectionPoolSize) {
this.slaveConnectionPoolSize = slaveConnectionPoolSize;
return (T)this;
return (T) this;
}
public int getSlaveConnectionPoolSize() {
return slaveConnectionPoolSize;
@ -162,7 +162,7 @@ public class BaseMasterSlaveServersConfig<T extends BaseMasterSlaveServersConfig
*/
public T setMasterConnectionPoolSize(int masterConnectionPoolSize) {
this.masterConnectionPoolSize = masterConnectionPoolSize;
return (T)this;
return (T) this;
}
public int getMasterConnectionPoolSize() {
return masterConnectionPoolSize;
@ -181,7 +181,7 @@ public class BaseMasterSlaveServersConfig<T extends BaseMasterSlaveServersConfig
*/
public T setLoadBalancer(LoadBalancer loadBalancer) {
this.loadBalancer = loadBalancer;
return (T)this;
return (T) this;
}
public LoadBalancer getLoadBalancer() {
return loadBalancer;
@ -214,7 +214,7 @@ public class BaseMasterSlaveServersConfig<T extends BaseMasterSlaveServersConfig
*/
public T setSubscriptionConnectionPoolSize(int subscriptionConnectionPoolSize) {
this.subscriptionConnectionPoolSize = subscriptionConnectionPoolSize;
return (T)this;
return (T) this;
}
public int getSubscriptionConnectionPoolSize() {
return subscriptionConnectionPoolSize;

@ -49,41 +49,41 @@ public class Config {
private ClusterServersConfig clusterServersConfig;
private ReplicatedServersConfig replicatedServersConfig;
private ConnectionManager connectionManager;
private ConnectionManager connectionManager;
/**
* Threads amount shared between all redis node clients
*/
private int threads = 16;
private int nettyThreads = 32;
/**
* Redis key/value codec. JsonJacksonCodec used by default
*/
private Codec codec;
private ExecutorService executor;
/**
* Config option for enabling Redisson Reference feature.
* Default value is TRUE
*/
private boolean referenceEnabled = true;
private TransportMode transportMode = TransportMode.NIO;
private EventLoopGroup eventLoopGroup;
private long lockWatchdogTimeout = 30 * 1000;
private boolean keepPubSubOrder = true;
private boolean decodeInExecutor = false;
private boolean useScriptCache = false;
/**
* AddressResolverGroupFactory switch between default and round robin
*/
@ -91,7 +91,7 @@ public class Config {
public Config() {
}
static {
URIBuilder.patchUriObject();
}
@ -132,7 +132,7 @@ public class Config {
setReplicatedServersConfig(new ReplicatedServersConfig(oldConf.getReplicatedServersConfig()));
}
if (oldConf.getConnectionManager() != null) {
useCustomServers(oldConf.getConnectionManager());
useCustomServers(oldConf.getConnectionManager());
}
}
@ -153,7 +153,7 @@ public class Config {
public Codec getCodec() {
return codec;
}
/**
* Config option indicate whether Redisson Reference feature is enabled.
* <p>
@ -175,7 +175,7 @@ public class Config {
public void setReferenceEnabled(boolean redissonReferenceEnabled) {
this.referenceEnabled = redissonReferenceEnabled;
}
/**
* Init cluster servers configuration
*
@ -234,28 +234,27 @@ public class Config {
void setReplicatedServersConfig(ReplicatedServersConfig replicatedServersConfig) {
this.replicatedServersConfig = replicatedServersConfig;
}
/**
* Returns the connection manager if supplied via
* {@link #useCustomServers(ConnectionManager)}
*
* @return ConnectionManager
*/
* Returns the connection manager if supplied via
* {@link #useCustomServers(ConnectionManager)}
*
* @return ConnectionManager
*/
ConnectionManager getConnectionManager() {
return connectionManager;
}
/**
* This is an extension point to supply custom connection manager.
*
* @see ReplicatedConnectionManager on how to implement a connection
* manager.
* @param connectionManager for supply
*/
* This is an extension point to supply custom connection manager.
*
* @see ReplicatedConnectionManager on how to implement a connection
* manager.
* @param connectionManager for supply
*/
public void useCustomServers(ConnectionManager connectionManager) {
this.connectionManager = connectionManager;
}
/**
* Init single server configuration.
@ -347,7 +346,7 @@ public class Config {
public boolean isClusterConfig() {
return clusterServersConfig != null;
}
public boolean isSentinelConfig() {
return sentinelServersConfig != null;
}
@ -415,10 +414,11 @@ public class Config {
this.transportMode = transportMode;
return this;
}
public TransportMode getTransportMode() {
return transportMode;
}
/**
* Threads amount shared between all redis clients used by Redisson.
* <p>
@ -433,11 +433,11 @@ public class Config {
this.nettyThreads = nettyThreads;
return this;
}
public int getNettyThreads() {
return nettyThreads;
}
/**
* Use external ExecutorService. ExecutorService processes
* all listeners of <code>RTopic</code>,
@ -453,7 +453,7 @@ public class Config {
this.executor = executor;
return this;
}
public ExecutorService getExecutor() {
return executor;
}
@ -500,6 +500,7 @@ public class Config {
this.lockWatchdogTimeout = lockWatchdogTimeout;
return this;
}
public long getLockWatchdogTimeout() {
return lockWatchdogTimeout;
}
@ -519,6 +520,7 @@ public class Config {
this.keepPubSubOrder = keepPubSubOrder;
return this;
}
public boolean isKeepPubSubOrder() {
return keepPubSubOrder;
}
@ -534,6 +536,7 @@ public class Config {
this.addressResolverGroupFactory = addressResolverGroupFactory;
return this;
}
public AddressResolverGroupFactory getAddressResolverGroupFactory() {
return addressResolverGroupFactory;
}
@ -655,7 +658,7 @@ public class Config {
public static Config fromYAML(File file) throws IOException {
return fromYAML(file, null);
}
public static Config fromYAML(File file, ClassLoader classLoader) throws IOException {
ConfigSupport support = new ConfigSupport();
return support.fromYAML(file, Config.class, classLoader);
@ -713,6 +716,7 @@ public class Config {
this.useScriptCache = useScriptCache;
return this;
}
public boolean isUseScriptCache() {
return useScriptCache;
}
@ -720,6 +724,7 @@ public class Config {
public boolean isDecodeInExecutor() {
return decodeInExecutor;
}
/**
* Defines whether to decode data by <code>codec</code> in executor's threads or netty's threads.
* If decoding data process takes long time and netty thread is used then `RedisTimeoutException` could arise time to time.

@ -16,7 +16,6 @@
package org.redisson.config;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;

@ -18,9 +18,9 @@ package org.redisson.connection;
/**
* @author <a href="mailto:mpaluch@paluch.biz">Mark Paluch</a>
**/
public class CRC16 {
public final class CRC16 {
private static final int LOOKUP_TABLE[] = { 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6,
private static final int[] LOOKUP_TABLE = { 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6,
0x70E7, 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF, 0x1231, 0x0210, 0x3273,
0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6, 0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF,
0xE3DE, 0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485, 0xA56A, 0xB54B, 0x8528,
@ -50,7 +50,7 @@ public class CRC16 {
int crc = 0x0000;
for (byte b : bytes) {
crc = ((crc << 8) ^ LOOKUP_TABLE[((crc >>> 8) ^ (b & 0xFF)) & 0xFF]);
crc = (crc << 8) ^ LOOKUP_TABLE[((crc >>> 8) ^ (b & 0xFF)) & 0xFF];
}
return crc & 0xFFFF;
}

@ -347,7 +347,7 @@ public class MasterSlaveConnectionManager implements ConnectionManager {
}
startDNSMonitoring(f.getNow());
} catch (RuntimeException e) {
} catch (Exception e) {
stopThreads();
throw e;
}
@ -555,9 +555,9 @@ public class MasterSlaveConnectionManager implements ConnectionManager {
return RedissonPromise.newFailedFuture(ex);
}
// fix for https://github.com/redisson/redisson/issues/1548
if (source.getRedirect() != null &&
!URIBuilder.compare(entry.getClient().getAddr(), source.getAddr()) &&
entry.hasSlave(source.getAddr())) {
if (source.getRedirect() != null
&& !URIBuilder.compare(entry.getClient().getAddr(), source.getAddr())
&& entry.hasSlave(source.getAddr())) {
return entry.redirectedConnectionWriteOp(command, source.getAddr());
}
return entry.connectionWriteOp(command);
@ -619,7 +619,7 @@ public class MasterSlaveConnectionManager implements ConnectionManager {
@Override
public void shutdown() {
shutdown(0, 2, TimeUnit.SECONDS);//default netty value
shutdown(0, 2, TimeUnit.SECONDS); //default netty value
}
@Override

@ -107,7 +107,7 @@ public class ReplicatedConnectionManager extends MasterSlaveConnectionManager {
@Override
protected MasterSlaveServersConfig create(BaseMasterSlaveServersConfig<?> cfg) {
MasterSlaveServersConfig res = super.create(cfg);
res.setDatabase(((ReplicatedServersConfig)cfg).getDatabase());
res.setDatabase(((ReplicatedServersConfig) cfg).getDatabase());
return res;
}

@ -529,7 +529,7 @@ public class SentinelConnectionManager extends MasterSlaveConnectionManager {
@Override
protected MasterSlaveServersConfig create(BaseMasterSlaveServersConfig<?> cfg) {
MasterSlaveServersConfig res = super.create(cfg);
res.setDatabase(((SentinelServersConfig)cfg).getDatabase());
res.setDatabase(((SentinelServersConfig) cfg).getDatabase());
return res;
}

@ -156,6 +156,7 @@ public class LoadBalancerManager {
return freeze(connectionEntry, freezeReason);
}
@SuppressWarnings("BooleanExpressionComplexity")
public ClientConnectionsEntry freeze(ClientConnectionsEntry connectionEntry, FreezeReason freezeReason) {
if (connectionEntry == null || (connectionEntry.isFailed()
&& connectionEntry.getFreezeReason() == FreezeReason.RECONNECT
@ -169,8 +170,7 @@ public class LoadBalancerManager {
|| connectionEntry.getFreezeReason() == FreezeReason.RECONNECT
|| (freezeReason == FreezeReason.MANAGER
&& connectionEntry.getFreezeReason() != FreezeReason.MANAGER
&& connectionEntry.getNodeType() == NodeType.SLAVE
)) {
&& connectionEntry.getNodeType() == NodeType.SLAVE)) {
connectionEntry.setFreezed(true);
connectionEntry.setFreezeReason(freezeReason);
return connectionEntry;

@ -15,18 +15,14 @@
*/
package org.redisson.connection.decoder;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.redisson.client.codec.LongCodec;
import org.redisson.client.handler.State;
import org.redisson.client.protocol.Decoder;
import org.redisson.client.protocol.decoder.MultiDecoder;
import io.netty.buffer.ByteBuf;
/**
*
* @author Nikita Koksharov

@ -19,7 +19,6 @@ import java.net.InetSocketAddress;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
@ -63,7 +62,7 @@ abstract class ConnectionPool<T extends RedisConnection> {
final MasterSlaveEntry masterSlaveEntry;
public ConnectionPool(MasterSlaveServersConfig config, ConnectionManager connectionManager, MasterSlaveEntry masterSlaveEntry) {
ConnectionPool(MasterSlaveServersConfig config, ConnectionManager connectionManager, MasterSlaveEntry masterSlaveEntry) {
this.config = config;
this.masterSlaveEntry = masterSlaveEntry;
this.connectionManager = connectionManager;
@ -189,8 +188,8 @@ abstract class ConnectionPool<T extends RedisConnection> {
List<ClientConnectionsEntry> entriesCopy = new LinkedList<ClientConnectionsEntry>(entries);
for (Iterator<ClientConnectionsEntry> iterator = entriesCopy.iterator(); iterator.hasNext();) {
ClientConnectionsEntry entry = iterator.next();
if (!((!entry.isFreezed() || entry.isMasterForRead()) &&
tryAcquireConnection(entry))) {
if (!((!entry.isFreezed() || entry.isMasterForRead())
&& tryAcquireConnection(entry))) {
iterator.remove();
}
}
@ -225,7 +224,7 @@ abstract class ConnectionPool<T extends RedisConnection> {
return acquireConnection(command, entry);
}
public static abstract class AcquireCallback<T> implements Runnable, BiConsumer<T, Throwable> {
public abstract static class AcquireCallback<T> implements Runnable, BiConsumer<T, Throwable> {
}

@ -70,7 +70,7 @@ abstract class EvictionTask implements Runnable {
if (sizeHistory.size() == 2) {
if (sizeHistory.peekFirst() > sizeHistory.peekLast()
&& sizeHistory.peekLast() > size) {
delay = Math.min(maxDelay, (int)(delay*1.5));
delay = Math.min(maxDelay, (int) (delay*1.5));
}
// if (sizeHistory.peekFirst() < sizeHistory.peekLast()
@ -84,7 +84,7 @@ abstract class EvictionTask implements Runnable {
delay = Math.max(minDelay, delay/4);
}
if (size == 0) {
delay = Math.min(maxDelay, (int)(delay*1.5));
delay = Math.min(maxDelay, (int) (delay*1.5));
}
}

@ -50,6 +50,9 @@ import java.util.TreeSet;
* @author Contributions from Mads Henderson
* @author Refactoring from CronTrigger to CronExpression by Aaron Craven
*/
@SuppressWarnings({"EmptyStatement", "InnerAssignment", "ConstantName",
"BooleanExpressionComplexity", "NestedIfDepth", "ParenPad",
"MethodLength", "WhitespaceAfter", "SuperClone", "UnnecessaryParentheses"})
public final class CronExpression implements Serializable, Cloneable {
private static final long serialVersionUID = 12423409423L;
@ -1499,6 +1502,7 @@ public final class CronExpression implements Serializable, Cloneable {
}
}
@SuppressWarnings("VisibilityModifier")
class ValueSet {
public int value;

@ -50,7 +50,7 @@ public class TasksBatchService extends TasksService {
}
public RFuture<List<Boolean>> executeAddAsync() {
return (RFuture<List<Boolean>>)(Object)batchCommandService.executeAsync();
return (RFuture<List<Boolean>>) (Object) batchCommandService.executeAsync();
}

@ -64,7 +64,7 @@ import io.netty.util.TimerTask;
*/
public class TasksRunnerService implements RemoteExecutorService {
private static final Map<HashValue, Codec> codecs = new LRUCacheMap<HashValue, Codec>(500, 0, 0);
private static final Map<HashValue, Codec> CODECS = new LRUCacheMap<HashValue, Codec>(500, 0, 0);
private final Codec codec;
private final String name;
@ -125,7 +125,7 @@ public class TasksRunnerService implements RemoteExecutorService {
RFuture<Void> future = asyncScheduledServiceAtFixed(params.getExecutorId(), params.getRequestId()).scheduleAtFixedRate(params);
try {
executeRunnable(params);
} catch (RuntimeException e) {
} catch (Exception e) {
// cancel task if it throws an exception
future.cancel(true);
throw e;
@ -145,7 +145,7 @@ public class TasksRunnerService implements RemoteExecutorService {
}
try {
executeRunnable(params, nextStartDate == null);
} catch (RuntimeException e) {
} catch (Exception e) {
// cancel task if it throws an exception
if (future != null) {
future.cancel(true);
@ -216,7 +216,7 @@ public class TasksRunnerService implements RemoteExecutorService {
}
protected void scheduleRetryTimeRenewal(final String requestId) {
((Redisson)redisson).getConnectionManager().newTimeout(new TimerTask() {
((Redisson) redisson).getConnectionManager().newTimeout(new TimerTask() {
@Override
public void run(Timeout timeout) throws Exception {
renewRetryTime(requestId);
@ -263,13 +263,13 @@ public class TasksRunnerService implements RemoteExecutorService {
ByteBuf stateBuf = Unpooled.wrappedBuffer(params.getState());
try {
HashValue hash = new HashValue(Hash.hash128(classBodyBuf));
Codec classLoaderCodec = codecs.get(hash);
Codec classLoaderCodec = CODECS.get(hash);
if (classLoaderCodec == null) {
RedissonClassLoader cl = new RedissonClassLoader(codec.getClassLoader());
cl.loadClass(params.getClassName(), params.getClassBody());
classLoaderCodec = this.codec.getClass().getConstructor(ClassLoader.class).newInstance(cl);
codecs.put(hash, classLoaderCodec);
CODECS.put(hash, classLoaderCodec);
}
T task;

Loading…
Cancel
Save