From 843d50c2762a6e2063461629c2f764a0c85fd6f9 Mon Sep 17 00:00:00 2001 From: Vladimir Eliezer Tokarev Date: Fri, 4 Mar 2016 05:36:48 -0800 Subject: [PATCH] changed the files according to the new futureInterface. --- .../sqlserver/BulletinBoardSQLServer.java | 31 +++++++++---------- .../meerkat/Registry/BooleanCallBack.java | 12 ++++--- .../Registry/RelevantDataCallBack.java | 8 ++--- .../src/main/java/meerkat/SimpleRegistry.java | 17 +++++----- .../src/test/java/SimpleRegistryTest.java | 11 ++++--- 5 files changed, 39 insertions(+), 40 deletions(-) diff --git a/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/BulletinBoardSQLServer.java b/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/BulletinBoardSQLServer.java index c7bcf57..679981a 100644 --- a/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/BulletinBoardSQLServer.java +++ b/bulletin-board-server/src/main/java/meerkat/bulletinboard/sqlserver/BulletinBoardSQLServer.java @@ -1,36 +1,33 @@ package meerkat.bulletinboard.sqlserver; -import java.sql.*; -import java.util.*; - -import com.google.protobuf.*; - +import com.google.protobuf.ByteString; +import com.google.protobuf.ProtocolStringList; import meerkat.bulletinboard.*; import meerkat.bulletinboard.sqlserver.mappers.*; -import static meerkat.bulletinboard.BulletinBoardConstants.*; - import meerkat.comm.CommunicationException; - import meerkat.comm.MessageOutputStream; import meerkat.crypto.concrete.ECDSASignature; import meerkat.crypto.concrete.SHA256Digest; - import meerkat.protobuf.BulletinBoardAPI.*; import meerkat.protobuf.Crypto.Signature; import meerkat.protobuf.Crypto.SignatureVerificationKey; - - -import static meerkat.bulletinboard.sqlserver.BulletinBoardSQLServer.SQLQueryProvider.*; - -import javax.sql.DataSource; - import meerkat.util.BulletinBoardUtils; -import meerkat.util.TimestampComparator; +import meerkat.util.TimeStampComparator; import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; import org.springframework.jdbc.support.GeneratedKeyHolder; import org.springframework.jdbc.support.KeyHolder; +import javax.sql.DataSource; +import java.sql.SQLException; +import java.sql.Types; +import java.util.*; + +import static meerkat.bulletinboard.BulletinBoardConstants.BATCH_ID_TAG_PREFIX; +import static meerkat.bulletinboard.BulletinBoardConstants.BATCH_TAG; +import static meerkat.bulletinboard.sqlserver.BulletinBoardSQLServer.SQLQueryProvider.FilterTypeParam; +import static meerkat.bulletinboard.sqlserver.BulletinBoardSQLServer.SQLQueryProvider.QueryType; + /** @@ -903,7 +900,7 @@ public class BulletinBoardSQLServer implements BulletinBoardServer{ com.google.protobuf.Timestamp lastTimeOfSync = null; - TimestampComparator timestampComparator = new TimestampComparator(); + TimeStampComparator timestampComparator = new TimeStampComparator(); long lastEntryNum = getLastMessageEntry(); diff --git a/voter-registry/src/main/java/meerkat/Registry/BooleanCallBack.java b/voter-registry/src/main/java/meerkat/Registry/BooleanCallBack.java index 073587c..7a41eba 100644 --- a/voter-registry/src/main/java/meerkat/Registry/BooleanCallBack.java +++ b/voter-registry/src/main/java/meerkat/Registry/BooleanCallBack.java @@ -1,8 +1,8 @@ package meerkat.Registry; +import com.google.common.util.concurrent.FutureCallback; import meerkat.MessageValidator; import meerkat.VoterRegistry; -import meerkat.bulletinboard.BulletinBoardClient.ClientCallback; /** * TODO: add logging @@ -12,7 +12,7 @@ import meerkat.bulletinboard.BulletinBoardClient.ClientCallback; * Created by Vladimir Eliezer Tokarev on 2/19/2016. * Handles the the after post state of VoterRegistry methods (that uses bulletinBoardClient to communicate with the server) */ -public class BooleanCallBack implements ClientCallback, MessageValidator { +public class BooleanCallBack implements FutureCallback, MessageValidator { public VoterRegistry.RegistryCallBack callback; /** @@ -24,11 +24,13 @@ public class BooleanCallBack implements ClientCallback, MessageValidato } /** - * Calls the callback HandleResult method with passed object from bulletinBoardClient + * Calls the callback HandleResult method with passed object from bulletinBoardClient when + * the action succeed + * * @param msg the message that the bulletinBoardClient passes to the callback */ @Override - public void handleCallback(Boolean msg) { + public void onSuccess(Boolean msg) { callback.HandleResult(msg); } @@ -37,7 +39,7 @@ public class BooleanCallBack implements ClientCallback, MessageValidato * @param t the exception data that have been thrown during the failure of the post method */ @Override - public void handleFailure(Throwable t) { + public void onFailure(Throwable t) { callback.HandleFailure(t); } diff --git a/voter-registry/src/main/java/meerkat/Registry/RelevantDataCallBack.java b/voter-registry/src/main/java/meerkat/Registry/RelevantDataCallBack.java index f6a662d..85e4c72 100644 --- a/voter-registry/src/main/java/meerkat/Registry/RelevantDataCallBack.java +++ b/voter-registry/src/main/java/meerkat/Registry/RelevantDataCallBack.java @@ -1,9 +1,9 @@ package meerkat.Registry; +import com.google.common.util.concurrent.FutureCallback; import com.google.protobuf.InvalidProtocolBufferException; import meerkat.MessageValidator; import meerkat.VoterRegistry.RegistryCallBack; -import meerkat.bulletinboard.BulletinBoardClient.ClientCallback; import meerkat.crypto.DigitalSignature; import meerkat.protobuf.BulletinBoardAPI; import meerkat.protobuf.BulletinBoardAPI.BulletinBoardMessage; @@ -28,7 +28,7 @@ import static meerkat.Registry.CollectionMessagesUtils.*; * Created by Vladimir Eliezer Tokarev on 2/19/2016. * Object that handles the GetGroups or the GetPersonIDDetails of the simpleRegistry */ -public class RelevantDataCallBack implements ClientCallback>, MessageValidator> { +public class RelevantDataCallBack implements FutureCallback>, MessageValidator> { public RegistryCallBack callback; protected DigitalSignature validator; protected Crypto.Signature signature; @@ -75,7 +75,7 @@ public class RelevantDataCallBack implements ClientCallback */ @Override - public void handleCallback(List msg) { + public void onSuccess(List msg) { try { if(isAddToGroupsList(msg)) { Map map = GetLatestGroupsActions(msg); @@ -96,7 +96,7 @@ public class RelevantDataCallBack implements ClientCallback> { + public class DummyBulletinBoardCallBackHandler implements FutureCallback> { public List messages; @Override - public void handleCallback(List msg) + public void onSuccess(List msg) { messages = msg; jobSemaphore.release(); } @Override - public void handleFailure(Throwable t){ + public void onFailure(Throwable t){ messages = null; jobSemaphore.release(); }