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
bc7a21f9
authored
May 28, 2017
by
amir
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
add Metrics view in html
parent
a2f7bf4a
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
91 additions
and
13 deletions
doc/ServicesDesign.md
doc/todo.txt
src/main/java/microservice/MicroserviceApp.java
src/main/java/microservice/params/RestServerParams.java
src/main/java/microservice/services/IRestServiceHttpImpl.java
src/main/java/microservice/services/IRestServiceZmqImpl.java
src/main/java/microservice/types/UserProfile.java
src/main/resources/microservice/services/metrics.html
doc/ServicesDesign.md
View file @
bc7a21f9
...
...
@@ -39,5 +39,8 @@
4 Mitfanen :sleeping:
### Metrics
To see the Metrics go to /_mon/_stat to get in json
to see in html go to /static/metrics.html
### ZMQRestService
![
alt text
](
ZMQRestService.png
)
doc/todo.txt
View file @
bc7a21f9
...
...
@@ -9,7 +9,7 @@
addTest(nsMicroservice_Iface::ITest *p_testClass)
*
- Add true async in http rest service, that we can send response after handleRequest ends.
+
- Add true async in http rest service, that we can send response after handleRequest ends.
// exchange.dispatch(() -> {
// new Timer().schedule(new TimerTask() {
// public void run() {
...
...
@@ -20,5 +20,6 @@
// }
// }, 5000);
// });
- ZMQ : All sockets must be handled from the same thread who created them.
so we can use Rx or my ipc or zmq ipc for event loops
\ No newline at end of file
- add static page for monitor metrics that calls http://localhost:32000/_mon/_stat?viewType=list
periodically via jquery and display the metrics in a table
\ No newline at end of file
src/main/java/microservice/MicroserviceApp.java
View file @
bc7a21f9
...
...
@@ -65,7 +65,7 @@ public class MicroserviceApp
Map
<
String
,
microservice
.
MicroserviceClient
>
msClientMap
=
null
;
List
<
IRestServer
>
serverList
=
null
;
Optional
<
MonitorHandler
>
optMonitorHandler
=
Optional
.
empty
();
/////////////// new design
services
///////////////////
/////////////// new design
microservice
///////////////////
Reactor
reactor
;
public
MicroserviceApp
(
String
appName
)
...
...
@@ -525,7 +525,7 @@ public class MicroserviceApp
/******** SERVICES DESIGN **********************************************/
/*************************************************************************/
//
/// the
services
array
/// the
microservice
array
//private final List<Map<String,CommonServices.IService>> servicesArray = new ArrayList<>(Enums.EnumServiceType.values().length);
private
final
Map
<
String
,
CommonServices
.
IService
>[]
servicesArray
=
new
Map
[
Enums
.
EnumServiceType
.
values
().
length
];
...
...
@@ -601,7 +601,7 @@ public class MicroserviceApp
reactor
.
init
(
logger
);
/**
* init
services
* init
microservice
* iterating only over non empty elements
*/
Arrays
.
stream
(
servicesArray
)
...
...
src/main/java/microservice/params/RestServerParams.java
View file @
bc7a21f9
...
...
@@ -21,7 +21,7 @@ public class RestServerParams
public
RestServerParams
(
int
port
,
String
host
,
int
workerThreadsNum
)
{
super
();
setParams
(
port
,
host
,
workerThreadsNum
,
"localhost"
,
fals
e
,
0
,
1883
);
setParams
(
port
,
host
,
workerThreadsNum
,
"localhost"
,
tru
e
,
0
,
1883
);
}
...
...
src/main/java/microservice/services/IRestServiceHttpImpl.java
View file @
bc7a21f9
...
...
@@ -27,7 +27,6 @@ import microservice.io.impl.IRequestRestImpl;
import
microservice.io.impl.IResponseRestImpl
;
import
microservice.params.CommandParams
;
import
microservice.params.RestServerParams
;
import
microservice.services.CommonServices
;
import
microservice.types.BaseRestResponse
;
import
microservice.types.UserProfile
;
...
...
@@ -316,9 +315,10 @@ public class IRestServiceHttpImpl extends CommonServices.IRestService implements
apiDocMimeMappingsBuilder
.
addMapping
(
"json"
,
"text/json"
);
apiDocMimeMappingsBuilder
.
addMapping
(
"yaml"
,
"text/x-yaml"
);
apiDocMimeMappingsBuilder
.
addMapping
(
"html"
,
"text/html"
);
pathHandler
.
addPrefixPath
(
"/static"
,
resource
(
new
ClassPathResourceManager
(
getClass
().
getClassLoader
(),
"static"
))
pathHandler
.
addPrefixPath
(
"/static"
,
resource
(
new
ClassPathResourceManager
(
getClass
().
getClassLoader
(),
getClass
().
getPackage
()))
//"static"))
.
addWelcomeFiles
(
"microservice/services/metrics.html"
)
.
setMimeMappings
(
apiDocMimeMappingsBuilder
.
build
())
.
setDirectoryListingEnabled
(
tru
e
));
.
setDirectoryListingEnabled
(
fals
e
));
}
@Override
...
...
src/main/java/microservice/services/IRestServiceZmqImpl.java
View file @
bc7a21f9
...
...
@@ -45,7 +45,7 @@ import static microservice.defs.Constants.EXIT_MSG_LEN;
* <img src="../../../../../../../doc/ZMQRestService.png" alt="">
* <p>Notes: <br>
* - All ZMQ sockets must be handled from the thread that created them (zmq not thread safe)<br>
* - Each Service has only one destination, for multiple destination create multiple zmq
services
* - Each Service has only one destination, for multiple destination create multiple zmq
microservice
* </p>
* </p>
* <p>
...
...
src/main/java/microservice/types/UserProfile.java
View file @
bc7a21f9
...
...
@@ -65,7 +65,7 @@ public class UserProfile extends DefaultClaims {
public
boolean
isServiceAuthorized
(
String
serviceName
,
CommonServices
.
EnumRestCommands
enumRestCommands
){
boolean
authorized
=
false
;
String
serviceAuth
=
serviceAuthorizations
.
get
(
serviceName
);
if
(
serviceAuth
==
null
)
// check for all
services
authorizations
if
(
serviceAuth
==
null
)
// check for all
microservice
authorizations
serviceAuth
=
serviceAuthorizations
.
get
(
ALL_SERVICES
);
if
(
serviceAuth
!=
null
)
...
...
src/main/resources/microservice/services/metrics.html
0 → 100644
View file @
bc7a21f9
<!DOCTYPE html>
<html>
<head>
<script
src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"
></script>
<link
rel=
"stylesheet"
href=
"https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.5/css/materialize.min.css"
>
<script
src=
"https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.5/js/materialize.min.js"
></script>
<script>
// Builds the HTML Table out of myList.
function
buildHtmlTable
(
data
)
{
var
selector
=
'#meterTable'
;
var
list
=
data
.
objectNode
.
meters
;
var
columns
=
addAllColumnHeaders
(
list
,
selector
);
addRows
(
selector
,
columns
,
list
);
selector
=
'#timerTable'
;
list
=
data
.
objectNode
.
timers
;
columns
=
addAllColumnHeaders
(
list
,
selector
);
addRows
(
selector
,
columns
,
list
);
}
function
addRows
(
selector
,
columns
,
myList
){
for
(
var
i
=
0
;
i
<
myList
.
length
;
i
++
)
{
var
row$
=
$
(
'
<
tr
/>
'
);
for
(
var
colIndex
=
0
;
colIndex
<
columns
.
length
;
colIndex
++
)
{
var
cellValue
=
myList
[
i
][
columns
[
colIndex
]];
if
(
cellValue
==
null
)
cellValue
=
""
;
row$
.
append
(
$
(
'
<
td
/>
').html(cellValue));
}
$(selector).append(row$);
}
}
// Adds a header row to the table and returns the set of columns.
// Need to do union of keys from all records as some records may not contain
// all records.
function addAllColumnHeaders(myList, selector) {
var columnSet = [];
var headerTr$ = $('
<
tr
/>
'
);
for
(
var
i
=
0
;
i
<
myList
.
length
;
i
++
)
{
var
rowHash
=
myList
[
i
];
for
(
var
key
in
rowHash
)
{
if
(
$
.
inArray
(
key
,
columnSet
)
==
-
1
)
{
columnSet
.
push
(
key
);
headerTr$
.
append
(
$
(
'
<
th
/>
'
).
html
(
key
));
}
}
}
$
(
selector
).
append
(
headerTr$
);
return
columnSet
;
}
$
(
document
).
ready
(
function
(){
$
.
get
(
"http://localhost:32000/_mon/_stat?viewType=list"
,
function
(
data
,
status
){
buildHtmlTable
(
data
);
});
});
</script>
</head>
<body>
<table
id=
"meterTable"
border=
"1"
>
</table>
<table
id=
"timerTable"
border=
"1"
>
</table>
</body>
</html>
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