From 5254e8e98d55534952bff44cb264bc38eabdf4d1 Mon Sep 17 00:00:00 2001 From: ANIL KOYUNCU Date: Tue, 21 Jan 2020 16:17:47 +0100 Subject: [PATCH] changes --- .../edu/lu/uni/serval/fixminer/Launcher.java | 21 ++++---- .../fixminer/akka/compare/CompareTrees.java | 52 ++++++++++++------- .../fixminer/akka/ediff/EDiffHunkParser.java | 6 +-- .../serval/fixminer/jobs/EnhancedASTDiff.java | 27 +++++++--- 4 files changed, 68 insertions(+), 38 deletions(-) diff --git a/src/main/java/edu/lu/uni/serval/fixminer/Launcher.java b/src/main/java/edu/lu/uni/serval/fixminer/Launcher.java index e7e43d8..35fd469 100755 --- a/src/main/java/edu/lu/uni/serval/fixminer/Launcher.java +++ b/src/main/java/edu/lu/uni/serval/fixminer/Launcher.java @@ -22,8 +22,8 @@ public class Launcher { Properties appProps = new Properties(); - String appConfigPath = "/Users/anil.koyuncu/projects/fixminer/fixminer_source/src/main/resource/app.properties"; -// String appConfigPath = args[0]; +// String appConfigPath = "/Users/anil.koyuncu/projects/fixminer/fixminer_source/src/main/resource/app.properties"; + String appConfigPath = args[0]; appProps.load(new FileInputStream(appConfigPath)); // String portInner = appProps.getProperty("portInner","6380"); @@ -33,17 +33,18 @@ public class Launcher { String actionType = appProps.getProperty("actionType","ALL"); String eDiffTimeout = appProps.getProperty("eDiffTimeout","900"); String parallelism = appProps.getProperty("parallelism","FORKJOIN"); + String hostname = appProps.getProperty("hostname","localhost"); String input = appProps.getProperty("inputPath","FORKJOIN"); String redisPath = appProps.getProperty("redisPath","FORKJOIN"); String srcMLPath = appProps.getProperty("srcMLPath","FORKJOIN"); -// String parameter = args[2]; -// String parameter = null; + String parameter = args[2]; +// String parameter = "L1"; // String parameter = "if"; - String parameter = "add"; -// String jobType = args[1]; - String jobType = "RICHEDITSCRIPT"; +// String parameter = "add"; + String jobType = args[1]; +// String jobType = "RICHEDITSCRIPT"; // String jobType = "LOAD"; // String jobType = "COMPARE"; @@ -56,12 +57,12 @@ public class Launcher { // // log.info(parameters); - mainLaunch( numOfWorkers, jobType, portDumps, pjName,actionType,eDiffTimeout,parallelism,input,redisPath,parameter, srcMLPath); + mainLaunch( numOfWorkers, jobType, portDumps, pjName,actionType,eDiffTimeout,parallelism,input,redisPath,parameter, srcMLPath,hostname); } - public static void mainLaunch(String numOfWorkers, String jobType, String portDumps, String pjName, String actionType, String eDiffTimeout, String parallelism,String input, String redisPath,String parameter,String srcMLPath){ + public static void mainLaunch(String numOfWorkers, String jobType, String portDumps, String pjName, String actionType, String eDiffTimeout, String parallelism,String input, String redisPath,String parameter,String srcMLPath,String hostname){ String dbDir; @@ -106,7 +107,7 @@ public class Launcher { } - CompareTrees.main(redisPath, portDumps,actionType+dumpsName, job); + CompareTrees.main(redisPath, portDumps,actionType+dumpsName, job,numOfWorkers,hostname); break; case "PATTERN": ClusterToPattern.main(portDumps,redisPath, actionType+dumpsName, parameter); diff --git a/src/main/java/edu/lu/uni/serval/fixminer/akka/compare/CompareTrees.java b/src/main/java/edu/lu/uni/serval/fixminer/akka/compare/CompareTrees.java index dbbab0c..15bf6f3 100755 --- a/src/main/java/edu/lu/uni/serval/fixminer/akka/compare/CompareTrees.java +++ b/src/main/java/edu/lu/uni/serval/fixminer/akka/compare/CompareTrees.java @@ -14,6 +14,7 @@ import redis.clients.jedis.JedisPool; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; @@ -29,7 +30,7 @@ public class CompareTrees { private static Logger log = LoggerFactory.getLogger(CompareTrees.class); - public static void main(String redisPath, String portDumps, String dumpsName, String job) throws Exception { + public static void main(String redisPath, String portDumps, String dumpsName, String job,String numOfWorkers,String host) throws Exception { // shape /Users/anil.koyuncu/projects/test/fixminer-core/python/data/redis ALLdumps-gumInput.rdb clusterl0-gumInputALL.rdb /Users/anil.koyuncu/projects/test/fixminer-core/python/data/richEditScript @@ -47,7 +48,7 @@ public class CompareTrees { // cs.runShell(cmdInner, portInner); // String numOfWorkers = "100000000";//args[4]; - String host = "localhost";//args[5]; +// String host = "localhost";//args[5]; // -Djava.util.concurrent.ForkJoinPool.common.parallelism=256 // final JedisPool innerPool = new JedisPool(PoolBuilder.getPoolConfig(), host,Integer.valueOf(portInner),20000000); @@ -62,26 +63,36 @@ public class CompareTrees { ArrayList samePairs = new ArrayList<>(); ArrayList errorPairs = new ArrayList<>(); + Integer numberOfWorkers = Integer.valueOf(numOfWorkers); + final ExecutorService executor = Executors.newWorkStealingPool(numberOfWorkers); + ArrayList> results = new ArrayList>(); + for (int i = 1; i future = executor.submit( new RunnableCompare( job,errorPairs,filenames,outerPool)); - - try { - // wait for task to complete - future.get(); - - } catch (InterruptedException e) { - - e.printStackTrace(); - } catch (ExecutionException e) { - - e.printStackTrace(); - } finally { - executor.shutdownNow(); + // schedule the work + log.info("Starting job {}",i); + final Future future = executor.submit(new RunnableCompare(job, errorPairs, filenames, outerPool, i)); + results.add(future); } + for (Future future:results){ + try { + // wait for task to complete + future.get(); + + } catch (InterruptedException e) { + + e.printStackTrace(); + } catch (ExecutionException e) { + + e.printStackTrace(); + } finally { + executor.shutdownNow(); + } + } + + + log.info("End process"); @@ -93,12 +104,14 @@ public class CompareTrees { ArrayList errorPairs; HashMap filenames; JedisPool outerPool; + Integer threadID; - public RunnableCompare(String treeType,ArrayList errorPairs, HashMap filenames,JedisPool outerPool) { + public RunnableCompare(String treeType,ArrayList errorPairs, HashMap filenames,JedisPool outerPool,Integer threadID) { this.job = treeType; this.errorPairs = errorPairs; this.filenames = filenames; this.outerPool = outerPool; + this.threadID = threadID; } @Override @@ -113,6 +126,7 @@ public class CompareTrees { stop = newCoreCompare(job, errorPairs, filenames, outerPool); // } } + log.info("Completed worker {}",threadID); } } diff --git a/src/main/java/edu/lu/uni/serval/fixminer/akka/ediff/EDiffHunkParser.java b/src/main/java/edu/lu/uni/serval/fixminer/akka/ediff/EDiffHunkParser.java index 0bac96d..fc1787a 100755 --- a/src/main/java/edu/lu/uni/serval/fixminer/akka/ediff/EDiffHunkParser.java +++ b/src/main/java/edu/lu/uni/serval/fixminer/akka/ediff/EDiffHunkParser.java @@ -40,9 +40,9 @@ public class EDiffHunkParser extends EDiffParser { try { String astNodeType = actionSet.getAstNodeType(); - if (astNodeType.equals(rootType)){ - - } +// if (astNodeType.equals(rootType)){ +// +// } actionSet.toString(); int size = actionSet.getActionSize(); diff --git a/src/main/java/edu/lu/uni/serval/fixminer/jobs/EnhancedASTDiff.java b/src/main/java/edu/lu/uni/serval/fixminer/jobs/EnhancedASTDiff.java index 9c35b53..e19232f 100755 --- a/src/main/java/edu/lu/uni/serval/fixminer/jobs/EnhancedASTDiff.java +++ b/src/main/java/edu/lu/uni/serval/fixminer/jobs/EnhancedASTDiff.java @@ -34,16 +34,29 @@ public class EnhancedASTDiff { CallShell cs = new CallShell(); String cmd = "bash "+dbDir + "/" + "startServer.sh" +" %s %s %s"; - if (rootType == null){ - cmd = String.format(cmd, dbDir,chunkName,Integer.valueOf(portInner)); - }else{ - cmd = String.format(cmd, dbDir,rootType+chunkName,Integer.valueOf(portInner)); - } +// if (rootType == null){ + cmd = String.format(cmd, dbDir,chunkName,Integer.valueOf(portInner)); +// }else{ +// cmd = String.format(cmd, dbDir,rootType+chunkName,Integer.valueOf(portInner)); +// } cs.runShell(cmd, portInner); JedisPool innerPool = new JedisPool(PoolBuilder.getPoolConfig(), "127.0.0.1",Integer.valueOf(portInner),20000000); + if (rootType == "add"){ + try (Jedis inner = innerPool.getResource()) { + inner.select(2); + inner.flushDB(); + inner.select(1); + inner.flushDB(); + inner.select(0); + inner.del("compare"); + + } + + } + File folder = new File(inputPath); File[] listOfFiles = folder.listFiles(); Stream stream = Arrays.stream(listOfFiles); @@ -79,8 +92,10 @@ public class EnhancedASTDiff { parsingActor = system.actorOf(EDiffActor.props(Integer.valueOf(numOfWorkers), project), "mine-fix-pattern-actor"); parsingActor.tell(msg, ActorRef.noSender()); } catch (Exception e) { - system.shutdown(); + system.terminate(); e.printStackTrace(); + }finally { + system.terminate(); } break; case "FORKJOIN":