Merge branch 'master' into 3.0.0

pull/1821/head
Nikita 7 years ago
commit 867511434b

@ -128,7 +128,9 @@
<module name="EmptyForIteratorPad"/>
<module name="MethodParamPad"/>
<module name="NoWhitespaceBefore"/>
<module name="OperatorWrap"/>
<module name="OperatorWrap">
<property name="tokens" value="QUESTION, COLON, EQUAL, NOT_EQUAL, DIV, MINUS, STAR, MOD, SR, BSR, GE, GT, SL, LE, LT, BXOR, BOR, LOR, BAND, LAND, TYPE_EXTENSION_AND, LITERAL_INSTANCEOF"/>
</module>
<module name="ParenPad"/>
<module name="TypecastParenPad"/>
<module name="WhitespaceAfter"/>

@ -350,7 +350,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.2</version>
<version>2.5</version>
</plugin>
<plugin>
@ -372,7 +372,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.6</version>
<version>3.9.0</version>
<executions>
<execution>
<phase>verify</phase>
@ -393,7 +393,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.17</version>
<version>3.0.0</version>
<executions>
<execution>
<phase>verify</phase>
@ -411,7 +411,7 @@
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<version>3.7.0</version>
<configuration>
<source>${source.version}</source>
<target>${source.version}</target>
@ -437,7 +437,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<version>2.21.0</version>
<configuration>
<properties>
<property>

