In the latest release of the Migration Toolkit for Application Binaries (which scans binaries), we have added the ability to produce the reports in JSON (JavaScript Object Notation) format. The JSON data can be used to populate a document database such as MongoDB. Users of our tool have been asking for this functionality to do easy data analysis. We listened and now it’s here!

The Migration Toolkit for Application Binaries (binary scanner from here on) is our command-line tool for migration analysis. You can use the tool to produce three different migration reports. If you are not familiar with the tool, please take a look at, What is the Migration Toolkit for Application Binaries? for more info.

This article covers how to:

  • Generate the Application Evaluation Report in JSON format using the binary scanner
  • Insert the JSON data into a MongoDB database
  • Query the database to extract some simple but useful information
  • The following examples use data from three different applications. The steps to generate the JSON data and to insert it into a MongoDB database should be repeated for each application. Let’s get started!

    Generate JSON data

    First off, we’ll need to generate the Application Evaluation Report for your application in a JSON format:

    java -jar binaryAppScanner.jar binaryInputPath format=json

    The tool tells you the location of the JSON report file upon completion:


    binaryScannerOutputFile

    Next, we need to open the file in a text editor that supports the JSON format. Depending on the application, the file varies in size. Here is a small snippet of the generated data so that you can see what it looks like:


    generated JSON snippet

    Now you can use this data to populate your Mongo database.

    Inserting JSON Data into a MongoDB Database

    Now that we have generated the JSON file, we will populate the database. There are two different ways that we can import the data. The first approach uses the filesystem to directly import files into MongoDB. The second technique is executed from within the MongoDB shell.

    Using the filesystem to import data

    A simple way to insert data in the database is to import the JSON file produced by the binary scanner from the command prompt:

    mongoimport --db migrateToLiberty --collection technologyReport --file /Users/villaa/Downloads/wamt/TechnologyReport.json

    The command creates the database and the collection if they don’t already exist. The command prompt displays the number of documents that were imported as shown below:


    screen-shot-2016-09-14-at-10-59-20-am

    Importing through MongoDB shell

    Alternatively, you can create the database and insert the data from the MongoDB shell.

    First, create a new database by issuing the following command in a mongoDB shell:

    use migrateToLiberty

    Next, we will create a collection in the migrateToLiberty database where all of the documents are stored. Inserting documents into the collection is done by issuing the command db.technologyReport.insert(). The collection we are creating with that command is named technologyReport. Inside of the parenthesis we will need to put the data from the generated JSON file:

    1. Go back to the JSON file in the editor, select and copy all of the text in the file including the curly braces.
    2. Paste the clipboard contents inside of the parenthesis of the db.technology.insert() command.

    Here is an example of what the command should look like:


    mongoinsertsnippetv2

    The middle of the file is not displayed here due to its length, but the end is included so you can see how all of the data is inside of the parenthesis. When the command completes, you see the WriteResult() on the last line, as shown below:


    mongoInsertSnippet2

    Repeat the above steps for each application you are interested in querying.

    Querying the Mongo Database

    Now we can go ahead and run a query against the data to see which applications are good candidates to migrate to Liberty.

    First, let’s see the documents in the collection by using the db.collection.find(query, projection) command:

    • The query represents what we are looking for. In this case it’s all of the documents in the database that have a "report" key with the value of "technology".
    • The projection limits what is displayed for the matches of the query. In the picture above we see the _id which is displayed by default, and applications which we explicitly requested. A projection is not required, but it makes it easier to find the data you are interested in. From the picture above we see that we have three documents in our collection.


    mongoalldocuments

    Now let’s answer this question: Which of my applications use technologies available on Liberty?

    Run the following command:

    db.technologyReport.find( {"summary.liberty" : true }, {"applications":1})

    Whereas the HTML report shows the supported applications by using check marks and shading, the JSON report provides a summary. The above query looks for all “summary.liberty” keys equal to true within the documents in our collection. Note that "summary.liberty" is not one key but represents nested keys as shown in the following example:

        {
         "summary": {
          "liberty": true,
          "websphereTraditional": false,
          }
        }
    

    The other half of the command displays the value of the “applications” key for all returned results. This allows us to see which applications match our query:


    mongoresult

    You can see that there is only one result displayed. Based on that result we can see that PlantsByWebSphereV8.ear is a good place to start migration to Liberty.

    Be sure to check out the Application Inventory Report (--inventory) and the Detailed Migration Analysis Report (--analyze) which are also available in JSON format. And let us know what you think! We are available for questions, comments and suggestions on our Application Migration Forum.

    Join The Discussion

    Your email address will not be published. Required fields are marked *