working version of VoterRegistry with localBulletinBoardServer.

Voter-Registry
Vladimir Eliezer Tokarev 2016-04-15 04:11:54 -07:00
parent 630588ca5b
commit 47f68acae4
3 changed files with 8 additions and 3 deletions

View File

@ -1,5 +1,6 @@
include 'meerkat-common'
include 'voting-booth'
include 'voter-registry'
include 'bulletin-board-server'
include 'polling-station'
include 'restful-api-common'

View File

@ -13,6 +13,8 @@ import meerkat.registry.AsyncRegistryCallbacks.HasVotedCallback;
import meerkat.registry.MessageCollectionUtils;
import meerkat.registry.RegistryTags;
import meerkat.util.BulletinBoardUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.security.SignatureException;
@ -30,17 +32,21 @@ import static meerkat.util.BulletinBoardUtils.signBulletinBoardMessage;
*/
public class AsyncRegistry implements VoterRegistry{
final Logger logger = LoggerFactory.getLogger(getClass());
protected DigitalSignature signer;
protected SubscriptionAsyncBulletinBoardClient cachedBulletinBoardClient;
@Override
public void init(DigitalSignature signer, SubscriptionAsyncBulletinBoardClient communicator) {
logger.debug("Initialized the AsyncRegistry");
this.signer = signer;
this.cachedBulletinBoardClient = communicator;
}
@Override
public void addVoter(VoterInfo voterInfo, FutureCallback<Boolean> callback) throws SignatureException {
logger.info("Adding voter : {0}", RegistryTags.ID_TAG);
UnsignedBulletinBoardMessage basicMessage =
UnsignedBulletinBoardMessage.newBuilder()
.addTag(RegistryTags.ID_TAG + voterInfo.getId().getId())

View File

@ -2,7 +2,7 @@ import com.google.common.util.concurrent.FutureCallback;
import meerkat.AsyncRegistry;
import meerkat.bulletinboard.BulletinBoardServer;
import meerkat.bulletinboard.LocalBulletinBoardClient;
import meerkat.bulletinboard.sqlserver.BulletinBoardSQLServer;
import meerkat.bulletinboard.sqlserver.*;
import meerkat.comm.CommunicationException;
import meerkat.crypto.DigitalSignature;
@ -57,10 +57,8 @@ public class SimpleRegistryTest {
public static String CERT1_PEM_EXAMPLE = "/certs/enduser-certs/user1.crt";
public static String KEYFILE_PASSWORD = "secret";
private static final String DB_NAME = "TestDB";
private static final String LOCALHOST = "127.0.0.1:8000";
private static final int SUBSCRIPTION_DELAY = 3000;
private static final int THREAD_NUM = 3;
private static final int FAIL_DELAY = 6000;
class DummyRegistryCallBackHandler<T> implements FutureCallback<T>{
public int counter;