Skip to content

Commit

Permalink
initializing groundhog parameters thru json file. a lot of work still…
Browse files Browse the repository at this point in the history
… have to be done on #33
  • Loading branch information
Gustavo Pinto committed May 17, 2013
1 parent 8b51012 commit ffbd6f9
Show file tree
Hide file tree
Showing 15 changed files with 237 additions and 171 deletions.
6 changes: 3 additions & 3 deletions groundhog.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"forge": "github",
"dest": "C:/groundhog/dest",
"out": "C:/groundhog/metrics",
"datetime": "2012-07-01_12_00",
"dest": "/opt/groundhog/dest",
"out": "/opt/groundhog/metrics",
"datetime": "2012-07-01 12:00",
"nprojects": 30,
"outputformat": "csv",
"search": {
Expand Down
9 changes: 0 additions & 9 deletions src/java/main/br/ufpe/cin/groundhog/Config.java

This file was deleted.

1 change: 1 addition & 0 deletions src/java/main/br/ufpe/cin/groundhog/Project.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package br.ufpe.cin.groundhog;

import japa.parser.ParseException;

import java.text.SimpleDateFormat;
import java.util.Date;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ public File checkoutToDate(String project, File repositoryFolder, final Date dat
try {
File projectFolder = new File(FileUtil.getInstance()
.createTempDir(), project);

FileUtil.getInstance().copyDirectory(repositoryFolder,
projectFolder);

this.gitClient.checkout(projectFolder, date);
return projectFolder;
} catch (Exception e) {
Expand Down
5 changes: 3 additions & 2 deletions src/java/main/br/ufpe/cin/groundhog/crawler/CrawlGitHub.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.File;
import java.io.IOException;
import java.util.Random;

import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.api.errors.InvalidRemoteException;
Expand All @@ -16,7 +17,7 @@
/**
* A concrete class to crawl GitHub.
*
* @author fjsj
* @author fjsj, gustavopinto
*/
public class CrawlGitHub extends ForgeCrawler {

Expand All @@ -32,7 +33,7 @@ public CrawlGitHub(GitClient gitClient, File destinationFolder) {
protected File downloadProject(Project project) throws JSONException,
IOException, InvalidRemoteException, TransportException,
GitAPIException {
String projectName = project.getName();
String projectName = project.getName() + "_" + new Random().nextInt();
String cloneUrl = project.getScmURL();
File projectFolder = new File(destinationFolder, projectName);

Expand Down
6 changes: 3 additions & 3 deletions src/java/main/br/ufpe/cin/groundhog/crawler/ForgeCrawler.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

import br.ufpe.cin.groundhog.Config;
import br.ufpe.cin.groundhog.Project;
import br.ufpe.cin.groundhog.main.JsonInput;

/**
* An abstract class that defines the forge crawl functionality.
* A forge crawler downloads projects from a certain forge
* to a given folder.
* @author fjsj
* @author fjsj, gustavopinto
*
*/
public abstract class ForgeCrawler {
Expand All @@ -27,7 +27,7 @@ public abstract class ForgeCrawler {
* @param destinationFolder folder into which projects will be downloaded
*/
protected ForgeCrawler(File destinationFolder) {
ex = Executors.newFixedThreadPool(Config.MAX_NUMBER_OF_THREADS);
ex = Executors.newFixedThreadPool(JsonInput.getMaxThreads());
this.destinationFolder = destinationFolder;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import br.ufpe.cin.groundhog.main.JsonInput;
import br.ufpe.cin.groundhog.util.FileUtil;
import br.ufpe.cin.groundhog.Config;

/**
* Singleton class to extract files and recursively extract all files within a hierarchy of folders.
Expand Down Expand Up @@ -45,7 +45,7 @@ private DefaultExtractor() {
* @param destinationFolder the destination folder to which the extracted files will be moved to
*/
private void recursiveExtract(final File root, File next, final File destinationFolder) {
ExecutorService executor = Executors.newFixedThreadPool(Config.MAX_NUMBER_OF_THREADS);
ExecutorService executor = Executors.newFixedThreadPool(JsonInput.getMaxThreads());
File[] subFiles = next.listFiles();
List<Future<?>> futures = new ArrayList<Future<?>>();

Expand Down
4 changes: 2 additions & 2 deletions src/java/main/br/ufpe/cin/groundhog/main/ArgsMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ public static void main(String[] args) {
CmdLineParser parser = new CmdLineParser(opt);
try {
parser.parseArgument(args);
System.out.println(opt.getInputFile());
new CmdMain().main(opt.getInputFile());
} catch (CmdLineException e) {
e.printStackTrace();
System.err.println("java -jar myprogram.jar [options...] arguments...");
System.err.println("java -jar groundhog.jar [options...] arguments...");
parser.printUsage(System.err);
return;
}
Expand Down
Loading

0 comments on commit ffbd6f9

Please sign in to comment.