CMR Architecture

The Central Measurement Repository (a.k.a. CMR) acts as the server component of the inspectIT architecture. Its purpose is to collect the measurements and persist them.

The CMR is based on the Spring Application Framework. The persistence is accomplished by using Hibernate as the persistency layer in Java and h2 as the database. Spring provides an additional abstraction from the Hibernate framework to make it even easier to use. The Spring framework is initialized in the main CMR.java class.

Spring

The Spring framework is based on XML files. The main XML file is called beanRefFactory.xml and is located in the root source folder (or the root of the generated jar file). This file is needed to locate the definition of the Beans (currently, these are again specified in different XML files). This additional abstraction is useful to just replace or modify this file for additional definitions without changing the Java class. Currently, three files are referenced in there, all residing in the spring sub-folder:

  • spring-context-database.xml: Everything related to the database is stored in there, like the data source, session factory or transaction manager.
  • spring-context-model.xml: All Beans which are persisted into the database are contained in there.
  • spring-context-service.xml: The service file initializes the beans which are accessible from outside, thus they are exported through a RMI exporter for example.
  • spring-context-jetty.xml: Jetty is embedded in the CMR for the data transmission to/from the User Interface. This context file starts jetty and registers a servlet which is accessed by the UI.
  • spring-context-jetty-service.xml: These services are exposed through jetty and cannot be accessed from the inspectIT Agent, thus the additional file.

Hibernate

Hibernate is configured through the Spring configuration files. The hbm files, used for the mapping between the classes and the database tables, are standard Hibernate mapping files which can be found in the hibernate sub-folder.

Logging configuration

The second file to configure is named log4j.properties. It defines the logging output of the application. As it is an external library, configuration hints can be found throughout the internet. Some direct links are provided here for faster access:

The default configuration used by the CMR is as follows:

### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} %-5p [%t|%t] %c: %m%n
log4j.rootLogger=debug, stdout

Starting the CMR with Java5

The CMR can also be started with Java 5. Here is a sample shell script for the startupecho

"Please set the NovaSpy CMR HOME folder within this script"
export NOVASPY_CMR_HOME=/home/sieglst/NovaSpy/CMR
export NOVASPY_CMR_LIB=$NOVASPY_CMR_HOME/lib

java \-Xmx2048M \-Xms1024m \-cp novaspy-cmr.jar:$NOVASPY_CMR_LIB/cglib-nodep.jar:$NOVASPY_CMR_LIB/commons-collections.jar:$NOVASPY_CMR_LIB/commons-logging.jar:$NOVASPY_CMR_LIB/dom4j.jar:$NOVASPY_CMR_LIB/hessian.jar:$NOVASPY_CMR_LIB/hibernate.jar:$NOVASPY_CMR_LIB/jetty.jar:$NOVASPY_CMR_LIB/jetty-util.jar:$NOVASPY_CMR_LIB/jta.jar:$NOVASPY_CMR_LIB/log4j.jar:$NOVASPY_CMR_LIB/novaspy-commons.jar:$NOVASPY_CMR_LIB/postgresql.jar:$NOVASPY_CMR_LIB/servlet-api.jar:$NOVASPY_CMR_LIB/slf4j-api.jar:$NOVASPY_CMR_LIB/slf4j-log4j12.jar:$NOVASPY_CMR_LIB/spring.jar:$NOVASPY_CMR_LIB/spring-test.jar:$NOVASPY_CMR_LIB/spring-web.jar:$NOVASPY_CMR_LIB/spring-webmvc.jar:$NOVASPY_CMR_LIB/c3p0.jar:$NOVASPY_CMR_LIB/h2.jar:$NOVASPY_CMR_LIB/antlr.jar info.novatec.novaspy.cmr.CMR

Access the h2 inspectIT database

inspectIT CMR currently comes with the fast, file-based h2 database. Sometimes it may be necessary to check the data within the database. To do that, one can use the built-in webbased query view of h2:

  • First the h2 Browser must be started. Go to the CMR installation folder and start it by executing: java -cp lib/prod/h2.jar org.h2.tools.Server -webAllowOthers -web (Using -webAllowOthers allows you to connect to this server from other computers, so you do not have to be on the actual computer)
  • The server should start up:sieglst@ipazhkorr06-2:~/inspectIT/CMR> java -cp lib/h2.jar org.h2.tools.Server -webAllowOthers -web
    Web server running on http://192.168.160.104:8082 (others can connect)
  • Access the server by pointing your browser to this URL (in my current environment I need to use the logical name instead of the IP)
  • The database can be accessed by using this connection string: jdbc:h2:[path_to_CMR_directory]/db/inspectit. User and password is inspectit
  • Note that the database only provides one connection. Thus if the CMR is running you cannot connect this way.