SlideShare a Scribd company logo
Harmony First Steps

Mining Software Repository with Java




              Harmony - Tutorial       1
INSTALL AND RUN


            Harmony - Tutorial   2
Requirements
Install
• Java 1.7
  – http://www.java.com
• Mercurial
  – http://mercurial.selenic.com/
• Maven
  – http://maven.apache.org/
• H2 (Used in this tuto to open the database)
  – http://www.h2database.com/html/main.html

                       Harmony - Tutorial       3
Install & Run
1. Download
  hg clone https://code.google.com/p/harmony.harmony/ harmony

2. Install
  cd harmony
  mvn install compile –DskipTests

3. Run
  cd cli
  mvn exec:java -Dexec.args="samples/configs/dummy.json
  samples/sources/harmony-test.json"




                               Harmony - Tutorial               4
Harmony’s Goal
• Harmony builds a model of a repository.
• Once the model is built, harmony launches analysis
=> The model and the analysis outputs are stored in a database

                                              Harmony Analysis




                                 Harmony Core            Harmony Data Base
         Versioned Items
    (Git, Mercurial, BugZilla)


                                    Harmony - Tutorial                       5
First Run
cd cli
mvn exec:java -Dexec.args="samples/configs/dummy.json
samples/sources/harmony-test.json"
• dummy.json states that Harmony should
  launch the DummyAnalysis
• harmony-test.json states that Harmony
  should fetch the HarmonyTest repository

=> /tmp/dummy.h2.db is the returned database

                       Harmony - Tutorial               6
The Harmony Model (Core)
                              • A Source is a repository
        Source                • An Item is a versioned
                                software artefact (a
                                source code file or a bug)
Event            Item         • An Event occurs (commit,
                                merge, new bugs, etc.)
        Action                • Action is performed on
                                items (add, change,
                                delete)
        Author                • Author executes actions

                   Harmony - Tutorial                        7
First Run Model (1/2)
• Launch H2 and open the /tmp/dummy
  database



                                  jdbc:h2:file:/tmp/dummy




                 Harmony - Tutorial                         8
First Run Model (2/2)



                            This query returns all
                            authors




       Harmony - Tutorial                            9
Config: dummy.json
{
    "database" : {
      "url" : jdbc:h2:/tmp/dummy;LOCK_TIMEOUT=10000",
      "user" : "SA",
      "password" : "",                                          DataBase
      "driver" : "org.h2.Driver",
      "dialect" : "org.hibernate.dialect.H2Dialect",
      "mappings" : []
     },
     "create-sources" : {
       "threads" : 1,
       "timeout" : 100000
                                                                Thread Policy
      },
      "source-analyses" : [
       {
    "class" : "fr.labri.harmony.analysis.dummy.DummyAnalysis"    Analysis
       }
     ]
}
                                     Harmony - Tutorial                     10
Sources: harmony-test.json

[
{
"url" : "https://code.google.com/p/harmony.harmony-test/",     URL
"class" : "fr.labri.harmony.source.vcs.hg.Hg4JAdapter"
}
]


                                                       Harmony Adapter




                                  Harmony - Tutorial                     11
Existing Configs & Sources
• cli/samples contains several configs and sources
• Examples
  – Configs
     • Compute Source Code Metrics
        – /samples/configs/metrics-h2.json
     • Compute Bug Metrics for GitHub Bugs
        – /samples/configs/git-issues.json
  – Sources
     • Harmony Source code
        – /samples/sources/harmony.json
     • GitHub Bugs
        – /samples/sources/git-issues-test.json


                             Harmony - Tutorial      12
Let’s Try !
1. Run Harmony DummyAnalysis on harmony
2. Run Harmony DummyAnalysis on a Git
   repository
3. Run Harmony MetricsAnalysis on harmony
4. Run Harmony GitHubAnalysis on GitHub test




                   Harmony - Tutorial          13
CUSTOMIZE AN EXISTING ANALYSIS


            Harmony - Tutorial   14
Analysis
• Each analysis is a development project
  – analysis.*
     • Artefact, bugCycleCorrelation, cloc, digraph, dummy,
       metrics, ownership, etc.
• Each analysis project must have a class that
  extends SourceAnalysis
  – fr.labri.harmony.analysis.dummy.DummyAnalysis
• Such a class must override the perform method
  – public void perform(Source src) throws
    WorkspaceException

                           Harmony - Tutorial                 15
Customize DummyAnalysis
• Modify the DummyAnalysis class to print
  Event native id !
    public void perform(Source src) throws WorkspaceException {
      for (Event ev : src.getEvents())
        System.out.println(ev.getNativeId());
    }



• Compile and run !



                                Harmony - Tutorial                16
Let’s Try !
• Change the dummy analysis:
1. to get all authors !
  Source.getAuthors
2. To get the first commit !
  Event.getParents
3. To get all items that have been modified by
   the same author !
4. …
                       Harmony - Tutorial        17
Analysis Output
• Store the result of your analysis whithin the
  database
