Commit 609c9ef6 authored by zhiguo.liu's avatar zhiguo.liu

fix: 去掉手动创建初始化 DisposableWorkerIdAssigner 的代码

parent fd0d7354
/*
* Copyright (c) 2017 Baidu, Inc. All Rights Reserve.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.quantgroup.tech.util.id; package cn.quantgroup.tech.util.id;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
...@@ -24,8 +9,6 @@ import java.math.BigInteger; ...@@ -24,8 +9,6 @@ import java.math.BigInteger;
/** /**
* Allocate 64 bits for the UID(long)<br> * Allocate 64 bits for the UID(long)<br>
* sign (fixed 1bit) -> deltaSecond -> workerId -> sequence(within the same second) * sign (fixed 1bit) -> deltaSecond -> workerId -> sequence(within the same second)
*
* @author yutianbao
*/ */
public class BitsAllocator { public class BitsAllocator {
/** /**
...@@ -81,7 +64,6 @@ public class BitsAllocator { ...@@ -81,7 +64,6 @@ public class BitsAllocator {
/** /**
* Allocate bits for UID according to delta seconds & workerId & sequence<br> * Allocate bits for UID according to delta seconds & workerId & sequence<br>
* <b>Note that: </b>The highest bit will always be 0 for sign
* *
* @param deltaSeconds * @param deltaSeconds
* @param workerId * @param workerId
......
...@@ -105,7 +105,6 @@ public class DefaultUidGenerator implements UidGenerator, InitializingBean { ...@@ -105,7 +105,6 @@ public class DefaultUidGenerator implements UidGenerator, InitializingBean {
public void afterPropertiesSet() throws Exception { public void afterPropertiesSet() throws Exception {
// initialize bits allocator // initialize bits allocator
bitsAllocator = new BitsAllocator(timeBits, dataCenterIdBits, workerBits, seqBits); bitsAllocator = new BitsAllocator(timeBits, dataCenterIdBits, workerBits, seqBits);
workerIdAssigner = new DisposableWorkerIdAssigner();
// initialize worker id // initialize worker id
workerId = workerIdAssigner.assignWorkerId(dataCenterId, bitsAllocator); workerId = workerIdAssigner.assignWorkerId(dataCenterId, bitsAllocator);
Assert.isTrue(workerId < bitsAllocator.getMaxWorkerId(), "workerId is too big"); Assert.isTrue(workerId < bitsAllocator.getMaxWorkerId(), "workerId is too big");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment