Disruptor分布式id生成策略


需要的pom文件:

 <!-- 顺序UUID -->
         <dependency>
            <groupId>com.fasterxml.uuid</groupId>
            <artifactId>java-uuid-generator</artifactId>
            <version>3.1.4</version>
         </dependency> 	

  有时间顺序:

import com.fasterxml.uuid.EthernetAddress;
import com.fasterxml.uuid.Generators;
import com.fasterxml.uuid.impl.TimeBasedGenerator;

public class KeyUtil {

	public static String generatorUUID(){
		TimeBasedGenerator timeBasedGenerator = Generators.timeBasedGenerator(EthernetAddress.fromInterface());
		return timeBasedGenerator.generate().toString();
	}
	
	public static void main(String[] args) {
		System.err.println(KeyUtil.generatorUUID());
		System.err.println(KeyUtil.generatorUUID());
	}
}

  

 

 

以下两种方式都不合适:

 

 

 

 

 

分布式生成ID架构图:

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM