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
622760e3
Commit
622760e3
authored
Nov 16, 2017
by
ag
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix : 更换一个包名
parent
47797ce3
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
14 deletions
+29
-14
pom.xml
pom.xml
+14
-3
ServiceUrls.java
src/main/java/cn/quantgroup/tech/constant/ServiceUrls.java
+6
-0
IDGenerator.java
src/main/java/cn/quantgroup/tech/util/IDGenerator.java
+5
-5
RedisUtils.java
src/main/java/cn/quantgroup/tech/util/RedisUtils.java
+4
-6
No files found.
pom.xml
View file @
622760e3
...
...
@@ -5,13 +5,15 @@
<modelVersion>
4.0.0
</modelVersion>
<groupId>
cn.quantgroup
</groupId>
<artifactId>
baitiao-
commons
</artifactId>
<artifactId>
commons
</artifactId>
<version>
0.0.2
</version>
<packaging>
jar
</packaging>
<properties>
<java.version>
1.8
</java.version>
<guava.version>
23.0
</guava.version>
<apollo.client.version>
0.9.2
</apollo.client.version>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.reporting.outputEncoding>
UTF-8
</project.reporting.outputEncoding>
</properties>
...
...
@@ -27,12 +29,21 @@
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-redis
</artifactId>
<version>
1.5.6.RELEASE
</version>
</dependency>
<dependency>
<groupId>
com.google.guava
</groupId>
<artifactId>
guava
</artifactId>
<version>
23.0
</version>
<version>
${guava.version}
</version>
</dependency>
<dependency>
<groupId>
com.ctrip.framework.apollo
</groupId>
<artifactId>
apollo-client
</artifactId>
<version>
${apollo.client.version}
</version>
</dependency>
<dependency>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
<version>
1.16.16
</version>
</dependency>
</dependencies>
...
...
src/main/java/cn/quantgroup/tech/constant/ServiceUrls.java
0 → 100644
View file @
622760e3
package
cn
.
quantgroup
.
tech
.
constant
;
@Deprecated
public
enum
ServiceUrls
{
}
src/main/java/cn/quantgroup/
xyqb
/util/IDGenerator.java
→
src/main/java/cn/quantgroup/
tech
/util/IDGenerator.java
View file @
622760e3
package
cn
.
quantgroup
.
xyqb
.
util
;
package
cn
.
quantgroup
.
tech
.
util
;
import
com.google.common.cache.CacheBuilder
;
import
com.google.common.cache.CacheLoader
;
import
com.google.common.cache.LoadingCache
;
import
lombok.extern.slf4j.Slf4j
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -30,10 +31,9 @@ import java.util.concurrent.locks.ReentrantLock;
* @date 2017/5/18
*/
@Component
@Slf4j
public
class
IDGenerator
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
IDGenerator
.
class
);
private
static
final
String
REDIS_WORK_ID_KEY
=
"GLOBAL:WORK:ID:"
;
private
static
final
String
ID_FORMAT
=
"yyyyMMddHHmmss"
;
...
...
@@ -130,7 +130,7 @@ public class IDGenerator {
AtomicInteger
historyCounter
=
(
AtomicInteger
)
cache
.
get
(
timeSecond
);
counter
=
historyCounter
.
incrementAndGet
();
}
catch
(
ExecutionException
e
)
{
LOGGER
.
error
(
"取出缓存时出错"
);
log
.
error
(
"取出缓存时出错"
);
}
}
...
...
@@ -140,7 +140,7 @@ public class IDGenerator {
Thread
.
sleep
(
500
);
return
getId
(
prefix
);
}
catch
(
InterruptedException
e
)
{
LOGGER
.
error
(
"发号器休眠时发生错误:{}"
,
e
);
log
.
error
(
"发号器休眠时发生错误:{}"
,
e
);
}
}
...
...
src/main/java/cn/quantgroup/
xyqb
/util/RedisUtils.java
→
src/main/java/cn/quantgroup/
tech
/util/RedisUtils.java
View file @
622760e3
package
cn
.
quantgroup
.
xyqb
.
util
;
package
cn
.
quantgroup
.
tech
.
util
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.data.redis.connection.RedisConnection
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
redis.clients.jedis.Jedis
;
/**
*
* @author zhiguo.liu
* @date 2017/7/28
*/
@Slf4j
public
class
RedisUtils
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
RedisUtils
.
class
);
/**
* 通过 setnx + expire 命令,原子性给某个 key 上锁并设置过期时间
* 上锁成功返回 true ,上锁失败返回 false.
...
...
@@ -30,7 +28,7 @@ public class RedisUtils {
Jedis
jedis
=
(
Jedis
)
connection
.
getNativeConnection
();
return
jedis
.
set
(
key
,
"1"
,
"nx"
,
"ex"
,
expire
)
!=
null
;
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"上锁出错:{}"
,
e
);
log
.
error
(
"上锁出错:{}"
,
e
);
}
finally
{
if
(
connection
!=
null
)
{
connection
.
close
();
...
...
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