[O] Start redis server with correct path
This commit is contained in:
+1308
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,6 @@ package edu.lu.uni.serval;
|
|||||||
|
|
||||||
import edu.lu.uni.serval.richedit.jobs.CompareTrees;
|
import edu.lu.uni.serval.richedit.jobs.CompareTrees;
|
||||||
import edu.lu.uni.serval.richedit.jobs.EnhancedASTDiff;
|
import edu.lu.uni.serval.richedit.jobs.EnhancedASTDiff;
|
||||||
import edu.lu.uni.serval.utils.ClusterToPattern;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.yaml.snakeyaml.Yaml;
|
import org.yaml.snakeyaml.Yaml;
|
||||||
@@ -18,7 +17,6 @@ import java.util.Properties;
|
|||||||
*/
|
*/
|
||||||
public class Launcher
|
public class Launcher
|
||||||
{
|
{
|
||||||
|
|
||||||
private static Logger log = LoggerFactory.getLogger(Launcher.class);
|
private static Logger log = LoggerFactory.getLogger(Launcher.class);
|
||||||
|
|
||||||
public static void main(String[] args) throws IOException
|
public static void main(String[] args) throws IOException
|
||||||
@@ -49,13 +47,16 @@ public class Launcher
|
|||||||
String input = (String) fixminer.get("inputPath");
|
String input = (String) fixminer.get("inputPath");
|
||||||
String redisPath = (String) fixminer.get("redisPath");
|
String redisPath = (String) fixminer.get("redisPath");
|
||||||
String srcMLPath = (String) fixminer.get("srcMLPath");
|
String srcMLPath = (String) fixminer.get("srcMLPath");
|
||||||
|
String srcPath = (String) fixminer.get("srcPath");
|
||||||
|
|
||||||
String jobType = args[1];
|
String jobType = args[1];
|
||||||
|
|
||||||
mainLaunch(numOfWorkers, jobType, portDumps, projectType, input, redisPath, srcMLPath, hunkLimit, projectList, patchSize);
|
mainLaunch(numOfWorkers, jobType, portDumps, projectType, input, redisPath, srcMLPath, hunkLimit, projectList, patchSize, srcPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void mainLaunch(String numOfWorkers, String jobType, String portDumps, String projectType, String input, String redisPath, String srcMLPath, String hunkLimit, String[] projectList, String patchSize)
|
public static void mainLaunch(String numOfWorkers, String jobType, String portDumps, String projectType, String input,
|
||||||
|
String redisPath, String srcMLPath, String hunkLimit, String[] projectList, String patchSize,
|
||||||
|
String srcPath)
|
||||||
{
|
{
|
||||||
String dbDir;
|
String dbDir;
|
||||||
String dumpsName;
|
String dumpsName;
|
||||||
@@ -71,12 +72,13 @@ public class Launcher
|
|||||||
switch (jobType)
|
switch (jobType)
|
||||||
{
|
{
|
||||||
case "RICHEDITSCRIPT":
|
case "RICHEDITSCRIPT":
|
||||||
EnhancedASTDiff.main(gumInput, portDumps, dbDir, dumpsName, srcMLPath, hunkLimit, projectList, patchSize, projectType);
|
EnhancedASTDiff.main(gumInput, portDumps, dbDir, dumpsName, srcMLPath, hunkLimit, projectList, patchSize, projectType, srcPath);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "COMPARE":
|
case "COMPARE":
|
||||||
CompareTrees.main(redisPath, portDumps, dumpsName, numOfWorkers);
|
CompareTrees.main(redisPath, portDumps, dumpsName, numOfWorkers);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new Error("unknown Job");
|
throw new Error("unknown Job");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,45 +22,53 @@ import java.util.regex.Pattern;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class EnhancedASTDiff {
|
public class EnhancedASTDiff
|
||||||
|
{
|
||||||
|
|
||||||
private static Logger log = LoggerFactory.getLogger(EnhancedASTDiff.class);
|
private static Logger log = LoggerFactory.getLogger(EnhancedASTDiff.class);
|
||||||
|
|
||||||
public static void main(String inputPath, String portInner, String dbDir, String chunkName,String srcMLPath,String hunkLimit,String[] projectList,String patchSize,String projectType) throws Exception {
|
public static void main(String inputPath, String redisPort, String dbDir, String chunkName, String srcMLPath, String hunkLimit,
|
||||||
|
String[] projectList, String patchSize, String projectType, String srcPath) throws Exception
|
||||||
|
{
|
||||||
String parameters = String.format("\nInput path %s", inputPath);
|
String parameters = String.format("\nInput path %s", inputPath);
|
||||||
log.info(parameters);
|
log.info(parameters);
|
||||||
|
|
||||||
CallShell cs = new CallShell();
|
CallShell cs = new CallShell();
|
||||||
String cmd = "bash " + dbDir + "/" + "startServer.sh" + " %s %s %s";
|
String cmd = String.format("redis-server %s/redis.conf --dir %s --dbfilename redis.rdb --port %s --daemonize yes", srcPath, dbDir, redisPort);
|
||||||
|
// String cmd = "bash " + dbDir + "/" + "startServer.sh" + " %s %s %s";
|
||||||
|
|
||||||
cmd = String.format(cmd, dbDir, chunkName, Integer.valueOf(portInner));
|
// cmd = String.format(cmd, dbDir, chunkName, Integer.valueOf(redisPort));
|
||||||
|
|
||||||
cs.runShell(cmd, portInner);
|
cs.runShell(cmd, redisPort);
|
||||||
|
|
||||||
JedisPool innerPool = new JedisPool(PoolBuilder.getPoolConfig(), "127.0.0.1", Integer.valueOf(portInner), 20000000);
|
JedisPool innerPool = new JedisPool(PoolBuilder.getPoolConfig(), "127.0.0.1", Integer.valueOf(redisPort), 20000000);
|
||||||
|
|
||||||
boolean isJava = false;
|
boolean isJava = false;
|
||||||
if (projectType.equals("java")) {
|
if (projectType.equals("java"))
|
||||||
|
{
|
||||||
isJava = true;
|
isJava = true;
|
||||||
}
|
}
|
||||||
File folder = new File(inputPath);
|
File folder = new File(inputPath);
|
||||||
File[] listOfFiles = folder.listFiles();
|
File[] listOfFiles = folder.listFiles();
|
||||||
if (listOfFiles == null) {
|
if (listOfFiles == null)
|
||||||
|
{
|
||||||
throw new Exception("No projects found, please verify the projects in the input path");
|
throw new Exception("No projects found, please verify the projects in the input path");
|
||||||
}
|
}
|
||||||
Stream<File> stream = Arrays.stream(listOfFiles);
|
Stream<File> stream = Arrays.stream(listOfFiles);
|
||||||
List<File> folders;
|
List<File> folders;
|
||||||
if (projectList.length == 1 && projectList[0].equals("ALL")){
|
if (projectList.length == 1 && projectList[0].equals("ALL"))
|
||||||
|
{
|
||||||
folders = stream
|
folders = stream
|
||||||
.filter(x -> !x.getName().startsWith("."))
|
.filter(x -> !x.getName().startsWith("."))
|
||||||
.filter(x -> !x.getName().startsWith("cocci"))
|
.filter(x -> !x.getName().startsWith("cocci"))
|
||||||
.filter(x -> !x.getName().endsWith(".index"))
|
.filter(x -> !x.getName().endsWith(".index"))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
List<Predicate<File>> allPredicates = new ArrayList<Predicate<File>>();
|
List<Predicate<File>> allPredicates = new ArrayList<Predicate<File>>();
|
||||||
for (String s : projectList) {
|
for (String s : projectList)
|
||||||
|
{
|
||||||
Predicate<File> predicate = x -> x.getName().endsWith(s);
|
Predicate<File> predicate = x -> x.getName().endsWith(s);
|
||||||
allPredicates.add(predicate);
|
allPredicates.add(predicate);
|
||||||
}
|
}
|
||||||
@@ -75,25 +83,30 @@ public class EnhancedASTDiff {
|
|||||||
|
|
||||||
String project = folder.getName();
|
String project = folder.getName();
|
||||||
List<MessageFile> allMessageFiles = new ArrayList<>();
|
List<MessageFile> allMessageFiles = new ArrayList<>();
|
||||||
for (File target : folders) {
|
for (File target : folders)
|
||||||
|
{
|
||||||
|
|
||||||
List<MessageFile> msgFiles = getMessageFiles(target.toString() + "/", project, patchSize, isJava); //"/Users/anilkoyuncu/bugStudy/code/python/GumTreeInput/Apache/CAMEL/"
|
List<MessageFile> msgFiles = getMessageFiles(target.toString() + "/", project, patchSize, isJava); //"/Users/anilkoyuncu/bugStudy/code/python/GumTreeInput/Apache/CAMEL/"
|
||||||
|
|
||||||
// msgFiles = msgFiles.subList(0,3000);
|
// msgFiles = msgFiles.subList(0,3000);
|
||||||
if (msgFiles == null)
|
if (msgFiles == null)
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
allMessageFiles.addAll(msgFiles);
|
allMessageFiles.addAll(msgFiles);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, String> diffEntry;
|
Map<String, String> diffEntry;
|
||||||
try (Jedis inner = innerPool.getResource()) {
|
try (Jedis inner = innerPool.getResource())
|
||||||
|
{
|
||||||
diffEntry = inner.hgetAll("diffEntry");
|
diffEntry = inner.hgetAll("diffEntry");
|
||||||
|
|
||||||
}
|
}
|
||||||
log.info("{} files to process ...", allMessageFiles.size());
|
log.info("{} files to process ...", allMessageFiles.size());
|
||||||
if (diffEntry != null) {
|
if (diffEntry != null)
|
||||||
|
{
|
||||||
log.info("{} files already process ...", diffEntry.size());
|
log.info("{} files already process ...", diffEntry.size());
|
||||||
allMessageFiles = allMessageFiles.stream().filter(f -> !diffEntry.containsKey(f.getProject() + "_" + f.getDiffEntryFile().getName())).collect(Collectors.toList());
|
allMessageFiles = allMessageFiles.stream().filter(f -> !diffEntry.containsKey(f.getProject() + "_" + f.getDiffEntryFile().getName())).collect(Collectors.toList());
|
||||||
log.info("{} files to process ...", allMessageFiles.size());
|
log.info("{} files to process ...", allMessageFiles.size());
|
||||||
@@ -120,17 +133,19 @@ public class EnhancedASTDiff {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static List<MessageFile> getMessageFiles(String gumTreeInput, String datasetName, String patchSize, boolean isJava)
|
||||||
private static List<MessageFile> getMessageFiles(String gumTreeInput,String datasetName,String patchSize,boolean isJava) {
|
{
|
||||||
String inputPath = gumTreeInput; // prevFiles revFiles diffentryFile positionsFile
|
String inputPath = gumTreeInput; // prevFiles revFiles diffentryFile positionsFile
|
||||||
File revFilesPath = new File(inputPath + "revFiles/");
|
File revFilesPath = new File(inputPath + "revFiles/");
|
||||||
log.info(revFilesPath.getPath());
|
log.info(revFilesPath.getPath());
|
||||||
File[] revFiles = revFilesPath.listFiles();
|
File[] revFiles = revFilesPath.listFiles();
|
||||||
if (revFiles!= null ){
|
if (revFiles != null)
|
||||||
|
{
|
||||||
// List<File> collect = Arrays.stream(revFiles).filter(x -> x.getName().startsWith("0a2756_7598f8_components#camel-cxf#src#main#java#org#apache#camel#component#cxf#CxfHeaderFilterStrategy"))
|
// List<File> collect = Arrays.stream(revFiles).filter(x -> x.getName().startsWith("0a2756_7598f8_components#camel-cxf#src#main#java#org#apache#camel#component#cxf#CxfHeaderFilterStrategy"))
|
||||||
// .collect(Collectors.toList());// project folders
|
// .collect(Collectors.toList());// project folders
|
||||||
List<MessageFile> msgFiles = new ArrayList<>();
|
List<MessageFile> msgFiles = new ArrayList<>();
|
||||||
for (File revFile : revFiles) {
|
for (File revFile : revFiles)
|
||||||
|
{
|
||||||
// for (File revFile : collect) {
|
// for (File revFile : collect) {
|
||||||
String fileName = revFile.getName();
|
String fileName = revFile.getName();
|
||||||
File prevFile = new File(gumTreeInput + "prevFiles/prev_" + fileName);// previous file
|
File prevFile = new File(gumTreeInput + "prevFiles/prev_" + fileName);// previous file
|
||||||
@@ -147,10 +162,14 @@ public class EnhancedASTDiff {
|
|||||||
Matcher matcher = pattern.matcher(s);
|
Matcher matcher = pattern.matcher(s);
|
||||||
int count = 0;
|
int count = 0;
|
||||||
while (matcher.find())
|
while (matcher.find())
|
||||||
|
{
|
||||||
count++;
|
count++;
|
||||||
|
}
|
||||||
if (count >= Integer.valueOf(patchSize))
|
if (count >= Integer.valueOf(patchSize))
|
||||||
// if(count>201)
|
// if(count>201)
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
// if(FileHelper.readFile(diffentryFile).split("@@\\s\\-\\d+,*\\d*\\s\\+\\d+,*\\d*\\s@@").length > 2)
|
// if(FileHelper.readFile(diffentryFile).split("@@\\s\\-\\d+,*\\d*\\s\\+\\d+,*\\d*\\s@@").length > 2)
|
||||||
// continue;
|
// continue;
|
||||||
|
|
||||||
@@ -166,11 +185,12 @@ public class EnhancedASTDiff {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return msgFiles;
|
return msgFiles;
|
||||||
}else{
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user