This commit is contained in:
Anil Koyuncu
2018-04-04 22:35:34 +02:00
parent a28043bf2c
commit 9807eb913c
2 changed files with 28 additions and 48 deletions
@@ -129,46 +129,31 @@ public class AkkaTreeLoader {
cmd = String.format(cmd, dbDir,"dumps.rdb",Integer.valueOf(port)); cmd = String.format(cmd, dbDir,"dumps.rdb",Integer.valueOf(port));
loadRedis(cmd,serverWait); loadRedis(cmd,serverWait);
comparePairs(inputPath, portInner, serverWait,chunkName,dbDir,numOfWorkers); String cmdInner = "bash "+dbDir + "/" + "startServer.sh" +" %s %s %s";
cmd = String.format(cmdInner, dbDir,chunkName,Integer.valueOf(portInner));
loadRedis(cmd,serverWait);
JedisPool outerPool = new JedisPool(poolConfig, "127.0.0.1",Integer.valueOf(port),20000000);
JedisPool innerPool = new JedisPool(poolConfig, "127.0.0.1",Integer.valueOf(portInner),20000000);
comparePairs(inputPath, innerPool,outerPool, serverWait,chunkName,dbDir,numOfWorkers);
String stopServer = "bash "+dbDir + "/" + "stopServer.sh" +" %s";
stopServer = String.format(stopServer,Integer.valueOf(portInner));
loadRedis(stopServer,serverWait);
// } // }
} }
public static void comparePairs(String inputPath, String innerPort,String serverWait,String chunkName, String dbDir,String numOfWorkers){ public static void comparePairs(String inputPath, JedisPool innerPool,JedisPool outerPool,String serverWait,String chunkName, String dbDir,String numOfWorkers){
// String cmd;
// cmd = "bash " + importScript +" %s";
List<String> dir;
List<String> path;
String orgDbname;
File files = new File(dbDir);
File[] listFiles = files.listFiles();
// Stream<File> stream = Arrays.stream(listFiles);
// List<File> folders = stream
// .filter(x -> x.getName().equals(chunkName))
// .collect(Collectors.toList());
// for (File folder : folders) {
String cmd = "bash "+dbDir + "/" + "startServer.sh" +" %s %s %s";
cmd = String.format(cmd, dbDir,chunkName,Integer.valueOf(innerPort));
loadRedis(cmd,serverWait);
JedisPool pool = new JedisPool(new JedisPoolConfig(), "127.0.0.1", Integer.valueOf(innerPort), 20000000);
ScanResult<String> scan; ScanResult<String> scan;
try (Jedis inner = pool.getResource()) { try (Jedis inner = innerPool.getResource()) {
while (inner.ping()== "PONG"){ while (inner.ping()== "PONG"){
log.info("wait"); log.info("wait");
} }
@@ -203,16 +188,14 @@ public class AkkaTreeLoader {
.parallelStream() .parallelStream()
.forEach(m -> .forEach(m ->
{ {
Compare compare = new Compare(poolConfig); Compare compare = new Compare();
compare.coreCompare(m, inputPath, innerPort); compare.coreCompare(m, innerPool, outerPool);
; ;
} }
); );
String stopServer = "bash "+dbDir + "/" + "stopServer.sh" +" %s";
stopServer = String.format(stopServer,Integer.valueOf(innerPort));
loadRedis(stopServer,serverWait);
// } // }
@@ -352,12 +335,12 @@ public class AkkaTreeLoader {
ois.close(); ois.close();
return o; return o;
} }
public static ITree getSimpliedTree(String fn,JedisPoolConfig config) { public static ITree getSimpliedTree(String fn,JedisPool outerPool) {
JedisPool pool = new JedisPool(config, "127.0.0.1", Integer.valueOf(6399), 20000000);
ITree tree = null; ITree tree = null;
Jedis inner = null; Jedis inner = null;
try { try {
inner = pool.getResource(); inner = outerPool.getResource();
String s = inner.get(fn.substring(1)); String s = inner.get(fn.substring(1));
HierarchicalActionSet actionSet = (HierarchicalActionSet) fromString(s); HierarchicalActionSet actionSet = (HierarchicalActionSet) fromString(s);
@@ -23,18 +23,15 @@ import static edu.lu.uni.serval.FixPatternParser.violations.AkkaTreeLoader.getSi
public class Compare { public class Compare {
private Logger log = LoggerFactory.getLogger(Compare.class); private Logger log = LoggerFactory.getLogger(Compare.class);
private JedisPoolConfig poolConfig;
public Compare(JedisPoolConfig pool) {
this.poolConfig = pool;
}
public void coreCompare(String name , String inputPath, String innerPort) {
JedisPool pool = new JedisPool(poolConfig, "127.0.0.1", Integer.valueOf(innerPort), 20000000); public void coreCompare(String name , JedisPool innerPool, JedisPool outerPool) {
Map<String, String> resultMap; Map<String, String> resultMap;
Jedis jedis = null; Jedis jedis = null;
try { try {
jedis = pool.getResource(); jedis = innerPool.getResource();
resultMap = jedis.hgetAll(name); resultMap = jedis.hgetAll(name);
String[] split = name.split("_"); String[] split = name.split("_");
@@ -45,9 +42,9 @@ public class Compare {
String firstValue = resultMap.get("0"); String firstValue = resultMap.get("0");
String secondValue = resultMap.get("1"); String secondValue = resultMap.get("1");
ITree oldTree = getSimpliedTree(firstValue,poolConfig); ITree oldTree = getSimpliedTree(firstValue,outerPool);
ITree newTree = getSimpliedTree(secondValue,poolConfig); ITree newTree = getSimpliedTree(secondValue,outerPool);
Matcher m = Matchers.getInstance().getMatcher(oldTree, newTree); Matcher m = Matchers.getInstance().getMatcher(oldTree, newTree);
m.match(); m.match();