@ -485,8 +485,12 @@ public class RedissonLiveObjectService implements RLiveObjectService {
}
@Override
public <T, K> void delete(Class<T> entityClass, K id) {
asLiveObject(get(entityClass, id)).delete();
public <T, K> boolean delete(Class<T> entityClass, K id) {
T entity = get(entityClass, id);
if (entity == null) {
return false;
}
return asLiveObject(entity).delete();
}
@Override

@ -122,7 +122,7 @@ public class BatchOptions {
}
/**
* Atomically executes all batched commands as a single command.
* Switches batch to atomic mode. Redis atomically executes all commands of this batch as a single command.
* <p>
* Please note, that in cluster mode all objects should be on the same cluster slot.
* https://github.com/antirez/redis/issues/3682
@ -138,7 +138,7 @@ public class BatchOptions {
}
/**
* Inform Redis not to send reply. It may save network traffic.
* Inform Redis not to send reply. This allows to save network traffic for commands with batch with big response.
* <p>
* NOTE: Redis 3.2+ required
*

@ -120,8 +120,10 @@ public interface RLiveObjectService {
* @param <K> Key type
* @param entityClass - object class
* @param id - object id
*
* @return <code>true</code> if entity was deleted successfully, <code>false</code> otherwise
*/
<T, K> void delete(Class<T> entityClass, K id);
<T, K> boolean delete(Class<T> entityClass, K id);
/**
* To cast the instance to RLiveObject instance.

@ -142,8 +142,6 @@ public class MasterSlaveConnectionManager implements ConnectionManager {
private final ConnectionEventsHub connectionEventsHub = new ConnectionEventsHub();
private final AsyncSemaphore[] locks = new AsyncSemaphore[50];
private final ExecutorService executor;
private final CommandSyncService commandExecutor;
@ -156,12 +154,6 @@ public class MasterSlaveConnectionManager implements ConnectionManager {
private final Map<Object, RedisConnection> nodeConnections = PlatformDependent.newConcurrentHashMap();
{
for (int i = 0; i < locks.length; i++) {
locks[i] = new AsyncSemaphore(1);
}
}
public MasterSlaveConnectionManager(MasterSlaveServersConfig cfg, Config config, UUID id) {
this(config, id);
this.config = cfg;
@ -186,7 +178,7 @@ public class MasterSlaveConnectionManager implements ConnectionManager {
} else if (cfg.getTransportMode() == TransportMode.KQUEUE) {
if (cfg.getEventLoopGroup() == null) {
this.group = new KQueueEventLoopGroup(cfg.getNettyThreads(), new DefaultThreadFactory("redisson-netty"));
} else {
} else {
this.group = cfg.getEventLoopGroup();
}
@ -219,6 +211,19 @@ public class MasterSlaveConnectionManager implements ConnectionManager {
this.commandExecutor = new CommandSyncService(this);
}
/*
* Remove it once https://github.com/netty/netty/issues/7882 get resolved
*/
protected DnsAddressResolverGroup createResolverGroup() {
if (cfg.getTransportMode() == TransportMode.EPOLL) {
return cfg.getAddressResolverGroupFactory().create(EpollDatagramChannel.class, DnsServerAddressStreamProviders.platformDefault());
} else if (cfg.getTransportMode() == TransportMode.KQUEUE) {
return cfg.getAddressResolverGroupFactory().create(KQueueDatagramChannel.class, DnsServerAddressStreamProviders.platformDefault());
}
return cfg.getAddressResolverGroupFactory().create(NioDatagramChannel.class, DnsServerAddressStreamProviders.platformDefault());
}
protected void closeNodeConnections() {
List<RFuture<Void>> futures = new ArrayList<RFuture<Void>>();
for (RedisConnection connection : nodeConnections.values()) {
@ -499,7 +504,7 @@ public class MasterSlaveConnectionManager implements ConnectionManager {
for (MasterSlaveEntry entry : client2entry.values()) {
if (URIBuilder.compare(entry.getClient().getAddr(), addr)) {
return entry;
}
}
if (entry.hasSlave(addr)) {
return entry;
}

@ -139,25 +139,25 @@ public class MasterSlaveEntry {
return;
}
masterEntry = new ClientConnectionsEntry(
client,
config.getMasterConnectionMinimumIdleSize(),
config.getMasterConnectionPoolSize(),
config.getSubscriptionConnectionMinimumIdleSize(),
config.getSubscriptionConnectionPoolSize(),
connectionManager,
masterEntry = new ClientConnectionsEntry(
client,
config.getMasterConnectionMinimumIdleSize(),
config.getMasterConnectionPoolSize(),
config.getSubscriptionConnectionMinimumIdleSize(),
config.getSubscriptionConnectionPoolSize(),
connectionManager,
NodeType.MASTER);
CountableListener<RedisClient> listener = new CountableListener<RedisClient>(result, client);
RFuture<Void> writeFuture = writeConnectionPool.add(masterEntry);
listener.incCounter();
writeFuture.addListener(listener);
CountableListener<RedisClient> listener = new CountableListener<RedisClient>(result, client);
RFuture<Void> writeFuture = writeConnectionPool.add(masterEntry);
listener.incCounter();
writeFuture.addListener(listener);
if (config.getSubscriptionMode() == SubscriptionMode.MASTER) {
RFuture<Void> pubSubFuture = pubSubConnectionPool.add(masterEntry);
listener.incCounter();
pubSubFuture.addListener(listener);
}
if (config.getSubscriptionMode() == SubscriptionMode.MASTER) {
RFuture<Void> pubSubFuture = pubSubConnectionPool.add(masterEntry);
listener.incCounter();
pubSubFuture.addListener(listener);
}
}
});
@ -346,6 +346,10 @@ public class MasterSlaveEntry {
return addSlave(client, freezed, nodeType);
}
public ClientConnectionsEntry getSlaveEntry(RedisClient client) {
return slaveBalancer.getEntry(client);
}
public Collection<ClientConnectionsEntry> getSlaveEntries() {
List<ClientConnectionsEntry> result = new ArrayList<ClientConnectionsEntry>();
for (ClientConnectionsEntry slaveEntry : slaveBalancer.getEntries()) {
@ -467,22 +471,6 @@ public class MasterSlaveEntry {
});
}
public boolean isFreezed() {
return masterEntry.isFreezed();
}
public FreezeReason getFreezeReason() {
return masterEntry.getFreezeReason();
}
public void unfreeze() {
masterEntry.resetFirstFail();
synchronized (masterEntry) {
masterEntry.setFreezed(false);
masterEntry.setFreezeReason(null);
}
}
public void shutdownMasterAsync() {
if (!active.compareAndSet(true, false)) {
return;

@ -86,8 +86,8 @@ public class LoadBalancerManager {
CountableListener<Void> listener = new CountableListener<Void>(result, null) {
@Override
protected void onSuccess(Void value) {
client2Entry.put(entry.getClient(), entry);
}
client2Entry.put(entry.getClient(), entry);
}
};
RFuture<Void> slaveFuture = slaveConnectionPool.add(entry);
@ -222,8 +222,7 @@ public class LoadBalancerManager {
return null;
}
protected ClientConnectionsEntry getEntry(RedisClient redisClient) {
public ClientConnectionsEntry getEntry(RedisClient redisClient) {
return client2Entry.get(redisClient);
}

@ -1401,6 +1401,11 @@ public class RedissonLiveObjectServiceTest extends BaseTest {
assertThat(redisson.getKeys().count()).isEqualTo(1);
}
@Test
public void testDeleteNotExisted() {
RLiveObjectService service = redisson.getLiveObjectService();
assertThat(service.delete(Customer.class, "id")).isFalse();
}
@Test
public void testDelete() {

Loading…
Cancel
Save