Skip to main content

How to successfully compile the Mongobird source code

In May I published this post (http://googlielmo.blogspot.ie/2014/05/open-source-projects-and-documentation.html) talking about a couple of bad habits I often find in Opens Source projects, in particular out-of-date build files. A couple of days ago I have downloaded from GitHub the latest source codes of the Mongobird (https://github.com/citsoft/mongobird), a tool providing a dashboard to monitor MongoDB databases in order to evaluate the non-commercial version and I tried to build it through Maven (the Mongobird project is a Maven Java project). Trying to compile first using the mvn compile command gave a lot of errors. I think at least compilation should work downloading a project from a public repository or have some documentation associated to the source code in order to guide the users to quickly have the tool built and running. Unfortunately none of those applies to the Mongobird project source code. In this post I am describing the steps to successfully compile it and make it working starting from the source code in order to help other people who should download this project to save their time.
Before starting, the details about the environment I am using:
  • IBM JDK 1.6 (but everything in this process works fine with the Oracle JDK as well)
  • Maven 3.1.1
  • Jetty 8.1.13
  • MongoDB 2.6.4
  • Mongobird 2.5.0 source code
A couple of dependencies should be manually added to the local Maven repository (not available in any public repository):

mvn install:install-file -DgroupId=net.cit.monad-Mongo -DartifactId=monad-Mongo -Dpackaging=jar -Dversion=0.0.1-SNAPSHOT -Dfile=monad-Mongo-0.0.1-20121219.074054-3.jar -DgeneratePom=true

and

mvn install:install-file -DgroupId=net.citsoft -DartifactId=distr-communication -Dpackaging=jar -Dversion=1.0.0 -Dfile=distr-communication-1.0.0.jar -DgeneratePom=true

monad-Mongo-0.0.1-20121219.074054-3.jar could be find in the lib folder of the project.
distr-communication-1.0.0.jar can be taken from the installation package of Mongobird downloadable from the Mongobird official website (http://mongobird.citsoft.net/?page_id=456).
Then replace the content of the POM file of the project with the following:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>net.cit.tetrad</groupId>
    <artifactId>tetrad</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <name>Tetrad Maven Webapp</name>

    <build>
        <finalName>tetrad</finalName>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
        <filters>
            <filter>${tetradConfigFile}</filter>
        </filters>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.10</version>
                <configuration>
                    <junitArtifactName>junit:junit</junitArtifactName>
                    <systemProperties>
                        <property>
                            <name>java.awt.headless</name>
                            <value>true</value>
                        </property>
                    </systemProperties>
                    <skipTests>true</skipTests>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1.1</version>
                <configuration>
                    <webResources>
                        <resource>
<!--                             this is relative to the pom.xml directory -->
                            <directory>src/main/java/net/cit/tetrad/template</directory>
                            <targetPath>WEB-INF/classes/net/cit/tetrad/template</targetPath>
                            <includes>
                                <include>**</include>
                            </includes>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>
        </plugins>
    </build>
   
    <properties>
        <spring.version>3.1.0.RELEASE</spring.version>
        <junit.version>3.8.1</junit.version>
        <log4j.version>1.2.16</log4j.version>
        <slf.version>1.6.4</slf.version>
        <jstl.version>1.2</jstl.version>
    </properties>
   
    <dependencies>
<!--         <dependency>      -->
<!--               <groupId>javax.servlet</groupId>      -->
<!--               <artifactId>servlet-api</artifactId>      -->
<!--               <version>2.5</version> -->
<!--           </dependency> -->
<!--           <dependency>      -->
<!--               <groupId>javax.servlet</groupId>      -->
<!--               <artifactId>jsp-api</artifactId>      -->
<!--               <version>2.0</version>      -->
<!--           </dependency> -->
        <dependency>    
              <groupId>javax.servlet</groupId>    
              <artifactId>servlet-api</artifactId>    
              <version>2.4</version>    
              <scope>provided</scope>  
          </dependency>
        <dependency>
            <groupId>net.cit.monad-Mongo</groupId>
            <artifactId>monad-Mongo</artifactId>
            <version>0.0.1-SNAPSHOT</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-oxm</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
          <groupId>org.springframework.data</groupId>
          <artifactId>spring-data-commons-core</artifactId>
          <version>1.2.0.M2</version>
          <exclusions>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-beans</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-tx</artifactId>
                </exclusion>
          </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aspects</artifactId>           
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>${jstl.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.activemq</groupId>
            <artifactId>activemq-core</artifactId>
            <version>5.4.2</version>
            <exclusions>
                <exclusion>
                    <groupId>commons-codec</groupId>
                    <artifactId>commons-codec</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
            <version>1.2.2</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>net.disy.jquery</groupId>
            <artifactId>jquery</artifactId>
            <version>1.4.2</version>
        </dependency>
        <dependency>
            <groupId>net.disy.jquery</groupId>
            <artifactId>jquery-ui</artifactId>
            <version>1.8.6</version>
        </dependency>
        <dependency>
      <groupId>org.rrd4j</groupId>
      <artifactId>rrd4j</artifactId>
      <version>2.1.1</version>
    </dependency>
        <dependency>
            <groupId>net.sf.ezmorph</groupId>
            <artifactId>ezmorph</artifactId>
            <version>1.0.6</version>
        </dependency>
        <dependency>
            <groupId>net.sf.json-lib</groupId>
            <artifactId>json-lib</artifactId>
            <version>2.4</version>
            <classifier>jdk15</classifier>
        </dependency>       
        <dependency>
            <groupId>com.thoughtworks.xstream</groupId>
            <artifactId>xstream</artifactId>
            <version>1.4.2</version>
        </dependency>
        <dependency>
            <groupId>org.quartz-scheduler</groupId>
            <artifactId>quartz</artifactId>
<!--             <version>1.8.6</version> -->
            <version>2.1.1</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-asl</artifactId>
            <version>1.9.3</version>
        </dependency>
        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
            <version>1.4.5</version>
        </dependency>
        <dependency>
            <groupId>org.apache.velocity</groupId>
            <artifactId>velocity</artifactId>
            <version>1.7</version>
        </dependency>
        <dependency>
            <groupId>net.citsoft</groupId>
            <artifactId>distr-communication</artifactId>
            <version>1.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.mongodb</groupId>
            <artifactId>mongo-java-driver</artifactId>
            <version>2.12.2</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>${log4j.version}</version>
        </dependency>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
            <version>1.7.3</version>
        </dependency>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
            <version>1.7.3</version>
        </dependency>
        <dependency>
            <groupId>cglib</groupId>
            <artifactId>cglib</artifactId>
            <version>3.1</version>
        </dependency>
        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcprov-jdk16</artifactId>
            <version>1.46</version>
        </dependency>
        <dependency>
            <groupId>commons-httpclient</groupId>
            <artifactId>commons-httpclient</artifactId>
            <version>3.1</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.7</version>
        </dependency>
    </dependencies>
   
    <profiles>
        <profile>
            <id>tetradBuild</id>
            <activation>
                <activeByDefault>true</activeByDefault>
                <file>
                    <exists>${configPath}/tetrad-config.prop</exists>
                </file>
            </activation>
            <properties>
                <tetradConfigFile>${configPath}/tetrad-config.prop</tetradConfigFile>
            </properties>
        </profile>
        <profile>
            <id>tetradDefault</id>
            <activation>
                <activeByDefault>false</activeByDefault>
                <file>
                    <missing>${configPath}/tetrad-config.prop</missing>
                </file>
            </activation>
            <properties>
                <tetradConfigFile>${basedir}/config/tetrad-config-default.prop</tetradConfigFile>
            </properties>
        </profile>
    </profiles>
   
</project>


I got most part of the missing dependencies and their release numbers form the pom.xml file embedded in the monad-Mongo-0.0.1-20121219.074054-3.jar library. Other dependencies were discovered checking the exceptions at runtime testing the single features of this software.
Before packaging the final WAR you need to change the connection to MongoDB timeout value. Open the tetrad-config-default.prop file you can find in the config folder of the project using any text editor and change the value for the mongo.connectTimeout property from 0 to any value greater than 0 (in milliseconds). For example:

mongo.connectTimeout:10000

Even if 0 means infinite time for this property, if you let this default value after the application start and the connection to the MongoDB database is established, the context deployment in the application server fails with the following error:

com.mongodb.MongoTimeoutException: Timed out while waiting for a server that matches AnyServerSelector{} after 0 ms

Of course in the same properties file you need to set up the connection details to your MongoDB database to store the monitoring data. Replace the following properties values with the correct ones:

mongo.host:localhost
mongo.port:27017
mongo.username:
mongo.password:


mongo.username and mongo.password are not mandatory. Leave them blank if your database doesn't require authentication.
Now you can package the WAR file:

mvn package

Then deploy it in your application server. I used Jetty 8.1.3 for this activity, so it was a simple copy and paste of the WAR file in its webapps folder and a start of the server.
To access the Mongobird dashboard open a web browser and go the following URL:

http://localhost:<port>/tetrad/

The login splash screen should show:



At first usage enter the following credentials to login:

ID: admin
PW: admin

and once logged in create your own users.

Comments

Popular posts from this blog

Streamsets Data Collector log shipping and analysis using ElasticSearch, Kibana and... the Streamsets Data Collector

One common use case scenario for the Streamsets Data Collector (SDC) is the log shipping to some system, like ElasticSearch, for real-time analysis. To build a pipeline for this particular purpose in SDC is really simple and fast and doesn't require coding at all. For this quick tutorial I will use the SDC logs as example. The log data will be shipped to Elasticsearch and then visualized through a Kibana dashboard. Basic knowledge of SDC, Elasticsearch and Kibana is required for a better understanding of this post. These are the releases I am referring to for each system involved in this tutorial: JDK 8 Streamsets Data Collector 1.4.0 ElasticSearch 2.3.3 Kibana 4.5.1 Elasticsearch and Kibana installation You should have your Elasticsearch cluster installed and configured and a Kibana instance pointing to that cluster in order to go on with this tutorial. Please refer to the official documentation for these two products in order to complete their installation (if you do

Exporting InfluxDB data to a CVS file

Sometimes you would need to export a sample of the data from an InfluxDB table to a CSV file (for example to allow a data scientist to do some offline analysis using a tool like Jupyter, Zeppelin or Spark Notebook). It is possible to perform this operation through the influx command line client. This is the general syntax: sudo /usr/bin/influx -database '<database_name>' -host '<hostname>' -username '<username>'  -password '<password>' -execute 'select_statement' -format '<format>' > <file_path>/<file_name>.csv where the format could be csv , json or column . Example: sudo /usr/bin/influx -database 'telegraf' -host 'localhost' -username 'admin'  -password '123456789' -execute 'select * from mem' -format 'csv' > /home/googlielmo/influxdb-export/mem-export.csv

Using Rapids cuDF in a Colab notebook

During last Spark+AI Summit Europe 2019 I had a chance to attend a talk from Miguel Martinez  who was presenting Rapids , the new Open Source framework from NVIDIA for GPU accelerated end-to-end Data Science and Analytics. Fig. 1 - Overview of the Rapids eco-system Rapids is a suite of Open Source libraries: cuDF cuML cuGraph cuXFilter I enjoied the presentation and liked the idea of this initiative, so I wanted to start playing with the Rapids libraries in Python on Colab , starting from cuDF, but the first attempt came with an issue that I eventually solved. So in this post I am going to share how I fixed it, with the hope it would be useful to someone else running into the same blocker. I am assuming here you are already familiar with Google Colab. I am using Python 3.x as Python 2 isn't supported by Rapids. Once you have created a new notebook in Colab, you need to check if the runtime for it is set to use Python 3 and uses a GPU as hardware accelerator. You