Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_57962205
redisson
提交
d69f4e9b
R
redisson
项目概览
weixin_57962205
/
redisson
与 Fork 源项目一致
从无法访问的项目Fork
通知
10
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redisson
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d69f4e9b
编写于
12月 24, 2018
作者:
N
Nikita Koksharov
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' into 3.0.0
上级
7afeb832
8617feb5
变更
38
展开全部
隐藏空白更改
内联
并排
Showing
38 changed file
with
2652 addition
and
201 deletion
+2652
-201
redisson/pom.xml
redisson/pom.xml
+9
-11
redisson/src/main/java/org/redisson/api/annotation/REntity.java
...on/src/main/java/org/redisson/api/annotation/REntity.java
+19
-2
redisson/src/main/java/org/redisson/api/annotation/RObjectField.java
...c/main/java/org/redisson/api/annotation/RObjectField.java
+23
-2
redisson/src/main/java/org/redisson/codec/DefaultReferenceCodecProvider.java
...ava/org/redisson/codec/DefaultReferenceCodecProvider.java
+25
-22
redisson/src/main/java/org/redisson/codec/ReferenceCodecProvider.java
.../main/java/org/redisson/codec/ReferenceCodecProvider.java
+6
-27
redisson/src/main/java/org/redisson/config/BaseConfig.java
redisson/src/main/java/org/redisson/config/BaseConfig.java
+1
-6
redisson/src/main/java/org/redisson/liveobject/core/AccessorInterceptor.java
...ava/org/redisson/liveobject/core/AccessorInterceptor.java
+5
-2
redisson/src/main/java/org/redisson/liveobject/core/LiveObjectInterceptor.java
...a/org/redisson/liveobject/core/LiveObjectInterceptor.java
+16
-15
redisson/src/main/java/org/redisson/liveobject/core/RedissonObjectBuilder.java
...a/org/redisson/liveobject/core/RedissonObjectBuilder.java
+2
-2
redisson/src/main/java/org/redisson/liveobject/resolver/DefaultNamingScheme.java
...org/redisson/liveobject/resolver/DefaultNamingScheme.java
+0
-4
redisson/src/main/java/org/redisson/misc/RedissonObjectFactory.java
...rc/main/java/org/redisson/misc/RedissonObjectFactory.java
+2
-2
redisson/src/main/resources/META-INF/spring.schemas
redisson/src/main/resources/META-INF/spring.schemas
+2
-1
redisson/src/main/resources/org/redisson/spring/support/redisson-1.3.xsd
...in/resources/org/redisson/spring/support/redisson-1.3.xsd
+2438
-0
redisson/src/test/java/org/redisson/BaseMapTest.java
redisson/src/test/java/org/redisson/BaseMapTest.java
+7
-6
redisson/src/test/java/org/redisson/RedissonBucketTest.java
redisson/src/test/java/org/redisson/RedissonBucketTest.java
+2
-0
redisson/src/test/java/org/redisson/RedissonLiveObjectServiceTest.java
...test/java/org/redisson/RedissonLiveObjectServiceTest.java
+6
-5
redisson/src/test/java/org/redisson/RedissonLocalCachedMapTest.java
...rc/test/java/org/redisson/RedissonLocalCachedMapTest.java
+6
-3
redisson/src/test/java/org/redisson/RedissonMapCacheTest.java
...sson/src/test/java/org/redisson/RedissonMapCacheTest.java
+23
-9
redisson/src/test/java/org/redisson/RedissonMapReactiveTest.java
...n/src/test/java/org/redisson/RedissonMapReactiveTest.java
+6
-3
redisson/src/test/java/org/redisson/RedissonPriorityBlockingDequeTest.java
.../java/org/redisson/RedissonPriorityBlockingDequeTest.java
+1
-1
redisson/src/test/java/org/redisson/RedissonRuntimeEnvironment.java
...rc/test/java/org/redisson/RedissonRuntimeEnvironment.java
+1
-1
redisson/src/test/java/org/redisson/RedissonScriptReactiveTest.java
...rc/test/java/org/redisson/RedissonScriptReactiveTest.java
+5
-3
redisson/src/test/java/org/redisson/RedissonScriptTest.java
redisson/src/test/java/org/redisson/RedissonScriptTest.java
+5
-7
redisson/src/test/java/org/redisson/RedissonTest.java
redisson/src/test/java/org/redisson/RedissonTest.java
+1
-1
redisson/src/test/java/org/redisson/RedissonTopicPatternTest.java
.../src/test/java/org/redisson/RedissonTopicPatternTest.java
+2
-1
redisson/src/test/java/org/redisson/RedissonTopicTest.java
redisson/src/test/java/org/redisson/RedissonTopicTest.java
+10
-7
redisson/src/test/java/org/redisson/executor/FailoverTask.java
...son/src/test/java/org/redisson/executor/FailoverTask.java
+3
-1
redisson/src/test/java/org/redisson/executor/RedissonExecutorServiceTest.java
...va/org/redisson/executor/RedissonExecutorServiceTest.java
+2
-2
redisson/src/test/java/org/redisson/executor/RedissonScheduledExecutorServiceTest.java
...disson/executor/RedissonScheduledExecutorServiceTest.java
+2
-1
redisson/src/test/java/org/redisson/executor/ScheduledCallableTask.java
...est/java/org/redisson/executor/ScheduledCallableTask.java
+2
-1
redisson/src/test/java/org/redisson/executor/ScheduledLongRepeatableTask.java
...va/org/redisson/executor/ScheduledLongRepeatableTask.java
+3
-1
redisson/src/test/java/org/redisson/executor/ScheduledRunnableTask.java
...est/java/org/redisson/executor/ScheduledRunnableTask.java
+3
-1
redisson/src/test/java/org/redisson/rx/RedissonListRxTest.java
...son/src/test/java/org/redisson/rx/RedissonListRxTest.java
+0
-10
redisson/src/test/java/org/redisson/rx/RedissonMapCacheRxTest.java
...src/test/java/org/redisson/rx/RedissonMapCacheRxTest.java
+0
-16
redisson/src/test/java/org/redisson/rx/RedissonMapRxTest.java
...sson/src/test/java/org/redisson/rx/RedissonMapRxTest.java
+6
-20
redisson/src/test/java/org/redisson/rx/RedissonScriptRxTest.java
...n/src/test/java/org/redisson/rx/RedissonScriptRxTest.java
+4
-3
redisson/src/test/java/org/redisson/spring/cache/RedissonSpringCacheShortTTLTest.java
...edisson/spring/cache/RedissonSpringCacheShortTTLTest.java
+2
-1
redisson/src/test/java/org/redisson/spring/cache/RedissonSpringCacheTest.java
...va/org/redisson/spring/cache/RedissonSpringCacheTest.java
+2
-1
未找到文件。
redisson/pom.xml
浏览文件 @
d69f4e9b
...
...
@@ -141,7 +141,7 @@
<dependency>
<groupId>
com.fasterxml.jackson.datatype
</groupId>
<artifactId>
jackson-datatype-jsr310
</artifactId>
<version>
2.9.
7
</version>
<version>
2.9.
8
</version>
<scope>
test
</scope>
</dependency>
<dependency>
...
...
@@ -188,13 +188,11 @@
<groupId>
de.ruedigermoeller
</groupId>
<artifactId>
fst
</artifactId>
<version>
2.56
</version>
<scope>
provided
</scope>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
com.esotericsoftware
</groupId>
<artifactId>
kryo
</artifactId>
<version>
4.0.
1
</version>
<version>
4.0.
2
</version>
<scope>
provided
</scope>
<optional>
true
</optional>
</dependency>
...
...
@@ -207,44 +205,44 @@
<dependency>
<groupId>
com.fasterxml.jackson.dataformat
</groupId>
<artifactId>
jackson-dataformat-yaml
</artifactId>
<version>
2.9.
7
</version>
<version>
2.9.
8
</version>
</dependency>
<dependency>
<groupId>
com.fasterxml.jackson.core
</groupId>
<artifactId>
jackson-core
</artifactId>
<version>
2.9.
7
</version>
<version>
2.9.
8
</version>
</dependency>
<dependency>
<groupId>
com.fasterxml.jackson.core
</groupId>
<artifactId>
jackson-databind
</artifactId>
<version>
2.9.
7
</version>
<version>
2.9.
8
</version>
</dependency>
<dependency>
<groupId>
com.fasterxml.jackson.dataformat
</groupId>
<artifactId>
jackson-dataformat-ion
</artifactId>
<version>
2.9.
7
</version>
<version>
2.9.
8
</version>
<scope>
provided
</scope>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
com.fasterxml.jackson.dataformat
</groupId>
<artifactId>
jackson-dataformat-cbor
</artifactId>
<version>
2.9.
7
</version>
<version>
2.9.
8
</version>
<scope>
provided
</scope>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
com.fasterxml.jackson.dataformat
</groupId>
<artifactId>
jackson-dataformat-smile
</artifactId>
<version>
2.9.
7
</version>
<version>
2.9.
8
</version>
<scope>
provided
</scope>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
com.fasterxml.jackson.dataformat
</groupId>
<artifactId>
jackson-dataformat-avro
</artifactId>
<version>
2.9.
7
</version>
<version>
2.9.
8
</version>
<scope>
provided
</scope>
<optional>
true
</optional>
</dependency>
...
...
redisson/src/main/java/org/redisson/api/annotation/REntity.java
浏览文件 @
d69f4e9b
...
...
@@ -21,7 +21,11 @@ import java.lang.annotation.ElementType;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
import
org.redisson.client.codec.BaseCodec
;
import
org.redisson.client.codec.Codec
;
import
org.redisson.client.protocol.Decoder
;
import
org.redisson.client.protocol.Encoder
;
import
org.redisson.codec.JsonJacksonCodec
;
/**
...
...
@@ -50,11 +54,12 @@ public @interface REntity {
Class
<?
extends
NamingScheme
>
namingScheme
()
default
DefaultNamingScheme
.
class
;
/**
* (Optional) Live Object state codec. Defaults to {@link JsonJacksonCodec}.
* (Optional) Live Object state codec.
* <code>null</code> means to use codec specified in Redisson configuration
*
* @return value
*/
Class
<?
extends
Codec
>
codec
()
default
JsonJacksonCodec
.
class
;
Class
<?
extends
Codec
>
codec
()
default
DEFAULT
.
class
;
/**
* (Optional) Live Object field transformation.
...
...
@@ -64,4 +69,16 @@ public @interface REntity {
*/
TransformationMode
fieldTransformation
()
default
TransformationMode
.
ANNOTATION_BASED
;
static
final
class
DEFAULT
extends
BaseCodec
{
@Override
public
Decoder
<
Object
>
getValueDecoder
()
{
return
null
;
}
@Override
public
Encoder
getValueEncoder
()
{
return
null
;
}
}
}
redisson/src/main/java/org/redisson/api/annotation/RObjectField.java
浏览文件 @
d69f4e9b
...
...
@@ -21,7 +21,11 @@ import java.lang.annotation.ElementType;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
import
org.redisson.client.codec.BaseCodec
;
import
org.redisson.client.codec.Codec
;
import
org.redisson.client.protocol.Decoder
;
import
org.redisson.client.protocol.Encoder
;
import
org.redisson.codec.JsonJacksonCodec
;
/**
...
...
@@ -41,12 +45,29 @@ public @interface RObjectField{
* (Optional) Live Object naming scheme. Defines how to assign key names for each instance of this class.
* Used to create a reference to an existing Live Object and materialising a new one in redis.
* Defaults to {@link DefaultNamingScheme} implementation.
*
* @return scheme
*/
Class
<?
extends
NamingScheme
>
namingScheme
()
default
DefaultNamingScheme
.
class
;
/**
* (Optional) Live Object state codec. Defaults to {@link JsonJacksonCodec}.
* (Optional) Live Object state codec.
* <code>null</code> means to use codec specified in Redisson configuration
*
* @return codec
*/
Class
<?
extends
Codec
>
codec
()
default
JsonJacksonCodec
.
class
;
Class
<?
extends
Codec
>
codec
()
default
DEFAULT
.
class
;
static
final
class
DEFAULT
extends
BaseCodec
{
@Override
public
Decoder
<
Object
>
getValueDecoder
()
{
return
null
;
}
@Override
public
Encoder
getValueEncoder
()
{
return
null
;
}
}
}
redisson/src/main/java/org/redisson/codec/DefaultReferenceCodecProvider.java
浏览文件 @
d69f4e9b
...
...
@@ -18,6 +18,7 @@ package org.redisson.codec;
import
io.netty.util.internal.PlatformDependent
;
import
java.util.concurrent.ConcurrentMap
;
import
org.redisson.client.codec.Codec
;
import
org.redisson.config.Config
;
import
org.redisson.api.RObject
;
import
org.redisson.api.annotation.REntity
;
import
org.redisson.api.annotation.RObjectField
;
...
...
@@ -33,26 +34,36 @@ public class DefaultReferenceCodecProvider implements ReferenceCodecProvider {
@Override
public
<
T
extends
Codec
>
T
getCodec
(
Class
<
T
>
codecClass
)
{
if
(!
codecCache
.
containsKey
(
codecClass
))
{
Codec
codec
=
codecCache
.
get
(
codecClass
);
if
(
codec
==
null
)
{
try
{
codecCache
.
putIfAbsent
(
codecClass
,
codecClass
.
newInstance
());
codec
=
codecClass
.
newInstance
();
codecCache
.
putIfAbsent
(
codecClass
,
codec
);
}
catch
(
Exception
ex
)
{
throw
new
RuntimeException
(
ex
);
}
}
return
(
T
)
codec
Cache
.
get
(
codecClass
)
;
return
(
T
)
codec
;
}
@Override
public
<
T
extends
Codec
>
T
getCodec
(
REntity
anno
,
Class
<?>
cls
)
{
public
<
T
extends
Codec
>
T
getCodec
(
REntity
anno
,
Class
<?>
cls
,
Config
config
)
{
if
(!
ClassUtils
.
isAnnotationPresent
(
cls
,
anno
.
annotationType
()))
{
throw
new
IllegalArgumentException
(
"Annotation REntity does not present on type ["
+
cls
.
getCanonicalName
()
+
"]"
);
}
return
this
.<
T
>
getCodec
((
Class
<
T
>)
anno
.
codec
());
Class
<?>
codecClass
;
if
(
anno
.
codec
()
==
REntity
.
DEFAULT
.
class
)
{
codecClass
=
config
.
getCodec
().
getClass
();
}
else
{
codecClass
=
anno
.
codec
();
}
return
this
.
getCodec
((
Class
<
T
>)
codecClass
);
}
@Override
public
<
T
extends
Codec
,
K
extends
RObject
>
T
getCodec
(
RObjectField
anno
,
Class
<?>
cls
,
Class
<
K
>
rObjectClass
,
String
fieldName
)
{
public
<
T
extends
Codec
,
K
extends
RObject
>
T
getCodec
(
RObjectField
anno
,
Class
<?>
cls
,
Class
<
K
>
rObjectClass
,
String
fieldName
,
Config
config
)
{
try
{
if
(!
ClassUtils
.
getDeclaredField
(
cls
,
fieldName
).
isAnnotationPresent
(
anno
.
getClass
()))
{
throw
new
IllegalArgumentException
(
"Annotation RObjectField does not present on field "
+
fieldName
+
" of type ["
+
cls
.
getCanonicalName
()
+
"]"
);
...
...
@@ -63,25 +74,17 @@ public class DefaultReferenceCodecProvider implements ReferenceCodecProvider {
if
(
rObjectClass
.
isInterface
())
{
throw
new
IllegalArgumentException
(
"Cannot lookup an interface class of RObject ["
+
rObjectClass
.
getCanonicalName
()
+
"]. Concrete class only."
);
}
return
this
.<
T
>
getCodec
((
Class
<
T
>)
anno
.
codec
());
}
@Override
public
<
T
extends
Codec
,
K
extends
RObject
>
T
getCodec
(
Class
<
T
>
codecClass
,
Class
<
K
>
rObjectClass
)
{
if
(
rObjectClass
.
isInterface
())
{
throw
new
IllegalArgumentException
(
"Cannot lookup an interface class of RObject ["
+
rObjectClass
.
getCanonicalName
()
+
"]. Concrete class only."
);
Class
<?>
codecClass
;
if
(
anno
.
codec
()
==
RObjectField
.
DEFAULT
.
class
)
{
codecClass
=
config
.
getCodec
().
getClass
();
}
else
{
codecClass
=
anno
.
codec
();
}
return
getCodec
(
codecClass
);
return
this
.<
T
>
getCodec
((
Class
<
T
>)
codecClass
);
}
@Override
public
<
T
extends
Codec
,
K
extends
RObject
>
T
getCodec
(
Class
<
T
>
codecClass
,
Class
<
K
>
rObjectClass
,
String
name
)
{
if
(
rObjectClass
.
isInterface
())
{
throw
new
IllegalArgumentException
(
"Cannot lookup an interface class of RObject ["
+
rObjectClass
.
getCanonicalName
()
+
"]. Concrete class only."
);
}
return
getCodec
(
codecClass
,
rObjectClass
);
}
@Override
public
<
T
extends
Codec
>
void
registerCodec
(
Class
<
T
>
cls
,
T
codec
)
{
if
(!
cls
.
isInstance
(
codec
))
{
...
...
redisson/src/main/java/org/redisson/codec/ReferenceCodecProvider.java
浏览文件 @
d69f4e9b
...
...
@@ -16,6 +16,7 @@
package
org.redisson.codec
;
import
org.redisson.client.codec.Codec
;
import
org.redisson.config.Config
;
import
org.redisson.api.RObject
;
import
org.redisson.api.annotation.REntity
;
import
org.redisson.api.annotation.RObjectField
;
...
...
@@ -42,9 +43,11 @@ public interface ReferenceCodecProvider {
* @param <T> the expected codec type.
* @param anno REntity annotation used on the class.
* @param cls The class that has the REntity annotation.
* @param config Redisson config object
*
* @return the cached codec instance.
*/
<
T
extends
Codec
>
T
getCodec
(
REntity
anno
,
Class
<?>
cls
);
<
T
extends
Codec
>
T
getCodec
(
REntity
anno
,
Class
<?>
cls
,
Config
config
);
/**
* Get a codec instance by a RObjectField annotation and the class annotated
...
...
@@ -59,35 +62,11 @@ public interface ReferenceCodecProvider {
* @param rObjectClass the implementation class of RObject the field is going
* to be transformed into.
* @param fieldName the name of the field with this RObjectField annotation.
* @return the cached codec instance.
*/
<
T
extends
Codec
,
K
extends
RObject
>
T
getCodec
(
RObjectField
anno
,
Class
<?>
cls
,
Class
<
K
>
rObjectClass
,
String
fieldName
);
/**
* Get a codec instance by its class, the implementation class of the RObject
* interface.
*
* @param <T> the expected codec type.
* @param <K> the RObject type.
* @param codecClass the codec class used to lookup the codec.
* @param rObjectClass the class of the RObject implementation.
* @return the cached codec instance.
*/
<
T
extends
Codec
,
K
extends
RObject
>
T
getCodec
(
Class
<
T
>
codecClass
,
Class
<
K
>
rObjectClass
);
/**
* Get a codec instance by its class, the implementation class of the RObject
* interface and the name of RObject (the value returned by RObject.getName()
* method).
* @param config Redisson config object
*
* @param <T> the expected codec type.
* @param <K> the RObject type.
* @param codecClass the codec class used to lookup the codec.
* @param rObjectClass the class of the RObject implementation.
* @param name the name of RObject.
* @return the cached codec instance.
*/
<
T
extends
Codec
,
K
extends
RObject
>
T
getCodec
(
Class
<
T
>
codecClass
,
Class
<
K
>
rObjectClass
,
String
name
);
<
T
extends
Codec
,
K
extends
RObject
>
T
getCodec
(
RObjectField
anno
,
Class
<?>
cls
,
Class
<
K
>
rObjectClass
,
String
fieldName
,
Config
config
);
/**
* Register a codec by its class or super class.
...
...
redisson/src/main/java/org/redisson/config/BaseConfig.java
浏览文件 @
d69f4e9b
...
...
@@ -226,12 +226,7 @@ class BaseConfig<T extends BaseConfig<T>> {
return
clientName
;
}
/**
* Ping timeout used in <code>Node.ping</code> and <code>Node.pingAll</code> operation
*
* @param pingTimeout - timeout in milliseconds
* @return config
*/
@Deprecated
public
T
setPingTimeout
(
int
pingTimeout
)
{
this
.
pingTimeout
=
pingTimeout
;
return
(
T
)
this
;
...
...
redisson/src/main/java/org/redisson/liveobject/core/AccessorInterceptor.java
浏览文件 @
d69f4e9b
...
...
@@ -84,7 +84,10 @@ public class AccessorInterceptor {
}
if
(
result
!=
null
&&
fieldType
.
isEnum
())
{
return
Enum
.
valueOf
((
Class
)
fieldType
,
(
String
)
result
);
if
(
result
instanceof
String
)
{
return
Enum
.
valueOf
((
Class
)
fieldType
,
(
String
)
result
);
}
return
result
;
}
if
(
result
instanceof
RedissonReference
)
{
return
RedissonObjectFactory
.
fromReference
(
redisson
,
(
RedissonReference
)
result
);
...
...
@@ -104,7 +107,7 @@ public class AccessorInterceptor {
REntity
anno
=
ClassUtils
.
getAnnotation
(
rEntity
,
REntity
.
class
);
NamingScheme
ns
=
anno
.
namingScheme
()
.
getDeclaredConstructor
(
Codec
.
class
)
.
newInstance
(
redisson
.
getConfig
().
getReferenceCodecProvider
().
getCodec
(
anno
,
(
Class
)
rEntity
));
.
newInstance
(
redisson
.
getConfig
().
getReferenceCodecProvider
().
getCodec
(
anno
,
(
Class
)
rEntity
,
redisson
.
getConfig
()
));
liveMap
.
fastPut
(
fieldName
,
new
RedissonReference
(
rEntity
,
ns
.
getName
(
rEntity
,
fieldType
,
getREntityIdFieldName
(
liveObject
),
liveObject
.
getLiveObjectId
())));
...
...
redisson/src/main/java/org/redisson/liveobject/core/LiveObjectInterceptor.java
浏览文件 @
d69f4e9b
...
...
@@ -16,23 +16,23 @@
package
org.redisson.liveobject.core
;
import
java.lang.reflect.Method
;
import
net.bytebuddy.implementation.bind.annotation.AllArguments
;
import
net.bytebuddy.implementation.bind.annotation.FieldProxy
;
import
net.bytebuddy.implementation.bind.annotation.FieldValue
;
import
net.bytebuddy.implementation.bind.annotation.Origin
;
import
net.bytebuddy.implementation.bind.annotation.RuntimeType
;
import
net.bytebuddy.implementation.bind.annotation.This
;
import
org.redisson.RedissonMap
;
import
org.redisson.client.RedisException
;
import
org.redisson.client.codec.Codec
;
import
org.redisson.api.RMap
;
import
org.redisson.api.RedissonClient
;
import
org.redisson.api.annotation.REntity
;
import
org.redisson.client.RedisException
;
import
org.redisson.client.codec.Codec
;
import
org.redisson.codec.ReferenceCodecProvider
;
import
org.redisson.liveobject.misc.ClassUtils
;
import
org.redisson.liveobject.resolver.NamingScheme
;
import
net.bytebuddy.implementation.bind.annotation.AllArguments
;
import
net.bytebuddy.implementation.bind.annotation.FieldProxy
;
import
net.bytebuddy.implementation.bind.annotation.FieldValue
;
import
net.bytebuddy.implementation.bind.annotation.Origin
;
import
net.bytebuddy.implementation.bind.annotation.RuntimeType
;
import
net.bytebuddy.implementation.bind.annotation.This
;
/**
*
* @author Rui Gu (https://github.com/jackygurui)
...
...
@@ -55,17 +55,19 @@ public class LiveObjectInterceptor {
private
final
String
idFieldName
;
private
final
Class
<?>
idFieldType
;
private
final
NamingScheme
namingScheme
;
private
final
Class
<?
extends
Codec
>
codecClass
;
private
Codec
codec
;
public
LiveObjectInterceptor
(
RedissonClient
redisson
,
Class
<?>
entityClass
,
String
idFieldName
)
{
this
.
redisson
=
redisson
;
this
.
codecProvider
=
redisson
.
getConfig
().
getReferenceCodecProvider
();
this
.
originalClass
=
entityClass
;
this
.
idFieldName
=
idFieldName
;
REntity
anno
=
(
REntity
)
ClassUtils
.
getAnnotation
(
entityClass
,
REntity
.
class
);
this
.
codecClass
=
anno
.
codec
();
REntity
anno
=
ClassUtils
.
getAnnotation
(
entityClass
,
REntity
.
class
);
codec
=
codecProvider
.
getCodec
(
anno
,
entityClass
,
redisson
.
getConfig
());
try
{
this
.
namingScheme
=
anno
.
namingScheme
().
getDeclaredConstructor
(
Codec
.
class
).
newInstance
(
codec
Provider
.
getCodec
(
anno
,
originalClass
)
);
this
.
namingScheme
=
anno
.
namingScheme
().
getDeclaredConstructor
(
Codec
.
class
).
newInstance
(
codec
);
this
.
idFieldType
=
ClassUtils
.
getDeclaredField
(
originalClass
,
idFieldName
).
getType
();
}
catch
(
Exception
e
)
{
throw
new
IllegalArgumentException
(
e
);
...
...
@@ -103,8 +105,7 @@ public class LiveObjectInterceptor {
//key may already renamed by others.
}
}
RMap
<
Object
,
Object
>
liveMap
=
redisson
.
getMap
(
idKey
,
codecProvider
.
getCodec
(
codecClass
,
RedissonMap
.
class
,
idKey
));
RMap
<
Object
,
Object
>
liveMap
=
redisson
.
getMap
(
idKey
,
codec
);
mapSetter
.
setValue
(
liveMap
);
return
null
;
...
...
redisson/src/main/java/org/redisson/liveobject/core/RedissonObjectBuilder.java
浏览文件 @
d69f4e9b
...
...
@@ -122,10 +122,10 @@ public class RedissonObjectBuilder {
Field
field
=
ClassUtils
.
getDeclaredField
(
rEntity
,
fieldName
);
if
(
field
.
isAnnotationPresent
(
RObjectField
.
class
))
{
RObjectField
anno
=
field
.
getAnnotation
(
RObjectField
.
class
);
return
codecProvider
.
getCodec
(
anno
,
rEntity
,
rObjectClass
,
fieldName
);
return
codecProvider
.
getCodec
(
anno
,
rEntity
,
rObjectClass
,
fieldName
,
redisson
.
getConfig
()
);
}
else
{
REntity
anno
=
ClassUtils
.
getAnnotation
(
rEntity
,
REntity
.
class
);
return
codecProvider
.
getCodec
(
anno
,
(
Class
<?>)
rEntity
);
return
codecProvider
.
getCodec
(
anno
,
(
Class
<?>)
rEntity
,
redisson
.
getConfig
()
);
}
}
...
...
redisson/src/main/java/org/redisson/liveobject/resolver/DefaultNamingScheme.java
浏览文件 @
d69f4e9b
...
...
@@ -19,10 +19,8 @@ import java.io.IOException;
import
org.redisson.client.codec.Codec
;
import
org.redisson.client.handler.State
;
import
org.redisson.codec.JsonJacksonCodec
;
import
io.netty.buffer.ByteBuf
;
import
io.netty.buffer.ByteBufAllocator
;
import
io.netty.buffer.ByteBufUtil
;
import
io.netty.buffer.Unpooled
;
...
...
@@ -32,8 +30,6 @@ import io.netty.buffer.Unpooled;
*/
public
class
DefaultNamingScheme
extends
AbstractNamingScheme
implements
NamingScheme
{
public
static
final
DefaultNamingScheme
INSTANCE
=
new
DefaultNamingScheme
(
new
JsonJacksonCodec
());
public
DefaultNamingScheme
(
Codec
codec
)
{
super
(
codec
);
}
...
...
redisson/src/main/java/org/redisson/misc/RedissonObjectFactory.java
浏览文件 @
d69f4e9b
...
...
@@ -112,7 +112,7 @@ public class RedissonObjectFactory {
REntity
anno
=
ClassUtils
.
getAnnotation
(
type
,
REntity
.
class
);
NamingScheme
ns
=
anno
.
namingScheme
()
.
getDeclaredConstructor
(
Codec
.
class
)
.
newInstance
(
codecProvider
.
getCodec
(
anno
,
type
));
.
newInstance
(
codecProvider
.
getCodec
(
anno
,
type
,
redisson
.
getConfig
()
));
Object
id
=
ns
.
resolveId
(
rr
.
getKeyName
());
return
liveObjectService
.
createLiveObject
(
type
,
id
);
}
...
...
@@ -192,7 +192,7 @@ public class RedissonObjectFactory {
REntity
anno
=
ClassUtils
.
getAnnotation
(
rEntity
,
REntity
.
class
);
NamingScheme
ns
=
anno
.
namingScheme
()
.
getDeclaredConstructor
(
Codec
.
class
)
.
newInstance
(
config
.
getReferenceCodecProvider
().
getCodec
(
anno
,
(
Class
)
rEntity
));
.
newInstance
(
config
.
getReferenceCodecProvider
().
getCodec
(
anno
,
(
Class
)
rEntity
,
config
));
String
name
=
Introspectior
.
getFieldsWithAnnotation
(
rEntity
,
RId
.
class
)
.
getOnly
().
getName
();
...
...
redisson/src/main/resources/META-INF/spring.schemas
浏览文件 @
d69f4e9b
http\://redisson.org/schema/redisson/redisson.xsd=org/redisson/spring/support/redisson-1.
2
.xsd
http\://redisson.org/schema/redisson/redisson.xsd=org/redisson/spring/support/redisson-1.
3
.xsd
http\://redisson.org/schema/redisson/redisson-1.0.xsd=org/redisson/spring/support/redisson-1.0.xsd
http\://redisson.org/schema/redisson/redisson-1.1.xsd=org/redisson/spring/support/redisson-1.1.xsd
http\://redisson.org/schema/redisson/redisson-1.2.xsd=org/redisson/spring/support/redisson-1.2.xsd
http\://redisson.org/schema/redisson/redisson-1.3.xsd=org/redisson/spring/support/redisson-1.3.xsd
redisson/src/main/resources/org/redisson/spring/support/redisson-1.3.xsd
0 → 100644
浏览文件 @
d69f4e9b
此差异已折叠。
点击以展开。
redisson/src/test/java/org/redisson/BaseMapTest.java
浏览文件 @
d69f4e9b
...
...
@@ -27,7 +27,10 @@ import org.redisson.api.RedissonClient;
import
org.redisson.api.map.MapLoader
;
import
org.redisson.api.map.MapWriter
;
import
org.redisson.client.codec.Codec
;
import
org.redisson.client.codec.DoubleCodec
;
import
org.redisson.client.codec.IntegerCodec
;
import
org.redisson.client.codec.StringCodec
;
import
org.redisson.codec.CompositeCodec
;
import
org.redisson.codec.JsonJacksonCodec
;
import
org.redisson.config.Config
;
...
...
@@ -441,9 +444,7 @@ public abstract class BaseMapTest extends BaseTest {
@Test
(
timeout
=
5000
)
public
void
testDeserializationErrorReturnsErrorImmediately
()
throws
Exception
{
redisson
.
getConfig
().
setCodec
(
new
JsonJacksonCodec
());
RMap
<
String
,
SimpleObjectWithoutDefaultConstructor
>
map
=
getMap
(
"deserializationFailure"
);
RMap
<
String
,
SimpleObjectWithoutDefaultConstructor
>
map
=
getMap
(
"deserializationFailure"
,
new
JsonJacksonCodec
());
Assume
.
assumeTrue
(!(
map
instanceof
RLocalCachedMap
));
SimpleObjectWithoutDefaultConstructor
object
=
new
SimpleObjectWithoutDefaultConstructor
(
"test-val"
);
...
...
@@ -948,7 +949,7 @@ public abstract class BaseMapTest extends BaseTest {
@Test
public
void
testAddAndGet
()
throws
InterruptedException
{
RMap
<
Integer
,
Integer
>
map
=
getMap
(
"getAll"
);
RMap
<
Integer
,
Integer
>
map
=
getMap
(
"getAll"
,
new
CompositeCodec
(
redisson
.
getConfig
().
getCodec
(),
IntegerCodec
.
INSTANCE
)
);
map
.
put
(
1
,
100
);
Integer
res
=
map
.
addAndGet
(
1
,
12
);
...
...
@@ -956,7 +957,7 @@ public abstract class BaseMapTest extends BaseTest {
res
=
map
.
get
(
1
);
assertThat
(
res
).
isEqualTo
(
112
);
RMap
<
Integer
,
Double
>
map2
=
getMap
(
"getAll2"
);
RMap
<
Integer
,
Double
>
map2
=
getMap
(
"getAll2"
,
new
CompositeCodec
(
redisson
.
getConfig
().
getCodec
(),
DoubleCodec
.
INSTANCE
)
);
map2
.
put
(
1
,
new
Double
(
100.2
));
Double
res2
=
map2
.
addAndGet
(
1
,
new
Double
(
12.1
));
...
...
@@ -964,7 +965,7 @@ public abstract class BaseMapTest extends BaseTest {
res2
=
map2
.
get
(
1
);
assertThat
(
res2
).
isEqualTo
(
112.3
);
RMap
<
String
,
Integer
>
mapStr
=
getMap
(
"mapStr"
);
RMap
<
String
,
Integer
>
mapStr
=
getMap
(
"mapStr"
,
new
CompositeCodec
(
redisson
.
getConfig
().
getCodec
(),
IntegerCodec
.
INSTANCE
)
);
assertThat
(
mapStr
.
put
(
"1"
,
100
)).
isNull
();
assertThat
(
mapStr
.
addAndGet
(
"1"
,
12
)).
isEqualTo
(
112
);
...
...
redisson/src/test/java/org/redisson/RedissonBucketTest.java
浏览文件 @
d69f4e9b
...
...
@@ -8,6 +8,7 @@ import java.util.List;
import
java.util.concurrent.TimeUnit
;
import
org.junit.Assert
;
import
org.junit.Assume
;
import
org.junit.Test
;
import
org.redisson.RedisRunner.FailedToStartRedisException
;
import
org.redisson.RedisRunner.RedisProcess
;
...
...
@@ -19,6 +20,7 @@ public class RedissonBucketTest extends BaseTest {
@Test
public
void
testSizeInMemory
()
{
Assume
.
assumeTrue
(
RedisRunner
.
getDefaultRedisServerInstance
().
getRedisVersion
().
compareTo
(
"4.0.0"
)
>
0
);
RBucket
<
Integer
>
al
=
redisson
.
getBucket
(
"test"
);
al
.
set
(
1234
);
assertThat
(
al
.
sizeInMemory
()).
isEqualTo
(
55
);
...
...
redisson/src/test/java/org/redisson/RedissonLiveObjectServiceTest.java
浏览文件 @
d69f4e9b
...
...
@@ -319,16 +319,17 @@ public class RedissonLiveObjectServiceTest extends BaseTest {
t
=
s
.
persist
(
t
);
assertEquals
(
"1"
,
t
.
getName
());
assertTrue
(
redisson
.
getMap
(
DefaultNamingScheme
.
INSTANCE
.
getName
(
TestREntity
.
class
,
String
.
class
,
"name"
,
"1"
)).
isExists
());
DefaultNamingScheme
scheme
=
new
DefaultNamingScheme
(
redisson
.
getConfig
().
getCodec
());
assertTrue
(
redisson
.
getMap
(
scheme
.
getName
(
TestREntity
.
class
,
String
.
class
,
"name"
,
"1"
)).
isExists
());
t
.
setName
(
"3333"
);
assertEquals
(
"3333"
,
t
.
getName
());
assertTrue
(
redisson
.
getMap
(
DefaultNamingScheme
.
INSTANCE
.
getName
(
TestREntity
.
class
,
String
.
class
,
"name"
,
"3333"
)).
isExists
());
assertTrue
(
redisson
.
getMap
(
scheme
.
getName
(
TestREntity
.
class
,
String
.
class
,
"name"
,
"3333"
)).
isExists
());
t
.
setValue
(
"111"
);
assertEquals
(
"111"
,
t
.
getValue
());
assertTrue
(
redisson
.
getMap
(
DefaultNamingScheme
.
INSTANCE
.
getName
(
TestREntity
.
class
,
String
.
class
,
"name"
,
"3333"
)).
isExists
());
assertTrue
(!
redisson
.
getMap
(
DefaultNamingScheme
.
INSTANCE
.
getName
(
TestREntity
.
class
,
String
.
class
,
"name"
,
"1"
)).
isExists
());
assertEquals
(
"111"
,
redisson
.
getMap
(
DefaultNamingScheme
.
INSTANCE
.
getName
(
TestREntity
.
class
,
String
.
class
,
"name"
,
"3333"
)).
get
(
"value"
));
assertTrue
(
redisson
.
getMap
(
scheme
.
getName
(
TestREntity
.
class
,
String
.
class
,
"name"
,
"3333"
)).
isExists
());
assertTrue
(!
redisson
.
getMap
(
scheme
.
getName
(
TestREntity
.
class
,
String
.
class
,
"name"
,
"1"
)).
isExists
());
assertEquals
(
"111"
,
redisson
.
getMap
(
scheme
.
getName
(
TestREntity
.
class
,
String
.
class
,
"name"
,
"3333"
)).
get
(
"value"
));
// ((RLiveObject) t).getLiveObjectLiveMap().put("value", "555");
// assertEquals("555", redisson.getMap(REntity.DefaultNamingScheme.INSTANCE.getName(TestREntity.class, "name", "3333")).get("value"));
...
...
redisson/src/test/java/org/redisson/RedissonLocalCachedMapTest.java
浏览文件 @
d69f4e9b
...
...
@@ -21,7 +21,10 @@ import org.redisson.api.RMap;
import
org.redisson.cache.Cache
;
import
org.redisson.cache.CacheKey
;
import
org.redisson.client.codec.Codec
;
import
org.redisson.client.codec.DoubleCodec
;
import
org.redisson.client.codec.IntegerCodec
;
import
org.redisson.client.codec.StringCodec
;
import
org.redisson.codec.CompositeCodec
;
import
mockit.Deencapsulation
;
...
...
@@ -538,7 +541,7 @@ public class RedissonLocalCachedMapTest extends BaseMapTest {
@Test
public
void
testAddAndGet
()
throws
InterruptedException
{
RMap
<
Integer
,
Integer
>
map
=
redisson
.
getLocalCachedMap
(
"getAll"
,
LocalCachedMapOptions
.
defaults
());
RMap
<
Integer
,
Integer
>
map
=
redisson
.
getLocalCachedMap
(
"getAll"
,
new
CompositeCodec
(
redisson
.
getConfig
().
getCodec
(),
IntegerCodec
.
INSTANCE
),
LocalCachedMapOptions
.
defaults
());
Cache
<
CacheKey
,
CacheValue
>
cache
=
Deencapsulation
.
getField
(
map
,
"cache"
);
map
.
put
(
1
,
100
);
...
...
@@ -548,7 +551,7 @@ public class RedissonLocalCachedMapTest extends BaseMapTest {
res
=
map
.
get
(
1
);
assertThat
(
res
).
isEqualTo
(
112
);
RMap
<
Integer
,
Double
>
map2
=
redisson
.
getLocalCachedMap
(
"getAll2"
,
LocalCachedMapOptions
.
defaults
());
RMap
<
Integer
,
Double
>
map2
=
redisson
.
getLocalCachedMap
(
"getAll2"
,
new
CompositeCodec
(
redisson
.
getConfig
().
getCodec
(),
DoubleCodec
.
INSTANCE
),
LocalCachedMapOptions
.
defaults
());
map2
.
put
(
1
,
new
Double
(
100.2
));
Double
res2
=
map2
.
addAndGet
(
1
,
new
Double
(
12.1
));
...
...
@@ -556,7 +559,7 @@ public class RedissonLocalCachedMapTest extends BaseMapTest {
res2
=
map2
.
get
(
1
);
assertThat
(
res2
).
isEqualTo
(
112.3
);
RMap
<
String
,
Integer
>
mapStr
=
redisson
.
getLocalCachedMap
(
"mapStr"
,
LocalCachedMapOptions
.
defaults
());
RMap
<
String
,
Integer
>
mapStr
=
redisson
.
getLocalCachedMap
(
"mapStr"
,
new
CompositeCodec
(
redisson
.
getConfig
().
getCodec
(),
IntegerCodec
.
INSTANCE
),
LocalCachedMapOptions
.
defaults
());
assertThat
(
mapStr
.
put
(
"1"
,
100
)).
isNull
();
assertThat
(
mapStr
.
addAndGet
(
"1"
,
12
)).
isEqualTo
(
112
);
...
...
redisson/src/test/java/org/redisson/RedissonMapCacheTest.java
浏览文件 @
d69f4e9b
...
...
@@ -18,6 +18,7 @@ import java.util.function.Consumer;
import
org.awaitility.Duration
;
import
org.junit.Assert
;
import
org.junit.Assume
;
import
org.junit.Test
;
import
org.redisson.api.MapOptions
;
import
org.redisson.api.RMap
;
...
...
@@ -29,8 +30,10 @@ import org.redisson.api.map.event.EntryRemovedListener;
import
org.redisson.api.map.event.EntryUpdatedListener
;
import
org.redisson.client.codec.Codec
;
import
org.redisson.client.codec.DoubleCodec
;
import
org.redisson.client.codec.IntegerCodec
;
import
org.redisson.client.codec.LongCodec
;
import
org.redisson.client.codec.StringCodec
;
import
org.redisson.codec.CompositeCodec
;
import
org.redisson.eviction.EvictionScheduler
;
import
mockit.Deencapsulation
;
...
...
@@ -72,6 +75,8 @@ public class RedissonMapCacheTest extends BaseMapTest {
@Test
public
void
testSizeInMemory
()
{
Assume
.
assumeTrue
(
RedisRunner
.
getDefaultRedisServerInstance
().
getRedisVersion
().
compareTo
(
"4.0.0"
)
>
0
);
RMapCache
<
Integer
,
Integer
>
map
=
redisson
.
getMapCache
(
"test"
);
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
map
.
put
(
i
,
i
,
5
,
TimeUnit
.
SECONDS
);
...
...
@@ -769,8 +774,11 @@ public class RedissonMapCacheTest extends BaseMapTest {
checkCreatedListener
(
map
,
14
,
2
,
()
->
map
.
putIfAbsent
(
14
,
2
,
2
,
TimeUnit
.
SECONDS
));
checkCreatedListener
(
map
,
4
,
1
,
()
->
map
.
fastPutIfAbsent
(
4
,
1
));
checkCreatedListener
(
map
,
15
,
2
,
()
->
map
.
fastPutIfAbsent
(
15
,
2
,
2
,
TimeUnit
.
SECONDS
));
checkCreatedListener
(
map
,
5
,
0
,
()
->
map
.
addAndGet
(
5
,
0
));
map
.
destroy
();
RMapCache
<
Integer
,
Integer
>
map2
=
redisson
.
getMapCache
(
"simple3"
,
new
CompositeCodec
(
redisson
.
getConfig
().
getCodec
(),
IntegerCodec
.
INSTANCE
));
checkCreatedListener
(
map2
,
5
,
10
,
()
->
map2
.
addAndGet
(
5
,
10
));
map2
.
destroy
();
}
private
void
checkCreatedListener
(
RMapCache
<
Integer
,
Integer
>
map
,
Integer
key
,
Integer
value
,
Runnable
runnable
)
{
...
...
@@ -779,11 +787,15 @@ public class RedissonMapCacheTest extends BaseMapTest {
@Override
public
void
onCreated
(
EntryEvent
<
Integer
,
Integer
>
event
)
{
assertThat
(
event
.
getKey
()).
isEqualTo
(
key
);
assertThat
(
event
.
getValue
()).
isEqualTo
(
value
);
if
(!
ref
.
compareAndSet
(
false
,
true
))
{
Assert
.
fail
();
try
{
assertThat
(
event
.
getKey
()).
isEqualTo
(
key
);
assertThat
(
event
.
getValue
()).
isEqualTo
(
value
);
if
(!
ref
.
compareAndSet
(
false
,
true
))
{
Assert
.
fail
();
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
...
...
@@ -814,10 +826,12 @@ public class RedissonMapCacheTest extends BaseMapTest {
map
.
put
(
14
,
1
);
checkUpdatedListener
(
map
,
14
,
2
,
1
,
()
->
map
.
replace
(
14
,
2
));
checkUpdatedListener
(
map
,
14
,
3
,
2
,
()
->
map
.
replace
(
14
,
2
,
3
));
map
.
put
(
5
,
1
);
checkUpdatedListener
(
map
,
5
,
4
,
1
,
()
->
map
.
addAndGet
(
5
,
3
));
map
.
destroy
();
RMapCache
<
Integer
,
Integer
>
map2
=
redisson
.
getMapCache
(
"simple2"
,
new
CompositeCodec
(
redisson
.
getConfig
().
getCodec
(),
IntegerCodec
.
INSTANCE
));
map2
.
put
(
5
,
1
);
checkUpdatedListener
(
map2
,
5
,
4
,
1
,
()
->
map2
.
addAndGet
(
5
,
3
));
map2
.
destroy
();
}
...
...
redisson/src/test/java/org/redisson/RedissonMapReactiveTest.java
浏览文件 @
d69f4e9b
...
...
@@ -16,6 +16,9 @@ import java.util.concurrent.ExecutionException;
import
org.junit.Assert
;
import
org.junit.Test
;
import
org.redisson.api.RMapReactive
;
import
org.redisson.client.codec.DoubleCodec
;
import
org.redisson.client.codec.IntegerCodec
;
import
org.redisson.codec.CompositeCodec
;
public
class
RedissonMapReactiveTest
extends
BaseReactiveTest
{
...
...
@@ -149,7 +152,7 @@ public class RedissonMapReactiveTest extends BaseReactiveTest {
@Test
public
void
testAddAndGet
()
throws
InterruptedException
{
RMapReactive
<
Integer
,
Integer
>
map
=
redisson
.
getMap
(
"getAll"
);
RMapReactive
<
Integer
,
Integer
>
map
=
redisson
.
getMap
(
"getAll"
,
new
CompositeCodec
(
redisson
.
getConfig
().
getCodec
(),
IntegerCodec
.
INSTANCE
)
);
sync
(
map
.
put
(
1
,
100
));
Integer
res
=
sync
(
map
.
addAndGet
(
1
,
12
));
...
...
@@ -157,7 +160,7 @@ public class RedissonMapReactiveTest extends BaseReactiveTest {
res
=
sync
(
map
.
get
(
1
));
Assert
.
assertEquals
(
112
,
(
int
)
res
);
RMapReactive
<
Integer
,
Double
>
map2
=
redisson
.
getMap
(
"getAll2"
);
RMapReactive
<
Integer
,
Double
>
map2
=
redisson
.
getMap
(
"getAll2"
,
new
CompositeCodec
(
redisson
.
getConfig
().
getCodec
(),
DoubleCodec
.
INSTANCE
)
);
sync
(
map2
.
put
(
1
,
new
Double
(
100.2
)));
Double
res2
=
sync
(
map2
.
addAndGet
(
1
,
new
Double
(
12.1
)));
...
...
@@ -165,7 +168,7 @@ public class RedissonMapReactiveTest extends BaseReactiveTest {
res2
=
sync
(
map2
.
get
(
1
));
Assert
.
assertTrue
(
new
Double
(
112.3
).
compareTo
(
res2
)
==
0
);
RMapReactive
<
String
,
Integer
>
mapStr
=
redisson
.
getMap
(
"mapStr"
);
RMapReactive
<
String
,
Integer
>
mapStr
=
redisson
.
getMap
(
"mapStr"
,
new
CompositeCodec
(
redisson
.
getConfig
().
getCodec
(),
IntegerCodec
.
INSTANCE
)
);
assertThat
(
sync
(
mapStr
.
put
(
"1"
,
100
))).
isNull
();
assertThat
(
sync
(
mapStr
.
addAndGet
(
"1"
,
12
))).
isEqualTo
(
112
);
...
...
redisson/src/test/java/org/redisson/RedissonPriorityBlockingDequeTest.java
浏览文件 @
d69f4e9b
...
...
@@ -102,7 +102,7 @@ public class RedissonPriorityBlockingDequeTest extends BaseTest {
long
s
=
System
.
currentTimeMillis
();
assertThat
(
queue1
.
pollFirst
(
5
,
TimeUnit
.
SECONDS
)).
isNull
();
assertThat
(
System
.
currentTimeMillis
()
-
s
).
isGreaterThan
(
50
00
);
assertThat
(
System
.
currentTimeMillis
()
-
s
).
isGreaterThan
(
49
00
);
}
@Test
...
...
redisson/src/test/java/org/redisson/RedissonRuntimeEnvironment.java
浏览文件 @
d69f4e9b
...
...
@@ -9,7 +9,7 @@ import java.util.Locale;
public
class
RedissonRuntimeEnvironment
{
public
static
final
boolean
isTravis
=
"true"
.
equalsIgnoreCase
(
System
.
getProperty
(
"travisEnv"
));
public
static
final
String
redisBinaryPath
=
System
.
getProperty
(
"redisBinary"
,
"C:\\Devel\\projects\\redis\\
redis-x64-4.0.2.2
\\redis-server.exe"
);
public
static
final
String
redisBinaryPath
=
System
.
getProperty
(
"redisBinary"
,
"C:\\Devel\\projects\\redis\\
Redis-x64-3.2.100
\\redis-server.exe"
);
public
static
final
String
tempDir
=
System
.
getProperty
(
"java.io.tmpdir"
);
public
static
final
String
OS
;
public
static
final
boolean
isWindows
;
...
...
redisson/src/test/java/org/redisson/RedissonScriptReactiveTest.java
浏览文件 @
d69f4e9b
...
...
@@ -9,15 +9,17 @@ import org.junit.Assert;
import
org.junit.Test
;
import
org.redisson.api.RScript
;
import
org.redisson.api.RScriptReactive
;
import
org.redisson.api.RScriptRx
;
import
org.redisson.client.RedisException
;
import
org.redisson.client.codec.StringCodec
;
public
class
RedissonScriptReactiveTest
extends
BaseReactiveTest
{
@Test
public
void
testEval
()
{
RScriptReactive
script
=
redisson
.
getScript
();
List
<
Object
>
res
=
sync
(
script
.
<
List
<
Object
>>
eval
(
RScript
.
Mode
.
READ_ONLY
,
"return {1,2,3.3333,'\"foo\"
',nil,'bar'}"
,
RScript
.
ReturnType
.
MULTI
,
Collections
.
emptyList
()));
assertThat
(
res
).
containsExactly
(
1L
,
2L
,
3L
,
"foo"
);
RScriptReactive
script
=
redisson
.
getScript
(
StringCodec
.
INSTANCE
);
List
<
Object
>
res
=
sync
(
script
.
eval
(
RScript
.
Mode
.
READ_ONLY
,
"return {'1','2','3.3333','foo
',nil,'bar'}"
,
RScript
.
ReturnType
.
MULTI
,
Collections
.
emptyList
()));
assertThat
(
res
).
containsExactly
(
"1"
,
"2"
,
"3.3333"
,
"foo"
);
}
@Test
...
...
redisson/src/test/java/org/redisson/RedissonScriptTest.java
浏览文件 @
d69f4e9b
...
...
@@ -31,7 +31,6 @@ public class RedissonScriptTest extends BaseTest {
l
=
l
+
1
;
}
StringCodec
codec
=
new
StringCodec
();
String
max
=
"'[DENY"
+
"\t"
+
"TESTREDISSON"
+
"\t"
+
"1506524856099'"
;
String
min
=
"'[DENY"
+
"\t"
+
"TESTREDISSON"
+
"\t"
+
"1506524856000'"
;
String
luaScript1
=
"local d = {}; d[1] = redis.call('zrevrangebylex','ABCD17436',"
+
max
+
","
+
min
+
",'LIMIT',0,5); "
;
...
...
@@ -39,15 +38,14 @@ public class RedissonScriptTest extends BaseTest {
luaScript1
=
luaScript1
+
" d[3] = redis.call('zrevrangebylex','ABCD17436',"
+
max
+
","
+
min
+
",'LIMIT',0,25); "
;
luaScript1
=
luaScript1
+
" return d;"
;
Future
<
Object
>
r1
=
redisson
.
getScript
().
evalAsync
(
RScript
.
Mode
.
READ_ONLY
,
codec
,
List
<
List
<
Object
>>
objs
=
redisson
.
getScript
(
StringCodec
.
INSTANCE
).
eval
(
RScript
.
Mode
.
READ_ONLY
,
luaScript1
,
RScript
.
ReturnType
.
MULTI
,
Collections
.
emptyList
());
List
<
List
<
Object
>>
obj1
=
(
List
<
List
<
Object
>>)
r1
.
get
();
assertThat
(
obj
1
).
hasSize
(
3
);
assertThat
(
obj
1
.
get
(
0
)).
hasSize
(
5
);
assertThat
(
obj
1
.
get
(
1
)).
hasSize
(
15
);
assertThat
(
obj
1
.
get
(
2
)).
hasSize
(
25
);
assertThat
(
obj
s
).
hasSize
(
3
);
assertThat
(
obj
s
.
get
(
0
)).
hasSize
(
5
);
assertThat
(
obj
s
.
get
(
1
)).
hasSize
(
15
);
assertThat
(
obj
s
.
get
(
2
)).
hasSize
(
25
);
}
@Test
...
...
redisson/src/test/java/org/redisson/RedissonTest.java
浏览文件 @
d69f4e9b
...
...
@@ -433,7 +433,7 @@ public class RedissonTest {
System
.
out
.
println
(
"master "
+
master
.
getRedisServerAddressAndPort
()
+
" has been stopped!"
);
Thread
.
sleep
(
TimeUnit
.
SECONDS
.
toMillis
(
2
0
));
Thread
.
sleep
(
TimeUnit
.
SECONDS
.
toMillis
(
3
0
));
RedisProcess
newMaster
=
null
;
Collection
<
ClusterNode
>
newMasterNodes
=
redisson
.
getClusterNodesGroup
().
getNodes
(
NodeType
.
MASTER
);
...
...
redisson/src/test/java/org/redisson/RedissonTopicPatternTest.java
浏览文件 @
d69f4e9b
...
...
@@ -3,6 +3,7 @@ package org.redisson;
import
static
org
.
awaitility
.
Awaitility
.
await
;
import
java.io.IOException
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.concurrent.CountDownLatch
;
...
...
@@ -28,7 +29,7 @@ import org.redisson.config.Config;
public
class
RedissonTopicPatternTest
extends
BaseTest
{
public
static
class
Message
{
public
static
class
Message
implements
Serializable
{
private
String
name
;
...
...
redisson/src/test/java/org/redisson/RedissonTopicTest.java
浏览文件 @
d69f4e9b
...
...
@@ -18,6 +18,7 @@ import java.util.concurrent.Future;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.atomic.AtomicBoolean
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.concurrent.atomic.AtomicLong
;
import
org.awaitility.Duration
;
import
org.junit.After
;
...
...
@@ -151,7 +152,9 @@ public class RedissonTopicTest {
CountDownLatch
latch
=
new
CountDownLatch
(
count
);
RTopic
eventsTopic
=
redisson
.
getTopic
(
"eventsTopic"
);
AtomicInteger
co
=
new
AtomicInteger
();
eventsTopic
.
addListener
(
String
.
class
,
(
channel
,
msg
)
->
{
co
.
incrementAndGet
();
latch
.
countDown
();
});
...
...
@@ -161,7 +164,7 @@ public class RedissonTopicTest {
Thread
.
sleep
(
10
);
}
assertThat
(
latch
.
await
(
3
0
,
TimeUnit
.
SECONDS
)).
isTrue
();
assertThat
(
latch
.
await
(
4
0
,
TimeUnit
.
SECONDS
)).
isTrue
();
redisson
.
shutdown
();
}
...
...
@@ -201,7 +204,7 @@ public class RedissonTopicTest {
futures
.
add
(
s
);
}
executor
.
shutdown
();
Assert
.
assertTrue
(
executor
.
awaitTermination
(
threads
*
loops
*
10
00
,
TimeUnit
.
SECONDS
));
Assert
.
assertTrue
(
executor
.
awaitTermination
(
1
00
,
TimeUnit
.
SECONDS
));
for
(
Future
<?>
future
:
futures
)
{
future
.
get
();
...
...
@@ -561,18 +564,17 @@ public class RedissonTopicTest {
redisson2
.
shutdown
();
}
volatile
long
counter
;
@Test
public
void
testHeavyLoad
()
throws
InterruptedException
{
final
CountDownLatch
messageRecieved
=
new
CountDownLatch
(
1000
);
AtomicLong
counter
=
new
AtomicLong
();
RedissonClient
redisson1
=
BaseTest
.
createInstance
();
RTopic
topic1
=
redisson1
.
getTopic
(
"topic"
);
topic1
.
addListener
(
Message
.
class
,
(
channel
,
msg
)
->
{
Assert
.
assertEquals
(
new
Message
(
"123"
),
msg
);
messageRecieved
.
countDown
();
counter
++
;
counter
.
incrementAndGet
()
;
});
RedissonClient
redisson2
=
BaseTest
.
createInstance
();
...
...
@@ -582,7 +584,8 @@ public class RedissonTopicTest {
messageRecieved
.
countDown
();
});
for
(
int
i
=
0
;
i
<
5000
;
i
++)
{
int
count
=
10000
;
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
topic2
.
publish
(
new
Message
(
"123"
));
}
...
...
@@ -590,7 +593,7 @@ public class RedissonTopicTest {
Thread
.
sleep
(
1000
);
Assert
.
assertEquals
(
5000
,
counter
);
Assert
.
assertEquals
(
count
,
counter
.
get
()
);
redisson1
.
shutdown
();
redisson2
.
shutdown
();
...
...
redisson/src/test/java/org/redisson/executor/FailoverTask.java
浏览文件 @
d69f4e9b
package
org.redisson.executor
;
import
java.io.Serializable
;
import
org.redisson.api.RedissonClient
;
import
org.redisson.api.annotation.RInject
;
public
class
FailoverTask
implements
Runnable
{
public
class
FailoverTask
implements
Runnable
,
Serializable
{
@RInject
private
RedissonClient
redisson
;
...
...
redisson/src/test/java/org/redisson/executor/RedissonExecutorServiceTest.java
浏览文件 @
d69f4e9b
...
...
@@ -442,7 +442,7 @@ public class RedissonExecutorServiceTest extends BaseTest {
}
@Test
public
void
testResetShutdownState
()
throws
InterruptedException
,
ExecutionException
{
public
void
testResetShutdownState
()
throws
InterruptedException
,
ExecutionException
,
TimeoutException
{
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
RExecutorService
e
=
redisson
.
getExecutorService
(
"test"
);
e
.
execute
(
new
RunnableTask
());
...
...
@@ -455,7 +455,7 @@ public class RedissonExecutorServiceTest extends BaseTest {
assertThat
(
e
.
isShutdown
()).
isFalse
();
assertThat
(
e
.
isTerminated
()).
isFalse
();
Future
<?>
future
=
e
.
submit
(
new
RunnableTask
());
future
.
get
();
future
.
get
(
30
,
TimeUnit
.
SECONDS
);
}
}
...
...
redisson/src/test/java/org/redisson/executor/RedissonScheduledExecutorServiceTest.java
浏览文件 @
d69f4e9b
...
...
@@ -3,6 +3,7 @@ package org.redisson.executor;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
java.io.IOException
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
...
...
@@ -58,7 +59,7 @@ public class RedissonScheduledExecutorServiceTest extends BaseTest {
node
.
shutdown
();
}
public
static
class
TestTask
implements
Runnable
{
public
static
class
TestTask
implements
Runnable
,
Serializable
{
@RInject
RedissonClient
redisson
;
...
...
redisson/src/test/java/org/redisson/executor/ScheduledCallableTask.java
浏览文件 @
d69f4e9b
package
org.redisson.executor
;
import
java.io.Serializable
;
import
java.util.concurrent.Callable
;
public
class
ScheduledCallableTask
implements
Callable
<
Long
>
{
public
class
ScheduledCallableTask
implements
Callable
<
Long
>
,
Serializable
{
@Override
public
Long
call
()
throws
Exception
{
...
...
redisson/src/test/java/org/redisson/executor/ScheduledLongRepeatableTask.java
浏览文件 @
d69f4e9b
package
org.redisson.executor
;
import
java.io.Serializable
;
import
org.redisson.api.RedissonClient
;
import
org.redisson.api.annotation.RInject
;
public
class
ScheduledLongRepeatableTask
implements
Runnable
{
public
class
ScheduledLongRepeatableTask
implements
Runnable
,
Serializable
{
@RInject
private
RedissonClient
redisson
;
...
...
redisson/src/test/java/org/redisson/executor/ScheduledRunnableTask.java
浏览文件 @
d69f4e9b
package
org.redisson.executor
;
import
java.io.Serializable
;
import
org.redisson.api.RedissonClient
;
import
org.redisson.api.annotation.RInject
;
public
class
ScheduledRunnableTask
implements
Runnable
{
public
class
ScheduledRunnableTask
implements
Runnable
,
Serializable
{
@RInject
private
RedissonClient
redisson
;
...
...
redisson/src/test/java/org/redisson/rx/RedissonListRxTest.java
浏览文件 @
d69f4e9b
...
...
@@ -17,16 +17,6 @@ import reactor.core.publisher.BaseSubscriber;
public
class
RedissonListRxTest
extends
BaseRxTest
{
@Test
public
void
testHashCode
()
throws
InterruptedException
{
RListRx
<
String
>
list
=
redisson
.
getList
(
"list"
);
sync
(
list
.
add
(
"a"
));
sync
(
list
.
add
(
"b"
));
sync
(
list
.
add
(
"c"
));
Assert
.
assertEquals
(
126145
,
list
.
hashCode
());
}
@Test
public
void
testAddByIndex
()
{
RListRx
<
String
>
test2
=
redisson
.
getList
(
"test2"
);
...
...
redisson/src/test/java/org/redisson/rx/RedissonMapCacheRxTest.java
浏览文件 @
d69f4e9b
...
...
@@ -409,20 +409,4 @@ public class RedissonMapCacheRxTest extends BaseRxTest {
Assert
.
assertEquals
(
0
,
values
.
size
());
}
@Test
public
void
testEquals
()
{
RMapCacheRx
<
String
,
String
>
map
=
redisson
.
getMapCache
(
"simple"
);
sync
(
map
.
put
(
"1"
,
"7"
));
sync
(
map
.
put
(
"2"
,
"4"
));
sync
(
map
.
put
(
"3"
,
"5"
));
Map
<
String
,
String
>
testMap
=
new
HashMap
<
String
,
String
>();
testMap
.
put
(
"1"
,
"7"
);
testMap
.
put
(
"2"
,
"4"
);
testMap
.
put
(
"3"
,
"5"
);
Assert
.
assertEquals
(
map
,
testMap
);
Assert
.
assertEquals
(
testMap
.
hashCode
(),
map
.
hashCode
());
}
}
redisson/src/test/java/org/redisson/rx/RedissonMapRxTest.java
浏览文件 @
d69f4e9b
...
...
@@ -15,6 +15,9 @@ import java.util.concurrent.ExecutionException;
import
org.junit.Assert
;
import
org.junit.Test
;
import
org.redisson.api.RMapRx
;
import
org.redisson.client.codec.DoubleCodec
;
import
org.redisson.client.codec.IntegerCodec
;
import
org.redisson.codec.CompositeCodec
;
public
class
RedissonMapRxTest
extends
BaseRxTest
{
...
...
@@ -122,7 +125,7 @@ public class RedissonMapRxTest extends BaseRxTest {
@Test
public
void
testAddAndGet
()
throws
InterruptedException
{
RMapRx
<
Integer
,
Integer
>
map
=
redisson
.
getMap
(
"getAll"
);
RMapRx
<
Integer
,
Integer
>
map
=
redisson
.
getMap
(
"getAll"
,
new
CompositeCodec
(
redisson
.
getConfig
().
getCodec
(),
IntegerCodec
.
INSTANCE
)
);
sync
(
map
.
put
(
1
,
100
));
Integer
res
=
sync
(
map
.
addAndGet
(
1
,
12
));
...
...
@@ -130,7 +133,7 @@ public class RedissonMapRxTest extends BaseRxTest {
res
=
sync
(
map
.
get
(
1
));
Assert
.
assertEquals
(
112
,
(
int
)
res
);
RMapRx
<
Integer
,
Double
>
map2
=
redisson
.
getMap
(
"getAll2"
);
RMapRx
<
Integer
,
Double
>
map2
=
redisson
.
getMap
(
"getAll2"
,
new
CompositeCodec
(
redisson
.
getConfig
().
getCodec
(),
DoubleCodec
.
INSTANCE
)
);
sync
(
map2
.
put
(
1
,
new
Double
(
100.2
)));
Double
res2
=
sync
(
map2
.
addAndGet
(
1
,
new
Double
(
12.1
)));
...
...
@@ -138,7 +141,7 @@ public class RedissonMapRxTest extends BaseRxTest {
res2
=
sync
(
map2
.
get
(
1
));
Assert
.
assertTrue
(
new
Double
(
112.3
).
compareTo
(
res2
)
==
0
);
RMapRx
<
String
,
Integer
>
mapStr
=
redisson
.
getMap
(
"mapStr"
);
RMapRx
<
String
,
Integer
>
mapStr
=
redisson
.
getMap
(
"mapStr"
,
new
CompositeCodec
(
redisson
.
getConfig
().
getCodec
(),
IntegerCodec
.
INSTANCE
)
);
assertThat
(
sync
(
mapStr
.
put
(
"1"
,
100
))).
isNull
();
assertThat
(
sync
(
mapStr
.
addAndGet
(
"1"
,
12
))).
isEqualTo
(
112
);
...
...
@@ -229,23 +232,6 @@ public class RedissonMapRxTest extends BaseRxTest {
Assert
.
assertEquals
(
1
,
sync
(
map
.
size
()).
intValue
());
}
@Test
public
void
testEquals
()
{
RMapRx
<
String
,
String
>
map
=
redisson
.
getMap
(
"simple"
);
sync
(
map
.
put
(
"1"
,
"7"
));
sync
(
map
.
put
(
"2"
,
"4"
));
sync
(
map
.
put
(
"3"
,
"5"
));
Map
<
String
,
String
>
testMap
=
new
HashMap
<
String
,
String
>();
testMap
.
put
(
"1"
,
"7"
);
testMap
.
put
(
"2"
,
"4"
);
testMap
.
put
(
"3"
,
"5"
);
Assert
.
assertEquals
(
map
,
testMap
);
Assert
.
assertEquals
(
map
.
hashCode
(),
testMap
.
hashCode
());
}
@Test
public
void
testPutAll
()
{
RMapRx
<
Integer
,
String
>
map
=
redisson
.
getMap
(
"simple"
);
...
...
redisson/src/test/java/org/redisson/rx/RedissonScriptRxTest.java
浏览文件 @
d69f4e9b
...
...
@@ -10,14 +10,15 @@ import org.junit.Test;
import
org.redisson.api.RScript
;
import
org.redisson.api.RScriptRx
;
import
org.redisson.client.RedisException
;
import
org.redisson.client.codec.StringCodec
;
public
class
RedissonScriptRxTest
extends
BaseRxTest
{
@Test
public
void
testEval
()
{
RScriptRx
script
=
redisson
.
getScript
();
List
<
Object
>
res
=
sync
(
script
.
<
List
<
Object
>>
eval
(
RScript
.
Mode
.
READ_ONLY
,
"return {1,2,3.3333,'\"foo\"
',nil,'bar'}"
,
RScript
.
ReturnType
.
MULTI
,
Collections
.
emptyList
()));
assertThat
(
res
).
containsExactly
(
1L
,
2L
,
3L
,
"foo"
);
RScriptRx
script
=
redisson
.
getScript
(
StringCodec
.
INSTANCE
);
List
<
Object
>
res
=
sync
(
script
.
eval
(
RScript
.
Mode
.
READ_ONLY
,
"return {'1','2','3.3333','foo
',nil,'bar'}"
,
RScript
.
ReturnType
.
MULTI
,
Collections
.
emptyList
()));
assertThat
(
res
).
containsExactly
(
"1"
,
"2"
,
"3.3333"
,
"foo"
);
}
@Test
...
...
redisson/src/test/java/org/redisson/spring/cache/RedissonSpringCacheShortTTLTest.java
浏览文件 @
d69f4e9b
...
...
@@ -3,6 +3,7 @@ package org.redisson.spring.cache;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
java.io.IOException
;
import
java.io.Serializable
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.Map
;
...
...
@@ -32,7 +33,7 @@ import org.springframework.stereotype.Service;
@RunWith
(
Parameterized
.
class
)
public
class
RedissonSpringCacheShortTTLTest
{
public
static
class
SampleObject
{
public
static
class
SampleObject
implements
Serializable
{
private
String
name
;
private
String
value
;
...
...
redisson/src/test/java/org/redisson/spring/cache/RedissonSpringCacheTest.java
浏览文件 @
d69f4e9b
...
...
@@ -3,6 +3,7 @@ package org.redisson.spring.cache;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
java.io.IOException
;
import
java.io.Serializable
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.Map
;
...
...
@@ -33,7 +34,7 @@ import org.springframework.stereotype.Service;
@RunWith
(
Parameterized
.
class
)
public
class
RedissonSpringCacheTest
{
public
static
class
SampleObject
{
public
static
class
SampleObject
implements
Serializable
{
private
String
name
;
private
String
value
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录