CosId介绍
CosId 旨在提供通用、灵活、高性能的分布式 ID 生成器。项目中还是很好集成,CosId本身采用spring boot与spring cloud框架,如果项目是这类的微服务框架,那集成CosId会比较简单
搭建CosId服务参考作者提供的Demo:https://gitee.com/AhooWang/CosId/tree/main/cosid-rest-api
搭建步骤
1、引入POM
<cosid.version>1.3.15</cosid.version> <dependencies> <dependency> <groupId>me.ahoo.cosid</groupId> <artifactId>cosid-dependencies</artifactId> <version>${cosid.version}</version> <type>pom</type> </dependency> <dependency> <groupId>me.ahoo.cosid</groupId> <artifactId>cosid-spring-boot-starter</artifactId> <version>${cosid.version}</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-boot-starter</artifactId> <version>3.0.0</version> </dependency> <dependency> <groupId>me.ahoo.cosid</groupId> <artifactId>cosid-spring-redis</artifactId> <version>${cosid.version}</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> <!-- <version></version>--> </dependency> <dependency> <groupId>me.ahoo.cosid</groupId> <artifactId>cosid-jdbc</artifactId> <version>${cosid.version}</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.23</version> </dependency> <dependency> <groupId>me.ahoo.cosid</groupId> <artifactId>cosid-mybatis</artifactId> <version>${cosid.version}</version> </dependency> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> </dependency> <!-- <dependency>--> <!-- <groupId>io.springfox</groupId>--> <!-- <artifactId>springfox-boot-starter</artifactId>--> <!-- <version>3.0.0</version>--> <!-- </dependency>--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>30.0-jre</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.20</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-configuration-processor</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> </dependency> </dependencies>
2、配置application.yaml,我是直接拿来使用的
spring:
application:
name: ${service.name:cosid-example}
datasource:
url: jdbc:mysql://localhost:3306/test_db
username: root
password: root
redis:
url: redis://localhost:6379
cosid:
namespace: ${spring.application.name}
snowflake:
enabled: true
# epoch: 1577203200000
clock-backwards:
spin-threshold: 10
broken-threshold: 2000
machine:
# stable: true
# machine-bit: 10
# instance-id: ${HOSTNAME}
distributor:
type: redis
# manual:
# machine-id: 0
state-storage:
local:
state-location: ./cosid-machine-state/
share:
clock-sync: true
friendly: true
provider:
bizA:
# timestamp-bit:
sequence-bit: 12
bizB:
# timestamp-bit:
sequence-bit: 12
segment:
enabled: true
mode: chain
chain:
safe-distance: 5
prefetch-worker:
core-pool-size: 2
prefetch-period: 1s
distributor:
type: redis
share:
offset: 0
step: 100
provider:
bizC:
offset: 10000
step: 100
bizD:
offset: 10000
step: 100
3、编写springboot启动类以及Controller
springboot启动类
package com.nebula.cloud.cosid; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; /** * @author XXX */ @SpringBootApplication public class CosIdApplication { public static void main(String[] args) { SpringApplication.run(CosIdApplication.class); } }
控制器代码,作者提供了示例,就直接使用了
package com.nebula.cloud.cosid.controller; import com.google.common.base.Preconditions; import com.google.common.base.Strings; import me.ahoo.cosid.IdGenerator; import me.ahoo.cosid.provider.IdGeneratorProvider; import me.ahoo.cosid.snowflake.SafeJavaScriptSnowflakeId; import me.ahoo.cosid.snowflake.SnowflakeFriendlyId; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.Optional; /** * @author buck */ @RestController @RequestMapping("id") public class IdController { private final IdGeneratorProvider idGeneratorProvider; public IdController(IdGeneratorProvider idGeneratorProvider) { this.idGeneratorProvider = idGeneratorProvider; } private IdGenerator getIdGenerator(String name) { Preconditions.checkNotNull(name, "name can not be null"); Optional<IdGenerator> optionalIdGenerator = idGeneratorProvider.get(name); if (!optionalIdGenerator.isPresent()) { throw new IllegalArgumentException(Strings.lenientFormat("idGenerator:[%s] not fond.", name)); } return optionalIdGenerator.get(); } @GetMapping("{name}") public Object generate(@PathVariable String name) { IdGenerator idGenerator = getIdGenerator(name); long id = idGenerator.generate(); if (SafeJavaScriptSnowflakeId.isSafeJavaScript(id)) { return id; } return String.valueOf(id); } @GetMapping("{name}/friendlyId") public String friendlyId(@PathVariable String name) { IdGenerator idGenerator = getIdGenerator(name); if (idGenerator instanceof SnowflakeFriendlyId) { return ((SnowflakeFriendlyId) idGenerator).friendlyId().getFriendlyId(); } throw new IllegalArgumentException(Strings.lenientFormat("idGenerator:[%s] is not SnowflakeFriendlyId.", name)); } }
完成以上步骤,集成CosId就已经OK,运行项目
项目启动报错,如下错误信息
Caused by: org.springframework.data.redis.RedisConnectionFailureException: Unable to connect to Redis; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to localhost/<unresolved>:6379 at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$SharedConnection.getNativeConnection(LettuceConnectionFactory.java:1199) ~[spring-data-redis-2.2.5.RELEASE.jar:2.2.5.RELEASE] at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$SharedConnection.getConnection(LettuceConnectionFactory.java:1178) ~[spring-data-redis-2.2.5.RELEASE.jar:2.2.5.RELEASE] at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory.getSharedConnection(LettuceConnectionFactory.java:942) ~[spring-data-redis-2.2.5.RELEASE.jar:2.2.5.RELEASE] at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory.getConnection(LettuceConnectionFactory.java:353) ~[spring-data-redis-2.2.5.RELEASE.jar:2.2.5.RELEASE] at org.springframework.data.redis.core.RedisConnectionUtils.doGetConnection(RedisConnectionUtils.java:134) ~[spring-data-redis-2.2.5.RELEASE.jar:2.2.5.RELEASE] at org.springframework.data.redis.core.RedisConnectionUtils.getConnection(RedisConnectionUtils.java:97) ~[spring-data-redis-2.2.5.RELEASE.jar:2.2.5.RELEASE] at org.springframework.data.redis.core.RedisConnectionUtils.getConnection(RedisConnectionUtils.java:84) ~[spring-data-redis-2.2.5.RELEASE.jar:2.2.5.RELEASE] at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:215) ~[spring-data-redis-2.2.5.RELEASE.jar:2.2.5.RELEASE] at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:188) ~[spring-data-redis-2.2.5.RELEASE.jar:2.2.5.RELEASE] at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:96) ~[spring-data-redis-2.2.5.RELEASE.jar:2.2.5.RELEASE] at org.springframework.data.redis.core.DefaultValueOperations.setIfAbsent(DefaultValueOperations.java:296) ~[spring-data-redis-2.2.5.RELEASE.jar:2.2.5.RELEASE] at me.ahoo.cosid.spring.redis.SpringRedisIdSegmentDistributor.ensureOffset(SpringRedisIdSegmentDistributor.java:78) ~[cosid-spring-redis-1.3.15.jar:na] at me.ahoo.cosid.spring.redis.SpringRedisIdSegmentDistributor.<init>(SpringRedisIdSegmentDistributor.java:71) ~[cosid-spring-redis-1.3.15.jar:na] at me.ahoo.cosid.spring.boot.starter.segment.CosIdSpringRedisSegmentAutoConfiguration.createSegmentIdOfSpring(CosIdSpringRedisSegmentAutoConfiguration.java:75) ~[cosid-spring-boot-starter-1.3.15.jar:na] at me.ahoo.cosid.spring.boot.starter.segment.CosIdSpringRedisSegmentAutoConfiguration.shareSpringRedisSegmentId(CosIdSpringRedisSegmentAutoConfiguration.java:55) ~[cosid-spring-boot-starter-1.3.15.jar:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na] at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na] at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.2.4.RELEASE.jar:5.2.4.RELEASE] ... 20 common frames omitted Caused by: io.lettuce.core.RedisConnectionException: Unable to connect to localhost/<unresolved>:6379 at io.lettuce.core.RedisConnectionException.create(RedisConnectionException.java:78) ~[lettuce-core-5.2.2.RELEASE.jar:5.2.2.RELEASE] at io.lettuce.core.RedisConnectionException.create(RedisConnectionException.java:56) ~[lettuce-core-5.2.2.RELEASE.jar:5.2.2.RELEASE] at io.lettuce.core.AbstractRedisClient.getConnection(AbstractRedisClient.java:234) ~[lettuce-core-5.2.2.RELEASE.jar:5.2.2.RELEASE] at io.lettuce.core.RedisClient.connect(RedisClient.java:207) ~[lettuce-core-5.2.2.RELEASE.jar:5.2.2.RELEASE] at org.springframework.data.redis.connection.lettuce.StandaloneConnectionProvider.lambda$getConnection$1(StandaloneConnectionProvider.java:115) ~[spring-data-redis-2.2.5.RELEASE.jar:2.2.5.RELEASE] at java.base/java.util.Optional.orElseGet(Optional.java:362) ~[na:na] at org.springframework.data.redis.connection.lettuce.StandaloneConnectionProvider.getConnection(StandaloneConnectionProvider.java:115) ~[spring-data-redis-2.2.5.RELEASE.jar:2.2.5.RELEASE] at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$SharedConnection.getNativeConnection(LettuceConnectionFactory.java:1197) ~[spring-data-redis-2.2.5.RELEASE.jar:2.2.5.RELEASE] ... 39 common frames omitted Caused by: io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: no further information: localhost/127.0.0.1:6379 Caused by: java.net.ConnectException: Connection refused: no further information at java.base/sun.nio.ch.Net.pollConnect(Native Method) ~[na:na] at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:589) ~[na:na] at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:839) ~[na:na] at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:330) ~[netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:334) ~[netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:702) ~[netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650) ~[netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576) ~[netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493) ~[netty-transport-4.1.45.Final.jar:4.1.45.Final] at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) ~[netty-common-4.1.45.Final.jar:4.1.45.Final] at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.45.Final.jar:4.1.45.Final] at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.45.Final.jar:4.1.45.Final] at java.base/java.lang.Thread.run(Thread.java:832) ~[na:na] 2021-08-30 23:26:38.861 INFO 9788 --- [ Thread-2] m.a.c.s.c.PrefetchWorkerExecutorService : Close gracefully! 2021-08-30 23:26:38.861 INFO 9788 --- [ Thread-3] m.a.c.s.c.PrefetchWorkerExecutorService : Close gracefully! 2021-08-30 23:26:38.861 INFO 9788 --- [ Thread-3] m.a.c.s.c.PrefetchWorkerExecutorService : shutdown! 2021-08-30 23:26:38.861 INFO 9788 --- [ Thread-2] m.a.c.s.c.PrefetchWorkerExecutorService : shutdown!
报错信息上报redis连接超时,查看本地redis服务,发现为启动。故解决方法为启动本地redis服务。
再次启动项目,控制台打印如下,说明项目启动成功
D:\develop\jdk-14\bin\java.exe -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:53806,suspend=y,server=n -javaagent:C:\Users\buck\AppData\Local\JetBrains\IdeaIC2020.1\captureAgent\debugger-agent.jar -Dfile.encoding=UTF-8 -classpath "D:\develop\code\nebula-cloud\nebula-cosid\target\classes;D:\repository\me\ahoo\cosid\cosid-spring-boot-starter\1.3.15\cosid-spring-boot-starter-1.3.15.jar;D:\repository\me\ahoo\cosid\cosid-core\1.3.15\cosid-core-1.3.15.jar;D:\repository\org\springframework\boot\spring-boot-starter\2.2.5.RELEASE\spring-boot-starter-2.2.5.RELEASE.jar;D:\repository\org\springframework\boot\spring-boot\2.2.5.RELEASE\spring-boot-2.2.5.RELEASE.jar;D:\repository\org\springframework\boot\spring-boot-autoconfigure\2.2.5.RELEASE\spring-boot-autoconfigure-2.2.5.RELEASE.jar;D:\repository\org\springframework\boot\spring-boot-starter-logging\2.2.5.RELEASE\spring-boot-starter-logging-2.2.5.RELEASE.jar;D:\repository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;D:\repository\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;D:\repository\org\apache\logging\log4j\log4j-to-slf4j\2.12.1\log4j-to-slf4j-2.12.1.jar;D:\repository\org\apache\logging\log4j\log4j-api\2.12.1\log4j-api-2.12.1.jar;D:\repository\org\slf4j\jul-to-slf4j\1.7.30\jul-to-slf4j-1.7.30.jar;D:\repository\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;D:\repository\org\yaml\snakeyaml\1.25\snakeyaml-1.25.jar;D:\repository\org\springframework\cloud\spring-cloud-commons\2.2.3.RELEASE\spring-cloud-commons-2.2.3.RELEASE.jar;D:\repository\org\springframework\security\spring-security-crypto\5.2.2.RELEASE\spring-security-crypto-5.2.2.RELEASE.jar;D:\repository\org\slf4j\slf4j-api\1.7.30\slf4j-api-1.7.30.jar;D:\repository\io\springfox\springfox-boot-starter\3.0.0\springfox-boot-starter-3.0.0.jar;D:\repository\io\springfox\springfox-oas\3.0.0\springfox-oas-3.0.0.jar;D:\repository\io\swagger\core\v3\swagger-annotations\2.1.2\swagger-annotations-2.1.2.jar;D:\repository\io\swagger\core\v3\swagger-models\2.1.2\swagger-models-2.1.2.jar;D:\repository\io\springfox\springfox-spi\3.0.0\springfox-spi-3.0.0.jar;D:\repository\io\springfox\springfox-schema\3.0.0\springfox-schema-3.0.0.jar;D:\repository\io\springfox\springfox-core\3.0.0\springfox-core-3.0.0.jar;D:\repository\io\springfox\springfox-spring-web\3.0.0\springfox-spring-web-3.0.0.jar;D:\repository\io\github\classgraph\classgraph\4.8.83\classgraph-4.8.83.jar;D:\repository\io\springfox\springfox-spring-webmvc\3.0.0\springfox-spring-webmvc-3.0.0.jar;D:\repository\io\springfox\springfox-spring-webflux\3.0.0\springfox-spring-webflux-3.0.0.jar;D:\repository\io\springfox\springfox-swagger-common\3.0.0\springfox-swagger-common-3.0.0.jar;D:\repository\org\mapstruct\mapstruct\1.3.1.Final\mapstruct-1.3.1.Final.jar;D:\repository\io\springfox\springfox-data-rest\3.0.0\springfox-data-rest-3.0.0.jar;D:\repository\io\springfox\springfox-bean-validators\3.0.0\springfox-bean-validators-3.0.0.jar;D:\repository\io\springfox\springfox-swagger2\3.0.0\springfox-swagger2-3.0.0.jar;D:\repository\io\swagger\swagger-annotations\1.5.20\swagger-annotations-1.5.20.jar;D:\repository\io\swagger\swagger-models\1.5.20\swagger-models-1.5.20.jar;D:\repository\io\springfox\springfox-swagger-ui\3.0.0\springfox-swagger-ui-3.0.0.jar;D:\repository\com\fasterxml\classmate\1.5.1\classmate-1.5.1.jar;D:\repository\org\springframework\plugin\spring-plugin-core\2.0.0.RELEASE\spring-plugin-core-2.0.0.RELEASE.jar;D:\repository\org\springframework\spring-beans\5.2.4.RELEASE\spring-beans-5.2.4.RELEASE.jar;D:\repository\org\springframework\spring-context\5.2.4.RELEASE\spring-context-5.2.4.RELEASE.jar;D:\repository\org\springframework\spring-aop\5.2.4.RELEASE\spring-aop-5.2.4.RELEASE.jar;D:\repository\org\springframework\plugin\spring-plugin-metadata\2.0.0.RELEASE\spring-plugin-metadata-2.0.0.RELEASE.jar;D:\repository\me\ahoo\cosid\cosid-spring-redis\1.3.15\cosid-spring-redis-1.3.15.jar;D:\repository\org\springframework\data\spring-data-redis\2.2.5.RELEASE\spring-data-redis-2.2.5.RELEASE.jar;D:\repository\org\springframework\data\spring-data-keyvalue\2.2.5.RELEASE\spring-data-keyvalue-2.2.5.RELEASE.jar;D:\repository\org\springframework\data\spring-data-commons\2.2.5.RELEASE\spring-data-commons-2.2.5.RELEASE.jar;D:\repository\org\springframework\spring-tx\5.2.4.RELEASE\spring-tx-5.2.4.RELEASE.jar;D:\repository\org\springframework\spring-oxm\5.2.4.RELEASE\spring-oxm-5.2.4.RELEASE.jar;D:\repository\org\springframework\spring-context-support\5.2.4.RELEASE\spring-context-support-5.2.4.RELEASE.jar;D:\repository\org\springframework\boot\spring-boot-starter-data-redis\2.2.5.RELEASE\spring-boot-starter-data-redis-2.2.5.RELEASE.jar;D:\repository\io\lettuce\lettuce-core\5.2.2.RELEASE\lettuce-core-5.2.2.RELEASE.jar;D:\repository\io\netty\netty-common\4.1.45.Final\netty-common-4.1.45.Final.jar;D:\repository\io\netty\netty-handler\4.1.45.Final\netty-handler-4.1.45.Final.jar;D:\repository\io\netty\netty-buffer\4.1.45.Final\netty-buffer-4.1.45.Final.jar;D:\repository\io\netty\netty-codec\4.1.45.Final\netty-codec-4.1.45.Final.jar;D:\repository\io\netty\netty-transport\4.1.45.Final\netty-transport-4.1.45.Final.jar;D:\repository\io\netty\netty-resolver\4.1.45.Final\netty-resolver-4.1.45.Final.jar;D:\repository\io\projectreactor\reactor-core\3.3.3.RELEASE\reactor-core-3.3.3.RELEASE.jar;D:\repository\org\reactivestreams\reactive-streams\1.0.3\reactive-streams-1.0.3.jar;D:\repository\me\ahoo\cosid\cosid-jdbc\1.3.15\cosid-jdbc-1.3.15.jar;D:\repository\org\springframework\boot\spring-boot-starter-jdbc\2.2.5.RELEASE\spring-boot-starter-jdbc-2.2.5.RELEASE.jar;D:\repository\com\zaxxer\HikariCP\3.4.2\HikariCP-3.4.2.jar;D:\repository\org\springframework\spring-jdbc\5.2.4.RELEASE\spring-jdbc-5.2.4.RELEASE.jar;D:\repository\mysql\mysql-connector-java\8.0.23\mysql-connector-java-8.0.23.jar;D:\repository\me\ahoo\cosid\cosid-mybatis\1.3.15\cosid-mybatis-1.3.15.jar;D:\repository\org\mybatis\mybatis\3.5.7\mybatis-3.5.7.jar;D:\repository\org\mybatis\spring\boot\mybatis-spring-boot-starter\1.3.2\mybatis-spring-boot-starter-1.3.2.jar;D:\repository\org\mybatis\spring\boot\mybatis-spring-boot-autoconfigure\1.3.2\mybatis-spring-boot-autoconfigure-1.3.2.jar;D:\repository\org\mybatis\mybatis-spring\1.3.2\mybatis-spring-1.3.2.jar;D:\repository\org\springframework\boot\spring-boot-starter-actuator\2.2.5.RELEASE\spring-boot-starter-actuator-2.2.5.RELEASE.jar;D:\repository\org\springframework\boot\spring-boot-actuator-autoconfigure\2.2.5.RELEASE\spring-boot-actuator-autoconfigure-2.2.5.RELEASE.jar;D:\repository\org\springframework\boot\spring-boot-actuator\2.2.5.RELEASE\spring-boot-actuator-2.2.5.RELEASE.jar;D:\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.10.2\jackson-datatype-jsr310-2.10.2.jar;D:\repository\io\micrometer\micrometer-core\1.3.5\micrometer-core-1.3.5.jar;D:\repository\org\hdrhistogram\HdrHistogram\2.1.11\HdrHistogram-2.1.11.jar;D:\repository\org\latencyutils\LatencyUtils\2.0.3\LatencyUtils-2.0.3.jar;D:\repository\com\google\guava\guava\30.0-jre\guava-30.0-jre.jar;D:\repository\com\google\guava\failureaccess\1.0.1\failureaccess-1.0.1.jar;D:\repository\com\google\guava\listenablefuture\9999.0-empty-to-avoid-conflict-with-guava\listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar;D:\repository\com\google\code\findbugs\jsr305\3.0.2\jsr305-3.0.2.jar;D:\repository\org\checkerframework\checker-qual\3.5.0\checker-qual-3.5.0.jar;D:\repository\com\google\errorprone\error_prone_annotations\2.3.4\error_prone_annotations-2.3.4.jar;D:\repository\com\google\j2objc\j2objc-annotations\1.3\j2objc-annotations-1.3.jar;D:\repository\org\springframework\boot\spring-boot-starter-web\2.2.5.RELEASE\spring-boot-starter-web-2.2.5.RELEASE.jar;D:\repository\org\springframework\boot\spring-boot-starter-json\2.2.5.RELEASE\spring-boot-starter-json-2.2.5.RELEASE.jar;D:\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.10.2\jackson-datatype-jdk8-2.10.2.jar;D:\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.10.2\jackson-module-parameter-names-2.10.2.jar;D:\repository\org\springframework\boot\spring-boot-starter-tomcat\2.2.5.RELEASE\spring-boot-starter-tomcat-2.2.5.RELEASE.jar;D:\repository\org\apache\tomcat\embed\tomcat-embed-core\9.0.31\tomcat-embed-core-9.0.31.jar;D:\repository\org\apache\tomcat\embed\tomcat-embed-el\9.0.31\tomcat-embed-el-9.0.31.jar;D:\repository\org\apache\tomcat\embed\tomcat-embed-websocket\9.0.31\tomcat-embed-websocket-9.0.31.jar;D:\repository\org\springframework\boot\spring-boot-starter-validation\2.2.5.RELEASE\spring-boot-starter-validation-2.2.5.RELEASE.jar;D:\repository\jakarta\validation\jakarta.validation-api\2.0.2\jakarta.validation-api-2.0.2.jar;D:\repository\org\hibernate\validator\hibernate-validator\6.0.18.Final\hibernate-validator-6.0.18.Final.jar;D:\repository\org\jboss\logging\jboss-logging\3.4.1.Final\jboss-logging-3.4.1.Final.jar;D:\repository\org\springframework\spring-web\5.2.4.RELEASE\spring-web-5.2.4.RELEASE.jar;D:\repository\org\springframework\spring-webmvc\5.2.4.RELEASE\spring-webmvc-5.2.4.RELEASE.jar;D:\repository\org\springframework\spring-expression\5.2.4.RELEASE\spring-expression-5.2.4.RELEASE.jar;D:\repository\org\projectlombok\lombok\1.18.20\lombok-1.18.20.jar;D:\repository\org\springframework\boot\spring-boot-configuration-processor\2.2.5.RELEASE\spring-boot-configuration-processor-2.2.5.RELEASE.jar;D:\repository\org\springframework\boot\spring-boot-starter-test\2.2.5.RELEASE\spring-boot-starter-test-2.2.5.RELEASE.jar;D:\repository\org\springframework\boot\spring-boot-test\2.2.5.RELEASE\spring-boot-test-2.2.5.RELEASE.jar;D:\repository\org\springframework\boot\spring-boot-test-autoconfigure\2.2.5.RELEASE\spring-boot-test-autoconfigure-2.2.5.RELEASE.jar;D:\repository\com\jayway\jsonpath\json-path\2.4.0\json-path-2.4.0.jar;D:\repository\net\minidev\json-smart\2.3\json-smart-2.3.jar;D:\repository\net\minidev\accessors-smart\1.2\accessors-smart-1.2.jar;D:\repository\org\ow2\asm\asm\5.0.4\asm-5.0.4.jar;D:\repository\jakarta\xml\bind\jakarta.xml.bind-api\2.3.2\jakarta.xml.bind-api-2.3.2.jar;D:\repository\jakarta\activation\jakarta.activation-api\1.2.2\jakarta.activation-api-1.2.2.jar;D:\repository\org\junit\jupiter\junit-jupiter\5.5.2\junit-jupiter-5.5.2.jar;D:\repository\org\junit\jupiter\junit-jupiter-api\5.5.2\junit-jupiter-api-5.5.2.jar;D:\repository\org\opentest4j\opentest4j\1.2.0\opentest4j-1.2.0.jar;D:\repository\org\junit\platform\junit-platform-commons\1.5.2\junit-platform-commons-1.5.2.jar;D:\repository\org\junit\jupiter\junit-jupiter-params\5.5.2\junit-jupiter-params-5.5.2.jar;D:\repository\org\junit\jupiter\junit-jupiter-engine\5.5.2\junit-jupiter-engine-5.5.2.jar;D:\repository\org\junit\vintage\junit-vintage-engine\5.5.2\junit-vintage-engine-5.5.2.jar;D:\repository\org\apiguardian\apiguardian-api\1.1.0\apiguardian-api-1.1.0.jar;D:\repository\org\junit\platform\junit-platform-engine\1.5.2\junit-platform-engine-1.5.2.jar;D:\repository\junit\junit\4.12\junit-4.12.jar;D:\repository\org\mockito\mockito-junit-jupiter\3.1.0\mockito-junit-jupiter-3.1.0.jar;D:\repository\org\assertj\assertj-core\3.13.2\assertj-core-3.13.2.jar;D:\repository\org\hamcrest\hamcrest\2.1\hamcrest-2.1.jar;D:\repository\org\mockito\mockito-core\3.1.0\mockito-core-3.1.0.jar;D:\repository\net\bytebuddy\byte-buddy\1.10.8\byte-buddy-1.10.8.jar;D:\repository\net\bytebuddy\byte-buddy-agent\1.10.8\byte-buddy-agent-1.10.8.jar;D:\repository\org\objenesis\objenesis\2.6\objenesis-2.6.jar;D:\repository\org\skyscreamer\jsonassert\1.5.0\jsonassert-1.5.0.jar;D:\repository\com\vaadin\external\google\android-json\0.0.20131108.vaadin1\android-json-0.0.20131108.vaadin1.jar;D:\repository\org\springframework\spring-core\5.2.4.RELEASE\spring-core-5.2.4.RELEASE.jar;D:\repository\org\springframework\spring-jcl\5.2.4.RELEASE\spring-jcl-5.2.4.RELEASE.jar;D:\repository\org\springframework\spring-test\5.2.4.RELEASE\spring-test-5.2.4.RELEASE.jar;D:\repository\org\xmlunit\xmlunit-core\2.6.3\xmlunit-core-2.6.3.jar;D:\repository\io\minio\minio\7.0.2\minio-7.0.2.jar;D:\repository\org\simpleframework\simple-xml\2.7.1\simple-xml-2.7.1.jar;D:\repository\stax\stax-api\1.0.1\stax-api-1.0.1.jar;D:\repository\stax\stax\1.2.0\stax-1.2.0.jar;D:\repository\xpp3\xpp3\1.1.3.3\xpp3-1.1.3.3.jar;D:\repository\com\squareup\okhttp3\okhttp\3.14.7\okhttp-3.14.7.jar;D:\repository\com\squareup\okio\okio\1.17.2\okio-1.17.2.jar;D:\repository\com\fasterxml\jackson\core\jackson-annotations\2.10.2\jackson-annotations-2.10.2.jar;D:\repository\com\fasterxml\jackson\core\jackson-core\2.10.2\jackson-core-2.10.2.jar;D:\repository\com\fasterxml\jackson\core\jackson-databind\2.10.2\jackson-databind-2.10.2.jar;D:\repository\com\github\spotbugs\spotbugs-annotations\4.0.0\spotbugs-annotations-4.0.0.jar;D:\repository\net\jcip\jcip-annotations\1.0\jcip-annotations-1.0.jar;D:\repository\commons-codec\commons-codec\1.15\commons-codec-1.15.jar;D:\develop\IntelliJ IDEA Community Edition 2020.1.1\lib\idea_rt.jar" com.nebula.cloud.cosid.CosIdApplication Connected to the target VM, address: '127.0.0.1:53806', transport: 'socket' OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.2.5.RELEASE) 2021-08-30 23:30:30.120 INFO 19076 --- [ main] com.nebula.cloud.cosid.CosIdApplication : Starting CosIdApplication on DESKTOP-5IHL26I with PID 19076 (D:\develop\code\nebula-cloud\nebula-cosid\target\classes started by buck in D:\develop\code\nebula-cloud) 2021-08-30 23:30:30.124 INFO 19076 --- [ main] com.nebula.cloud.cosid.CosIdApplication : No active profile set, falling back to default profiles: default 2021-08-30 23:30:31.386 WARN 19076 --- [ main] o.m.s.mapper.ClassPathMapperScanner : No MyBatis mapper was found in '[com.nebula.cloud.cosid]' package. Please check your configuration. 2021-08-30 23:30:31.534 INFO 19076 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode! 2021-08-30 23:30:31.536 INFO 19076 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Redis repositories in DEFAULT mode. 2021-08-30 23:30:31.555 INFO 19076 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 6ms. Found 0 Redis repository interfaces. 2021-08-30 23:30:32.494 INFO 19076 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) 2021-08-30 23:30:32.514 INFO 19076 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2021-08-30 23:30:32.515 INFO 19076 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.31] 2021-08-30 23:30:32.655 INFO 19076 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2021-08-30 23:30:32.656 INFO 19076 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2473 ms 2021-08-30 23:30:33.679 INFO 19076 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 2 endpoint(s) beneath base path '/actuator' 2021-08-30 23:30:33.991 INFO 19076 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor' 2021-08-30 23:30:34.212 DEBUG 19076 --- [ main] .a.c.s.r.SpringRedisIdSegmentDistributor : ensureOffset -[cosid:{nebula-cosid.__share__}.adder]- offset:[0]. 2021-08-30 23:30:34.320 INFO 19076 --- [ main] io.lettuce.core.EpollProvider : Starting without optional epoll library 2021-08-30 23:30:34.322 INFO 19076 --- [ main] io.lettuce.core.KqueueProvider : Starting without optional kqueue library 2021-08-30 23:30:34.607 DEBUG 19076 --- [ main] .a.c.s.r.SpringRedisIdSegmentDistributor : ensureOffset -[cosid:{nebula-cosid.__share__}.adder]- offset:[0] - notExists:[false]. 2021-08-30 23:30:34.612 INFO 19076 --- [ main] m.a.c.s.c.PrefetchWorkerExecutorService : submit - jobId:[nebula-cosid.__share__]. 2021-08-30 23:30:34.612 DEBUG 19076 --- [ main] m.a.c.s.c.PrefetchWorkerExecutorService : initWorkers - [DefaultPrefetchWorker-1]. 2021-08-30 23:30:34.612 DEBUG 19076 --- [ main] m.a.c.s.c.PrefetchWorkerExecutorService : initWorkers - [DefaultPrefetchWorker-2]. 2021-08-30 23:30:34.613 INFO 19076 --- [ main] m.a.c.s.c.PrefetchWorkerExecutorService : submit - jobId:[nebula-cosid.__share__] is bound to thread:[DefaultPrefetchWorker-1]. 2021-08-30 23:30:34.613 INFO 19076 --- [ main] m.a.c.s.c.PrefetchWorkerExecutorService : submit - jobId:[nebula-cosid.__share__] is bound to thread:[DefaultPrefetchWorker-1] start. 2021-08-30 23:30:34.613 INFO 19076 --- [ main] m.a.c.s.c.DefaultPrefetchWorker : submit - [nebula-cosid.__share__] jobSize:[0]. 2021-08-30 23:30:34.614 DEBUG 19076 --- [ main] .a.c.s.r.SpringRedisIdSegmentDistributor : ensureOffset -[cosid:{nebula-cosid.bizC}.adder]- offset:[10000]. 2021-08-30 23:30:34.614 DEBUG 19076 --- [refetchWorker-1] me.ahoo.cosid.segment.SegmentChainId : appendChain - [nebula-cosid.__share__] - headChain.version:[-1] - tailChain.version:[-1] - prefetchSegments:[5]. 2021-08-30 23:30:34.617 DEBUG 19076 --- [refetchWorker-1] .a.c.s.r.SpringRedisIdSegmentDistributor : nextMaxId -[cosid:{nebula-cosid.__share__}.adder]- step:[500]. 2021-08-30 23:30:34.618 DEBUG 19076 --- [ main] .a.c.s.r.SpringRedisIdSegmentDistributor : ensureOffset -[cosid:{nebula-cosid.bizC}.adder]- offset:[10000] - notExists:[false]. 2021-08-30 23:30:34.619 INFO 19076 --- [ main] m.a.c.s.c.PrefetchWorkerExecutorService : submit - jobId:[nebula-cosid.bizC]. 2021-08-30 23:30:34.619 INFO 19076 --- [ main] m.a.c.s.c.PrefetchWorkerExecutorService : submit - jobId:[nebula-cosid.bizC] is bound to thread:[DefaultPrefetchWorker-2]. 2021-08-30 23:30:34.619 INFO 19076 --- [ main] m.a.c.s.c.PrefetchWorkerExecutorService : submit - jobId:[nebula-cosid.bizC] is bound to thread:[DefaultPrefetchWorker-2] start. 2021-08-30 23:30:34.620 INFO 19076 --- [ main] m.a.c.s.c.DefaultPrefetchWorker : submit - [nebula-cosid.bizC] jobSize:[0]. 2021-08-30 23:30:34.620 DEBUG 19076 --- [ main] .a.c.s.r.SpringRedisIdSegmentDistributor : ensureOffset -[cosid:{nebula-cosid.bizD}.adder]- offset:[10000]. 2021-08-30 23:30:34.625 DEBUG 19076 --- [ main] .a.c.s.r.SpringRedisIdSegmentDistributor : ensureOffset -[cosid:{nebula-cosid.bizD}.adder]- offset:[10000] - notExists:[false]. 2021-08-30 23:30:34.626 INFO 19076 --- [ main] m.a.c.s.c.PrefetchWorkerExecutorService : submit - jobId:[nebula-cosid.bizD]. 2021-08-30 23:30:34.626 INFO 19076 --- [ main] m.a.c.s.c.PrefetchWorkerExecutorService : submit - jobId:[nebula-cosid.bizD] is bound to thread:[DefaultPrefetchWorker-1]. 2021-08-30 23:30:34.626 INFO 19076 --- [ main] m.a.c.s.c.DefaultPrefetchWorker : submit - [nebula-cosid.bizD] jobSize:[1]. 2021-08-30 23:30:34.627 DEBUG 19076 --- [refetchWorker-1] .a.c.s.r.SpringRedisIdSegmentDistributor : nextMaxId -[cosid:{nebula-cosid.__share__}.adder]- step:[500] - nextMaxId:[3000]. 2021-08-30 23:30:34.628 DEBUG 19076 --- [refetchWorker-1] me.ahoo.cosid.segment.SegmentChainId : appendChain - [nebula-cosid.__share__] - restTail - tailChain.version:[30:-1->0] . 2021-08-30 23:30:34.904 INFO 19076 --- [ main] m.a.c.s.m.LocalMachineStateStorage : get - read from stateLocation : [D:\develop\code\nebula-cloud\.\cosid-machine-state\nebula-cosid__192.168.43.234:19076]. 2021-08-30 23:30:34.905 INFO 19076 --- [ main] m.a.c.s.m.LocalMachineStateStorage : get - read from stateLocation : [D:\develop\code\nebula-cloud\.\cosid-machine-state\nebula-cosid__192.168.43.234:19076] not found. 2021-08-30 23:30:34.906 INFO 19076 --- [ main] .a.c.s.r.SpringRedisMachineIdDistributor : distribute0 - instanceId:[InstanceId{instanceId='192.168.43.234:19076', stable=false}] - machineBit:[10] @ namespace:[nebula-cosid]. 2021-08-30 23:30:34.967 INFO 19076 --- [ main] .a.c.s.r.SpringRedisMachineIdDistributor : distribute0 - machineState:[MachineState{machineId=4, lastTimeStamp=1630335691906}] - instanceId:[InstanceId{instanceId='192.168.43.234:19076', stable=false}] - machineBit:[10] @ namespace:[nebula-cosid]. 2021-08-30 23:30:34.968 INFO 19076 --- [ main] m.a.c.s.m.LocalMachineStateStorage : set - write machineId:[4] to stateLocation : [D:\develop\code\nebula-cloud\.\cosid-machine-state\nebula-cosid__192.168.43.234:19076]. 2021-08-30 23:30:34.973 INFO 19076 --- [ main] m.a.c.s.m.LocalMachineStateStorage : get - read from stateLocation : [D:\develop\code\nebula-cloud\.\cosid-machine-state\nebula-cosid__192.168.43.234:19076]. 2021-08-30 23:30:34.985 INFO 19076 --- [ main] m.a.c.s.m.LocalMachineStateStorage : get - state data : [4|1630337434968]. 2021-08-30 23:30:34.995 INFO 19076 --- [ main] m.a.c.s.m.LocalMachineStateStorage : get - read from stateLocation : [D:\develop\code\nebula-cloud\.\cosid-machine-state\nebula-cosid__192.168.43.234:19076]. 2021-08-30 23:30:34.995 INFO 19076 --- [ main] m.a.c.s.m.LocalMachineStateStorage : get - state data : [4|1630337434968]. 2021-08-30 23:30:35.630 DEBUG 19076 --- [refetchWorker-2] me.ahoo.cosid.segment.SegmentChainId : appendChain - [nebula-cosid.bizC] - headChain.version:[-1] - tailChain.version:[-1] - prefetchSegments:[5]. 2021-08-30 23:30:35.630 DEBUG 19076 --- [refetchWorker-2] .a.c.s.r.SpringRedisIdSegmentDistributor : nextMaxId -[cosid:{nebula-cosid.bizC}.adder]- step:[500]. 2021-08-30 23:30:35.630 DEBUG 19076 --- [refetchWorker-1] me.ahoo.cosid.segment.SegmentChainId : forward - [nebula-cosid.__share__] - [IdSegmentChain{version=-1, idSegment=DefaultIdSegment{maxId=-1, offset=-1, step=0, sequence=-1, fetchTime=1630337434, ttl=9223372036854775807}}] -> [IdSegmentChain{version=0, idSegment=MergedIdSegment{segments=5, idSegment=DefaultIdSegment{maxId=3000, offset=2500, step=500, sequence=2500, fetchTime=1630337434, ttl=9223372036854775807}, singleStep=100}}]. 2021-08-30 23:30:35.630 DEBUG 19076 --- [refetchWorker-1] me.ahoo.cosid.segment.SegmentChainId : appendChain - [nebula-cosid.bizD] - headChain.version:[-1] - tailChain.version:[-1] - prefetchSegments:[5]. 2021-08-30 23:30:35.631 DEBUG 19076 --- [refetchWorker-1] .a.c.s.r.SpringRedisIdSegmentDistributor : nextMaxId -[cosid:{nebula-cosid.bizD}.adder]- step:[500]. 2021-08-30 23:30:35.634 DEBUG 19076 --- [refetchWorker-2] .a.c.s.r.SpringRedisIdSegmentDistributor : nextMaxId -[cosid:{nebula-cosid.bizC}.adder]- step:[500] - nextMaxId:[13000]. 2021-08-30 23:30:35.634 DEBUG 19076 --- [refetchWorker-1] .a.c.s.r.SpringRedisIdSegmentDistributor : nextMaxId -[cosid:{nebula-cosid.bizD}.adder]- step:[500] - nextMaxId:[13100]. 2021-08-30 23:30:35.634 DEBUG 19076 --- [refetchWorker-2] me.ahoo.cosid.segment.SegmentChainId : appendChain - [nebula-cosid.bizC] - restTail - tailChain.version:[130:-1->0] . 2021-08-30 23:30:35.634 DEBUG 19076 --- [refetchWorker-1] me.ahoo.cosid.segment.SegmentChainId : appendChain - [nebula-cosid.bizD] - restTail - tailChain.version:[131:-1->0] . 2021-08-30 23:30:36.106 INFO 19076 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path '' 2021-08-30 23:30:36.342 INFO 19076 --- [ main] com.nebula.cloud.cosid.CosIdApplication : Started CosIdApplication in 7.092 seconds (JVM running for 7.652) 2021-08-30 23:30:36.640 DEBUG 19076 --- [refetchWorker-1] me.ahoo.cosid.segment.SegmentChainId : forward - [nebula-cosid.bizD] - [IdSegmentChain{version=-1, idSegment=DefaultIdSegment{maxId=-1, offset=-1, step=0, sequence=-1, fetchTime=1630337434, ttl=9223372036854775807}}] -> [IdSegmentChain{version=0, idSegment=MergedIdSegment{segments=5, idSegment=DefaultIdSegment{maxId=13100, offset=12600, step=500, sequence=12600, fetchTime=1630337435, ttl=9223372036854775807}, singleStep=100}}]. 2021-08-30 23:30:36.640 DEBUG 19076 --- [refetchWorker-2] me.ahoo.cosid.segment.SegmentChainId : forward - [nebula-cosid.bizC] - [IdSegmentChain{version=-1, idSegment=DefaultIdSegment{maxId=-1, offset=-1, step=0, sequence=-1, fetchTime=1630337434, ttl=9223372036854775807}}] -> [IdSegmentChain{version=0, idSegment=MergedIdSegment{segments=5, idSegment=DefaultIdSegment{maxId=13000, offset=12500, step=500, sequence=12500, fetchTime=1630337435, ttl=9223372036854775807}, singleStep=100}}].
调用服务接口,正确返回order编号
由于集成swagger编译报错,为找到原因,故将集成swagger给去掉了