cn.cyejing:dsync-common

分布式锁,基于Netty长连接实现,自定义协议,高性能锁

License

License

GroupId

GroupId

cn.cyejing
ArtifactId

ArtifactId

dsync-common
Last Version

Last Version

0.1.3
Release Date

Release Date

Type

Type

jar
Description

Description

分布式锁,基于Netty长连接实现,自定义协议,高性能锁

Download dsync-common

How to add to project

<!-- https://jarcasting.com/artifacts/cn.cyejing/dsync-common/ -->
<dependency>
    <groupId>cn.cyejing</groupId>
    <artifactId>dsync-common</artifactId>
    <version>0.1.3</version>
</dependency>
// https://jarcasting.com/artifacts/cn.cyejing/dsync-common/
implementation 'cn.cyejing:dsync-common:0.1.3'
// https://jarcasting.com/artifacts/cn.cyejing/dsync-common/
implementation ("cn.cyejing:dsync-common:0.1.3")
'cn.cyejing:dsync-common:jar:0.1.3'
<dependency org="cn.cyejing" name="dsync-common" rev="0.1.3">
  <artifact name="dsync-common" type="jar" />
</dependency>
@Grapes(
@Grab(group='cn.cyejing', module='dsync-common', version='0.1.3')
)
libraryDependencies += "cn.cyejing" % "dsync-common" % "0.1.3"
[cn.cyejing/dsync-common "0.1.3"]

Dependencies

compile (4)

Group / Artifact Type Version
io.netty : netty-all jar 4.1.30.Final
com.alibaba : fastjson jar 1.2.47
org.projectlombok : lombok jar 1.16.20
org.slf4j : slf4j-api jar 1.7.25

runtime (1)

Group / Artifact Type Version
ch.qos.logback : logback-classic jar 1.1.7

test (2)

Group / Artifact Type Version
junit : junit jar 4.12
org.mockito : mockito-core jar 2.15.0

Project Modules

There are no modules declared in this project.

Distributed Synchronize 分布式同步组件

  1. 分布式锁.
  2. 基于Netty长连接实现.
  3. 自定义协议,内置等待队列,性能远超redis锁.
  4. 服务下线立刻感知,无需等待超时.
  5. 支持优雅关闭.
  6. 规避Redis分布式锁缺陷: http://zhangtielei.com/posts/blog-redlock-reasoning.html , http://zhangtielei.com/posts/blog-redlock-reasoning-part2.html

启动服务端

java -jar -server dsync-dominate-xxx.jar

启动jar可以在maven下载,或者下载源码 mvn package 获得.

分布式锁 DLock

  1. 添加依赖
<dependency>
  <groupId>cn.cyejing</groupId>
  <artifactId>dsync-toolkit</artifactId>
</dependency>
  1. 使用方法
Config config = Config.config().host("localhost").port(4843); //配置服务端地址
DSync dSync = DSync.create(config);
DLock lock = dSync.getLock();

try {
    lock.lock("adder");
    //Do Something
} finally {
    lock.unlock();
}

Versions

Version
0.1.3
0.1.2