Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Getting Insight in Neo4j’s JMX Beans When Running Embedded

DZone's Guide to

Getting Insight in Neo4j’s JMX Beans When Running Embedded

· Java Zone
Free Resource

Build vs Buy a Data Quality Solution: Which is Best for You? Gain insights on a hybrid approach. Download white paper now!

Neo4j exposes a lot of valuable information via JMX. Sometimes you want to gain some insight in some JMX beans when running Neo4j in embedded mode. For this it’s crucial to have the neo4j-jmx-[version].jar file on the classpath.

The following short Groovy script demos this by using the @Grab annotation to fetch dependencies:

@Grab(group="org.neo4j", module="neo4j-kernel", version="2.0.1")
@Grab(group="org.neo4j", module="neo4j-lucene-index", version="2.0.1")
@Grab(group='org.neo4j', module='neo4j-jmx', version='2.0.1')

import org.neo4j.graphdb.factory.GraphDatabaseFactory
import org.neo4j.jmx.JmxUtils
def db = new GraphDatabaseFactory().newEmbeddedDatabaseBuilder("/tmp/graph.db")
  .newGraphDatabase()

println "started embedded graph db"

def objectName = JmxUtils.getObjectName(db, "Primitive count")
def numberOfNodesIds = JmxUtils.getAttribute(objectName, "NumberOfNodeIdsInUse")

println "JMX says, we have $numberOfNodesIds node ids in use"

println "shutting down embedded graph db now"
db.shutdown()

For a full reference of all available JMX beans, see the Neo4j manual.


Build vs Buy a Data Quality Solution: Which is Best for You? Maintaining high quality data is essential for operational efficiency, meaningful analytics and good long-term customer relationships. But, when dealing with multiple sources of data, data quality becomes complex, so you need to know when you should build a custom data quality tools effort over canned solutions. Download our whitepaper for more insights into a hybrid approach.

Topics:

Published at DZone with permission of Stefan Armbruster, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}