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();
//150000000
sc.count(150000000);
sc.match("pair_*");
@@ -183,7 +184,7 @@ public class AkkaTreeLoader {
try {
log.info("Akka begins...");
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());
} catch (Exception e) {
system.shutdown();
@@ -12,6 +12,8 @@ import org.slf4j.LoggerFactory;
import java.util.List;
import static edu.lu.uni.serval.FixPatternParser.violations.AkkaTreeLoader.loadRedis;
public class TreeActor extends UntypedActor {
private static Logger logger = LoggerFactory.getLogger(TreeActor.class);
@@ -20,13 +22,20 @@ public class TreeActor extends UntypedActor {
private final int numberOfWorkers;
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)
.props(TreeWorker.props()), "tree-router");
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>() {
@@ -34,7 +43,7 @@ public class TreeActor extends UntypedActor {
@Override
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(getSelf());
this.getContext().system().shutdown();
String stopServer = "bash "+dbDir + "/" + "stopServer.sh" +" %s";
stopServer = String.format(stopServer,Integer.valueOf(innerPort));
loadRedis(stopServer,serverWait);
}
} else {
unhandled(message);
@@ -58,7 +58,7 @@ public class TreeWorker extends UntypedActor {
public void onReceive(Object message) throws Exception {
if(message instanceof edu.lu.uni.serval.FixPatternParser.violations.WorkMessage) {
log.info("do sometihng");
// if (message instanceof edu.lu.uni.serval.MultipleThreadsParser.WorkMessage) {
edu.lu.uni.serval.FixPatternParser.violations.WorkMessage msg = (WorkMessage) message;
List<String> files = msg.getMsgFiles();
@@ -66,38 +66,13 @@ public class TreeWorker extends UntypedActor {
String inputPath = msg.getInputPath();
String dbDir = msg.getDbDir();
String serverWait = msg.getServerWait();
// StringBuilder editScripts = new StringBuilder();
// StringBuilder patchesSourceCode = new StringBuilder();
// 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();
int id = msg.getId();
int counter = 0;
//
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();
// // schedule the work
@@ -105,7 +80,7 @@ public class TreeWorker extends UntypedActor {
try {
// wait for task to complete
future.get(Configuration.SECONDS_TO_WAIT, TimeUnit.SECONDS);
//
counter++;
// nullDiffEntry += parser.nullMatchedDiffEntry;
// nullMappingGumTreeResults += parser.nullMappingGumTreeResult;
// pureDeletion += parser.pureDeletions;
@@ -161,9 +136,14 @@ public class TreeWorker extends UntypedActor {
executor.shutdownNow();
}
}
String stopServer = "bash "+dbDir + "/" + "stopServer.sh" +" %s";
stopServer = String.format(stopServer,Integer.valueOf(innerPort));
loadRedis(stopServer,serverWait);
log.info("bitti");
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) {
// FileHelper.outputToFile(editScriptsFilePath + "editScripts_" + id + ".list", editScripts, true);