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="EmptyForIteratorPad"/>
<module name="MethodParamPad"/> <module name="MethodParamPad"/>
<module name="NoWhitespaceBefore"/> <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="ParenPad"/>
<module name="TypecastParenPad"/> <module name="TypecastParenPad"/>
<module name="WhitespaceAfter"/> <module name="WhitespaceAfter"/>

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

@ -485,8 +485,12 @@ public class RedissonLiveObjectService implements RLiveObjectService {
} }
@Override @Override
public <T, K> void delete(Class<T> entityClass, K id) { public <T, K> boolean delete(Class<T> entityClass, K id) {
asLiveObject(get(entityClass, id)).delete(); T entity = get(entityClass, id);
if (entity == null) {
return false;
}
return asLiveObject(entity).delete();
} }
@Override @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> * <p>
* Please note, that in cluster mode all objects should be on the same cluster slot. * Please note, that in cluster mode all objects should be on the same cluster slot.
* https://github.com/antirez/redis/issues/3682 * 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> * <p>
* NOTE: Redis 3.2+ required * NOTE: Redis 3.2+ required
* *

@ -120,8 +120,10 @@ public interface RLiveObjectService {
* @param <K> Key type * @param <K> Key type
* @param entityClass - object class * @param entityClass - object class
* @param id - object id * @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. * To cast the instance to RLiveObject instance.

@ -142,8 +142,6 @@ public class MasterSlaveConnectionManager implements ConnectionManager {
private final ConnectionEventsHub connectionEventsHub = new ConnectionEventsHub(); private final ConnectionEventsHub connectionEventsHub = new ConnectionEventsHub();
private final AsyncSemaphore[] locks = new AsyncSemaphore[50];
private final ExecutorService executor; private final ExecutorService executor;
private final CommandSyncService commandExecutor; private final CommandSyncService commandExecutor;
@ -156,12 +154,6 @@ public class MasterSlaveConnectionManager implements ConnectionManager {
private final Map<Object, RedisConnection> nodeConnections = PlatformDependent.newConcurrentHashMap(); 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) { public MasterSlaveConnectionManager(MasterSlaveServersConfig cfg, Config config, UUID id) {
this(config, id); this(config, id);
this.config = cfg; this.config = cfg;
@ -219,6 +211,19 @@ public class MasterSlaveConnectionManager implements ConnectionManager {
this.commandExecutor = new CommandSyncService(this); 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() { protected void closeNodeConnections() {
List<RFuture<Void>> futures = new ArrayList<RFuture<Void>>(); List<RFuture<Void>> futures = new ArrayList<RFuture<Void>>();
for (RedisConnection connection : nodeConnections.values()) { for (RedisConnection connection : nodeConnections.values()) {

@ -346,6 +346,10 @@ public class MasterSlaveEntry {
return addSlave(client, freezed, nodeType); return addSlave(client, freezed, nodeType);
} }
public ClientConnectionsEntry getSlaveEntry(RedisClient client) {
return slaveBalancer.getEntry(client);
}
public Collection<ClientConnectionsEntry> getSlaveEntries() { public Collection<ClientConnectionsEntry> getSlaveEntries() {
List<ClientConnectionsEntry> result = new ArrayList<ClientConnectionsEntry>(); List<ClientConnectionsEntry> result = new ArrayList<ClientConnectionsEntry>();
for (ClientConnectionsEntry slaveEntry : slaveBalancer.getEntries()) { 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() { public void shutdownMasterAsync() {
if (!active.compareAndSet(true, false)) { if (!active.compareAndSet(true, false)) {
return; return;

@ -222,8 +222,7 @@ public class LoadBalancerManager {
return null; return null;
} }
public ClientConnectionsEntry getEntry(RedisClient redisClient) {
protected ClientConnectionsEntry getEntry(RedisClient redisClient) {
return client2Entry.get(redisClient); return client2Entry.get(redisClient);
} }

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

Loading…
Cancel
Save