Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
midjourney-proxy
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
徐少华
midjourney-proxy
Commits
f56b6d16
Commit
f56b6d16
authored
Jul 07, 2021
by
李传峰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:[none] 初始集成新版本框架
parent
d46bb088
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
50 additions
and
879 deletions
+50
-879
clear.bat
clear.bat
+3
-0
deploy.bat
deploy.bat
+3
-0
install.bat
install.bat
+4
-0
pom.xml
pcloud-common-config/pom.xml
+2
-2
pom.xml
pcloud-common-core/pom.xml
+3
-15
CommonBeans.java
...c/main/java/com/pcloud/common/core/tools/CommonBeans.java
+0
-166
PercentageLocalSampler.java
...com/pcloud/common/core/zipkin/PercentageLocalSampler.java
+0
-161
RefreshSamplerLocalProperties.java
...oud/common/core/zipkin/RefreshSamplerLocalProperties.java
+0
-148
SamplerLocalProperties.java
...com/pcloud/common/core/zipkin/SamplerLocalProperties.java
+0
-33
UriSampleProperties.java
...va/com/pcloud/common/core/zipkin/UriSampleProperties.java
+0
-31
ZipkinConfig.java
...main/java/com/pcloud/common/core/zipkin/ZipkinConfig.java
+0
-21
pom.xml
pcloud-common/pom.xml
+15
-26
pom.xml
pcloud-solr/pom.xml
+3
-13
pom.xml
pom.xml
+17
-263
No files found.
clear.bat
0 → 100644
View file @
f56b6d16
@echo off
call mvn eclipse:clean
call pause
deploy.bat
0 → 100644
View file @
f56b6d16
call mvn clean source:jar deploy -Denforcer.skip=true -Dmaven.test.skip=true -U
@pause
\ No newline at end of file
install.bat
0 → 100644
View file @
f56b6d16
call mvn clean install -Denforcer.skip=true -Dmaven.test.skip=true -U
call pause
\ No newline at end of file
pcloud-common-config/pom.xml
View file @
f56b6d16
...
...
@@ -5,7 +5,7 @@
<parent>
<groupId>
com.pcloud.common
</groupId>
<artifactId>
pcloud-common-parent
</artifactId>
<version>
2.1.0-RELEASE
</version>
<version>
3.1.0-SNAPSHOT
</version>
</parent>
<artifactId>
pcloud-common-config
</artifactId>
...
...
@@ -16,7 +16,7 @@
<url>
http://maven.apache.org
</url>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
</properties>
</project>
pcloud-common-core/pom.xml
View file @
f56b6d16
...
...
@@ -5,50 +5,38 @@
<parent>
<groupId>
com.pcloud.common
</groupId>
<artifactId>
pcloud-common-parent
</artifactId>
<version>
2.1.0-RELEASE
</version>
<version>
3.1.0-SNAPSHOT
</version>
</parent>
<artifactId>
pcloud-common-core
</artifactId>
<packaging>
jar
</packaging>
<version>
${
pcloud-common-core.
version}
</version>
<version>
${
re
version}
</version>
<name>
pcloud-common-core
</name>
<url>
http://maven.apache.org
</url>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<universe-springcloud-monitor-starter.version>
1.0.1-SNAPSHOT
</universe-springcloud-monitor-starter.version>
<universe-dbmonitor-starter.version>
1.0.1-SNAPSHOT
</universe-dbmonitor-starter.version>
<universe-monitorlog-logback-starter.version>
1.0.1-SNAPSHOT
</universe-monitorlog-logback-starter.version>
</properties>
<dependencies>
<dependency>
<groupId>
com.pcloud.common
</groupId>
<artifactId>
pcloud-common
</artifactId>
<version>
${pcloud-common.version}
</version>
</dependency>
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<scope>
test
</scope>
<version>
${reversion}
</version>
</dependency>
<dependency>
<groupId>
com.pcloud.universe
</groupId>
<artifactId>
universe-springcloud-monitor-starter
</artifactId>
<version>
${universe-springcloud-monitor-starter.version}
</version>
</dependency>
<dependency>
<groupId>
com.pcloud.universe
</groupId>
<artifactId>
universe-dbmonitor-starter
</artifactId>
<version>
${universe-dbmonitor-starter.version}
</version>
</dependency>
<dependency>
<groupId>
com.pcloud.universe
</groupId>
<artifactId>
universe-monitorlog-logback-starter
</artifactId>
<version>
${universe-monitorlog-logback-starter.version}
</version>
</dependency>
<!-- Database connect Begin -->
...
...
pcloud-common-core/src/main/java/com/pcloud/common/core/tools/CommonBeans.java
deleted
100644 → 0
View file @
d46bb088
package
com
.
pcloud
.
common
.
core
.
tools
;
import
io.micrometer.core.instrument.binder.jvm.JvmGcMetrics
;
import
io.micrometer.core.instrument.binder.jvm.JvmThreadMetrics
;
import
io.micrometer.core.instrument.binder.system.ProcessorMetrics
;
import
io.micrometer.spring.autoconfigure.MeterRegistryConfigurer
;
import
org.apache.catalina.connector.Connector
;
import
org.apache.tomcat.util.threads.ThreadPoolExecutor
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
//import org.springframework.cloud.netflix.hystrix.EnableHystrix;
//import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer
;
import
org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer
;
import
org.springframework.boot.context.embedded.tomcat.TomcatConnectorCustomizer
;
import
org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory
;
import
org.springframework.cloud.client.loadbalancer.LoadBalanced
;
import
org.springframework.context.ApplicationListener
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.context.event.ContextClosedEvent
;
import
org.springframework.core.env.Environment
;
import
org.springframework.web.client.RestTemplate
;
import
java.net.Inet4Address
;
import
java.net.InetAddress
;
import
java.net.NetworkInterface
;
import
java.net.SocketException
;
import
java.util.Enumeration
;
import
java.util.concurrent.Executor
;
import
java.util.concurrent.TimeUnit
;
/**
* Created by zengqiang on 17-11-16.
*/
//@EnableHystrix
//@EnableHystrixDashboard
@Configuration
public
class
CommonBeans
{
private
static
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
CommonBeans
.
class
);
@Autowired
private
Environment
environment
;
private
long
timeout
=
10
;
@Bean
public
ProcessorMetrics
processorMetrics
()
{
return
new
ProcessorMetrics
();
}
@Bean
public
JvmGcMetrics
jvmGcMetrics
()
{
return
new
JvmGcMetrics
();
}
@Bean
public
JvmThreadMetrics
jvmThreadMetrics
()
{
return
new
JvmThreadMetrics
();
}
@Bean
@LoadBalanced
public
RestTemplate
restTemplate
()
{
return
new
RestTemplate
();
}
@Bean
@Primary
MeterRegistryConfigurer
configurer
()
{
try
{
InetAddress
inetAddress
=
getLocalInetAddress
();
String
host
=
null
==
inetAddress
?
"unknown"
:
inetAddress
.
getHostName
()
+
"/"
+
inetAddress
.
getHostAddress
();
return
registry
->
{
registry
.
config
().
commonTags
(
"host/ip"
,
host
);
};
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"create MeterRegistryConfigurer error"
,
e
);
return
null
;
}
}
/**
* 取当前系统站点本地地址 linux下 和 window下可用
*
* @return
*/
public
InetAddress
getLocalInetAddress
()
{
InetAddress
ia
=
null
,
inetAddress
=
null
;
try
{
for
(
Enumeration
<
NetworkInterface
>
interfaces
=
NetworkInterface
.
getNetworkInterfaces
();
interfaces
.
hasMoreElements
();)
{
NetworkInterface
networkInterface
=
interfaces
.
nextElement
();
if
(
networkInterface
.
isLoopback
()
||
networkInterface
.
isVirtual
()
||
!
networkInterface
.
isUp
())
{
continue
;
}
Enumeration
<
InetAddress
>
addresses
=
networkInterface
.
getInetAddresses
();
while
(
addresses
.
hasMoreElements
())
{
ia
=
addresses
.
nextElement
();
if
(
ia
instanceof
Inet4Address
)
{
inetAddress
=
ia
;
}
}
}
}
catch
(
SocketException
e
)
{
return
null
;
}
return
inetAddress
;
}
@Bean
public
GracefulShutdownConnector
gracefulShutdown
()
{
return
new
GracefulShutdownConnector
();
}
@Bean
public
EmbeddedServletContainerCustomizer
tomcatCustomizer
(
@Autowired
GracefulShutdownConnector
connector
)
{
return
new
EmbeddedServletContainerCustomizer
()
{
@Override
public
void
customize
(
ConfigurableEmbeddedServletContainer
container
)
{
if
(
container
instanceof
TomcatEmbeddedServletContainerFactory
)
{
((
TomcatEmbeddedServletContainerFactory
)
container
)
.
addConnectorCustomizers
(
connector
);
}
}
};
}
class
GracefulShutdownConnector
implements
TomcatConnectorCustomizer
,
ApplicationListener
<
ContextClosedEvent
>
{
private
volatile
Connector
connector
;
@Override
public
void
customize
(
Connector
connector
)
{
this
.
connector
=
connector
;
}
@Override
public
void
onApplicationEvent
(
ContextClosedEvent
event
)
{
if
(
environment
.
containsProperty
(
"shutdownTimeout"
))
{
timeout
=
environment
.
getProperty
(
"shutdownTimeout"
,
Long
.
class
);
}
this
.
connector
.
pause
();
Executor
executor
=
this
.
connector
.
getProtocolHandler
().
getExecutor
();
if
(
executor
instanceof
ThreadPoolExecutor
)
{
try
{
ThreadPoolExecutor
threadPoolExecutor
=
(
ThreadPoolExecutor
)
executor
;
threadPoolExecutor
.
shutdown
();
if
(!
threadPoolExecutor
.
awaitTermination
(
timeout
,
TimeUnit
.
SECONDS
))
{
LOGGER
.
warn
(
"Tomcat thread pool did not shut down gracefully within "
+
timeout
+
" seconds. Proceeding with forceful shutdown"
);
}
}
catch
(
InterruptedException
ex
)
{
Thread
.
currentThread
().
interrupt
();
}
}
}
}
}
pcloud-common-core/src/main/java/com/pcloud/common/core/zipkin/PercentageLocalSampler.java
deleted
100644 → 0
View file @
d46bb088
package
com
.
pcloud
.
common
.
core
.
zipkin
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.springframework.cloud.sleuth.Sampler
;
import
org.springframework.cloud.sleuth.Span
;
import
java.util.BitSet
;
import
java.util.Map
;
import
java.util.Random
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.concurrent.locks.ReentrantReadWriteLock
;
/**
* 自定义采样率Sampler
*/
@Slf4j
public
class
PercentageLocalSampler
implements
Sampler
{
//采样率最小值
private
static
final
Float
MIN_PERCENTAGE
=
0.0f
;
//采样率最大值
private
static
final
Float
MAX_PERCENTAGE
=
1.0f
;
private
Map
<
String
,
BitSet
>
sampleDecisionsMap
;
//本地采样器
private
final
SamplerLocalProperties
configuration
;
private
Float
globalPercentage
;
private
static
final
String
all
=
"all"
;
//替换访问地址前缀正则表达式
private
static
final
String
regex
=
"^(http://www\\.|http://|www\\.|http:)"
;
//uri访问次数
private
final
Map
<
String
,
AtomicInteger
>
concurrentSampleCount
;
//刷新本地采样器和读取采样器配置使用读写锁,该场景读大于写,后期可优化为类似eureka注册表多级缓存
ReentrantReadWriteLock
readWriteLock
=
new
ReentrantReadWriteLock
();
//读锁
ReentrantReadWriteLock
.
ReadLock
readLock
=
readWriteLock
.
readLock
();
//写锁
ReentrantReadWriteLock
.
WriteLock
writeLock
=
readWriteLock
.
writeLock
();
public
PercentageLocalSampler
(
SamplerLocalProperties
configuration
)
{
this
.
configuration
=
configuration
;
sampleDecisionsMap
=
buildRandomBit
();
concurrentSampleCount
=
new
ConcurrentHashMap
<>();
concurrentSampleCount
.
put
(
all
,
new
AtomicInteger
(
0
));
}
public
Map
<
String
,
AtomicInteger
>
getConcurrentSampleCount
()
{
return
this
.
concurrentSampleCount
;
}
@Override
public
boolean
isSampled
(
Span
currentSpan
)
{
try
{
readLock
.
lock
();
if
(
currentSpan
==
null
)
{
return
false
;
}
// 获取span中的请求uri
String
uri
=
currentSpan
.
getName
();
uri
=
uri
.
replaceFirst
(
regex
,
""
);
AtomicInteger
count
=
this
.
concurrentSampleCount
.
get
(
all
);
// 获取全局的bitSet
BitSet
bitSet
=
this
.
sampleDecisionsMap
.
get
(
all
);
// 获取全局的采样率
float
percentage
=
this
.
configuration
.
getPercentage
();
for
(
UriSampleProperties
sampleProperties
:
configuration
.
getUriSamples
())
{
// 正则匹配
if
(
uri
.
matches
(
sampleProperties
.
getUriRegex
()))
{
//匹配上了自定义采样率的正则
// 多个线程会有并发问题,加个局部锁
synchronized
(
this
)
{
// 判断当前uri是否在map中
if
(!
concurrentSampleCount
.
containsKey
(
uri
))
{
concurrentSampleCount
.
put
(
uri
,
new
AtomicInteger
(
0
));
}
}
// 获取当前URI对应的访问次数
count
=
concurrentSampleCount
.
get
(
uri
);
// 获取当前URI对应的bitSet
bitSet
=
sampleDecisionsMap
.
get
(
sampleProperties
.
getUriRegex
());
// 获取当前URI对应的采样率
percentage
=
sampleProperties
.
getUriPercentage
();
break
;
}
}
log
.
warn
(
"replace uri {} , percentage {}"
,
uri
,
percentage
);
// 如果采样率是0 ,直接返回false
if
(
percentage
==
MIN_PERCENTAGE
)
{
return
false
;
}
else
if
(
percentage
==
MAX_PERCENTAGE
)
{
// 如果采样率是1 ,那么直接返回true
return
true
;
}
synchronized
(
this
)
{
// 访问次数加1
final
int
i
=
count
.
getAndIncrement
();
// 判断当前的访问 次数是否在 bitSet中,存在则返回true
boolean
result
=
bitSet
.
get
(
i
);
// 等于99的时候,重新设置为0
if
(
i
==
99
)
{
count
.
set
(
0
);
}
return
result
;
}
}
finally
{
readLock
.
unlock
();
}
}
private
static
BitSet
randomBitSet
(
int
size
,
int
cardinality
,
Random
rnd
)
{
BitSet
result
=
new
BitSet
(
size
);
int
[]
chosen
=
new
int
[
cardinality
];
int
i
;
for
(
i
=
0
;
i
<
cardinality
;
++
i
)
{
chosen
[
i
]
=
i
;
result
.
set
(
i
);
}
for
(;
i
<
size
;
++
i
)
{
int
j
=
rnd
.
nextInt
(
i
+
1
);
if
(
j
<
cardinality
)
{
result
.
clear
(
chosen
[
j
]);
result
.
set
(
i
);
chosen
[
j
]
=
i
;
}
}
return
result
;
}
private
Map
<
String
,
BitSet
>
buildRandomBit
()
{
Map
<
String
,
BitSet
>
map
=
new
ConcurrentHashMap
<>();
int
size
=
100
;
// 设置全局的采样率
int
outOf100
=
(
int
)
(
configuration
.
getPercentage
()
*
size
);
map
.
put
(
all
,
randomBitSet
(
size
,
outOf100
,
new
Random
()));
if
(
CollectionUtils
.
isNotEmpty
(
configuration
.
getUriSamples
()))
{
for
(
UriSampleProperties
sampleProperties
:
configuration
.
getUriSamples
())
{
// 设置个性化的采样率
map
.
put
(
sampleProperties
.
getUriRegex
(),
randomBitSet
(
size
,
(
int
)
(
sampleProperties
.
getUriPercentage
()
*
size
),
new
Random
()));
}
}
return
map
;
}
public
void
initPercentage
(
SamplerLocalProperties
samplerRemoteProperties
)
{
try
{
writeLock
.
lock
();
configuration
.
setPercentage
(
samplerRemoteProperties
.
getPercentage
());
configuration
.
setUriSamples
(
samplerRemoteProperties
.
getUriSamples
());
sampleDecisionsMap
=
buildRandomBit
();
}
finally
{
writeLock
.
unlock
();
}
}
public
SamplerLocalProperties
getConfiguration
()
{
return
configuration
;
}
}
pcloud-common-core/src/main/java/com/pcloud/common/core/zipkin/RefreshSamplerLocalProperties.java
deleted
100644 → 0
View file @
d46bb088
package
com
.
pcloud
.
common
.
core
.
zipkin
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.TypeReference
;
import
com.pcloud.common.utils.string.StringUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.BeansException
;
import
org.springframework.beans.factory.InitializingBean
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cloud.bootstrap.config.PropertySourceLocator
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContextAware
;
import
org.springframework.core.env.Environment
;
import
org.springframework.core.env.PropertySource
;
import
org.springframework.stereotype.Component
;
import
java.util.*
;
/**
* 刷新本地采样率
*/
@Slf4j
@Component
public
class
RefreshSamplerLocalProperties
implements
ApplicationContextAware
,
InitializingBean
{
@Autowired
(
required
=
false
)
private
List
<
PropertySourceLocator
>
propertySourceLocators
=
new
ArrayList
<>();
@Autowired
(
required
=
false
)
private
PercentageLocalSampler
percentageLocalSampler
;
//线程休眠时间
private
static
final
Long
REFRESH_SLEEP_TIME
=
60
*
1000L
;
//个性化采样率map的key
private
static
final
String
SPRING_ZIPKIN_URISAMPLEMAPJSONSTR
=
"spring.zipkin.uriSampleMapJsonStr"
;
//个性化设置全局采样率的key
private
static
final
String
SPRING_ZIPKIN_GLOBALPERCENTAGE
=
"spring.zipkin.globalPercentage"
;
//容器上下文
private
ApplicationContext
applicationContext
;
//个性化采样率默认值
private
static
final
String
DEFAULT_URISAMPLEMAPJSONSTR
=
"{}"
;
//全局采样率默认值
private
static
final
Float
DEFAULT_GLOBALPERCENTAGE
=
0.01f
;
private
Environment
environment
;
private
static
final
String
STATUS_DELIMITER
=
"-"
;
@Override
public
void
setApplicationContext
(
ApplicationContext
applicationContext
)
throws
BeansException
{
this
.
applicationContext
=
applicationContext
;
environment
=
applicationContext
.
getEnvironment
();
}
@Override
public
void
afterPropertiesSet
()
throws
Exception
{
new
RefreshRequest
().
start
();
}
public
void
setPropertySourceLocators
(
Collection
<
PropertySourceLocator
>
propertySourceLocators
)
{
this
.
propertySourceLocators
=
new
ArrayList
<>(
propertySourceLocators
);
}
/**
* 读取git配置文件线程
*/
class
RefreshRequest
extends
Thread
{
@Override
public
void
run
()
{
while
(
true
)
{
try
{
for
(
PropertySourceLocator
locator
:
propertySourceLocators
)
{
PropertySource
<?>
source
=
null
;
source
=
locator
.
locate
(
environment
);
if
(
source
==
null
)
{
continue
;
}
float
globalPercentage
=
source
.
getProperty
(
SPRING_ZIPKIN_GLOBALPERCENTAGE
)
!=
null
?
Float
.
parseFloat
(
source
.
getProperty
(
SPRING_ZIPKIN_GLOBALPERCENTAGE
).
toString
())
:
DEFAULT_GLOBALPERCENTAGE
;
String
uriSampleMapJsonStr
=
source
.
getProperty
(
SPRING_ZIPKIN_URISAMPLEMAPJSONSTR
)
!=
null
?
source
.
getProperty
(
SPRING_ZIPKIN_URISAMPLEMAPJSONSTR
).
toString
()
:
DEFAULT_URISAMPLEMAPJSONSTR
;
log
.
warn
(
"读取git配置文件 globalPercentage {} ,globalPercentageJsonStr {}"
,
globalPercentage
,
uriSampleMapJsonStr
);
if
(!
uriSampleMapJsonStr
.
equals
(
DEFAULT_URISAMPLEMAPJSONSTR
))
{
loadSamplerProperties
(
globalPercentage
,
uriSampleMapJsonStr
);
}
}
Thread
.
sleep
(
REFRESH_SLEEP_TIME
);
}
catch
(
Exception
e
)
{
log
.
error
(
"刷新采样率异常 {}"
,
e
);
}
}
}
}
/**
* 刷新PercentageLocalSampler
*
* @param globalPercentage 全局采样率
* @param uriSampleMapJsonStr url正则表达式和个性化采样率
*/
public
void
loadSamplerProperties
(
Float
globalPercentage
,
String
uriSampleMapJsonStr
)
{
//获取容器的percentageLocalSampler
if
(
null
==
percentageLocalSampler
)
{
percentageLocalSampler
=
(
PercentageLocalSampler
)
applicationContext
.
getBean
(
"percentageLocalSampler"
);
}
SamplerLocalProperties
samplerLocalProperties
=
percentageLocalSampler
.
getConfiguration
();
SamplerLocalProperties
samplerRemoteLocalProperties
=
new
SamplerLocalProperties
();
//全局采样率配置更新
if
(
globalPercentage
!=
null
&&
globalPercentage
!=
DEFAULT_GLOBALPERCENTAGE
)
{
samplerRemoteLocalProperties
.
setPercentage
(
globalPercentage
);
}
if
(!
StringUtil
.
isEmpty
(
uriSampleMapJsonStr
)
&&
!
uriSampleMapJsonStr
.
equals
(
DEFAULT_URISAMPLEMAPJSONSTR
))
{
List
<
UriSampleProperties
>
uriSamples
=
new
ArrayList
<>();
Map
<
Float
,
ArrayList
<
String
>>
uriSampleMap
=
(
HashMap
<
Float
,
ArrayList
<
String
>>)
JSON
.
parseObject
(
uriSampleMapJsonStr
,
new
TypeReference
<
HashMap
<
Float
,
ArrayList
<
String
>>>()
{
});
if
(
uriSampleMap
!=
null
&&
uriSampleMap
.
size
()
>
0
)
{
for
(
Map
.
Entry
<
Float
,
ArrayList
<
String
>>
entry
:
uriSampleMap
.
entrySet
())
{
float
percentage
=
entry
.
getKey
();
for
(
String
uri
:
entry
.
getValue
())
{
UriSampleProperties
uriSampleProperties
=
new
UriSampleProperties
();
uriSampleProperties
.
setUriPercentage
(
percentage
);
uriSampleProperties
.
setUriRegex
(
uri
);
uriSamples
.
add
(
uriSampleProperties
);
}
}
}
samplerRemoteLocalProperties
.
setUriSamples
(
uriSamples
);
}
if
(!
getPercentageSamplerHashCode
(
samplerRemoteLocalProperties
).
equals
(
getPercentageSamplerHashCode
(
samplerLocalProperties
))){
log
.
warn
(
"更新采样率 globalPercentage {} ,globalPercentageJsonStr {}"
,
globalPercentage
,
uriSampleMapJsonStr
);
percentageLocalSampler
.
initPercentage
(
samplerRemoteLocalProperties
);
}
}
/**
* 计算计算hash值
*
* @param samplerLocalProperties
* @return
*/
public
static
String
getPercentageSamplerHashCode
(
SamplerLocalProperties
samplerLocalProperties
)
{
StringBuffer
reconcileHashCode
=
new
StringBuffer
((
samplerLocalProperties
.
getPercentage
()
+
STATUS_DELIMITER
));
for
(
UriSampleProperties
uriSampleProperties
:
samplerLocalProperties
.
getUriSamples
())
{
reconcileHashCode
.
append
(
uriSampleProperties
.
getUriRegex
().
hashCode
()
+
STATUS_DELIMITER
);
reconcileHashCode
.
append
((
uriSampleProperties
.
getUriPercentage
()
+
STATUS_DELIMITER
));
}
return
reconcileHashCode
.
toString
();
}
}
pcloud-common-core/src/main/java/com/pcloud/common/core/zipkin/SamplerLocalProperties.java
deleted
100644 → 0
View file @
d46bb088
package
com
.
pcloud
.
common
.
core
.
zipkin
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* 本地采样器集合
*/
public
class
SamplerLocalProperties
{
//采样器集合
private
List
<
UriSampleProperties
>
uriSamples
=
new
ArrayList
<>(
10
);
//全局采样率
private
float
percentage
=
0.1f
;
public
List
<
UriSampleProperties
>
getUriSamples
()
{
return
uriSamples
;
}
public
void
setUriSamples
(
List
<
UriSampleProperties
>
uriSamples
)
{
this
.
uriSamples
=
uriSamples
;
}
public
float
getPercentage
()
{
return
percentage
;
}
public
void
setPercentage
(
float
percentage
)
{
this
.
percentage
=
percentage
;
}
}
pcloud-common-core/src/main/java/com/pcloud/common/core/zipkin/UriSampleProperties.java
deleted
100644 → 0
View file @
d46bb088
package
com
.
pcloud
.
common
.
core
.
zipkin
;
import
java.lang.reflect.Array
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* 本地取样器
*/
public
class
UriSampleProperties
{
//url正则表达式表达式
private
String
uriRegex
;
//采样率
private
float
uriPercentage
=
0.01f
;
public
String
getUriRegex
()
{
return
uriRegex
;
}
public
void
setUriRegex
(
String
uriRegex
)
{
this
.
uriRegex
=
uriRegex
;
}
public
float
getUriPercentage
()
{
return
uriPercentage
;
}
public
void
setUriPercentage
(
float
uriPercentage
)
{
this
.
uriPercentage
=
uriPercentage
;
}
}
pcloud-common-core/src/main/java/com/pcloud/common/core/zipkin/ZipkinConfig.java
deleted
100644 → 0
View file @
d46bb088
package
com
.
pcloud
.
common
.
core
.
zipkin
;
import
org.springframework.boot.autoconfigure.AutoConfigureBefore
;
import
org.springframework.cloud.sleuth.Sampler
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
/**
* 重新配置自定义采样率
*/
@Configuration
@AutoConfigureBefore
(
RefreshSamplerLocalProperties
.
class
)
public
class
ZipkinConfig
{
//ZipkinAutoConfiguration使用@ConditionalOnMissingBean注解的,也就是容器中不存在这个Bean的时候,才初始化他自己默认的配置,可以重写他的配置
@Bean
public
Sampler
percentageLocalSampler
(){
SamplerLocalProperties
samplerLocalProperties
=
new
SamplerLocalProperties
();
return
new
PercentageLocalSampler
(
samplerLocalProperties
);
}
}
pcloud-common/pom.xml
View file @
f56b6d16
...
...
@@ -6,27 +6,22 @@
<parent>
<groupId>
com.pcloud.common
</groupId>
<artifactId>
pcloud-common-parent
</artifactId>
<version>
2.1.0-RELEASE
</version>
<version>
3.1.0-SNAPSHOT
</version>
</parent>
<artifactId>
pcloud-common
</artifactId>
<packaging>
jar
</packaging>
<version>
${
pcloud-common.
version}
</version>
<version>
${
re
version}
</version>
<name>
pcloud-common
</name>
<url>
http://maven.apache.org
</url>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>
com.pcloud.common
</groupId>
<artifactId>
pcloud-common-config
</artifactId>
<version>
${pcloud-common-config.version}
</version>
</dependency>
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
</dependency>
...
...
@@ -49,7 +44,7 @@
<!-- Spring Cloud Begin -->
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-
eureka
</artifactId>
<artifactId>
spring-cloud-starter-
netflix-eureka-client
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
...
...
@@ -57,23 +52,23 @@
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-feign
</artifactId>
<artifactId>
spring-cloud-starter-
open
feign
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-ribbon
</artifactId>
<artifactId>
spring-cloud-starter-
netflix-
ribbon
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-turbine
</artifactId>
<artifactId>
spring-cloud-starter-
netflix-
turbine
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-hystrix
</artifactId>
<artifactId>
spring-cloud-starter-
netflix-
hystrix
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-hystrix-dashboard
</artifactId>
<artifactId>
spring-cloud-starter-
netflix-
hystrix-dashboard
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.retry
</groupId>
...
...
@@ -83,24 +78,14 @@
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-stream-rabbit
</artifactId>
</dependency>
<dependency>
<
!--<
dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>
<dependency>
<groupId>
io.micrometer
</groupId>
<artifactId>
micrometer-spring-legacy
</artifactId>
<version>
1.0.0-rc.2
</version>
</dependency>
<dependency>
<groupId>
io.micrometer
</groupId>
<artifactId>
micrometer-registry-influx
</artifactId>
<version>
1.0.0-rc.2
</version>
</dependency>
</dependency>-->
<dependency>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-swagger2
</artifactId>
...
...
@@ -119,6 +104,10 @@
<artifactId>
cglib
</artifactId>
</dependency>
<dependency>
<groupId>
org.apache.ant
</groupId>
<artifactId>
ant
</artifactId>
</dependency>
<dependency>
<groupId>
org.slf4j
</groupId>
<artifactId>
slf4j-api
</artifactId>
</dependency>
...
...
pcloud-solr/pom.xml
View file @
f56b6d16
...
...
@@ -6,27 +6,21 @@
<parent>
<groupId>
com.pcloud.common
</groupId>
<artifactId>
pcloud-common-parent
</artifactId>
<version>
2.1.0-RELEASE
</version>
<version>
3.1.0-SNAPSHOT
</version>
</parent>
<artifactId>
pcloud-solr
</artifactId>
<packaging>
jar
</packaging>
<version>
${
pcloud-solr.
version}
</version>
<version>
${
re
version}
</version>
<name>
pcloud-solr
</name>
<url>
http://maven.apache.org
</url>
<properties>
<
project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding
>
<
spring.data.solr.version>
2.1.7.RELEASE
</spring.data.solr.version
>
</properties>
<dependencies>
<dependency>
<groupId>
com.pcloud.common
</groupId>
<artifactId>
pcloud-common-config
</artifactId>
<version>
${pcloud-common-config.version}
</version>
</dependency>
<!-- solr add by gaop at 2018-4-23 11:33:47 -->
<dependency>
<groupId>
org.springframework.data
</groupId>
...
...
@@ -49,22 +43,18 @@
<dependency>
<groupId>
org.slf4j
</groupId>
<artifactId>
slf4j-api
</artifactId>
<version>
1.7.18
</version>
</dependency>
<dependency>
<groupId>
org.apache.commons
</groupId>
<artifactId>
commons-lang3
</artifactId>
<version>
3.4
</version>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
<version>
1.2.38
</version>
</dependency>
<dependency>
<groupId>
org.apache.commons
</groupId>
<artifactId>
commons-collections4
</artifactId>
<version>
4.1
</version>
</dependency>
<!-- Common Dependency End -->
...
...
pom.xml
View file @
f56b6d16
...
...
@@ -5,17 +5,16 @@
<modelVersion>
4.0.0
</modelVersion>
<parent>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter
-parent
</artifactId>
<version>
1.5.8.RELEASE
</version>
<relativePath
/>
<!-- lookup parent from repository --
>
<groupId>
com.pcloud.universe
</groupId>
<artifactId>
universe-commons
-parent
</artifactId>
<version>
3.0.0-SNAPSHOT
</version>
<relativePath
/
>
</parent>
<groupId>
com.pcloud.common
</groupId>
<artifactId>
pcloud-common-parent
</artifactId>
<version>
2.1.0-RELEASE
</version>
<version>
3.1.0-SNAPSHOT
</version>
<modules>
<module>
pcloud-common-config
</module>
<module>
pcloud-common
</module>
<module>
pcloud-common-core
</module>
<module>
pcloud-solr
</module>
...
...
@@ -23,175 +22,33 @@
<packaging>
pom
</packaging>
<name>
pcloud-common-parent
</name>
<url>
http://maven.apache.org
</url>
<profiles>
<!-- UAT -->
<profile>
<id>
uat
</id>
<activation>
<activeByDefault>
true
</activeByDefault>
</activation>
<build>
<resources>
<resource>
<directory>
src/main/resources
</directory>
</resource>
<resource>
<directory>
src/main/resources.uat
</directory>
</resource>
</resources>
</build>
<properties>
<!-- 部署环境(对应配置文件版本) -->
<env>
uat
</env>
<pcloud-common.version>
2.1.0-RELEASE
</pcloud-common.version>
<pcloud-common-config.version>
2.1.0-RELEASE
</pcloud-common-config.version>
<pcloud-common-core.version>
2.1.0-RELEASE
</pcloud-common-core.version>
<pcloud-solr.version>
2.1.0-RELEASE
</pcloud-solr.version>
</properties>
</profile>
<profile>
<id>
tsrpd
</id>
<activation>
<activeByDefault>
true
</activeByDefault>
</activation>
<build>
<resources>
<resource>
<directory>
src/main/resources
</directory>
</resource>
<resource>
<directory>
src/main/resources.tsrpd
</directory>
</resource>
</resources>
</build>
<properties>
<!-- 部署环境(对应配置文件版本) -->
<env>
tsrpd
</env>
<pcloud-common.version>
2.1.2-RELEASE
</pcloud-common.version>
<pcloud-common-config.version>
2.1.2-RELEASE
</pcloud-common-config.version>
<pcloud-common-core.version>
2.1.2-RELEASE
</pcloud-common-core.version>
<pcloud-solr.version>
2.1.0-RELEASE
</pcloud-solr.version>
</properties>
</profile>
<!-- 压测环境 -->
<profile>
<id>
perf
</id>
<build>
<resources>
<resource>
<directory>
src/main/resources
</directory>
</resource>
<resource>
<directory>
src/main/resources.perf
</directory>
</resource>
</resources>
</build>
<properties>
<!-- 部署环境(对应配置文件版本) -->
<env>
perf
</env>
<pcloud-common.version>
2.1.1-SNAPSHOT
</pcloud-common.version>
<pcloud-common-config.version>
2.1.1-SNAPSHOT
</pcloud-common-config.version>
<pcloud-common-core.version>
2.1.1-SNAPSHOT
</pcloud-common-core.version>
<pcloud-solr.version>
2.1.0-RELEASE
</pcloud-solr.version>
</properties>
</profile>
<!-- 生产环境 RAYS -->
<profile>
<id>
prod
</id>
<build>
<resources>
<resource>
<directory>
src/main/resources
</directory>
</resource>
<resource>
<directory>
src/main/resources.prod
</directory>
</resource>
</resources>
</build>
<properties>
<!-- 部署环境(对应配置文件版本) -->
<env>
prod
</env>
<pcloud-common.version>
2.1.1-RELEASE
</pcloud-common.version>
<pcloud-common-config.version>
2.1.1-RELEASE
</pcloud-common-config.version>
<pcloud-common-core.version>
2.1.1-RELEASE
</pcloud-common-core.version>
<pcloud-solr.version>
2.1.1-RELEASE
</pcloud-solr.version>
</properties>
</profile>
</profiles>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.reporting.outputEncoding>
UTF-8
</project.reporting.outputEncoding>
<java.version>
1.8
</java.version>
<spring-cloud.version>
Edgware.SR3
</spring-cloud.version>
<spring.data.solr.version>
2.1.7.RELEASE
</spring.data.solr.version>
<!-- frameworks -->
<slf4j.version>
1.7.18
</slf4j.version>
<reversion>
3.1.0-SNAPSHOT
</reversion>
<mpc-sdk-version>
2.0.7
</mpc-sdk-version>
</properties>
<dependencies>
<!-- Test Dependency Begin -->
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
</dependency>
<!-- Test Dependency End -->
</dependencies>
<dependencyManagement>
<dependencies>
<!-- Spring begin -->
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-dependencies
</artifactId>
<version>
${spring-cloud.version}
</version>
<type>
pom
</type>
<scope>
import
</scope>
</dependency>
<dependency>
<groupId>
org.mybatis.spring.boot
</groupId>
<artifactId>
mybatis-spring-boot-starter
</artifactId>
<version>
1.3.0
</version>
</dependency>
<!-- spring end -->
<!-- Common Dependency Begin -->
<dependency>
<groupId>
cglib
</groupId>
<artifactId>
cglib
</artifactId>
<version>
3.2.1
</version>
</dependency>
<dependency>
<groupId>
org.slf4j
</groupId>
<artifactId>
slf4j-api
</artifactId>
<version>
${slf4j.version}
</version>
</dependency>
<dependency>
<groupId>
org.slf4j
</groupId>
<artifactId>
jcl-over-slf4j
</artifactId>
<version>
${slf4j.version}
</version>
<version>
3.3.0
</version>
</dependency>
<dependency>
<groupId>
ch.qos.logback
</groupId>
<artifactId>
logback-classic
</artifactId>
<version>
1.1
.6
</version>
<groupId>
org.apache.ant
</groupId>
<artifactId>
ant
</artifactId>
<version>
1.1
0.10
</version>
</dependency>
<dependency>
<groupId>
ch.qos.logback
</groupId>
<artifactId>
logback-core
</artifactId>
<version>
1.1.6
</version>
</dependency>
<dependency>
<groupId>
ch.qos.logback
</groupId>
<artifactId>
logback-access
</artifactId>
<version>
1.1.6
</version>
<groupId>
redis.clients
</groupId>
<artifactId>
jedis
</artifactId>
<version>
2.10.2
</version>
</dependency>
<dependency>
<groupId>
commons-lang
</groupId>
...
...
@@ -199,24 +56,14 @@
<version>
2.6
</version>
</dependency>
<dependency>
<groupId>
org.apache.commons
</groupId>
<artifactId>
commons-lang3
</artifactId>
<version>
3.4
</version>
</dependency>
<dependency>
<groupId>
commons-codec
</groupId>
<artifactId>
commons-codec
</artifactId>
<version>
1.9
</version>
</dependency>
<dependency>
<groupId>
commons-beanutils
</groupId>
<artifactId>
commons-beanutils
</artifactId>
<version>
1.9.
2
</version>
<version>
1.9.
4
</version>
</dependency>
<dependency>
<groupId>
commons-io
</groupId>
<artifactId>
commons-io
</artifactId>
<version>
2.
4
</version>
<version>
2.
10.0
</version>
</dependency>
<dependency>
<groupId>
commons-logging
</groupId>
...
...
@@ -241,33 +88,13 @@
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
<version>
1.2.
38
</version>
<version>
1.2.
76
</version>
</dependency>
<dependency>
<groupId>
org.jdom
</groupId>
<artifactId>
jdom2
</artifactId>
<version>
2.0.6
</version>
</dependency>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpclient
</artifactId>
<version>
4.5.3
</version>
</dependency>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpcore
</artifactId>
<version>
4.4.6
</version>
</dependency>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<artifactId>
httpmime
</artifactId>
<version>
4.5.3
</version>
</dependency>
<dependency>
<groupId>
redis.clients
</groupId>
<artifactId>
jedis
</artifactId>
<version>
2.9.0
</version>
</dependency>
<!-- Common Dependency End -->
<!-- logback-json -->
...
...
@@ -288,13 +115,6 @@
</dependency>
<!-- Mysql Driver Begin -->
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
<version>
6.0.6
</version>
</dependency>
<!-- Mysql Driver End -->
<!-- 图片处理工具 added by songx at 2017-05-17 -->
<dependency>
...
...
@@ -378,70 +198,4 @@
</dependencies>
</dependencyManagement>
<repositories>
<repository>
<snapshots>
<enabled>
true
</enabled>
</snapshots>
<id>
public
</id>
<name>
public repositories
</name>
<url>
http://192.168.83.20:8081/nexus/content/groups/public/
</url>
</repository>
<repository>
<snapshots>
<enabled>
true
</enabled>
</snapshots>
<id>
jboss
</id>
<name>
public jboss
</name>
<url>
http://192.168.83.20:8081/nexus/content/repositories/jboss
</url>
</repository>
<repository>
<id>
sonatype-nexus-staging
</id>
<name>
Sonatype Nexus Staging
</name>
<url>
https://oss.sonatype.org/service/local/staging/deploy/maven2/
</url>
<releases>
<enabled>
true
</enabled>
</releases>
<snapshots>
<enabled>
true
</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>
public
</id>
<name>
public repositories
</name>
<url>
http://192.168.83.20:8081/nexus/content/groups/public/
</url>
</pluginRepository>
<pluginRepository>
<releases>
<updatePolicy>
never
</updatePolicy>
</releases>
<snapshots>
<enabled>
false
</enabled>
</snapshots>
<id>
central
</id>
<name>
Central Repository
</name>
<url>
http://repo.maven.apache.org/maven2
</url>
</pluginRepository>
<pluginRepository>
<id>
Codehaus repository
</id>
<url>
http://repository.codehaus.org/
</url>
</pluginRepository>
</pluginRepositories>
<distributionManagement>
<repository>
<id>
nexus-releases
</id>
<name>
Nexus Release Repository
</name>
<url>
http://192.168.83.20:8081/nexus/content/repositories/releases/
</url>
</repository>
<snapshotRepository>
<id>
nexus-snapshots
</id>
<name>
Nexus Snapshot Repository
</name>
<url>
http://192.168.83.20:8081/nexus/content/repositories/snapshots/
</url>
</snapshotRepository>
</distributionManagement>
</project>
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