• Have a look at the CLOC analysis to
  understand how we use hibernate




                     Harmony - Tutorial           18
CONCLUSION


             Harmony - Tutorial   19
Harmony is good for
•   Repository Mining
•   Use existing analysis
•   Create your own analysis
•   Exploit the output of your analysis

https://code.google.com/p/harmony/



                       Harmony - Tutorial   20

More Related Content

PDF
Puppet control-repo 
to the next level
PPTX
Everything you wanted to know about writing async, concurrent http apps in java
KEY
PyCon US 2012 - State of WSGI 2
PDF
Pragmatic plone projects
PDF
Puppet modules: A Holistic Approach - Geneva
PPT
An introduction to maven gradle and sbt
PPTX
ABCs of docker
PDF
Puppet Continuous Integration with PE and GitLab
Puppet control-repo 
to the next level
Everything you wanted to know about writing async, concurrent http apps in java
PyCon US 2012 - State of WSGI 2
Pragmatic plone projects
Puppet modules: A Holistic Approach - Geneva
An introduction to maven gradle and sbt
ABCs of docker
Puppet Continuous Integration with PE and GitLab

What's hot (20)

PDF
How to Reverse Engineer Web Applications
PDF
Tornadoweb
PDF
Puppet evolutions
PDF
Dependencies Managers in C/C++. Using stdcpp 2014
PDF
Can you upgrade to Puppet 4.x?
PDF
Puppet modules: An Holistic Approach
PDF
Programming in Linux Environment
PDF
We Are All Testers Now: The Testing Pyramid and Front-End Development
PDF
Essential applications management with Tiny Puppet
PPT
Apache Ant
PDF
Packaging perl (LPW2010)
PDF
Inside the JVM - Follow the white rabbit!
PPTX
Java Libraries You Can’t Afford to Miss
PDF
CMake: Improving Software Quality and Process
KEY
PyCon AU 2010 - Getting Started With Apache/mod_wsgi.
PDF
Puppet Systems Infrastructure Construction Kit
PDF
walkmod: how it works
PPTX
Professional Help for PowerShell Modules
PDF
Making the Most of Your Gradle Build
PDF
Testing with PostgreSQL
How to Reverse Engineer Web Applications
Tornadoweb
Puppet evolutions
Dependencies Managers in C/C++. Using stdcpp 2014
Can you upgrade to Puppet 4.x?
Puppet modules: An Holistic Approach
Programming in Linux Environment
We Are All Testers Now: The Testing Pyramid and Front-End Development
Essential applications management with Tiny Puppet
Apache Ant
Packaging perl (LPW2010)
Inside the JVM - Follow the white rabbit!
Java Libraries You Can’t Afford to Miss
CMake: Improving Software Quality and Process
PyCon AU 2010 - Getting Started With Apache/mod_wsgi.
Puppet Systems Infrastructure Construction Kit
walkmod: how it works
Professional Help for PowerShell Modules
Making the Most of Your Gradle Build
Testing with PostgreSQL
Ad

Similar to Harmony first step (20)

PPTX
Composer JSON kills make files
PDF
Embedded Systems: Lecture 13: Introduction to GNU Toolchain (Build Tools)
PDF
Hands-on with the Symfony2 Framework
PPTX
Introduction to Maven
PPTX
PHP Dependency Management with Composer
PDF
Assignment 1 MapReduce With Hadoop
PDF
Organizing Your PHP Projects (2010 ConFoo)
PPTX
Selenium digitalinfobytes-120829005812-phpapp02
PPTX
Basic Selenium Training
PDF
Organinzing Your PHP Projects (2010 Memphis PHP)
PDF
Unit testing symfony plugins with php unit
PDF
Plugin-based software design with Ruby and RubyGems
PPT
Maven: Managing Software Projects for Repeatable Results
PDF
Spring Roo Add-On Development & Distribution
PPTX
Exploring Java Heap Dumps (Oracle Code One 2018)
PDF
Practical Chaos Engineering
PDF
How to test infrastructure code: automated testing for Terraform, Kubernetes,...
PDF
Introduction to Drupal 7 - Updating core, themes and modules. applying patches
PDF
Property Based Testing in PHP
PPTX
Composer namespacing
Composer JSON kills make files
Embedded Systems: Lecture 13: Introduction to GNU Toolchain (Build Tools)
Hands-on with the Symfony2 Framework
Introduction to Maven
PHP Dependency Management with Composer
Assignment 1 MapReduce With Hadoop
Organizing Your PHP Projects (2010 ConFoo)
Selenium digitalinfobytes-120829005812-phpapp02
Basic Selenium Training
Organinzing Your PHP Projects (2010 Memphis PHP)
Unit testing symfony plugins with php unit
Plugin-based software design with Ruby and RubyGems
Maven: Managing Software Projects for Repeatable Results
Spring Roo Add-On Development & Distribution
Exploring Java Heap Dumps (Oracle Code One 2018)
Practical Chaos Engineering
How to test infrastructure code: automated testing for Terraform, Kubernetes,...
Introduction to Drupal 7 - Updating core, themes and modules. applying patches
Property Based Testing in PHP
Composer namespacing
Ad

