Skip to content

Commit 324c745

Browse files
authored
Merge pull request #898 from oskarhane/nicer-jmx
Don’t fetch everything from jmx in background fetches
2 parents a9c1ae8 + c8de875 commit 324c745

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

src/shared/modules/jmx/jmxDuck.js

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020

2121
import Rx from 'rxjs/Rx'
2222
import bolt from 'services/bolt/bolt'
23-
import { toObjects, extractFromNeoObjects } from 'services/bolt/boltMappings'
23+
import {
24+
recordsToTableArray,
25+
extractFromNeoObjects
26+
} from 'services/bolt/boltMappings'
2427
import { APP_START } from 'shared/modules/app/appDuck'
2528
import {
2629
CONNECTED_STATE,
@@ -61,10 +64,21 @@ export const getJmxValues = ({ jmx }, arr) => {
6164
* Helpers
6265
*/
6366

67+
const jmxQuery = `
68+
CALL dbms.queryJmx("org.neo4j:instance=*,name=Kernel") yield attributes
69+
RETURN {name: 'Kernel', data: collect(attributes)} as result
70+
UNION ALL
71+
CALL dbms.queryJmx("org.neo4j:instance=*,name=Store file sizes") yield attributes
72+
RETURN {name: 'Store file sizes', data: collect(attributes)} as result
73+
UNION ALL
74+
CALL dbms.queryJmx("org.neo4j:instance=*,name=Configuration") yield attributes
75+
RETURN {name: 'Configuration', data: collect(attributes)} as result
76+
`
77+
6478
const fetchJmxValues = store => {
6579
return bolt
6680
.directTransaction(
67-
'CALL dbms.queryJmx("org.neo4j:*")',
81+
jmxQuery,
6882
{},
6983
{
7084
useCypherThread: shouldUseCypherThread(store.getState()),
@@ -79,15 +93,18 @@ const fetchJmxValues = store => {
7993
intConverter: val => val.toString(),
8094
objectConverter: extractFromNeoObjects
8195
}
82-
return toObjects(res.records, converters).map(
83-
([name, description, attributes]) => {
84-
return {
85-
name,
86-
description,
87-
attributes
88-
}
96+
let objs = recordsToTableArray(res.records, converters)
97+
if (!objs || !objs.length) {
98+
return []
99+
}
100+
objs.shift() // remove title
101+
objs = objs.map(rec => {
102+
return {
103+
name: rec[0].name,
104+
attributes: rec[0].data[0]
89105
}
90-
)
106+
})
107+
return objs
91108
})
92109
}
93110

0 commit comments

Comments
 (0)