changed the files according to the new futureInterface.
parent
5c4b5a2150
commit
843d50c276
|
@ -1,36 +1,33 @@
|
||||||
package meerkat.bulletinboard.sqlserver;
|
package meerkat.bulletinboard.sqlserver;
|
||||||
|
|
||||||
import java.sql.*;
|
import com.google.protobuf.ByteString;
|
||||||
import java.util.*;
|
import com.google.protobuf.ProtocolStringList;
|
||||||
|
|
||||||
import com.google.protobuf.*;
|
|
||||||
|
|
||||||
import meerkat.bulletinboard.*;
|
import meerkat.bulletinboard.*;
|
||||||
import meerkat.bulletinboard.sqlserver.mappers.*;
|
import meerkat.bulletinboard.sqlserver.mappers.*;
|
||||||
import static meerkat.bulletinboard.BulletinBoardConstants.*;
|
|
||||||
|
|
||||||
import meerkat.comm.CommunicationException;
|
import meerkat.comm.CommunicationException;
|
||||||
|
|
||||||
import meerkat.comm.MessageOutputStream;
|
import meerkat.comm.MessageOutputStream;
|
||||||
import meerkat.crypto.concrete.ECDSASignature;
|
import meerkat.crypto.concrete.ECDSASignature;
|
||||||
import meerkat.crypto.concrete.SHA256Digest;
|
import meerkat.crypto.concrete.SHA256Digest;
|
||||||
|
|
||||||
import meerkat.protobuf.BulletinBoardAPI.*;
|
import meerkat.protobuf.BulletinBoardAPI.*;
|
||||||
import meerkat.protobuf.Crypto.Signature;
|
import meerkat.protobuf.Crypto.Signature;
|
||||||
import meerkat.protobuf.Crypto.SignatureVerificationKey;
|
import meerkat.protobuf.Crypto.SignatureVerificationKey;
|
||||||
|
|
||||||
|
|
||||||
import static meerkat.bulletinboard.sqlserver.BulletinBoardSQLServer.SQLQueryProvider.*;
|
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
|
||||||
|
|
||||||
import meerkat.util.BulletinBoardUtils;
|
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.MapSqlParameterSource;
|
||||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||||
import org.springframework.jdbc.support.GeneratedKeyHolder;
|
import org.springframework.jdbc.support.GeneratedKeyHolder;
|
||||||
import org.springframework.jdbc.support.KeyHolder;
|
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;
|
com.google.protobuf.Timestamp lastTimeOfSync = null;
|
||||||
|
|
||||||
TimestampComparator timestampComparator = new TimestampComparator();
|
TimeStampComparator timestampComparator = new TimeStampComparator();
|
||||||
|
|
||||||
long lastEntryNum = getLastMessageEntry();
|
long lastEntryNum = getLastMessageEntry();
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package meerkat.Registry;
|
package meerkat.Registry;
|
||||||
|
|
||||||
|
import com.google.common.util.concurrent.FutureCallback;
|
||||||
import meerkat.MessageValidator;
|
import meerkat.MessageValidator;
|
||||||
import meerkat.VoterRegistry;
|
import meerkat.VoterRegistry;
|
||||||
import meerkat.bulletinboard.BulletinBoardClient.ClientCallback;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: add logging
|
* TODO: add logging
|
||||||
|
@ -12,7 +12,7 @@ import meerkat.bulletinboard.BulletinBoardClient.ClientCallback;
|
||||||
* Created by Vladimir Eliezer Tokarev on 2/19/2016.
|
* 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)
|
* Handles the the after post state of VoterRegistry methods (that uses bulletinBoardClient to communicate with the server)
|
||||||
*/
|
*/
|
||||||
public class BooleanCallBack implements ClientCallback<Boolean>, MessageValidator<Boolean> {
|
public class BooleanCallBack implements FutureCallback<Boolean>, MessageValidator<Boolean> {
|
||||||
public VoterRegistry.RegistryCallBack callback;
|
public VoterRegistry.RegistryCallBack callback;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,11 +24,13 @@ public class BooleanCallBack implements ClientCallback<Boolean>, 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
|
* @param msg the message that the bulletinBoardClient passes to the callback
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void handleCallback(Boolean msg) {
|
public void onSuccess(Boolean msg) {
|
||||||
callback.HandleResult(msg);
|
callback.HandleResult(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +39,7 @@ public class BooleanCallBack implements ClientCallback<Boolean>, MessageValidato
|
||||||
* @param t the exception data that have been thrown during the failure of the post method
|
* @param t the exception data that have been thrown during the failure of the post method
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void handleFailure(Throwable t) {
|
public void onFailure(Throwable t) {
|
||||||
callback.HandleFailure(t);
|
callback.HandleFailure(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package meerkat.Registry;
|
package meerkat.Registry;
|
||||||
|
|
||||||
|
import com.google.common.util.concurrent.FutureCallback;
|
||||||
import com.google.protobuf.InvalidProtocolBufferException;
|
import com.google.protobuf.InvalidProtocolBufferException;
|
||||||
import meerkat.MessageValidator;
|
import meerkat.MessageValidator;
|
||||||
import meerkat.VoterRegistry.RegistryCallBack;
|
import meerkat.VoterRegistry.RegistryCallBack;
|
||||||
import meerkat.bulletinboard.BulletinBoardClient.ClientCallback;
|
|
||||||
import meerkat.crypto.DigitalSignature;
|
import meerkat.crypto.DigitalSignature;
|
||||||
import meerkat.protobuf.BulletinBoardAPI;
|
import meerkat.protobuf.BulletinBoardAPI;
|
||||||
import meerkat.protobuf.BulletinBoardAPI.BulletinBoardMessage;
|
import meerkat.protobuf.BulletinBoardAPI.BulletinBoardMessage;
|
||||||
|
@ -28,7 +28,7 @@ import static meerkat.Registry.CollectionMessagesUtils.*;
|
||||||
* Created by Vladimir Eliezer Tokarev on 2/19/2016.
|
* Created by Vladimir Eliezer Tokarev on 2/19/2016.
|
||||||
* Object that handles the GetGroups or the GetPersonIDDetails of the simpleRegistry
|
* Object that handles the GetGroups or the GetPersonIDDetails of the simpleRegistry
|
||||||
*/
|
*/
|
||||||
public class RelevantDataCallBack implements ClientCallback<List<BulletinBoardMessage>>, MessageValidator<List<BulletinBoardMessage>> {
|
public class RelevantDataCallBack implements FutureCallback<List<BulletinBoardMessage>>, MessageValidator<List<BulletinBoardMessage>> {
|
||||||
public RegistryCallBack callback;
|
public RegistryCallBack callback;
|
||||||
protected DigitalSignature validator;
|
protected DigitalSignature validator;
|
||||||
protected Crypto.Signature signature;
|
protected Crypto.Signature signature;
|
||||||
|
@ -75,7 +75,7 @@ public class RelevantDataCallBack implements ClientCallback<List<BulletinBoardMe
|
||||||
* @param msg List<BulletinBoardAPI.BulletinBoardMessage>
|
* @param msg List<BulletinBoardAPI.BulletinBoardMessage>
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void handleCallback(List<BulletinBoardMessage> msg) {
|
public void onSuccess(List<BulletinBoardMessage> msg) {
|
||||||
try {
|
try {
|
||||||
if(isAddToGroupsList(msg)) {
|
if(isAddToGroupsList(msg)) {
|
||||||
Map<String, BulletinBoardMessage> map = GetLatestGroupsActions(msg);
|
Map<String, BulletinBoardMessage> map = GetLatestGroupsActions(msg);
|
||||||
|
@ -96,7 +96,7 @@ public class RelevantDataCallBack implements ClientCallback<List<BulletinBoardMe
|
||||||
* @param t the exception data that have been thrown during the failure of the post method
|
* @param t the exception data that have been thrown during the failure of the post method
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void handleFailure(Throwable t) {
|
public void onFailure(Throwable t) {
|
||||||
callback.HandleFailure(t);
|
callback.HandleFailure(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
package meerkat;
|
package meerkat;
|
||||||
|
|
||||||
import meerkat.Registry.*;
|
import meerkat.Registry.BooleanCallBack;
|
||||||
import meerkat.bulletinboard.BulletinBoardClient;
|
import meerkat.Registry.CollectionMessagesUtils;
|
||||||
|
import meerkat.Registry.RegistryTags;
|
||||||
|
import meerkat.Registry.RelevantDataCallBack;
|
||||||
|
import meerkat.bulletinboard.AsyncBulletinBoardClient;
|
||||||
import meerkat.crypto.DigitalSignature;
|
import meerkat.crypto.DigitalSignature;
|
||||||
import meerkat.protobuf.BulletinBoardAPI.BulletinBoardMessage;
|
import meerkat.protobuf.BulletinBoardAPI.BulletinBoardMessage;
|
||||||
import meerkat.protobuf.BulletinBoardAPI.UnsignedBulletinBoardMessage;
|
import meerkat.protobuf.BulletinBoardAPI.UnsignedBulletinBoardMessage;
|
||||||
import meerkat.protobuf.Crypto;
|
import meerkat.protobuf.Crypto;
|
||||||
import meerkat.protobuf.VoterRegistry.GroupID;
|
import meerkat.protobuf.VoterRegistry.*;
|
||||||
import meerkat.protobuf.VoterRegistry.VoterGroup;
|
|
||||||
import meerkat.protobuf.VoterRegistry.VoterID;
|
|
||||||
import meerkat.protobuf.VoterRegistry.VoterInfo;
|
|
||||||
import meerkat.protobuf.VoterRegistry.VoterRegistryMessage;
|
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.security.SignatureException;
|
import java.security.SignatureException;
|
||||||
|
@ -28,12 +27,12 @@ import java.util.List;
|
||||||
public class SimpleRegistry implements VoterRegistry{
|
public class SimpleRegistry implements VoterRegistry{
|
||||||
|
|
||||||
protected DigitalSignature signer;
|
protected DigitalSignature signer;
|
||||||
protected BulletinBoardClient bulletinBoardClient ;
|
protected AsyncBulletinBoardClient bulletinBoardClient ;
|
||||||
protected Crypto.Signature signature;
|
protected Crypto.Signature signature;
|
||||||
protected InputStream certificateStream;
|
protected InputStream certificateStream;
|
||||||
|
|
||||||
public SimpleRegistry(DigitalSignature signer,
|
public SimpleRegistry(DigitalSignature signer,
|
||||||
BulletinBoardClient communicator,
|
AsyncBulletinBoardClient communicator,
|
||||||
InputStream certificateStream) {
|
InputStream certificateStream) {
|
||||||
this.signer = signer;
|
this.signer = signer;
|
||||||
this.bulletinBoardClient = communicator;
|
this.bulletinBoardClient = communicator;
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
|
import com.google.common.util.concurrent.FutureCallback;
|
||||||
import com.google.protobuf.InvalidProtocolBufferException;
|
import com.google.protobuf.InvalidProtocolBufferException;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
import meerkat.Registry.CollectionMessagesUtils;
|
import meerkat.Registry.CollectionMessagesUtils;
|
||||||
import meerkat.Registry.RegistryTags;
|
import meerkat.Registry.RegistryTags;
|
||||||
import meerkat.SimpleRegistry;
|
import meerkat.SimpleRegistry;
|
||||||
import meerkat.bulletinboard.BulletinBoardClient;
|
import meerkat.bulletinboard.AsyncBulletinBoardClient;
|
||||||
import meerkat.bulletinboard.ThreadedBulletinBoardClient;
|
import meerkat.bulletinboard.ThreadedBulletinBoardClient;
|
||||||
import meerkat.crypto.concrete.ECDSASignature;
|
import meerkat.crypto.concrete.ECDSASignature;
|
||||||
import meerkat.protobuf.BulletinBoardAPI.BulletinBoardMessage;
|
import meerkat.protobuf.BulletinBoardAPI.BulletinBoardMessage;
|
||||||
|
@ -35,7 +36,7 @@ import java.util.concurrent.Semaphore;
|
||||||
public class SimpleRegistryTest extends TestCase {
|
public class SimpleRegistryTest extends TestCase {
|
||||||
|
|
||||||
private ECDSASignature signer;
|
private ECDSASignature signer;
|
||||||
private BulletinBoardClient bulletinBoardClient;
|
private AsyncBulletinBoardClient bulletinBoardClient;
|
||||||
private InputStream certStream;
|
private InputStream certStream;
|
||||||
private SecureRandom random = new SecureRandom();
|
private SecureRandom random = new SecureRandom();
|
||||||
|
|
||||||
|
@ -65,18 +66,18 @@ public class SimpleRegistryTest extends TestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DummyBulletinBoardCallBackHandler implements BulletinBoardClient.ClientCallback<List<BulletinBoardMessage>> {
|
public class DummyBulletinBoardCallBackHandler implements FutureCallback<List<BulletinBoardMessage>> {
|
||||||
public List<BulletinBoardMessage> messages;
|
public List<BulletinBoardMessage> messages;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleCallback(List<BulletinBoardMessage> msg)
|
public void onSuccess(List<BulletinBoardMessage> msg)
|
||||||
{
|
{
|
||||||
messages = msg;
|
messages = msg;
|
||||||
jobSemaphore.release();
|
jobSemaphore.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleFailure(Throwable t){
|
public void onFailure(Throwable t){
|
||||||
messages = null;
|
messages = null;
|
||||||
jobSemaphore.release();
|
jobSemaphore.release();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue