pool
This commit is contained in:
@@ -354,39 +354,27 @@ public class AkkaTreeLoader {
|
||||
}
|
||||
public static ITree getSimpliedTree(String fn,JedisPoolConfig config) {
|
||||
JedisPool pool = new JedisPool(config, "127.0.0.1", Integer.valueOf(6399), 20000000);
|
||||
HierarchicalActionSet actionSet = null;
|
||||
try (Jedis inner = pool.getResource()) {
|
||||
ITree tree = null;
|
||||
Jedis inner = null;
|
||||
try {
|
||||
inner = pool.getResource();
|
||||
String s = inner.get(fn.substring(1));
|
||||
actionSet = (HierarchicalActionSet) fromString(s);
|
||||
HierarchicalActionSet actionSet = (HierarchicalActionSet) fromString(s);
|
||||
|
||||
ITree parent = null;
|
||||
ITree children =null;
|
||||
tree = getASTTree(actionSet, parent, children);
|
||||
tree.setParent(null);
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if (inner != null) {
|
||||
inner.close();
|
||||
}
|
||||
}
|
||||
// try {
|
||||
// FileInputStream fi = new FileInputStream(new File(fn));
|
||||
// ObjectInputStream oi = new ObjectInputStream(fi);
|
||||
// actionSet = (HierarchicalActionSet) oi.readObject();
|
||||
// oi.close();
|
||||
// fi.close();
|
||||
//
|
||||
//
|
||||
// } catch (FileNotFoundException e) {
|
||||
// log.error("File not found");
|
||||
// e.printStackTrace();
|
||||
// } catch (IOException e) {
|
||||
// log.error("Error initializing stream");
|
||||
// e.printStackTrace();
|
||||
// } catch (ClassNotFoundException e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
|
||||
ITree parent = null;
|
||||
ITree children =null;
|
||||
ITree tree = getASTTree(actionSet, parent, children);
|
||||
tree.setParent(null);
|
||||
|
||||
return tree;
|
||||
|
||||
}
|
||||
@@ -637,12 +625,12 @@ public class AkkaTreeLoader {
|
||||
poolConfig.setMaxTotal(128);
|
||||
poolConfig.setMaxIdle(128);
|
||||
poolConfig.setMinIdle(16);
|
||||
poolConfig.setTestOnBorrow(true);
|
||||
poolConfig.setTestOnReturn(true);
|
||||
poolConfig.setTestOnBorrow(false);
|
||||
poolConfig.setTestOnReturn(false);
|
||||
poolConfig.setTestWhileIdle(true);
|
||||
poolConfig.setMinEvictableIdleTimeMillis(Duration.ofMinutes(60).toMillis());
|
||||
poolConfig.setTimeBetweenEvictionRunsMillis(Duration.ofHours(30).toMillis());
|
||||
poolConfig.setNumTestsPerEvictionRun(3);
|
||||
// poolConfig.setNumTestsPerEvictionRun(3);
|
||||
poolConfig.setBlockWhenExhausted(true);
|
||||
|
||||
return poolConfig;
|
||||
|
||||
@@ -31,33 +31,19 @@ public class Compare {
|
||||
public void coreCompare(String name , String inputPath, String innerPort) {
|
||||
JedisPool pool = new JedisPool(poolConfig, "127.0.0.1", Integer.valueOf(innerPort), 20000000);
|
||||
Map<String, String> resultMap;
|
||||
try (Jedis jedis = pool.getResource()) {
|
||||
resultMap = jedis.hgetAll(name);
|
||||
}
|
||||
String[] split = name.split("_");
|
||||
|
||||
|
||||
String i = split[1];
|
||||
String j = split[2];
|
||||
String firstValue = resultMap.get("0");
|
||||
String secondValue = resultMap.get("1");
|
||||
|
||||
// String[] firstValueSplit = firstValue.split("GumTreeOutput2");
|
||||
// String[] secondValueSplit = secondValue.split("GumTreeOutput2");
|
||||
//
|
||||
// if (firstValueSplit.length == 1) {
|
||||
// firstValue = inputPath + firstValueSplit[0];
|
||||
// } else {
|
||||
// firstValue = inputPath + firstValueSplit[1];
|
||||
// }
|
||||
//
|
||||
// if (secondValueSplit.length == 1) {
|
||||
// secondValue = inputPath + secondValueSplit[0];
|
||||
// } else {
|
||||
// secondValue = inputPath + secondValueSplit[1];
|
||||
// }
|
||||
Jedis jedis = null;
|
||||
|
||||
try {
|
||||
jedis = pool.getResource();
|
||||
resultMap = jedis.hgetAll(name);
|
||||
|
||||
String[] split = name.split("_");
|
||||
|
||||
|
||||
String i = split[1];
|
||||
String j = split[2];
|
||||
String firstValue = resultMap.get("0");
|
||||
String secondValue = resultMap.get("1");
|
||||
|
||||
ITree oldTree = getSimpliedTree(firstValue,poolConfig);
|
||||
|
||||
@@ -87,22 +73,26 @@ public class Compare {
|
||||
|| ((Double) jaccardSimilarity1).equals(1.0) || actions.size() == 0) {
|
||||
String matchKey = "match_" + (String.valueOf(i)) + "_" + String.valueOf(j);
|
||||
log.info(matchKey);
|
||||
try (Jedis jedis = pool.getResource()) {
|
||||
jedis.select(1);
|
||||
jedis.set(matchKey, result);
|
||||
}
|
||||
|
||||
jedis.select(1);
|
||||
jedis.set(matchKey, result);
|
||||
|
||||
}
|
||||
|
||||
|
||||
try (Jedis jedis = pool.getResource()) {
|
||||
jedis.del("pair_" + (String.valueOf(i)) + "_" + String.valueOf(j));
|
||||
}
|
||||
|
||||
jedis.del("pair_" + (String.valueOf(i)) + "_" + String.valueOf(j));
|
||||
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error(e.toString() + " {}", (name));
|
||||
|
||||
|
||||
}finally {
|
||||
if (jedis != null) {
|
||||
jedis.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user