From: adash Date: Wed, 4 Nov 2009 00:07:05 +0000 (+0000) Subject: fix some compile bugs ...still some more to go X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=74dec57a5c86e91f178b68cd63fdbadefc7b6fa1;p=IRC.git fix some compile bugs ...still some more to go need a Global string to create a new hash entry for an each email and then compare it with the global entry in the distributed hash map --- diff --git a/Robust/src/Benchmarks/Distributed/SpamFilter/DistributedHashMap.java b/Robust/src/Benchmarks/Distributed/SpamFilter/DistributedHashMap.java index 5b785723..93ffe3a9 100644 --- a/Robust/src/Benchmarks/Distributed/SpamFilter/DistributedHashMap.java +++ b/Robust/src/Benchmarks/Distributed/SpamFilter/DistributedHashMap.java @@ -19,10 +19,6 @@ public class DistributedHashMap { return value; } - public DistributedHashMapIterator iterator(int type) { - return new DistributedHashMapIterator(this, type); - } - Object remove(Object key) { int hashcode=key.hashCode(); int index1=hash1(hashcode, table.length); diff --git a/Robust/src/Benchmarks/Distributed/SpamFilter/EphemeralSignature.java b/Robust/src/Benchmarks/Distributed/SpamFilter/EphemeralSignature.java index b5a80a5a..f938aac9 100644 --- a/Robust/src/Benchmarks/Distributed/SpamFilter/EphemeralSignature.java +++ b/Robust/src/Benchmarks/Distributed/SpamFilter/EphemeralSignature.java @@ -30,10 +30,6 @@ public class EphemeralSignature { return signature; } - private String computeHexDigest(String body) { - return - } - /* public long DEKHash(String str) { diff --git a/Robust/src/Benchmarks/Distributed/SpamFilter/FilterResult.java b/Robust/src/Benchmarks/Distributed/SpamFilter/FilterResult.java index 2a8a2bf2..2eab89cc 100644 --- a/Robust/src/Benchmarks/Distributed/SpamFilter/FilterResult.java +++ b/Robust/src/Benchmarks/Distributed/SpamFilter/FilterResult.java @@ -37,7 +37,7 @@ public class FilterResult { public boolean getResult(int[] confidenceVals) { int[] res = new int[3]; - for(int i=0; i= 0 && confidenceVals[i] < 500) @@ -60,7 +60,7 @@ public class FilterResult { if(max==2) return true; - System.out.println("Err: getResult() Shouldn't come here\n"); + System.out.println("Err: getResult() Control shouldn't come here\n"); return false; } diff --git a/Robust/src/Benchmarks/Distributed/SpamFilter/Mail.java b/Robust/src/Benchmarks/Distributed/SpamFilter/Mail.java index e14633e7..41cb3cda 100644 --- a/Robust/src/Benchmarks/Distributed/SpamFilter/Mail.java +++ b/Robust/src/Benchmarks/Distributed/SpamFilter/Mail.java @@ -11,7 +11,7 @@ public class Mail { String cc; String subject; String body; - String noURLBody; + String noURLBody; String sourceCode; boolean hasAttachement; String encoding; //rich text, plain, html @@ -343,6 +343,22 @@ public class Mail { return isSpam; } + /** + * Returns result to the Spam filter + **/ + public Vector checkMail(int userid) { + //Preprocess emails + //Vector partsOfMailStrings = mail.createMailStringsWithURL(); + Vector partsOfMailStrings = getCommonPart(); + partsOfMailStrings.addElement(getBodyString()); + + //Compute signatures + SignatureComputer sigComp = new SignatureComputer(); + Vector signatures = sigComp.computeSigs(partsOfMailStrings);//vector of strings + + return signatures; + } + /* For tests only */ /* public static void main(String[] args) diff --git a/Robust/src/Benchmarks/Distributed/SpamFilter/SignatureComputer.java b/Robust/src/Benchmarks/Distributed/SpamFilter/SignatureComputer.java index ab9caae8..1986d080 100644 --- a/Robust/src/Benchmarks/Distributed/SpamFilter/SignatureComputer.java +++ b/Robust/src/Benchmarks/Distributed/SpamFilter/SignatureComputer.java @@ -95,26 +95,11 @@ public class SignatureComputer { System.out.println("Couldn't find the signature engine\n"); } - /* - switch (engineNo) { - case 4: - sig = computeSignature(engineNo,mail); - break; - case 8: - sig = computeSignature(engineNo,mail); - break; - default: - System.out.println("Couldn't find the signature engine\n"); - //sig = computeSignature(engineNo,curPart.getCleaned()); - break; - }//switch engineNo - */ - - if (sig != null && sig.length() > 0) { + if (sig != null) { String hash = engineNo + ":" + sig; printableSigs.addElement(hash); } else { - /* we didn't produce a signature for the mail. */ + // we didn't produce a signature for the mail. } }//engine }//each emails part @@ -128,29 +113,19 @@ public class SignatureComputer { */ private String computeSignature(int engineNo, String mail) { if(engineNo==4) { - String s1 = this.sig4.computeSignature(mail); + //String s1 = this.sig4.computeSignature(mail); + return this.sig4.computeSignature(mail); //return new String { this.sig4.computeSignature(mail) }; } + /* if(engineNo==8) { //String cleanedButKeepHTML = Preprocessor.preprocess(mail,Preprocessor.ConfigParams.NO_DEHTML); //return this.sig8.computeSignature(cleanedButKeepHTML); return this.sig8.computeSignature(mail); } + */ return null; - - /* - switch (engineNo) { - case 4: - return new String { this.sig4.computeSignature(mail) }; - case 8: - //TODO device and equivalent for this - //String cleanedButKeepHTML = Preprocessor.preprocess(mail,Preprocessor.ConfigParams.NO_DEHTML); - return this.sig8.computeSignature(cleanedButKeepHTML); - default: - return null; - } - */ } } diff --git a/Robust/src/Benchmarks/Distributed/SpamFilter/SpamFilter.java b/Robust/src/Benchmarks/Distributed/SpamFilter/SpamFilter.java index 1002c811..60d5c50a 100644 --- a/Robust/src/Benchmarks/Distributed/SpamFilter/SpamFilter.java +++ b/Robust/src/Benchmarks/Distributed/SpamFilter/SpamFilter.java @@ -1,8 +1,18 @@ public class SpamFilter extends Thread { DistributedHashMap mydhmap; + int id; //thread id + + /** + * Total number of iterations + **/ int numiter; + + /** + * Total number of emails + **/ int numemail; + /** * Total number of threads **/ @@ -12,10 +22,12 @@ public class SpamFilter extends Thread { } - public SpamFilter(int numiter, int numemail,int id) { + public SpamFilter(int numiter, int numemail,int id, DistributedHashMap mydhmap, int nthreads) { this.numiter=numiter; this.numemail=numemail; this.id = id; + this.mydhmap = mydhmap; + this.nthreads = nthreads; } public void run() { @@ -35,17 +47,28 @@ public class SpamFilter extends Thread { int pickemail = rand.nextInt(100); Mail email = new Mail("emails/email"+pickemail); //Mail email = getEmail(pickemail); - boolean filterAnswer = checkMail(email, thid); + Vector signatures = email.checkMail(thid); + //check with global data structure + int[] confidenceVals=null; + atomic { + confidenceVals = check(signatures,thid); + } + + //---- create and return results -------- + FilterResult filterResult = new FilterResult(); + boolean filterAnswer = filterResult.getResult(confidenceVals); + boolean userAnswer = email.getIsSpam(); if(filterAnswer != userAnswer) { - sendFeedBack(email, userAnswer); + atomic { + sendFeedBack(email, userAnswer, thid); + } } - } - } + } //end num emails + }//end num iter } public static void main(String[] args) { - int nthreads; int[] mid = new int[8]; mid[0] = (128<<24)|(195<<16)|(136<<8)|162; //dc-1.calit2 mid[1] = (128<<24)|(195<<16)|(136<<8)|163; //dc-2.calit2 @@ -56,18 +79,17 @@ public class SpamFilter extends Thread { mid[6] = (128<<24)|(195<<16)|(136<<8)|168; //dc-7.calit2 mid[7] = (128<<24)|(195<<16)|(136<<8)|169; //dc-8.calit2 - - - //Read options from command prompt + //Read options from command prompt SpamFilter sf = new SpamFilter(); SpamFilter.parseCmdLine(args, sf); + int nthreads = sf.nthreads; Random rand = new Random(8); //Randomly set Spam vals for each email for(int i=0; i