Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
commons
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DevOps
commons
Commits
609c9ef6
Commit
609c9ef6
authored
Apr 08, 2018
by
zhiguo.liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 去掉手动创建初始化 DisposableWorkerIdAssigner 的代码
parent
fd0d7354
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
19 deletions
+0
-19
BitsAllocator.java
...c/main/java/cn/quantgroup/tech/util/id/BitsAllocator.java
+0
-18
DefaultUidGenerator.java
.../java/cn/quantgroup/tech/util/id/DefaultUidGenerator.java
+0
-1
No files found.
commons-spring/src/main/java/cn/quantgroup/tech/util/id/BitsAllocator.java
View file @
609c9ef6
/*
* 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
...
...
commons-spring/src/main/java/cn/quantgroup/tech/util/id/DefaultUidGenerator.java
View file @
609c9ef6
...
@@ -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"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment