forked from plusone/plusone-commons
fix bug.
parent
8d9ccdb08e
commit
dc9e0d1b53
|
@ -64,9 +64,9 @@ public class SnowflakeIdGenerator {
|
||||||
* @param datacenterId 数据中心ID (0~31)
|
* @param datacenterId 数据中心ID (0~31)
|
||||||
*/
|
*/
|
||||||
public SnowflakeIdGenerator(final long workerId, final long datacenterId) {
|
public SnowflakeIdGenerator(final long workerId, final long datacenterId) {
|
||||||
Preconditions.checkArgument((workerId > MAX_WORKER_ID || workerId < 0),
|
Preconditions.checkArgument((workerId <= MAX_WORKER_ID || workerId >= 0),
|
||||||
"WorkerId can't be greater than %s or less than 0.", MAX_WORKER_ID);
|
"WorkerId can't be greater than %s or less than 0.", MAX_WORKER_ID);
|
||||||
Preconditions.checkArgument((datacenterId > MAX_DATACENTER_ID || datacenterId < 0),
|
Preconditions.checkArgument((datacenterId <= MAX_DATACENTER_ID || datacenterId >= 0),
|
||||||
"DatacenterId can't be greater than %s or less than 0.", MAX_DATACENTER_ID);
|
"DatacenterId can't be greater than %s or less than 0.", MAX_DATACENTER_ID);
|
||||||
this.datacenterIdAndWorkerId
|
this.datacenterIdAndWorkerId
|
||||||
= (datacenterId << DATACENTER_ID_SHIFT) | (workerId << WORKER_ID_SHIFT);
|
= (datacenterId << DATACENTER_ID_SHIFT) | (workerId << WORKER_ID_SHIFT);
|
||||||
|
|
Loading…
Reference in New Issue