Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
ipgallery.common.java
/
microservice
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Registry
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
47538921
authored
Jul 07, 2016
by
amir
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
- create with metrics false/true
- init metrics publisher only once
parent
30f9cd9f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
6 deletions
README.md
build.gradle
src/main/java/microservice/io/impl/IRestClientRestImpl.java
src/main/java/microservice/params/RestClientParams.java
src/test/java/microservice/TestMicroClient.java
README.md
View file @
47538921
### Microservice Framework in JAVA
## Version 1.2.1:
-
create with metrics false/true
-
init metrics publisher only once
## Version 1.2.0:
-
Add Graphite Repoter for metrics:
...
...
build.gradle
View file @
47538921
group
'com.ipgallery.common'
version
'1.2.
0
'
version
'1.2.
1
'
apply
plugin:
'java'
apply
plugin:
'maven-publish'
...
...
src/main/java/microservice/io/impl/IRestClientRestImpl.java
View file @
47538921
...
...
@@ -32,6 +32,7 @@ import microservice.params.RestClientParams;
public
class
IRestClientRestImpl
implements
ICommandClient
{
public
static
final
String
HYSTRIX_PLUGIN_HYSTRIX_METRICS_PUBLISHER_IMPLEMENTATION
=
"hystrix.plugin.HystrixMetricsPublisher.implementation"
;
private
static
final
int
POLLING_DELAY
=
500
;
/*************************************************************************
...
...
@@ -220,8 +221,7 @@ public class IRestClientRestImpl implements ICommandClient
/*********************************************************************************************************************************************/
private
static
final
String
COMMAND_ERROR
=
"Command Error: "
;
private
static
final
String
COMMAND_ERROR
=
"Command Error: "
;
RestClientParams
clientParams
=
null
;
SimpleRestClient
httpRestClient
=
null
;
// HystrixMetricsPoller poller = null;
...
...
@@ -240,15 +240,28 @@ public class IRestClientRestImpl implements ICommandClient
httpRestClient
.
Initialize
(
clientParams
.
getMaxConnection
());
if
(
clientParams
.
isMetricsEnabled
())
{
IMetricsFactoryImpl
factoryImpl
=
(
IMetricsFactoryImpl
)
IMetricsFactoryImpl
.
getInstance
();
HystrixMetricsPublisher
publisher
=
new
HystrixCodaHaleMetricsPublisher
(
factoryImpl
.
getMetrics
());
HystrixPlugins
.
getInstance
().
registerMetricsPublisher
(
publisher
);
initMetricsPublisher
();
// jsonListener = new MetricJsonListener();
// poller = new HystrixMetricsPoller(jsonListener, POLLING_DELAY);
// poller.start();
}
}
private
synchronized
void
initMetricsPublisher
()
{
String
publisherStr
=
System
.
getProperty
(
HYSTRIX_PLUGIN_HYSTRIX_METRICS_PUBLISHER_IMPLEMENTATION
);
if
(
publisherStr
==
null
)
{
try
{
IMetricsFactoryImpl
factoryImpl
=
(
IMetricsFactoryImpl
)
IMetricsFactoryImpl
.
getInstance
();
HystrixMetricsPublisher
publisher
=
new
HystrixCodaHaleMetricsPublisher
(
factoryImpl
.
getMetrics
());
HystrixPlugins
.
getInstance
().
registerMetricsPublisher
(
publisher
);
System
.
setProperty
(
HYSTRIX_PLUGIN_HYSTRIX_METRICS_PUBLISHER_IMPLEMENTATION
,
publisher
.
getClass
().
getName
());
}
catch
(
IllegalStateException
ise
){
}
}
}
public
IRestClientRestImpl
withServiceDiscovery
(
IServiceDiscovery
servDisco
)
{
serviceDiscovery
=
Optional
.
ofNullable
(
servDisco
);
...
...
src/main/java/microservice/params/RestClientParams.java
View file @
47538921
...
...
@@ -11,6 +11,12 @@ public class RestClientParams extends BaseClientParams
this
.
address
=
address
;
}
public
RestClientParams
(
String
serviceName
,
boolean
useCache
,
int
cacheTimeout
,
String
address
,
String
cacheHost
,
boolean
enableMetrics
)
{
super
(
serviceName
,
useCache
,
cacheTimeout
,
enableMetrics
,
cacheHost
);
this
.
address
=
address
;
}
public
RestClientParams
(
String
serviceName
,
boolean
useCache
,
int
cacheTimeout
,
String
address
,
String
cacheHost
,
int
maxConnection
)
{
super
(
serviceName
,
useCache
,
cacheTimeout
,
true
,
cacheHost
);
...
...
src/test/java/microservice/TestMicroClient.java
View file @
47538921
...
...
@@ -34,6 +34,7 @@ public class TestMicroClient
{
ICommandClient
cmdClient
=
new
IRestClientRestImpl
(
clientParams
).
withServiceDiscovery
(
serDisco
);
client
=
new
MicroserviceClient
(
cmdClient
,
clientParams
);
new
MicroserviceClient
(
new
IRestClientRestImpl
(
clientParams
),
clientParams
);
CommandParams
cmdParams
=
new
CommandParams
(
"entities"
,
"MCX/entities/lili/person"
,
null
,
null
,
null
);
System
.
out
.
println
(
"Start Testing"
);
for
(
int
i
=
0
;
i
<
MAX_ITERATION
;
i
++)
...
...
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