Harmony first step

  • 1. Harmony First Steps Mining Software Repository with Java Harmony - Tutorial 1
  • 2. INSTALL AND RUN Harmony - Tutorial 2
  • 3. Requirements Install • Java 1.7 – http://www.java.com • Mercurial – http://mercurial.selenic.com/ • Maven – http://maven.apache.org/ • H2 (Used in this tuto to open the database) – http://www.h2database.com/html/main.html Harmony - Tutorial 3
  • 4. Install & Run 1. Download hg clone https://code.google.com/p/harmony.harmony/ harmony 2. Install cd harmony mvn install compile –DskipTests 3. Run cd cli mvn exec:java -Dexec.args="samples/configs/dummy.json samples/sources/harmony-test.json" Harmony - Tutorial 4
  • 5. Harmony’s Goal • Harmony builds a model of a repository. • Once the model is built, harmony launches analysis => The model and the analysis outputs are stored in a database Harmony Analysis Harmony Core Harmony Data Base Versioned Items (Git, Mercurial, BugZilla) Harmony - Tutorial 5
  • 6. First Run cd cli mvn exec:java -Dexec.args="samples/configs/dummy.json samples/sources/harmony-test.json" • dummy.json states that Harmony should launch the DummyAnalysis • harmony-test.json states that Harmony should fetch the HarmonyTest repository => /tmp/dummy.h2.db is the returned database Harmony - Tutorial 6
  • 7. The Harmony Model (Core) • A Source is a repository Source • An Item is a versioned software artefact (a source code file or a bug) Event Item • An Event occurs (commit, merge, new bugs, etc.) Action • Action is performed on items (add, change, delete) Author • Author executes actions Harmony - Tutorial 7
  • 8. First Run Model (1/2) • Launch H2 and open the /tmp/dummy database jdbc:h2:file:/tmp/dummy Harmony - Tutorial 8
  • 9. First Run Model (2/2) This query returns all authors Harmony - Tutorial 9
  • 10. Config: dummy.json { "database" : { "url" : jdbc:h2:/tmp/dummy;LOCK_TIMEOUT=10000", "user" : "SA", "password" : "", DataBase "driver" : "org.h2.Driver", "dialect" : "org.hibernate.dialect.H2Dialect", "mappings" : [] }, "create-sources" : { "threads" : 1, "timeout" : 100000 Thread Policy }, "source-analyses" : [ { "class" : "fr.labri.harmony.analysis.dummy.DummyAnalysis" Analysis } ] } Harmony - Tutorial 10
  • 11. Sources: harmony-test.json [ { "url" : "https://code.google.com/p/harmony.harmony-test/", URL "class" : "fr.labri.harmony.source.vcs.hg.Hg4JAdapter" } ] Harmony Adapter Harmony - Tutorial 11
  • 12. Existing Configs & Sources • cli/samples contains several configs and sources • Examples – Configs • Compute Source Code Metrics – /samples/configs/metrics-h2.json • Compute Bug Metrics for GitHub Bugs – /samples/configs/git-issues.json – Sources • Harmony Source code – /samples/sources/harmony.json • GitHub Bugs – /samples/sources/git-issues-test.json Harmony - Tutorial 12
  • 13. Let’s Try ! 1. Run Harmony DummyAnalysis on harmony 2. Run Harmony DummyAnalysis on a Git repository 3. Run Harmony MetricsAnalysis on harmony 4. Run Harmony GitHubAnalysis on GitHub test Harmony - Tutorial 13
  • 14. CUSTOMIZE AN EXISTING ANALYSIS Harmony - Tutorial 14
  • 15. Analysis • Each analysis is a development project – analysis.* • Artefact, bugCycleCorrelation, cloc, digraph, dummy, metrics, ownership, etc. • Each analysis project must have a class that extends SourceAnalysis – fr.labri.harmony.analysis.dummy.DummyAnalysis • Such a class must override the perform method – public void perform(Source src) throws WorkspaceException Harmony - Tutorial 15
  • 16. Customize DummyAnalysis • Modify the DummyAnalysis class to print Event native id ! public void perform(Source src) throws WorkspaceException { for (Event ev : src.getEvents()) System.out.println(ev.getNativeId()); } • Compile and run ! Harmony - Tutorial 16
  • 17. Let’s Try ! • Change the dummy analysis: 1. to get all authors ! Source.getAuthors 2. To get the first commit ! Event.getParents 3. To get all items that have been modified by the same author ! 4. … Harmony - Tutorial 17
  • 18. Analysis Output • Store the result of your analysis whithin the database • Have a look at the CLOC analysis to understand how we use hibernate Harmony - Tutorial 18
  • 19. CONCLUSION Harmony - Tutorial 19
  • 20. Harmony is good for • Repository Mining • Use existing analysis • Create your own analysis • Exploit the output of your analysis https://code.google.com/p/harmony/ Harmony - Tutorial 20