|
@@ -19,22 +19,29 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|
public class Analyzer {
|
|
public class Analyzer {
|
|
private static final int threadPoolSize = 8;
|
|
private static final int threadPoolSize = 8;
|
|
|
|
|
|
- public static final int roundLength = 3600;
|
|
|
|
|
|
+ public static final int roundLength = 1800;
|
|
public static final int clientNo = 1000000;
|
|
public static final int clientNo = 1000000;
|
|
|
|
|
|
|
|
+ public static final boolean coverTraffic = false;
|
|
|
|
+ public static final int delay = 0;
|
|
|
|
+ public static final String childPath = coverTraffic ? "ct" : delay > 0 ? "delay" : roundLength + "";
|
|
public static final String logType = "random_"; //"top-" "random_"
|
|
public static final String logType = "random_"; //"top-" "random_"
|
|
- public static final String logPath = "C:\\Users\\Admin\\Desktop\\Skripts\\Thesis\\Repo\\local\\vm-mount\\logs\\" + roundLength + "\\" + logType + clientNo;
|
|
|
|
- public static final String clientLogPath = logPath + "\\clogs.txt";
|
|
|
|
|
|
+ //public static final String logPath = "C:\\Users\\Admin\\Desktop\\Skripts\\Thesis\\Repo\\local\\vm-mount\\logs\\" + logType + clientNo + "\\" + roundLength;
|
|
|
|
+ public static final String logPath = "C:\\Users\\Admin\\Desktop\\Skripts\\Thesis\\Repo\\local\\vm-mount\\logs\\" + logType + clientNo + "\\" + childPath;
|
|
|
|
+ public static String clientLogPath = logPath + "\\clogs.txt";
|
|
public static String serverLogPath = logPath + "\\slogs.txt";
|
|
public static String serverLogPath = logPath + "\\slogs.txt";
|
|
|
|
|
|
- //public static final User toTraceUser = new User(306637085);
|
|
|
|
- public static final String toTraceHashtag = "InstantFollowBack";
|
|
|
|
- public static final String intersectingClientID = "client-6220";
|
|
|
|
|
|
+ //TEST
|
|
|
|
+ //private static final User toTraceUser = new User(306637085);
|
|
|
|
+ private static final String toTraceHashtag = "InstantFollowBack";
|
|
|
|
+ private static final String intersectingClientID = "client-1034";
|
|
|
|
+ private static final long targetUserID = 398449825L;
|
|
|
|
+
|
|
|
|
|
|
public static void main(String[] args) throws InterruptedException, ExecutionException {
|
|
public static void main(String[] args) throws InterruptedException, ExecutionException {
|
|
- //new Analyzer().traceHashtag();
|
|
|
|
- //new Analyzer().calculatePointsGivenHashtags(ClientLogParser.clients.get("client-6220"), new Hashtag[] {ServerLogParser.hashtags.get("InstantFollowBack"), ServerLogParser.hashtags.get("sales")}, 0, true);
|
|
|
|
- new Analyzer().intersectUsers(ClientLogParser.clients.get("client-6219"), 0, true);
|
|
|
|
|
|
+ //a.traceHashtag();
|
|
|
|
+ //traceClientHashtagLink();
|
|
|
|
+ traceClientUserLink();
|
|
}
|
|
}
|
|
|
|
|
|
public Analyzer () throws InterruptedException {
|
|
public Analyzer () throws InterruptedException {
|
|
@@ -45,17 +52,37 @@ public class Analyzer {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
- //Thread clogs = new Thread(ClientLogParser::run);
|
|
|
|
|
|
+ Thread clogs = new Thread(ClientLogParser::run);
|
|
slogs.start();
|
|
slogs.start();
|
|
- //clogs.start();
|
|
|
|
|
|
+ clogs.start();
|
|
slogs.join();
|
|
slogs.join();
|
|
- //clogs.join();
|
|
|
|
|
|
+ clogs.join();
|
|
//checkParsing();
|
|
//checkParsing();
|
|
System.out.println("round length: " + Analyzer.roundLength);
|
|
System.out.println("round length: " + Analyzer.roundLength);
|
|
|
|
|
|
//new ServerLogParser(serverLogPath).traceUser();
|
|
//new ServerLogParser(serverLogPath).traceUser();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private static void traceClientUserLink() throws InterruptedException, ExecutionException {
|
|
|
|
+ Analyzer privateInst = new Analyzer();
|
|
|
|
+ int roundNum = privateInst.intersectUsers(ClientLogParser.clients.get(intersectingClientID), 1, true);
|
|
|
|
+ System.out.println("roundNum: " + roundNum);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static void traceClientHashtagLink() throws ExecutionException, InterruptedException {
|
|
|
|
+ Analyzer privateInst = new Analyzer();
|
|
|
|
+ List<Map.Entry<String, Integer>> intersection = privateInst.intersectHashtags(ClientLogParser.clients.get(intersectingClientID), 1000, true);
|
|
|
|
+ Hashtag[] hashtags = new Hashtag[intersection.size()];
|
|
|
|
+ for(int i = 0; i < hashtags.length; i++)
|
|
|
|
+ hashtags[i] = ServerLogParser.hashtags.get(intersection.get(i).getKey());
|
|
|
|
+ System.out.println();
|
|
|
|
+ List<Map.Entry<Hashtag, Integer>> results = privateInst.calculatePointsGivenHashtags(ClientLogParser.clients.get(intersectingClientID), hashtags, 1, true);
|
|
|
|
+ System.out.println("Result size: " + results.size());
|
|
|
|
+ User targetUser = ServerLogParser.users.get(targetUserID);
|
|
|
|
+ System.out.println();
|
|
|
|
+ targetUser.getHashtags().forEach((k, v) -> System.out.println(k.getName()));
|
|
|
|
+ }
|
|
|
|
+
|
|
public void traceHashtag() throws InterruptedException, ExecutionException {
|
|
public void traceHashtag() throws InterruptedException, ExecutionException {
|
|
Hashtag staticTargetHashtag = ServerLogParser.hashtags.get(toTraceHashtag);
|
|
Hashtag staticTargetHashtag = ServerLogParser.hashtags.get(toTraceHashtag);
|
|
Client staticTargetClient = ClientLogParser.clients.get(intersectingClientID);
|
|
Client staticTargetClient = ClientLogParser.clients.get(intersectingClientID);
|
|
@@ -169,16 +196,7 @@ public class Analyzer {
|
|
sortedList.sort(((o1, o2) -> o2.getValue().compareTo(o1.getValue())));
|
|
sortedList.sort(((o1, o2) -> o2.getValue().compareTo(o1.getValue())));
|
|
long sortTime = System.currentTimeMillis() - startSortTime;
|
|
long sortTime = System.currentTimeMillis() - startSortTime;
|
|
|
|
|
|
- if(printOut) {
|
|
|
|
- System.out.println("Points for Client " + client.getId());
|
|
|
|
- System.out.println("Sorting time : " + sortTime + " ms");
|
|
|
|
- System.out.println("Client-ID\tPoints");
|
|
|
|
- int maxPrintOut = Math.min(20, sortedList.size());
|
|
|
|
- for(int i=0; i < maxPrintOut; i++) {
|
|
|
|
- Map.Entry<Hashtag, Integer> e = sortedList.get(i);
|
|
|
|
- System.out.println(e.getKey().getName() + "\t" + e.getValue());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
if(returnNum > 0) {
|
|
if(returnNum > 0) {
|
|
if(returnNum >= sortedList.size())
|
|
if(returnNum >= sortedList.size())
|
|
return sortedList;
|
|
return sortedList;
|
|
@@ -196,6 +214,15 @@ public class Analyzer {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if(printOut) {
|
|
|
|
+ System.out.println("Points for Client " + client.getId());
|
|
|
|
+ System.out.println("Sorting time : " + sortTime + " ms");
|
|
|
|
+ System.out.println("Client-ID\tPoints");
|
|
|
|
+ for(int i=0; i < returnList.size(); i++) {
|
|
|
|
+ Map.Entry<Hashtag, Integer> e = returnList.get(i);
|
|
|
|
+ System.out.println(e.getKey().getName() + "\t" + e.getValue());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
return returnList;
|
|
return returnList;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -231,12 +258,7 @@ public class Analyzer {
|
|
//results.entrySet().removeIf(e -> (e.getValue() < targetNoRound /2));
|
|
//results.entrySet().removeIf(e -> (e.getValue() < targetNoRound /2));
|
|
List<Map.Entry<String, Integer>> sortedList = new ArrayList<>(results.entrySet());
|
|
List<Map.Entry<String, Integer>> sortedList = new ArrayList<>(results.entrySet());
|
|
sortedList.sort(Map.Entry.comparingByValue((v1, v2) -> Integer.compare(v2, v1)));
|
|
sortedList.sort(Map.Entry.comparingByValue((v1, v2) -> Integer.compare(v2, v1)));
|
|
- if(printOut) {
|
|
|
|
- System.out.print(targetClient.getId() + ": ");
|
|
|
|
- System.out.println("no of rounds of " + targetClient.getId() + ": " + targetNoRounds);
|
|
|
|
- sortedList.forEach(e -> System.out.print(e.getKey() + "|" + e.getValue() + " "));
|
|
|
|
- System.out.println();
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
|
|
if(returnNum > 0) {
|
|
if(returnNum > 0) {
|
|
if(returnNum >= sortedList.size())
|
|
if(returnNum >= sortedList.size())
|
|
@@ -255,6 +277,15 @@ public class Analyzer {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if(printOut) {
|
|
|
|
+ System.out.print(targetClient.getId() + ": ");
|
|
|
|
+ System.out.println("no of rounds of " + targetClient.getId() + ": " + targetNoRounds);
|
|
|
|
+ for(int i = 0; i < returnList.size(); i++) {
|
|
|
|
+ System.out.print(returnList.get(i).getKey() + "|" + returnList.get(i).getValue() + " ");
|
|
|
|
+ }
|
|
|
|
+ //sortedList.forEach(e -> System.out.print(e.getKey() + "|" + e.getValue() + " "));
|
|
|
|
+ System.out.println();
|
|
|
|
+ }
|
|
return returnList;
|
|
return returnList;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -288,10 +319,12 @@ public class Analyzer {
|
|
roundProcessed = -1;
|
|
roundProcessed = -1;
|
|
}
|
|
}
|
|
if(printOut) {
|
|
if(printOut) {
|
|
- for(User u: userList)
|
|
|
|
- System.out.print(u.getId() + " ");
|
|
|
|
|
|
+ System.out.println("Suspect(s): ");
|
|
|
|
+ userList.forEach(e -> System.out.println(e.getId()));
|
|
|
|
+ System.out.println();
|
|
System.out.println("rounds processed: " + roundProcessed);
|
|
System.out.println("rounds processed: " + roundProcessed);
|
|
System.out.println();
|
|
System.out.println();
|
|
|
|
+ System.out.println();
|
|
}
|
|
}
|
|
return roundProcessed;
|
|
return roundProcessed;
|
|
}
|
|
}
|
|
@@ -300,11 +333,6 @@ public class Analyzer {
|
|
* This method checks the parsing processes, exits the JVM if there is an error.
|
|
* This method checks the parsing processes, exits the JVM if there is an error.
|
|
*/
|
|
*/
|
|
private static void checkParsing() {
|
|
private static void checkParsing() {
|
|
- if(ClientLogParser.clientLineCounter != ServerLogParser.serverLineCounter) {
|
|
|
|
- System.out.println("Parsing Error: Line numbers are not equals");
|
|
|
|
- System.exit(1);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
if(ClientLogParser.clientRoundNo != ServerLogParser.serverRoundNo) {
|
|
if(ClientLogParser.clientRoundNo != ServerLogParser.serverRoundNo) {
|
|
System.out.println("Parsing Error: Round numbers are not equals");
|
|
System.out.println("Parsing Error: Round numbers are not equals");
|
|
System.exit(1);
|
|
System.exit(1);
|