EDEN-MACE 1.6.0 release, the new distributed lock to ensure the security of accounts

EDEN-MACE is a flexible set of management commission of the distribution management system, which covers and summarizes the current popular mode of distribution, and provide post-comprehensive account management system that allows easier distribution.

Open Source Address: https://gitee.com/codingdb/distribution_management

Video Tutorial

Links: https://pan.baidu.com/s/1he3Tnk324JKoMPsbtEPcyw  extraction code: p20v

 

This update is distributed by zookeeper lock operation amounts to ensure the security of accounts.

Below, using a distributed lock temporary zk ordered node implementation.

 In the class file system zookeeper.properties path switch is provided, the case is not locked off here discuss only the case of open, specific locking procedure is as follows:
 1. First, the configuration file in the file zookeeper.properties zk disposed relative address
 2. the system runs a CuratorFramework when loading and start
 3. increase in the associated spring assembly @AmoutLock annotation
 4. Please enter the method determines whether the front lock into the process proceeds according to the configuration of it will pass the curator InterProcessMutex class
 5. Create a / amount / {userId} accounts that could ensure that a plurality of users enter the method
 6. by lock.acquire () Create / amount / {userId} at the nodes in order to create a temporary zk
 7. perform operation account
 8 via lock.release () if a node, if there is a next minimum node, the node enters a method of notification by the watch mechanism
 advantages:
  1. distributed locking the account may be implemented, facilitate distribution deployment of applications
  2. by monitoring each account to ensure the robustness of the program

  Drawback
  1. zk be locked due to the need to access, due to network and other reasons, will cause the program to run slower
  2. increase the complexity of the program
 part of the code

if(args!=null&&args.length>0&&curatorFramework!=null){
            String path = "/amount/"+args[0];
            final InterProcessMutex lock = new InterProcessMutex(curatorFramework,path);
            try {
                log.info("金额开始锁表{}",path);
                lock.acquire();
                return point.proceed();
            }finally {
                lock.release();
                log.info("金额锁表完成{}",path);
            }
}

Specific classes of operation may be achieved with reference to AmountMangeServiceImpl and related comments.

Guess you like

Origin www.oschina.net/news/110162/eden-mace-1-6-0-released