This commit is contained in:
Anil Koyuncu
2018-04-04 11:14:52 +02:00
parent 61b6c7a840
commit 8aedc4ec40
3 changed files with 31 additions and 38 deletions
@@ -167,6 +167,7 @@ public class AkkaTreeLoader {
} }
ScanParams sc = new ScanParams(); ScanParams sc = new ScanParams();
//150000000
sc.count(150000000); sc.count(150000000);
sc.match("pair_*"); sc.match("pair_*");
@@ -183,7 +184,7 @@ public class AkkaTreeLoader {
try { try {
log.info("Akka begins..."); log.info("Akka begins...");
system = ActorSystem.create("Tree-System"); system = ActorSystem.create("Tree-System");
parsingActor = system.actorOf(TreeActor.props(Integer.valueOf(numOfWorkers)), "tree-actor"); parsingActor = system.actorOf(TreeActor.props(Integer.valueOf(numOfWorkers),dbDir,innerPort,serverWait), "tree-actor");
parsingActor.tell(msg, ActorRef.noSender()); parsingActor.tell(msg, ActorRef.noSender());
} catch (Exception e) { } catch (Exception e) {
system.shutdown(); system.shutdown();
@@ -12,6 +12,8 @@ import org.slf4j.LoggerFactory;
import java.util.List; import java.util.List;
import static edu.lu.uni.serval.FixPatternParser.violations.AkkaTreeLoader.loadRedis;
public class TreeActor extends UntypedActor { public class TreeActor extends UntypedActor {
private static Logger logger = LoggerFactory.getLogger(TreeActor.class); private static Logger logger = LoggerFactory.getLogger(TreeActor.class);
@@ -20,13 +22,20 @@ public class TreeActor extends UntypedActor {
private final int numberOfWorkers; private final int numberOfWorkers;
private int counter = 0; private int counter = 0;
public TreeActor(int numberOfWorkers) { private String innerPort;
private String dbDir;
private String serverWait;
public TreeActor(int numberOfWorkers,String dbDir,String innerPort,String serverWait) {
mineRouter = this.getContext().actorOf(new RoundRobinPool(numberOfWorkers) mineRouter = this.getContext().actorOf(new RoundRobinPool(numberOfWorkers)
.props(TreeWorker.props()), "tree-router"); .props(TreeWorker.props()), "tree-router");
this.numberOfWorkers = numberOfWorkers; this.numberOfWorkers = numberOfWorkers;
this.innerPort = innerPort;
this.dbDir = dbDir;
this.serverWait = serverWait;
} }
public static Props props(final int numberOfWorkers) { public static Props props(final int numberOfWorkers, final String dbDir,final String innerPort, final String serverWait) {
return Props.create(new Creator<TreeActor>() { return Props.create(new Creator<TreeActor>() {
@@ -34,7 +43,7 @@ public class TreeActor extends UntypedActor {
@Override @Override
public TreeActor create() throws Exception { public TreeActor create() throws Exception {
return new TreeActor(numberOfWorkers); return new TreeActor(numberOfWorkers,dbDir,innerPort,serverWait);
} }
}); });
@@ -73,6 +82,9 @@ public class TreeActor extends UntypedActor {
this.getContext().stop(mineRouter); this.getContext().stop(mineRouter);
this.getContext().stop(getSelf()); this.getContext().stop(getSelf());
this.getContext().system().shutdown(); this.getContext().system().shutdown();
String stopServer = "bash "+dbDir + "/" + "stopServer.sh" +" %s";
stopServer = String.format(stopServer,Integer.valueOf(innerPort));
loadRedis(stopServer,serverWait);
} }
} else { } else {
unhandled(message); unhandled(message);
@@ -58,7 +58,7 @@ public class TreeWorker extends UntypedActor {
public void onReceive(Object message) throws Exception { public void onReceive(Object message) throws Exception {
if(message instanceof edu.lu.uni.serval.FixPatternParser.violations.WorkMessage) { if(message instanceof edu.lu.uni.serval.FixPatternParser.violations.WorkMessage) {
log.info("do sometihng");
// if (message instanceof edu.lu.uni.serval.MultipleThreadsParser.WorkMessage) { // if (message instanceof edu.lu.uni.serval.MultipleThreadsParser.WorkMessage) {
edu.lu.uni.serval.FixPatternParser.violations.WorkMessage msg = (WorkMessage) message; edu.lu.uni.serval.FixPatternParser.violations.WorkMessage msg = (WorkMessage) message;
List<String> files = msg.getMsgFiles(); List<String> files = msg.getMsgFiles();
@@ -66,38 +66,13 @@ public class TreeWorker extends UntypedActor {
String inputPath = msg.getInputPath(); String inputPath = msg.getInputPath();
String dbDir = msg.getDbDir(); String dbDir = msg.getDbDir();
String serverWait = msg.getServerWait(); String serverWait = msg.getServerWait();
// StringBuilder editScripts = new StringBuilder(); int id = msg.getId();
// StringBuilder patchesSourceCode = new StringBuilder(); int counter = 0;
// StringBuilder sizes = new StringBuilder();
// StringBuilder tokens = new StringBuilder();
// StringBuilder testingInfo = new StringBuilder();
//
// int id = msg.getId();
// int counter = 0;
//
// int nullGumTreeResults = 0;
// int noSourceCodeChanges = 0;
// int noStatementChanges = 0;
// int nullDiffEntry = 0;
// int nullMappingGumTreeResults = 0;
// int pureDeletion = 0;
// int largeHunk = 0;
// int nullSourceCode = 0;
// int testInfos = 0;
// int timeouts = 0;
// StringBuilder builder = new StringBuilder();
// //
for (String name : files) { for (String name : files) {
// log.info(name);
// File revFile = msgFile.getRevFile();
// File prevFile = msgFile.getPrevFile();
// File diffentryFile = msgFile.getDiffEntryFile();
//// File positionFile = msgFile.getPositionFile();
// /*if (revFile.getName().toLowerCase().contains("test")) {
// continue;
// }*/
// FixedViolationHunkParser parser = new FixedViolationHunkParser();
// //
final ExecutorService executor = Executors.newSingleThreadExecutor(); final ExecutorService executor = Executors.newSingleThreadExecutor();
// // schedule the work // // schedule the work
@@ -105,7 +80,7 @@ public class TreeWorker extends UntypedActor {
try { try {
// wait for task to complete // wait for task to complete
future.get(Configuration.SECONDS_TO_WAIT, TimeUnit.SECONDS); future.get(Configuration.SECONDS_TO_WAIT, TimeUnit.SECONDS);
// counter++;
// nullDiffEntry += parser.nullMatchedDiffEntry; // nullDiffEntry += parser.nullMatchedDiffEntry;
// nullMappingGumTreeResults += parser.nullMappingGumTreeResult; // nullMappingGumTreeResults += parser.nullMappingGumTreeResult;
// pureDeletion += parser.pureDeletions; // pureDeletion += parser.pureDeletions;
@@ -161,9 +136,14 @@ public class TreeWorker extends UntypedActor {
executor.shutdownNow(); executor.shutdownNow();
} }
} }
String stopServer = "bash "+dbDir + "/" + "stopServer.sh" +" %s";
stopServer = String.format(stopServer,Integer.valueOf(innerPort)); log.info("bitti");
loadRedis(stopServer,serverWait); log.info("Worker #" + id +"finialized parsing " + counter + " files...");
log.info("Worker #" + id + " finialized the work...");
this.getSender().tell("STOP", getSelf());
// String stopServer = "bash "+dbDir + "/" + "stopServer.sh" +" %s";
// stopServer = String.format(stopServer,Integer.valueOf(innerPort));
// loadRedis(stopServer,serverWait);
// //
// if (sizes.length() > 0) { // if (sizes.length() > 0) {
// FileHelper.outputToFile(editScriptsFilePath + "editScripts_" + id + ".list", editScripts, true); // FileHelper.outputToFile(editScriptsFilePath + "editScripts_" + id + ".list", editScripts, true);