From 87420a9d7d83541d785c435aa72bd126f5709243 Mon Sep 17 00:00:00 2001 From: Vladimir Eliezer Tokarev Date: Sat, 27 Feb 2016 03:46:36 -0800 Subject: [PATCH] Removed the voterRegistryMessage and swaped the usage of it to BulletinBoardMessage --- bulletin-board-server/meerkat | Bin 169984 -> 192512 bytes .../main/java/meerkat/MessageValidator.java | 2 +- .../meerkat/Registry/BooleanCallBack.java | 6 +- .../Registry/CollectionMessagesUtils.java | 82 +++++++++++++----- .../Registry/RelevantDataCallBack.java | 15 ++-- .../src/main/java/meerkat/VoterRegistry.java | 2 + .../java/meerkat/VoterRegistryMessage.java | 59 ------------- .../src/test/java/SimpleRegistryTest.java | 29 ++++--- 8 files changed, 85 insertions(+), 110 deletions(-) delete mode 100644 voter-registry/src/main/java/meerkat/VoterRegistryMessage.java diff --git a/bulletin-board-server/meerkat b/bulletin-board-server/meerkat index 46153c6d3581fe83d79e36439e604adaa177c801..af8adb63c3abc4204ceee67f8dc111152f562137 100644 GIT binary patch delta 21425 zcma)E2V4}#_urjG4zQhw4N*A})Tns9pr9xU7O*8&EZ2K4w&;l-r>L=AbZxODu|yNQ zVnMO@-XiwiORUk@{g1@lA z@%VB*;7>)MRRn!$<3NToF_2%rDc*)$6^_%ge43f&!Ds<7e^2atk5!AXosQDzJmoV687*g|X{_6VfXY%_6nIV4B{B#@K$u%UiK+!y^FMZ0-k(SAH9h#?h-)#b1D0APuNM0ayu6gEy#Lh$#W_AP$}gEBo}opz?`<$AgOKhp2aG ze!&{z*3X(wT{3ScezWmyab(q_mxdiW-?YJl`yGsXv2%fC^69i_{VS$BtsBl<`SPv3 z{BGU#Nw0cWn=zdhJ}oQ;d|Ts#k70xQ5XP@}X0oP-si4$+p-6O)Pc#0B{OJaGZm zGkFOf8%C8c`9nI051dmrfK9b1kT$4xz;Yw9Njh~(y7ge>)%N#_!z7LOr+>`6J2SV| za_)|Pf$29+-gWl{-09tTV$R|i@#Y5! zu{}?&Shgl_$tvt>VAWp7H`G;~3+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QQ%Nw2Cyl`~6OcEbla{~P56ddfgXSIL4>uKN;$yf9cZn361QRS_xM9Bn z%RzT$jq`A;|5&seq0MmFOUr`Jiv7!RNfb zuog!TAm{bOZbq-);j6H|U7(ASE>DJMVYBGO5x9ySMa(ARGq?#W@gn(BPa042sEj_L zZz+-Pr@6$mhwlp!nikB*F8s**xW$9DnJa~R7{@=phh@fzt=JP|QM&F2ubR_xu^?y! zE|l4EmO6{HAEosop0CmZXmZ5{%mH)it>xDvFohrPi#DSv0vmzXjzkN>Z+tWglY{ZP z@`W4b@!&xmg2e*LO?a3>44WNyOLe2~g*5&1mN;|1z929{-j)s#Jh&_7d1biOAvefW ziaL2eo{u@OyI0&Dx7F<~c0UjN)+Eg~BcmHu`f6$LoZ`rGfm?AoIs)A-*`kzZ+8>at zj`HeW_>I^5at@enR6B7lwv#V(647JdN{sgZ6IE)C8p&x(Fq;!fq%{xp#(l8dJ>HE^ zQiNSjlO@5bOsVtIUZ*M(g;)e{!C|!znlTXjVXlmsZFmB2Q3MU98SJcuaK3dEW3^}+ zg}iezMrjxvLwq6)om@RvdM_W!O~XapxgUnJEgc`>*V56(4e7$IIT09Z^gD_*@UC_r z+Cu!`hQcgiV<~%r&^m`o*f{~?3}-3q0G==b{rKS17-ob{!pnYftz-PpQ-V3Y zrs3VE1UVg0xgi?i5B$t27{hu4%+xPfTSradVwnV6>Tt9XQjbr8w^@Y|>a^l}gV}#J+J@D@OuXjlU5y~Lxy?+(s~+=nS#YJ*#00$DX2xTa$2@}f;w9cT3vFJ9 zu?POZE5r<_mJOcsET|UTf6r6ITTq43c*f(cl7q&#t)?L5bep#;HhRoMB5Vz9rXA~B zO<7yl=8eKr9yRoRPT(4?>8Q)+_pjuF&^%N<^fR_Rvn+LhFspMm&Zr XDeU6)Iu=-fW+ * @param object object which will be checked * @return T object */ - T validate(T object) throws ValidationError ; + T validate(T object) throws ValidationError; class ValidationError extends Exception { public ValidationError(String message) { diff --git a/voter-registry/src/main/java/meerkat/Registry/BooleanCallBack.java b/voter-registry/src/main/java/meerkat/Registry/BooleanCallBack.java index 680a652..073587c 100644 --- a/voter-registry/src/main/java/meerkat/Registry/BooleanCallBack.java +++ b/voter-registry/src/main/java/meerkat/Registry/BooleanCallBack.java @@ -38,13 +38,13 @@ public class BooleanCallBack implements ClientCallback, MessageValidato */ @Override public void handleFailure(Throwable t) { - callback.HandleResult(false); + callback.HandleFailure(t); } /** - * always return true because there no need to check boolean + * always return true because there no n * @param object object which will be checked - * @return + * @return alwyas true * @throws ValidationError */ @Override diff --git a/voter-registry/src/main/java/meerkat/Registry/CollectionMessagesUtils.java b/voter-registry/src/main/java/meerkat/Registry/CollectionMessagesUtils.java index c44f009..385df42 100644 --- a/voter-registry/src/main/java/meerkat/Registry/CollectionMessagesUtils.java +++ b/voter-registry/src/main/java/meerkat/Registry/CollectionMessagesUtils.java @@ -1,11 +1,8 @@ package meerkat.Registry; import com.google.protobuf.InvalidProtocolBufferException; -import meerkat.VoterRegistryMessage; -import meerkat.protobuf.BulletinBoardAPI.BulletinBoardMessage; -import meerkat.protobuf.BulletinBoardAPI.FilterType; -import meerkat.protobuf.BulletinBoardAPI.MessageFilter; -import meerkat.protobuf.BulletinBoardAPI.MessageFilterList; +import meerkat.protobuf.BulletinBoardAPI.*; +import meerkat.protobuf.VoterRegistry; import java.text.ParseException; import java.util.*; @@ -31,33 +28,54 @@ public abstract class CollectionMessagesUtils { * @param messages list * @return List */ - public static List ConvertToVoterRegistryMessages(List messages){ - List voterMessages = new ArrayList<>(); + public static List ConvertToVoterRegistryMessages(List messages){ + List voterMessages = new ArrayList<>(); for (int i = 0 ; i < messages.size() ; i++) { - voterMessages.add(new VoterRegistryMessage(messages.get(i))); + voterMessages.add(messages.get(i).getMsg()); } return voterMessages; } + /** + * Return true if message1 was created before message 2 + * @param message1 BulletinBoardMessage object + * @param message2 BulletinBoardMessage object + * @return boolean + * @throws InvalidProtocolBufferException + */ + private static boolean FirstBeforeSecond(BulletinBoardMessage message1, BulletinBoardMessage message2) + throws InvalidProtocolBufferException { + try { + long firstCreationTime = VoterRegistry.VoterRegistryMessage.newBuilder() + .mergeFrom(message1.getMsg().getData()).build().getCreationMiliseconds(); + long secondCreationTime = VoterRegistry.VoterRegistryMessage.newBuilder() + .mergeFrom(message2.getMsg().getData()).build().getCreationMiliseconds(); + return firstCreationTime < secondCreationTime; + } catch (InvalidProtocolBufferException e) { + e.printStackTrace(); + throw e; + } + } + /** * Gets map of GroupId to basicMessage, where the basicMessages are the last actions for those groups * @param messages List * @return Map{String:VoterRegistryMessage} * @throws ParseException */ - public static Map GetLatestGroupsActions(List messages) + public static Map GetLatestGroupsActions(List messages) throws ParseException, InvalidProtocolBufferException { - Map groupIdToMessage = new HashMap<>(); + Map groupIdToMessage = new HashMap<>(messages.size()); // iterate trough all the messages and put into the map the last updated groups actions for (int i = 0 ; i < messages.size() ; i++) { - VoterRegistryMessage message = messages.get(i); - String groupId = message.GetWantedTagFromBasicMessage(RegistryTags.GROUP_ID_TAG); - VoterRegistryMessage temp = groupIdToMessage.get(groupId); + BulletinBoardMessage message = messages.get(i); + String groupId = GetTagByName(message.getMsg().getTagList(), RegistryTags.GROUP_ID_TAG); + BulletinBoardMessage temp = groupIdToMessage.get(groupId); if (temp != null && temp != message) { - if (temp.GetCreationTime() < message.GetCreationTime()) { + if (FirstBeforeSecond(temp, message)) { groupIdToMessage.put(groupId, message); } } @@ -71,13 +89,14 @@ public abstract class CollectionMessagesUtils { * @param groupIdToMessage Map * @return List */ - public static List GetListOfGroupIds(Map groupIdToMessage) { - List groupsIds = new ArrayList<>(); + public static List GetListOfGroupIds(Map groupIdToMessage) { + List groupsIds = new ArrayList<>(groupIdToMessage.size()); Iterator entries = groupIdToMessage.entrySet().iterator(); while (entries.hasNext()) { Map.Entry tuple = (Map.Entry) entries.next(); - VoterRegistryMessage message = (VoterRegistryMessage) tuple.getValue(); - String groupId = message.GetWantedTagFromBasicMessage(RegistryTags.GROUP_ID_TAG); + BulletinBoardMessage message = (BulletinBoardMessage) tuple.getValue(); + String groupId = GetTagByName(message.getMsg().getTagList(), RegistryTags.GROUP_ID_TAG); + groupId.replace(RegistryTags.GROUP_ID_TAG, ""); groupsIds.add(groupId); } return groupsIds; @@ -90,22 +109,39 @@ public abstract class CollectionMessagesUtils { * @throws ParseException * @throws EmptyListException */ - public static VoterRegistryMessage GetLatestMessage(List messages) + public static BulletinBoardMessage GetLatestMessage(List messages) throws ParseException, EmptyListException, InvalidProtocolBufferException { - System.out.print("1"); if (messages.size() == 0 ){ throw new EmptyListException("The list of messages passed to GetLatestMessage is empty."); } - VoterRegistryMessage LatestMessage = messages.get(0); + BulletinBoardMessage LatestMessage = messages.get(0); for (int i = 0 ; i < messages.size() ; i++) { - VoterRegistryMessage message = messages.get(i); - if (message.GetCreationTime() < LatestMessage.GetCreationTime()) { + BulletinBoardMessage message = messages.get(i); + if (FirstBeforeSecond(message, LatestMessage)) { LatestMessage = message; } } return LatestMessage; } + /** + * Gets the wanted tag from given basic message + * + * @param content the name of the tag + * @param tags the list of tags + * @return string + */ + public static String GetTagByName(List tags, String content) { + for (int i = 0 ; i < tags.size() ; i++) { + String tag = tags.get(i); + if (tag.startsWith(content) || tag.endsWith(content)) { + return tag; + } + } + return null; + } + + /** * Gets messages that have the wanted id tag and have or the ADD_TO_GROUP_TAG or REMOVE_FROM_GROUP_TAG * diff --git a/voter-registry/src/main/java/meerkat/Registry/RelevantDataCallBack.java b/voter-registry/src/main/java/meerkat/Registry/RelevantDataCallBack.java index 9eabb1b..f6a662d 100644 --- a/voter-registry/src/main/java/meerkat/Registry/RelevantDataCallBack.java +++ b/voter-registry/src/main/java/meerkat/Registry/RelevantDataCallBack.java @@ -3,7 +3,6 @@ package meerkat.Registry; import com.google.protobuf.InvalidProtocolBufferException; import meerkat.MessageValidator; import meerkat.VoterRegistry.RegistryCallBack; -import meerkat.VoterRegistryMessage; import meerkat.bulletinboard.BulletinBoardClient.ClientCallback; import meerkat.crypto.DigitalSignature; import meerkat.protobuf.BulletinBoardAPI; @@ -35,7 +34,6 @@ public class RelevantDataCallBack implements ClientCallback msg) { try { - List messages = ConvertToVoterRegistryMessages(validate(msg)); - if(isAddToGroupsList(msg)) { - Map map = GetLatestGroupsActions(messages); + Map map = GetLatestGroupsActions(msg); List groupsOfUser = GetListOfGroupIds(map); callback.HandleResult(groupsOfUser); } else { - callback.HandleResult(GetLatestMessage(messages)); + callback.HandleResult(GetLatestMessage(msg)); } - } catch (ValidationError | ParseException | EmptyListException - | InvalidProtocolBufferException validationError) { - callback.HandleResult(null); + } catch (ParseException | EmptyListException | InvalidProtocolBufferException validationError) { + callback.HandleFailure(validationError); validationError.printStackTrace(); } } @@ -102,7 +97,7 @@ public class RelevantDataCallBack implements ClientCallback { void HandleResult(T result); + void HandleFailure(Throwable throwable); } /** diff --git a/voter-registry/src/main/java/meerkat/VoterRegistryMessage.java b/voter-registry/src/main/java/meerkat/VoterRegistryMessage.java deleted file mode 100644 index d232b8e..0000000 --- a/voter-registry/src/main/java/meerkat/VoterRegistryMessage.java +++ /dev/null @@ -1,59 +0,0 @@ -package meerkat; - -import com.google.protobuf.InvalidProtocolBufferException; -import meerkat.protobuf.BulletinBoardAPI.BulletinBoardMessage; -import meerkat.protobuf.BulletinBoardAPI.UnsignedBulletinBoardMessage; -import meerkat.protobuf.VoterRegistry; - -import java.util.List; - - -/** - * TODO: add logging - */ - -/** - * Created by Vladimir Eliezer Tokarev on 1/15.2016 - * this class wraps BasicMessage and gives the ability to find wanted tags - */ -public class VoterRegistryMessage { - - public UnsignedBulletinBoardMessage base; - - public VoterRegistryMessage(BulletinBoardMessage message) { - UnsignedBulletinBoardMessage.Builder unsignedBase = - UnsignedBulletinBoardMessage.newBuilder().addAllTag(message.getMsg().getTagList()); - unsignedBase.setData(message.getMsg().getData()); - base = unsignedBase.build(); - } - - /** - * Gets the wanted tag from given basic message - * - * @param tagName the name of the tag - * @return string - */ - public String GetWantedTagFromBasicMessage(String tagName) { - List tags = base.getTagList(); - for (int i = 0 ; i < tags.size() ; i++) { - String tag = tags.get(i); - if (tag.contains(tagName)) { - return tag; - } - } - return null; - } - - /** - * Gets the creation time milliseconds of the tag adding - * @return long that represent the creation time - */ - public long GetCreationTime() throws InvalidProtocolBufferException { - try { - VoterRegistry.VoterRegistryMessage wrapper = VoterRegistry.VoterRegistryMessage.parseFrom(base.getData()); - return wrapper.getCreationMiliseconds(); - } catch (InvalidProtocolBufferException e) { - throw e; - } - } -} diff --git a/voter-registry/src/test/java/SimpleRegistryTest.java b/voter-registry/src/test/java/SimpleRegistryTest.java index 69c3dc2..4a0e2d6 100644 --- a/voter-registry/src/test/java/SimpleRegistryTest.java +++ b/voter-registry/src/test/java/SimpleRegistryTest.java @@ -3,7 +3,6 @@ import junit.framework.TestCase; import meerkat.Registry.CollectionMessagesUtils; import meerkat.Registry.RegistryTags; import meerkat.SimpleRegistry; -import meerkat.VoterRegistryMessage; import meerkat.bulletinboard.BulletinBoardClient; import meerkat.bulletinboard.ThreadedBulletinBoardClient; import meerkat.crypto.concrete.ECDSASignature; @@ -23,8 +22,6 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.Semaphore; -import static meerkat.Registry.CollectionMessagesUtils.ConvertToVoterRegistryMessages; - /** * TODO: add logs prints for the tests to be clear what they are */ @@ -62,6 +59,10 @@ public class SimpleRegistryTest extends TestCase { data = result; jobSemaphore.release(); } + + @Override + public void HandleFailure(Throwable throwable) { + } } public class DummyBulletinBoardCallBackHandler implements BulletinBoardClient.ClientCallback> { @@ -76,7 +77,6 @@ public class SimpleRegistryTest extends TestCase { @Override public void handleFailure(Throwable t){ - System.out.println(t); messages = null; jobSemaphore.release(); } @@ -139,17 +139,17 @@ public class SimpleRegistryTest extends TestCase { * @param tags List * @return integer that represent the amount of messages with wanted tags */ - private int countMessagesWithTags(List messages, List tags) + private int countMessagesWithTags(List messages, List tags) { int counter = 0 ; for (int i = 0 ; i < messages.size() ; i++) { - VoterRegistryMessage message = messages.get(i); + BulletinBoardMessage message = messages.get(i); int wantedTagsCounter = 0; for (int j = 0 ;j < tags.size() ; j++) { String tag = tags.get(j); - if(message.GetWantedTagFromBasicMessage(tag)!=null){ + if(CollectionMessagesUtils.GetTagByName(message.getMsg().getTagList(), tag)!=null){ wantedTagsCounter++; } } @@ -187,7 +187,7 @@ public class SimpleRegistryTest extends TestCase { tags.add(id); - int counter = countMessagesWithTags(ConvertToVoterRegistryMessages(bulletinHandler.messages), tags); + int counter = countMessagesWithTags(bulletinHandler.messages, tags); assert counter == 1 : "The server don't have the new user data."; } @@ -214,7 +214,7 @@ public class SimpleRegistryTest extends TestCase { jobSemaphore.acquire(); tags.add(id); - int counter = countMessagesWithTags(ConvertToVoterRegistryMessages(bulletinHandler.messages), tags); + int counter = countMessagesWithTags(bulletinHandler.messages, tags); assert counter == 1 : "The server don't have the new user id."; } @@ -246,7 +246,7 @@ public class SimpleRegistryTest extends TestCase { tags.add(voterId); tags.add(groupId); - int counter = countMessagesWithTags(ConvertToVoterRegistryMessages(bulletinHandler.messages), tags); + int counter = countMessagesWithTags(bulletinHandler.messages, tags); assert counter == 1 : "The server don't have the new user added to group."; } @@ -298,13 +298,14 @@ public class SimpleRegistryTest extends TestCase { jobSemaphore.acquire(); assertEquals(1, handler.counter ); - DummyRegistryCallBackHandler personalHandler = new DummyRegistryCallBackHandler<>(); + DummyRegistryCallBackHandler personalHandler = new DummyRegistryCallBackHandler<>(); registry.GetPersonIDDetails(VoterID.newBuilder().setId(id).build(), personalHandler); jobSemaphore.acquire(1); - assertEquals(RegistryTags.ID_TAG + id, - personalHandler.data.GetWantedTagFromBasicMessage(RegistryTags.ID_TAG)); - assertTrue(personalHandler.data.GetWantedTagFromBasicMessage(RegistryTags.VOTER_DATA_TAG).contains(data)); + assertEquals(RegistryTags.ID_TAG + id, CollectionMessagesUtils.GetTagByName(personalHandler + .data.getMsg().getTagList(), RegistryTags.ID_TAG)); + assertTrue(CollectionMessagesUtils.GetTagByName(personalHandler.data.getMsg().getTagList(), + RegistryTags.VOTER_DATA_TAG).contains(data)); } }