├── settings.gradle
├── lib
├── core-0.1.4.jar
└── BenchmarkExecutor.jar
├── config
├── java.security
├── keysECDSA
│ ├── privatekey1
│ ├── privatekey2
│ ├── publickey0
│ ├── publickey1
│ ├── publickey2
│ ├── publickey3
│ ├── publickey1001
│ ├── privatekey0
│ ├── privatekey3
│ └── privatekey1001
├── keysSunEC
│ ├── privatekey0
│ ├── privatekey1
│ ├── privatekey1001
│ ├── privatekey2
│ ├── privatekey3
│ ├── publickey0
│ ├── publickey1
│ ├── publickey2
│ ├── publickey3
│ └── publickey1001
├── keysSSL_TLS
│ ├── EC_KeyPair_256.pkcs12
│ ├── EC_KeyPair_384.pkcs12
│ ├── RSA_KeyPair_1024.pkcs12
│ └── RSA_KeyPair_2048.pkcs12
├── keysRSA
│ ├── publickey
│ ├── publickey0
│ ├── publickey1
│ ├── publickey1001
│ ├── publickey2
│ ├── publickey3
│ ├── privatekey
│ ├── privatekey0
│ ├── privatekey1
│ ├── privatekey2
│ ├── privatekey3
│ └── privatekey1001
├── benchmark.config
├── hosts.config
├── logback.xml
└── workloads
│ └── workloada
├── docs
└── javadoc
│ ├── resources
│ ├── x.png
│ └── glass.png
│ ├── type-search-index.zip
│ ├── member-search-index.zip
│ ├── package-search-index.zip
│ ├── jquery-ui.overrides.css
│ ├── overview-summary.html
│ ├── element-list
│ ├── package-search-index.js
│ └── jquery
│ ├── jszip-utils
│ └── dist
│ │ ├── jszip-utils-ie.min.js
│ │ ├── jszip-utils.min.js
│ │ └── jszip-utils-ie.js
│ └── jquery-ui.min.css
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── runscripts
├── smartrun.cmd
├── generate-javadoc.sh
├── smartrun.sh
├── startReplicaYCSB.sh
├── ycsbClient.sh
└── ycsb.sh
├── src
└── main
│ └── java
│ └── bftsmart
│ ├── demo
│ ├── map
│ │ ├── MapRequestType.java
│ │ └── MapInteractiveClient.java
│ ├── ycsb
│ │ └── YCSBTable.java
│ └── counter
│ │ └── CounterClient.java
│ ├── tests
│ ├── util
│ │ ├── Operation.java
│ │ ├── ErrorPrinter.java
│ │ └── ProcessExecutor.java
│ ├── normal
│ │ ├── AsynchronousNormalTest.java
│ │ ├── SynchronousNormalTest.java
│ │ ├── SynchronousRequestClient.java
│ │ ├── AbstractNormalTest.java
│ │ └── AsyncRequestClient.java
│ ├── recovery
│ │ ├── RecoveryEventProcessor.java
│ │ ├── RecoveryTest.java
│ │ ├── RecoveryTestClient.java
│ │ └── RecoveryTestServer.java
│ ├── common
│ │ ├── SimpleServiceEventProcessor.java
│ │ └── SimpleServiceServer.java
│ └── AbstractIntegrationTest.java
│ ├── benchmark
│ ├── Measurement.java
│ ├── ThroughputEventProcessor.java
│ ├── ThroughputLatencyServer.java
│ └── ThroughputLatencyClient.java
│ ├── reconfiguration
│ ├── views
│ │ ├── ViewStorage.java
│ │ ├── TestViewSerialization.java
│ │ ├── DefaultViewStorage.java
│ │ └── View.java
│ ├── util
│ │ └── DefaultVMServices.java
│ ├── VMMessage.java
│ ├── ReconfigurationTest.java
│ ├── View.java
│ ├── VMServices.java
│ ├── ClientViewController.java
│ ├── Reconfiguration.java
│ ├── ReconfigureReply.java
│ ├── ViewController.java
│ └── ReconfigureRequest.java
│ ├── tom
│ ├── server
│ │ ├── RequestVerifier.java
│ │ ├── Replier.java
│ │ ├── BatchExecutable.java
│ │ ├── SingleExecutable.java
│ │ ├── defaultservices
│ │ │ └── DefaultReplier.java
│ │ └── Executable.java
│ ├── util
│ │ ├── DebugInfo.java
│ │ ├── Extractor.java
│ │ ├── KeyLoader.java
│ │ ├── SignatureTest.java
│ │ ├── RSAKeyPairGenerator.java
│ │ └── ECDSAKeyPairGenerator.java
│ ├── core
│ │ ├── messages
│ │ │ ├── TOMMessageType.java
│ │ │ └── ForwardedMessage.java
│ │ └── ReplyManager.java
│ ├── client
│ │ ├── NormalRequestHandler.java
│ │ └── HashedRequestHandler.java
│ ├── ReplicaContext.java
│ ├── RequestContext.java
│ └── leaderchange
│ │ └── LCMessage.java
│ ├── communication
│ ├── client
│ │ ├── CommunicationSystemServerSide.java
│ │ ├── CommunicationSystemServerSideFactory.java
│ │ ├── ReplyReceiver.java
│ │ ├── CommunicationSystemClientSideFactory.java
│ │ ├── RequestReceiver.java
│ │ ├── CommunicationSystemClientSide.java
│ │ ├── ReplyListener.java
│ │ └── netty
│ │ │ ├── NettyClientServerSession.java
│ │ │ ├── NettyServerPipelineFactory.java
│ │ │ ├── NettyClientPipelineFactory.java
│ │ │ └── NettyTOMMessageEncoder.java
│ ├── server
│ │ └── TestSerialization.java
│ └── SystemMessage.java
│ ├── statemanagement
│ ├── durability
│ │ ├── CSTRequest.java
│ │ ├── StateSender.java
│ │ ├── CSTSMMessage.java
│ │ ├── StateSenderServer.java
│ │ └── CSTRequestFGT1.java
│ ├── standard
│ │ └── StandardSMMessage.java
│ └── ApplicationState.java
│ └── consensus
│ └── roles
│ └── Proposer.java
├── .gitignore
└── gradlew.bat
/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'library'
2 |
--------------------------------------------------------------------------------
/lib/core-0.1.4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bft-smart/library/HEAD/lib/core-0.1.4.jar
--------------------------------------------------------------------------------
/config/java.security:
--------------------------------------------------------------------------------
1 | security.provider.10=org.bouncycastle.jce.provider.BouncyCastleProvider
2 |
--------------------------------------------------------------------------------
/lib/BenchmarkExecutor.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bft-smart/library/HEAD/lib/BenchmarkExecutor.jar
--------------------------------------------------------------------------------
/docs/javadoc/resources/x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bft-smart/library/HEAD/docs/javadoc/resources/x.png
--------------------------------------------------------------------------------
/docs/javadoc/resources/glass.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bft-smart/library/HEAD/docs/javadoc/resources/glass.png
--------------------------------------------------------------------------------
/config/keysECDSA/privatekey1:
--------------------------------------------------------------------------------
1 | MEECAQAwEwYHKoZIzj0CAQYIKoZIzj0DAQcEJzAlAgEBBCBisAauousSwa53qbwzSnA/H6zWCZCzB+PQnGpGKMUnZA==
--------------------------------------------------------------------------------
/config/keysECDSA/privatekey2:
--------------------------------------------------------------------------------
1 | MEECAQAwEwYHKoZIzj0CAQYIKoZIzj0DAQcEJzAlAgEBBCB/eMk4/sUQZUVFQh30Cn0HPdcHOU8wvXb/mbdLwFDq6g==
--------------------------------------------------------------------------------
/config/keysSunEC/privatekey0:
--------------------------------------------------------------------------------
1 | MEECAQAwEwYHKoZIzj0CAQYIKoZIzj0DAQcEJzAlAgEBBCCWnmor2QfcYpvkoxfP/JlWhSfC9J/yGSRWHHiZx6sL9Q==
--------------------------------------------------------------------------------
/config/keysSunEC/privatekey1:
--------------------------------------------------------------------------------
1 | MEECAQAwEwYHKoZIzj0CAQYIKoZIzj0DAQcEJzAlAgEBBCCbY/slFi0bqgns3p7XMfl5Xn5lLnX5ViwICGV1iK8zUQ==
--------------------------------------------------------------------------------
/config/keysSunEC/privatekey1001:
--------------------------------------------------------------------------------
1 | MEECAQAwEwYHKoZIzj0CAQYIKoZIzj0DAQcEJzAlAgEBBCBIiauyq/F7n1hOqomza0bl1r+sp0Owpb/O+JnmpD3O1g==
--------------------------------------------------------------------------------
/config/keysSunEC/privatekey2:
--------------------------------------------------------------------------------
1 | MEECAQAwEwYHKoZIzj0CAQYIKoZIzj0DAQcEJzAlAgEBBCBXn3kUjdMlGL+Ayrt7PUDr97p+4FgpmZ6M69qAOcwlWA==
--------------------------------------------------------------------------------
/config/keysSunEC/privatekey3:
--------------------------------------------------------------------------------
1 | MEECAQAwEwYHKoZIzj0CAQYIKoZIzj0DAQcEJzAlAgEBBCAtJ6SnBswCvaK6HcC2T7R1Z/NQdRSYVzKRSWeY/LVShA==
--------------------------------------------------------------------------------
/docs/javadoc/type-search-index.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bft-smart/library/HEAD/docs/javadoc/type-search-index.zip
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bft-smart/library/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/docs/javadoc/member-search-index.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bft-smart/library/HEAD/docs/javadoc/member-search-index.zip
--------------------------------------------------------------------------------
/docs/javadoc/package-search-index.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bft-smart/library/HEAD/docs/javadoc/package-search-index.zip
--------------------------------------------------------------------------------
/config/keysSSL_TLS/EC_KeyPair_256.pkcs12:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bft-smart/library/HEAD/config/keysSSL_TLS/EC_KeyPair_256.pkcs12
--------------------------------------------------------------------------------
/config/keysSSL_TLS/EC_KeyPair_384.pkcs12:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bft-smart/library/HEAD/config/keysSSL_TLS/EC_KeyPair_384.pkcs12
--------------------------------------------------------------------------------
/config/keysSSL_TLS/RSA_KeyPair_1024.pkcs12:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bft-smart/library/HEAD/config/keysSSL_TLS/RSA_KeyPair_1024.pkcs12
--------------------------------------------------------------------------------
/config/keysSSL_TLS/RSA_KeyPair_2048.pkcs12:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bft-smart/library/HEAD/config/keysSSL_TLS/RSA_KeyPair_2048.pkcs12
--------------------------------------------------------------------------------
/runscripts/smartrun.cmd:
--------------------------------------------------------------------------------
1 | java -cp "lib\*" -Djava.security.properties="./config/java.security" -Dlogback.configurationFile=config\logback.xml %*
--------------------------------------------------------------------------------
/config/keysECDSA/publickey0:
--------------------------------------------------------------------------------
1 | MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE7FWs5+FTlGUFb7gtut4Cq6Lfo5yS7gwC8gDJbrQ+YFefkKYMSMUjo5RCG1xrFHaFrVaZpiVEOokzIcQXnQgt/g==
--------------------------------------------------------------------------------
/config/keysECDSA/publickey1:
--------------------------------------------------------------------------------
1 | MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEf8n4phNQcxy4dWXVQ+mgohjf1DEWOBo82oTCNqjDa/z6hexXRP4vQ5rV6qjlwkHex8JCwmGkfV9CcmqzgaQx7A==
--------------------------------------------------------------------------------
/config/keysECDSA/publickey2:
--------------------------------------------------------------------------------
1 | MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE0aau6c8rDUDi9EBylL/66wcdng+80IHk0xi23cJB9KkAD/lEBxF3Y67a+ewyWLZb7MeTBJ8z9x8vQEZIaj8RSg==
--------------------------------------------------------------------------------
/config/keysECDSA/publickey3:
--------------------------------------------------------------------------------
1 | MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAELkL03d7eerml6Zh56TdwCfUQKlzbcOJIJZdo+9yGNuUk7lZyuIFjxoVarpFcHNUkH0CxhGk+vhqQ044kZ297uA==
--------------------------------------------------------------------------------
/config/keysSunEC/publickey0:
--------------------------------------------------------------------------------
1 | MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEnj/UYaihskrz75tjovBB6a4JJMmxN1u5WNFDVhIH2f6WHVuAzVHnBw1nmWnFEh8qUK6Jarlekfw7HML1l+N9Rw==
--------------------------------------------------------------------------------
/config/keysSunEC/publickey1:
--------------------------------------------------------------------------------
1 | MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEpQkXMt5fgOufqui1NbhMj28P2sNOQT15aEUur4TkhzGaHYHl1eYf2iuS2sY1zVNu47ILjpHOOaZmzLFUn/3GkQ==
--------------------------------------------------------------------------------
/config/keysSunEC/publickey2:
--------------------------------------------------------------------------------
1 | MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE8AJL+YVw44YI+mWRLhoIlWlMysZiM34CKaieMqYhgyvNoSbTGMHVk17BzntDQj5wYekCI+QJgHKV1LZ4xX1Wbw==
--------------------------------------------------------------------------------
/config/keysSunEC/publickey3:
--------------------------------------------------------------------------------
1 | MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAERNFRmBVFZ9g0I6Tk6KsGrdOxr6+e+p0c+jtasHwiK3qt4K6tghI75tHna+0VA34IkDmLgD8p59huf66TtFWVZw==
--------------------------------------------------------------------------------
/config/keysECDSA/publickey1001:
--------------------------------------------------------------------------------
1 | MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEQS4fYK7CAsYyvKQoxvEv9GwpPvVvcV5sNbu6ZHrnJ9KaBnCh4eu83KtJn7GJNi9C3fSfSh3q2Gam+AIhL/5lFQ==
--------------------------------------------------------------------------------
/config/keysSunEC/publickey1001:
--------------------------------------------------------------------------------
1 | MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE8ArsjzE5ETl/5YSkSCJ0eNONzZjmMxk2dNYPrJRFG5fON6nqp1aHOEJOxrQPtEiVQ8KSGtAWnTHf0891GYpQ7A==
--------------------------------------------------------------------------------
/config/keysECDSA/privatekey0:
--------------------------------------------------------------------------------
1 | MIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHkwdwIBAQQgTAiHxNOFYHLQH5t2QpNcf1kfv5sQkqaje2+ly88YWfWgCgYIKoZIzj0DAQehRANCAATsVazn4VOUZQVvuC263gKrot+jnJLuDALyAMlutD5gV5+QpgxIxSOjlEIbXGsUdoWtVpmmJUQ6iTMhxBedCC3+
--------------------------------------------------------------------------------
/config/keysECDSA/privatekey3:
--------------------------------------------------------------------------------
1 | MIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHkwdwIBAQQga0/il+FZFb4zEY7IYFTXJA/yahL0tuO9D30L7V6aOVCgCgYIKoZIzj0DAQehRANCAAQuQvTd3t56uaXpmHnpN3AJ9RAqXNtw4kgll2j73IY25STuVnK4gWPGhVqukVwc1SQfQLGEaT6+GpDTjiRnb3u4
--------------------------------------------------------------------------------
/config/keysECDSA/privatekey1001:
--------------------------------------------------------------------------------
1 | MIGTAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBHkwdwIBAQQgG/obXkbU5IFp1es5y07ySarDTtW3ybKSpsSP+ryfcAigCgYIKoZIzj0DAQehRANCAARBLh9grsICxjK8pCjG8S/0bCk+9W9xXmw1u7pkeucn0poGcKHh67zcq0mfsYk2L0Ld9J9KHerYZqb4AiEv/mUV
--------------------------------------------------------------------------------
/src/main/java/bftsmart/demo/map/MapRequestType.java:
--------------------------------------------------------------------------------
1 | package bftsmart.demo.map;
2 |
3 | /**
4 | * Types of operation for BFT Map implementation
5 | *
6 | */
7 |
8 | public enum MapRequestType {
9 | PUT, GET, SIZE, REMOVE, KEYSET;
10 | }
--------------------------------------------------------------------------------
/config/keysRSA/publickey:
--------------------------------------------------------------------------------
1 | MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCwuoTWbSFDnVjohwdZftoAwv3oCxUPnUiiNNH9
2 | pXryEW8kSFRGVJ7zJCwxJnt3YZGnpPGxnC3hAI4XkG26hO7+TxkgaYmv5GbamL946uZISxv0aNX3
3 | YbaOf//MC6F8tShFfCnpWlj68FYulM5dC2OOOHaUJfofQhmXfsaEWU251wIDAQAB
--------------------------------------------------------------------------------
/config/keysRSA/publickey0:
--------------------------------------------------------------------------------
1 | MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCwuoTWbSFDnVjohwdZftoAwv3oCxUPnUiiNNH9
2 | pXryEW8kSFRGVJ7zJCwxJnt3YZGnpPGxnC3hAI4XkG26hO7+TxkgaYmv5GbamL946uZISxv0aNX3
3 | YbaOf//MC6F8tShFfCnpWlj68FYulM5dC2OOOHaUJfofQhmXfsaEWU251wIDAQAB
--------------------------------------------------------------------------------
/config/keysRSA/publickey1:
--------------------------------------------------------------------------------
1 | MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDuFjuIK3SAUlrEk9ViAZjp30JWdXopBQZAO8pc
2 | 1B3GmYD/8g33HLJ0uukFc30c2WtfdUcPNnTW09GBlpoM8VIbGYsUje1JQhlGiDIio8o3qr8imsdz
3 | HDnOyizvuW+gpufHcnHauqoC18V242r69uEdfoEqJPoEQjda905HyxYRvQIDAQAB
--------------------------------------------------------------------------------
/config/keysRSA/publickey1001:
--------------------------------------------------------------------------------
1 | MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCDrLsNj3cyNjb1gPNYpbZ5o/ul51J9bDEPJDa6
2 | OmfYdL6xI8HHI7arAMOSrqcyxY4GQWZZXd8cAoinb1x9AuS5pfYQgd70qJZ296FslDckufU78GNM
3 | gfyDPmWCAjvm9iy6KPu9g0dB1D21kDl1wIOEBTQiAVYtxvoSNWjtiN3utwIDAQAB
--------------------------------------------------------------------------------
/config/keysRSA/publickey2:
--------------------------------------------------------------------------------
1 | MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCApoEu6VOdaxYHy61rvn3YGjl9wnlgy5ikGQNz
2 | I7Pb6AVZN0NkXd622AbtJhfsv0J1FuHfUQDlu2vpbSOT9ju2t2iD1zugOsV9511F7pq2G070jnMZ
3 | 0s5AnE1ygMfj7x8sIZEQoHqS5UMgqpgz1SuS63hZLhmayAnxSjYYVtIkMQIDAQAB
--------------------------------------------------------------------------------
/config/keysRSA/publickey3:
--------------------------------------------------------------------------------
1 | MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCE4SByyp9nkZJZDtEkNQBPA84I0DFtu6vfuL0b
2 | yw3GzSS1Cceywu2T8SerM/fGt6cawjHXR33S3vmewNIb99CSF4NgWGrB6D7dWK4HJ4kRLb/+NrQI
3 | oRzrwien/NKyaVZE6Y1h9pIwPpiLrAa49r58t8/wS4W8j5gkpbtfuGFTIQIDAQAB
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | bin
2 | config/currentView
3 | test
4 |
5 | # Ignore Gradle project-specific cache directory
6 | .gradle
7 |
8 | # Ignore Gradle build output directory
9 | build
10 |
11 | # Ignore IntelliJ IDEA setting folder
12 | .idea
13 | /gradle.properties
14 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/tests/util/Operation.java:
--------------------------------------------------------------------------------
1 | package bftsmart.tests.util;
2 |
3 | /**
4 | * @author robin
5 | */
6 | public enum Operation {
7 | PUT,
8 | GET;
9 |
10 | public static Operation[] values = values();
11 |
12 | public static Operation getOperation(int ordinal) {
13 | return values[ordinal];
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/runscripts/generate-javadoc.sh:
--------------------------------------------------------------------------------
1 | rm -r doc/*
2 | javadoc -cp src -d doc bftsmart.tom bftsmart.tom.server src/bftsmart/tom/util/KeyLoader.java src/bftsmart/tom/util/Extractor.java src/bftsmart/tom/server/defaultservices/DefaultRecoverable.java src/bftsmart/tom/server/defaultservices/DefaultSingleRecoverable.java src/bftsmart/tom/server/defaultservices/durability/DurabilityCoordinator.java src/bftsmart/reconfiguration/VMServices.java
3 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/tests/normal/AsynchronousNormalTest.java:
--------------------------------------------------------------------------------
1 | package bftsmart.tests.normal;
2 |
3 | import bftsmart.tom.core.messages.TOMMessageType;
4 |
5 | public class AsynchronousNormalTest extends AbstractNormalTest {
6 |
7 | public AsynchronousNormalTest(String workingDirectory, int f, boolean isBFT, boolean isUnorderedRequestEnabled, TOMMessageType requestType) {
8 | super(workingDirectory, f, isBFT, isUnorderedRequestEnabled, requestType);
9 | }
10 |
11 | public String getClientClass() {
12 | return "bftsmart.tests.normal.AsyncRequestClient";
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/tests/normal/SynchronousNormalTest.java:
--------------------------------------------------------------------------------
1 | package bftsmart.tests.normal;
2 |
3 | import bftsmart.tom.core.messages.TOMMessageType;
4 |
5 | public class SynchronousNormalTest extends AbstractNormalTest {
6 |
7 | public SynchronousNormalTest(String workingDirectory, int f, boolean isBFT, boolean isUnorderedRequestEnabled, TOMMessageType requestType) {
8 | super(workingDirectory, f, isBFT, isUnorderedRequestEnabled, requestType);
9 | }
10 |
11 | public String getClientClass() {
12 | return "bftsmart.tests.normal.SynchronousRequestClient";
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/benchmark/Measurement.java:
--------------------------------------------------------------------------------
1 | package bftsmart.benchmark;
2 |
3 | import worker.IProcessingResult;
4 |
5 | import java.util.Arrays;
6 |
7 | public class Measurement implements IProcessingResult {
8 | private final long[][] measurements;
9 |
10 | public Measurement(long[]... measurements) {
11 | this.measurements = measurements;
12 | }
13 |
14 | public long[][] getMeasurements() {
15 | return measurements;
16 | }
17 |
18 | @Override
19 | public String toString() {
20 | return "Measurement{" +
21 | "measurements=" + Arrays.toString(measurements) +
22 | '}';
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/docs/javadoc/jquery-ui.overrides.css:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
3 | * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
4 | *
5 | *
6 | *
7 | *
8 | *
9 | *
10 | *
11 | *
12 | *
13 | *
14 | *
15 | *
16 | *
17 | *
18 | *
19 | *
20 | *
21 | *
22 | *
23 | *
24 | */
25 |
26 | .ui-state-active,
27 | .ui-widget-content .ui-state-active,
28 | .ui-widget-header .ui-state-active,
29 | a.ui-button:active,
30 | .ui-button:active,
31 | .ui-button.ui-state-active:hover {
32 | /* Overrides the color of selection used in jQuery UI */
33 | background: #F8981D;
34 | border: 1px solid #F8981D;
35 | }
36 |
--------------------------------------------------------------------------------
/docs/javadoc/overview-summary.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | library API
7 |
8 |
9 |
12 |
13 |
14 |
15 |
16 |
17 |
20 | index.html
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/runscripts/smartrun.sh:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2007-2013 Alysson Bessani, Eduardo Alchieri, Paulo Sousa, and the authors indicated in the @author tags
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | java -Djava.security.properties="./config/java.security" -Dlogback.configurationFile="./config/logback.xml" -cp "lib/*" $@
--------------------------------------------------------------------------------
/src/main/java/bftsmart/tests/util/ErrorPrinter.java:
--------------------------------------------------------------------------------
1 | package bftsmart.tests.util;
2 |
3 | import java.io.BufferedReader;
4 | import java.io.IOException;
5 | import java.io.InputStream;
6 | import java.io.InputStreamReader;
7 |
8 | /**
9 | * @author Robin
10 | */
11 | public class ErrorPrinter extends Thread {
12 | private final InputStream errorStream;
13 |
14 | ErrorPrinter(InputStream errorStream) {
15 | super("Error Printer Thread");
16 | this.errorStream = errorStream;
17 | }
18 |
19 | @Override
20 | public void run() {
21 | try (BufferedReader in =
22 | new BufferedReader(new InputStreamReader(errorStream))) {
23 | String line;
24 | while ((line = in.readLine()) != null) {
25 | System.err.println(line);
26 | }
27 | } catch (IOException ignored) {}
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/runscripts/startReplicaYCSB.sh:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2007-2013 Alysson Bessani, Eduardo Alchieri, Paulo Sousa, and the authors indicated in the @author tags
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | #/bin/bash
16 |
17 | REPLICA_INDEX=$1
18 |
19 | java -Dlogback.configurationFile="./config/logback.xml" -cp bin/:lib/* bftsmart.demo.ycsb.YCSBServer $REPLICA_INDEX
20 |
--------------------------------------------------------------------------------
/config/keysRSA/privatekey:
--------------------------------------------------------------------------------
1 | MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBALC6hNZtIUOdWOiHB1l+2gDC/egL
2 | FQ+dSKI00f2levIRbyRIVEZUnvMkLDEme3dhkaek8bGcLeEAjheQbbqE7v5PGSBpia/kZtqYv3jq
3 | 5khLG/Ro1fdhto5//8wLoXy1KEV8KelaWPrwVi6Uzl0LY444dpQl+h9CGZd+xoRZTbnXAgMBAAEC
4 | gYAJaUVdrd4RnbV4XIh1qZ2uYLPowX5ToIqXqLxuB3vunCMRCZEDVcpJJGn+DBCTIO0CwnPkg26m
5 | BsOKWbSeNCoN5gOi5yd6Poe0D40ZmvHP1hMCQ9LYhwjLB3Aa+Cl5gYL074Qe/eJFqJaYjZApkeJU
6 | Ay1HkXhM5OBW9grrXxg6YQJBAPTIni5fG5f2SYutkR2pUydZP4haKVabRkZr8nSHuClGDE2HzbNQ
7 | jb17z5rRVxJCKMLb2HiPg7ZsUgGK/J1ri78CQQC405h45rL1mCIyZQCXcK/nQZTVi8UaaelKN/ub
8 | LQKtTGenJao/zoL+m39i+gGRkHWiG6HNaGFdOkRJmeeH+rfpAkEAn0fwDjKbDP4ZC0fM1uU4k7Ey
9 | czJgFdgCGY7ifMtXnZvUI5sL0fPH15W6GH7BzsK4LVvK92BDj6/aiOB80p6JlwJASjL4NSE4mwv2
10 | PpD5ydI9a/OSEqDIAjCerWMIKWXKe1P/EMU4MeFwCVLXsx523r9F2kyJinLrE4g+veWBY7+tcQJB
11 | AKCTm3tbbwLJnnPN46mAgrYb5+LFOmHyNtEDgjxEVrzpQaCChZici2YGY1jTBjb/De4jii8RXllA
12 | tUhBEsqyXDA=
--------------------------------------------------------------------------------
/config/keysRSA/privatekey0:
--------------------------------------------------------------------------------
1 | MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBALC6hNZtIUOdWOiHB1l+2gDC/egL
2 | FQ+dSKI00f2levIRbyRIVEZUnvMkLDEme3dhkaek8bGcLeEAjheQbbqE7v5PGSBpia/kZtqYv3jq
3 | 5khLG/Ro1fdhto5//8wLoXy1KEV8KelaWPrwVi6Uzl0LY444dpQl+h9CGZd+xoRZTbnXAgMBAAEC
4 | gYAJaUVdrd4RnbV4XIh1qZ2uYLPowX5ToIqXqLxuB3vunCMRCZEDVcpJJGn+DBCTIO0CwnPkg26m
5 | BsOKWbSeNCoN5gOi5yd6Poe0D40ZmvHP1hMCQ9LYhwjLB3Aa+Cl5gYL074Qe/eJFqJaYjZApkeJU
6 | Ay1HkXhM5OBW9grrXxg6YQJBAPTIni5fG5f2SYutkR2pUydZP4haKVabRkZr8nSHuClGDE2HzbNQ
7 | jb17z5rRVxJCKMLb2HiPg7ZsUgGK/J1ri78CQQC405h45rL1mCIyZQCXcK/nQZTVi8UaaelKN/ub
8 | LQKtTGenJao/zoL+m39i+gGRkHWiG6HNaGFdOkRJmeeH+rfpAkEAn0fwDjKbDP4ZC0fM1uU4k7Ey
9 | czJgFdgCGY7ifMtXnZvUI5sL0fPH15W6GH7BzsK4LVvK92BDj6/aiOB80p6JlwJASjL4NSE4mwv2
10 | PpD5ydI9a/OSEqDIAjCerWMIKWXKe1P/EMU4MeFwCVLXsx523r9F2kyJinLrE4g+veWBY7+tcQJB
11 | AKCTm3tbbwLJnnPN46mAgrYb5+LFOmHyNtEDgjxEVrzpQaCChZici2YGY1jTBjb/De4jii8RXllA
12 | tUhBEsqyXDA=
--------------------------------------------------------------------------------
/config/keysRSA/privatekey1:
--------------------------------------------------------------------------------
1 | MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAO4WO4grdIBSWsST1WIBmOnfQlZ1
2 | eikFBkA7ylzUHcaZgP/yDfccsnS66QVzfRzZa191Rw82dNbT0YGWmgzxUhsZixSN7UlCGUaIMiKj
3 | yjeqvyKax3McOc7KLO+5b6Cm58dycdq6qgLXxXbjavr24R1+gSok+gRCN1r3TkfLFhG9AgMBAAEC
4 | gYEArSvWmTCiSEOeaaTta5+lzVXqNmC0Pem9pjLW+bX/Aljcj01MAxUIaAcbPi/GLJmnk4MF8Ha3
5 | fRoMJKmZ2xgbkttZRKTlJX/gwjjNGUsSwiV8Xn0sTnnB33kGgSFQZqkKyp3yScC6Ndxj4yihKjm5
6 | Dp+W+Gk24PKpphOs9MQ1O7ECQQD3Nq5u5j8w9QKmV9CmfgXDomwYqGKBcnUZzJkS4QJ2bxJ02p1Z
7 | wOn+JhsMx8Lagh5Euks8W24XqepfJM2IH45HAkEA9oyCfLjVEMkrqerkn8PdOEHgdEWgdTn4o7v9
8 | gGshQ6WmJILa46ZRP2T5K1FLFdgssw4gUfL6OIB19S8U/VRN2wJBAKoXsYUUXr4slholqaYkZ4rn
9 | okCE+uHeArwxjdDziGI8ohJMqJ8soNMBHPN6LpNxm6nmFAX/UoxtmJjGFbRnIdkCQFYffRFuS1dC
10 | vpLrb5Nzito1AN/81nE8n+MqLwJl6cfEnIXSg/3Twjvf3L5J9m2aBvtBKv8VXlzQWuQb3zwi79MC
11 | QGgQOgtb/WQ3c/xd1It8tAbxagcYUYYm8c74+uOqzPsE5hVLsfL+1eB4kWW8U+MSWESuCcIpMkmb
12 | roUKzw6NHlw=
--------------------------------------------------------------------------------
/config/keysRSA/privatekey2:
--------------------------------------------------------------------------------
1 | MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAICmgS7pU51rFgfLrWu+fdgaOX3C
2 | eWDLmKQZA3Mjs9voBVk3Q2Rd3rbYBu0mF+y/QnUW4d9RAOW7a+ltI5P2O7a3aIPXO6A6xX3nXUXu
3 | mrYbTvSOcxnSzkCcTXKAx+PvHywhkRCgepLlQyCqmDPVK5LreFkuGZrICfFKNhhW0iQxAgMBAAEC
4 | gYB/a2qbmgF08rE5O2QiSOO/fAnhIxKw6jXeod+m1H+5mI5jlLas28RQeJozm/0qQSyDaAyC8Gnh
5 | H8Z7xdrtG357xfbtwbrl+LYTi6jdIiYQoMZeS7Levy1RRdIbnMDFT9DvbdWHiX4YzRX3mN/YEjly
6 | GKx6BPN0XQDKkzGyoozDgQJBANv4VCr235hyUQW1+4bMzu96H22FKUq2/QD30ft8uvycEKjrweJg
7 | A3TbLG/xIp4uLnR2qDRIpLl98jYJ0veyBjkCQQCVuQIF+3m/YCpj0zD2k9RjDuICXAVEwIkUE39h
8 | ZP4NB7R4AMcLQZaUr+d8pwQk9cmMEJzE+kfH7imMCRmJsM25AkEAm8/dHsncPAnNpnPvhN6SPkOM
9 | +3D1fLz9na/tB2ykrsaFboIAxi8og5+0bF6sHMutkEV0hARo2hOCfBCdZWKu0QJAc1hBZ8xx4e67
10 | GYalLQF8WQgpM/oikPHnaREQTD8avX0XGnA258QStt/BbbXZqoO0TvSpYdMTI8KmPVzxULNl+QJA
11 | SW6TIWfvr5LIn7WXPPHjrElrywKzed/NRJxCy+j5f68nU9Y5mBLuoEOI8CToWMNz0xUB+7i0PnNI
12 | 3EYimDKS3Q==
--------------------------------------------------------------------------------
/config/keysRSA/privatekey3:
--------------------------------------------------------------------------------
1 | MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAIThIHLKn2eRklkO0SQ1AE8DzgjQ
2 | MW27q9+4vRvLDcbNJLUJx7LC7ZPxJ6sz98a3pxrCMddHfdLe+Z7A0hv30JIXg2BYasHoPt1Yrgcn
3 | iREtv/42tAihHOvCJ6f80rJpVkTpjWH2kjA+mIusBrj2vny3z/BLhbyPmCSlu1+4YVMhAgMBAAEC
4 | gYBhYhRDzJeycY9N0XwZCvbk8abn8pynDSlTVrLRUakRD3tdaoN+UTmIeO5XnEh0zFedVsDsQyrF
5 | hkBuxmW1tZKWzyrp2I1DSYeDDzuFxcLBksqr41OWNyF08T+xOX8dh8prE6WyW91TN9oCFPzRko3b
6 | TORWdmO4W110krtU4DXGgQJBAMsAiriGm1eoSjayZrIgUBS+nEXCEoWn0AG9VvvSdWmTRcAy9Rfy
7 | wHX64hJn75tcD30/CXgDXhZdLQ/Bj5gONDkCQQCnkf+Nn+1vAUHFiUhAO/mkCCiiDaMdhD7G0Y5Y
8 | jLtN/C7aoris3RPjXa53ZZe3d/ioWvcqA6OQ4A8XFGP2LqYpAkEAqC4Hvz5Nfj6/VTdR22rnzXfp
9 | EeXp4G8Z5gcOBEzk1xWa6NOOuEt15Yh3ORaArK6FapcJ6jKoBVEmXvJWW3wRCQJAFWLApqZ+euhC
10 | KJ+4pNoCpjiUVvo+kwnJqT4dWJe9X9qLcEPMJeOhIidWmM5SaovZJENXv/ju6xJtWpizmTui4QJA
11 | CxUOypjq0rTpveleNPytDJQUILsr6m5QjHeZLamKQVdiv8DhgXvuc2282YFM5hfOaIxJkKRIxsQz
12 | PJn9FRQYlQ==
--------------------------------------------------------------------------------
/config/keysRSA/privatekey1001:
--------------------------------------------------------------------------------
1 | MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAIOsuw2PdzI2NvWA81iltnmj+6Xn
2 | Un1sMQ8kNro6Z9h0vrEjwccjtqsAw5KupzLFjgZBZlld3xwCiKdvXH0C5Lml9hCB3vSolnb3oWyU
3 | NyS59TvwY0yB/IM+ZYICO+b2LLoo+72DR0HUPbWQOXXAg4QFNCIBVi3G+hI1aO2I3e63AgMBAAEC
4 | gYBv0O3jXRJGhH11S7TacZacg2F+iAqn0YlzpzgGOvTWfoU03f1/Q1eqrXJnDIOVfOfXbhAhEbMW
5 | ERzEuq+axSs/LcjYSlj1PyWbKm0OoiVQS9YklqVl2oQyN7mrUspRBnvq35M33+cOec/0BnbXjl8L
6 | H2N2q5xC/7b76U83ktKJgQJBAOyNtcwcsY0J+NZNJQwdpW4hmOriy672AZjAZ7spSrXngF3rTrqP
7 | N/dIczudLYVc6Ws04aJdHnadlR4TMfqcZUECQQCOf9YuM8pSdqVsM4cS/E8DvmbM1w7OY3HWYuZz
8 | 4wsWWylDbiBu0ETsGC2M+ojfd4Ap6/DPayT/g1GBZRn/J/33AkEA6QjJmaSCvQCf5O3mm0LxX8c1
9 | T9/Q7DFpbUPObLDG6uB+swdGbb79UVxMOOQkngbj5DsaNMsrYYroBdK/H7XGgQJAFuyL2SztvGxn
10 | 2ktDzJMYZwLHaOaj9CHdW17XsgbxbqxFrBpYT1tj6xNMqKRZRpHj5VqWh9e1wQEwKH/KOdkGKwJB
11 | AOEO/Xs8BWnzF/vsXGN7E/xiFOhio4mP862NqQSL8cxRmswzMeLJ3cdv1Z1lxXGFIY+aOczB6Sm4
12 | jnszzWPp0yA=
--------------------------------------------------------------------------------
/runscripts/ycsbClient.sh:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2007-2013 Alysson Bessani, Eduardo Alchieri, Paulo Sousa, and the authors indicated in the @author tags
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | #/bin/bash
16 | java -Dlogback.configurationFile="./config/logback.xml" -cp ./lib/*:./bin/ com.yahoo.ycsb.Client -threads 10 -P config/workloads/workloada -p measurementtype=timeseries -p timeseries.granularity=1000 -db bftsmart.demo.ycsb.YCSBClient -s
17 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/reconfiguration/views/ViewStorage.java:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2007-2013 Alysson Bessani, Eduardo Alchieri, Paulo Sousa, and the authors indicated in the @author tags
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package bftsmart.reconfiguration.views;
17 |
18 | /**
19 | *
20 | * @author eduardo
21 | */
22 | public interface ViewStorage {
23 |
24 | public boolean storeView(View view);
25 | public View readView();
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/docs/javadoc/element-list:
--------------------------------------------------------------------------------
1 | bftsmart.benchmark
2 | bftsmart.clientsmanagement
3 | bftsmart.communication
4 | bftsmart.communication.client
5 | bftsmart.communication.client.netty
6 | bftsmart.communication.server
7 | bftsmart.consensus
8 | bftsmart.consensus.messages
9 | bftsmart.consensus.roles
10 | bftsmart.demo.counter
11 | bftsmart.demo.map
12 | bftsmart.demo.microbenchmarks
13 | bftsmart.demo.ycsb
14 | bftsmart.reconfiguration
15 | bftsmart.reconfiguration.util
16 | bftsmart.reconfiguration.views
17 | bftsmart.statemanagement
18 | bftsmart.statemanagement.durability
19 | bftsmart.statemanagement.standard
20 | bftsmart.tests
21 | bftsmart.tests.normal
22 | bftsmart.tests.recovery
23 | bftsmart.tests.requests
24 | bftsmart.tests.requests.hashed
25 | bftsmart.tests.requests.normal
26 | bftsmart.tests.util
27 | bftsmart.tom
28 | bftsmart.tom.client
29 | bftsmart.tom.core
30 | bftsmart.tom.core.messages
31 | bftsmart.tom.leaderchange
32 | bftsmart.tom.server
33 | bftsmart.tom.server.defaultservices
34 | bftsmart.tom.server.durability
35 | bftsmart.tom.util
36 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/tom/server/RequestVerifier.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package bftsmart.tom.server;
7 |
8 | import bftsmart.tom.core.messages.TOMMessage;
9 |
10 | /**
11 | *
12 | * Classes that implement this interface are invoked within
13 | * consensus instances upon reception of a PROPOSE message
14 | * in order to enforce the "external validity". More precisely,
15 | * objects extending this class must verify if the requests
16 | * are valid in accordance to the application semantics (and not
17 | * an erroneous requests sent by a Byzantine leader).
18 | *
19 | */
20 | public interface RequestVerifier {
21 |
22 | /**
23 | * Given a request, validated it
24 | *
25 | * @param request The request to be validated
26 | * @return true if the request is valid, false otherwise
27 | */
28 | public boolean isValidRequest(TOMMessage request);
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/demo/ycsb/YCSBTable.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2007-2013 Alysson Bessani, Eduardo Alchieri, Paulo Sousa, and the authors indicated in the @author tags
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package bftsmart.demo.ycsb;
17 |
18 | import java.io.Serializable;
19 | import java.util.HashMap;
20 | import java.util.TreeMap;
21 |
22 | /**
23 | *
24 | * @author Marcel Santos
25 | *
26 | */
27 | public class YCSBTable extends TreeMap> implements Serializable {
28 | private static final long serialVersionUID = 3786544460082473686L;
29 | }
30 |
--------------------------------------------------------------------------------
/docs/javadoc/package-search-index.js:
--------------------------------------------------------------------------------
1 | packageSearchIndex = [{"l":"All Packages","url":"allpackages-index.html"},{"l":"bftsmart.benchmark"},{"l":"bftsmart.clientsmanagement"},{"l":"bftsmart.communication"},{"l":"bftsmart.communication.client"},{"l":"bftsmart.communication.client.netty"},{"l":"bftsmart.communication.server"},{"l":"bftsmart.consensus"},{"l":"bftsmart.consensus.messages"},{"l":"bftsmart.consensus.roles"},{"l":"bftsmart.demo.counter"},{"l":"bftsmart.demo.map"},{"l":"bftsmart.demo.microbenchmarks"},{"l":"bftsmart.demo.ycsb"},{"l":"bftsmart.reconfiguration"},{"l":"bftsmart.reconfiguration.util"},{"l":"bftsmart.reconfiguration.views"},{"l":"bftsmart.statemanagement"},{"l":"bftsmart.statemanagement.durability"},{"l":"bftsmart.statemanagement.standard"},{"l":"bftsmart.tests"},{"l":"bftsmart.tests.normal"},{"l":"bftsmart.tests.recovery"},{"l":"bftsmart.tests.requests"},{"l":"bftsmart.tests.requests.hashed"},{"l":"bftsmart.tests.requests.normal"},{"l":"bftsmart.tests.util"},{"l":"bftsmart.tom"},{"l":"bftsmart.tom.client"},{"l":"bftsmart.tom.core"},{"l":"bftsmart.tom.core.messages"},{"l":"bftsmart.tom.leaderchange"},{"l":"bftsmart.tom.server"},{"l":"bftsmart.tom.server.defaultservices"},{"l":"bftsmart.tom.server.durability"},{"l":"bftsmart.tom.util"}]
--------------------------------------------------------------------------------
/src/main/java/bftsmart/tests/recovery/RecoveryEventProcessor.java:
--------------------------------------------------------------------------------
1 | package bftsmart.tests.recovery;
2 |
3 | import org.slf4j.Logger;
4 | import org.slf4j.LoggerFactory;
5 | import worker.IProcessingResult;
6 | import worker.IWorkerEventProcessor;
7 |
8 | public class RecoveryEventProcessor implements IWorkerEventProcessor {
9 | private final Logger logger = LoggerFactory.getLogger("benchmarking");
10 | private static final String SERVER_READY_PATTERN = "Ready to process operations";
11 | private static final String CLIENT_READY_PATTERN = "Executing experiment";
12 | private boolean isReady;
13 |
14 | @Override
15 | public void process(String line) {
16 | logger.debug("{}", line);
17 | if(!isReady && (line.contains(SERVER_READY_PATTERN) || line.contains(CLIENT_READY_PATTERN)))
18 | isReady = true;
19 | }
20 |
21 | @Override
22 | public void startProcessing() {
23 |
24 | }
25 |
26 | @Override
27 | public void stopProcessing() {
28 |
29 | }
30 |
31 | @Override
32 | public IProcessingResult getProcessingResult() {
33 | return null;
34 | }
35 |
36 | @Override
37 | public boolean isReady() {
38 | return isReady;
39 | }
40 |
41 | @Override
42 | public boolean ended() {
43 | return false;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/tom/util/DebugInfo.java:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2007-2013 Alysson Bessani, Eduardo Alchieri, Paulo Sousa, and the authors indicated in the @author tags
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package bftsmart.tom.util;
17 |
18 | import bftsmart.tom.core.messages.TOMMessage;
19 |
20 | /**
21 | *
22 | * @author Joao Sousa
23 | */
24 | public class DebugInfo {
25 |
26 | public final int cid;
27 | public final int epoch;
28 | public final int leader;
29 | public final TOMMessage msg;
30 |
31 | public DebugInfo(int cid, int epoch, int leader, TOMMessage msg) {
32 | this.cid = cid;
33 | this.epoch = epoch;
34 | this.leader = leader;
35 | this.msg = msg;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/communication/client/CommunicationSystemServerSide.java:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2007-2013 Alysson Bessani, Eduardo Alchieri, Paulo Sousa, and the authors indicated in the @author tags
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package bftsmart.communication.client;
17 |
18 | import bftsmart.tom.core.messages.TOMMessage;
19 |
20 | /**
21 | * Methods that should be implemented by the server side of the client-server communication system
22 | *
23 | * @author Paulo
24 | */
25 | public interface CommunicationSystemServerSide {
26 | public void send(int[] targets, TOMMessage sm, boolean serializeClassHeaders);
27 | public int[] getClients();
28 | public void setRequestReceiver(RequestReceiver requestReceiver);
29 | public void shutdown();
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/communication/client/CommunicationSystemServerSideFactory.java:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2007-2013 Alysson Bessani, Eduardo Alchieri, Paulo Sousa, and the authors indicated in the @author tags
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package bftsmart.communication.client;
17 |
18 | import bftsmart.communication.client.netty.NettyClientServerCommunicationSystemServerSide;
19 | import bftsmart.reconfiguration.ServerViewController;
20 |
21 | /**
22 | *
23 | * @author Paulo
24 | */
25 | public class CommunicationSystemServerSideFactory {
26 |
27 | public static CommunicationSystemServerSide getCommunicationSystemServerSide(ServerViewController controller) {
28 | return new NettyClientServerCommunicationSystemServerSide(controller);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/tom/core/messages/TOMMessageType.java:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2007-2013 Alysson Bessani, Eduardo Alchieri, Paulo Sousa, and the authors indicated in the @author tags
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package bftsmart.tom.core.messages;
17 |
18 | /**
19 | * Possible types of TOMMessage
20 | *
21 | * @author alysson
22 | */
23 | public enum TOMMessageType {
24 | ORDERED_REQUEST, //0
25 | UNORDERED_REQUEST, //1
26 | REPLY, //2
27 | RECONFIG, //3
28 | ASK_STATUS, // 4
29 | STATUS_REPLY,// 5
30 | UNORDERED_HASHED_REQUEST, //6
31 | ORDERED_HASHED_REQUEST; //7
32 |
33 | public static TOMMessageType[] values = values();
34 |
35 | public static TOMMessageType getMessageType(int ordinal) {
36 | return values[ordinal];
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/communication/client/ReplyReceiver.java:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2007-2013 Alysson Bessani, Eduardo Alchieri, Paulo Sousa, and the authors indicated in the @author tags
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package bftsmart.communication.client;
17 |
18 | import bftsmart.tom.core.messages.TOMMessage;
19 |
20 | /**
21 | * Interface meant for objects that receive replies from replicas
22 | */
23 | public interface ReplyReceiver {
24 |
25 |
26 | /**
27 | * This is the method invoked by the client side comunication system, and where the
28 | * code to handle the reply is to be written
29 | *
30 | * @param reply The reply delivered by the client side comunication system
31 | */
32 | public void replyReceived(TOMMessage reply);
33 |
34 | }
35 |
36 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/communication/client/CommunicationSystemClientSideFactory.java:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2007-2013 Alysson Bessani, Eduardo Alchieri, Paulo Sousa, and the authors indicated in the @author tags
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package bftsmart.communication.client;
17 |
18 | import bftsmart.communication.client.netty.NettyClientServerCommunicationSystemClientSide;
19 | import bftsmart.reconfiguration.ClientViewController;
20 |
21 | /**
22 | *
23 | * @author Paulo
24 | */
25 | public class CommunicationSystemClientSideFactory {
26 |
27 | public static CommunicationSystemClientSide getCommunicationSystemClientSide(int clientId, ClientViewController controller) {
28 | return new NettyClientServerCommunicationSystemClientSide(clientId, controller);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/communication/client/RequestReceiver.java:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2007-2013 Alysson Bessani, Eduardo Alchieri, Paulo Sousa, and the authors indicated in the @author tags
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package bftsmart.communication.client;
17 |
18 | import bftsmart.tom.core.messages.TOMMessage;
19 |
20 | /**
21 | * Interface meant for objects that receive requests from clients
22 | */
23 | public interface RequestReceiver {
24 |
25 | /**
26 | * This is the method invoked by the CommunicationSystemServerSide, to
27 | * deliver a client request. The code to handle requests should be
28 | * put here.
29 | *
30 | * @param msg The request delivered by the TOM layer
31 | * @param fromClient The request was received from a client
32 | */
33 | public void requestReceived(TOMMessage msg, boolean fromClient);
34 | }
--------------------------------------------------------------------------------
/src/main/java/bftsmart/communication/client/CommunicationSystemClientSide.java:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2007-2013 Alysson Bessani, Eduardo Alchieri, Paulo Sousa, and the authors indicated in the @author tags
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package bftsmart.communication.client;
17 |
18 | import bftsmart.tom.core.messages.TOMMessage;
19 |
20 | /**
21 | * Methods that should be implemented by the client side of the client-server communication system
22 | *
23 | * @author Paulo
24 | */
25 | public interface CommunicationSystemClientSide {
26 | public void send(boolean sign, int[] targets, TOMMessage sm);
27 | public void setReplyReceiver(ReplyReceiver trr);
28 | public void sign(TOMMessage sm);
29 | public void close();
30 |
31 | //******* EDUARDO BEGIN **************//
32 | public void updateConnections();
33 | //******* EDUARDO END **************//
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/communication/client/ReplyListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2007-2013 Alysson Bessani, Eduardo Alchieri, Paulo Sousa, and the authors indicated in the @author tags
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package bftsmart.communication.client;
17 |
18 | import bftsmart.tom.RequestContext;
19 | import bftsmart.tom.core.messages.TOMMessage;
20 |
21 |
22 | public interface ReplyListener {
23 |
24 | /**
25 | * Indicates that the proxy re-issued the request and the listener should re-initialize
26 | */
27 | public void reset();
28 |
29 | /**
30 | * Used to deliver a reply from a replica
31 | * @param context The context associated to the reply
32 | * @param reply the TOMMessage including the reply
33 | */
34 | public void replyReceived(RequestContext context, TOMMessage reply);
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/tests/common/SimpleServiceEventProcessor.java:
--------------------------------------------------------------------------------
1 | package bftsmart.tests.common;
2 |
3 | import org.slf4j.Logger;
4 | import org.slf4j.LoggerFactory;
5 | import worker.IProcessingResult;
6 | import worker.IWorkerEventProcessor;
7 |
8 | public class SimpleServiceEventProcessor implements IWorkerEventProcessor {
9 | private final Logger logger = LoggerFactory.getLogger("benchmarking");
10 | private static final String SERVER_READY_PATTERN = "Replica state is up to date";
11 | private static final String CLIENT_READY_PATTERN = "Executing experiment";
12 | private static final String CLIENT_END_PATTERN = "Experiment ended";
13 | private boolean isReady;
14 | private boolean isEnded;
15 |
16 | @Override
17 | public void startProcessing() {
18 |
19 | }
20 |
21 | @Override
22 | public void stopProcessing() {
23 |
24 | }
25 |
26 | @Override
27 | public IProcessingResult getProcessingResult() {
28 | return null;
29 | }
30 |
31 | @Override
32 | public void process(String line) {
33 | logger.debug("{}", line);
34 | if (!isReady && (line.contains(SERVER_READY_PATTERN) || line.contains(CLIENT_READY_PATTERN))) {
35 | isReady = true;
36 | }
37 | if (!isEnded && line.contains(CLIENT_END_PATTERN)) {
38 | isEnded = true;
39 | }
40 | }
41 |
42 | @Override
43 | public boolean isReady() {
44 | return isReady;
45 | }
46 |
47 | @Override
48 | public boolean ended() {
49 | return isEnded;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/config/benchmark.config:
--------------------------------------------------------------------------------
1 | #######################
2 | # Required parameters #
3 | #######################
4 | #IP address where the controller will listen for workers' connections
5 | controller.listening.ip =
6 |
7 | #Port number where the controller will listen for workers' connections
8 | controller.listening.port =
9 |
10 | #Number of machines
11 | global.worker.machines =
12 |
13 | #Controller benchmark strategy class implementing IBenchmarkStrategy
14 | controller.benchmark.strategy =
15 |
16 | #Worker setup class implementing ISetupWorker
17 | controller.worker.setup =
18 |
19 | #Worker event processor class implementing IWorkerEventProcessor
20 | controller.worker.processor =
21 |
22 | #############################################################################
23 | # Extra parameters provided in IBenchmarkStrategy through Properties object #
24 | #############################################################################
25 | experiment.hosts.file =
26 | experiment.f = 1
27 | experiment.clients_per_round = 1 10 50
28 | experiment.measure_resources = true
29 |
30 | experiment.request_data_size = 1024
31 | experiment.response_data_size = 1024
32 | experiment.send_ordered_request = true
33 | experiment.use_hashed_response = false
34 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/tom/util/Extractor.java:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2007-2013 Alysson Bessani, Eduardo Alchieri, Paulo Sousa, and the authors indicated in the @author tags
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package bftsmart.tom.util;
17 |
18 | import bftsmart.tom.core.messages.TOMMessage;
19 |
20 | /**
21 | * Provides support for building custom response extractors to be used in the
22 | * ServiceProxy.
23 | *
24 | */
25 | public interface Extractor {
26 |
27 | /**
28 | * Extracts a reply given a set of replies from a set of replicas.
29 | *
30 | * @param replies Set of replies from a set of replicas.
31 | * @param sameContent Whether or not the replies are supposed to have the same content
32 | * @param lastReceived Last reply received from the replicas. This is an index in relation to the `replies` parameter.
33 | * @return
34 | */
35 | TOMMessage extractResponse(TOMMessage[] replies, int sameContent, int lastReceived);
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/reconfiguration/util/DefaultVMServices.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package bftsmart.reconfiguration.util;
7 |
8 | import bftsmart.reconfiguration.VMServices;
9 |
10 | /**
11 | *
12 | * @author joao
13 | */
14 | public class DefaultVMServices extends VMServices {
15 |
16 | public static void main(String[] args) throws InterruptedException {
17 |
18 | if(args.length == 1){
19 | System.out.println("####Tpp Service[Disjoint]####");
20 |
21 | int smartId = Integer.parseInt(args[0]);
22 |
23 | (new DefaultVMServices()).removeServer(smartId);
24 |
25 |
26 | }else if(args.length == 4){
27 | System.out.println("####Tpp Service[Join]####");
28 |
29 | int smartId = Integer.parseInt(args[0]);
30 | String ipAddress = args[1];
31 | int port = Integer.parseInt(args[2]);
32 | int portRR = Integer.parseInt(args[3]);
33 |
34 | (new DefaultVMServices()).addServer(smartId, ipAddress, port, portRR);
35 |
36 | }else{
37 | System.out.println("Usage: java -jar TppServices [ip address] [port]");
38 | System.exit(1);
39 | }
40 |
41 | Thread.sleep(2000);//2s
42 |
43 |
44 | System.exit(0);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/tom/server/Replier.java:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2007-2013 Alysson Bessani, Eduardo Alchieri, Paulo Sousa, and the authors indicated in the @author tags
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package bftsmart.tom.server;
17 |
18 | import bftsmart.tom.MessageContext;
19 | import bftsmart.tom.ReplicaContext;
20 | import bftsmart.tom.core.messages.TOMMessage;
21 |
22 | /**
23 | * Provides support for building custom reply management
24 | * to be used in the ServiceReplica.
25 | *
26 | */
27 | public interface Replier {
28 |
29 | /**
30 | * Sets the replica context
31 | * @param replicaContext The replica context
32 | */
33 | public void setReplicaContext(ReplicaContext replicaContext);
34 |
35 | /**
36 | * Given an executed request, send it to a target
37 | *
38 | * @param request The executed request
39 | * @param msgCtx The message context associated to the request
40 | */
41 | public void manageReply(TOMMessage request, MessageContext msgCtx);
42 |
43 | }
44 |
45 |
--------------------------------------------------------------------------------
/docs/javadoc/jquery/jszip-utils/dist/jszip-utils-ie.min.js:
--------------------------------------------------------------------------------
1 | /*!
2 |
3 | JSZipUtils - A collection of cross-browser utilities to go along with JSZip.
4 |
5 |
6 | (c) 2014 Stuart Knightley, David Duponchel
7 | Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip-utils/master/LICENSE.markdown.
8 |
9 | */
10 | !function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g\r\n\r\n";document.write(b),a.JSZipUtils._getBinaryFromXHR=function(a){for(var b=a.responseBody,c={},d=0;256>d;d++)for(var e=0;256>e;e++)c[String.fromCharCode(d+(e<<8))]=String.fromCharCode(d)+String.fromCharCode(e);var f=IEBinaryToArray_ByteStr(b),g=IEBinaryToArray_ByteStr_Last(b);return f.replace(/[\s\S]/g,function(a){return c[a]})+g}},{}]},{},[1]);
11 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/tests/recovery/RecoveryTest.java:
--------------------------------------------------------------------------------
1 | package bftsmart.tests.recovery;
2 |
3 | import bftsmart.tests.AbstractIntegrationTest;
4 |
5 | import java.util.Properties;
6 |
7 | /**
8 | * @author robin
9 | */
10 | public class RecoveryTest extends AbstractIntegrationTest {
11 |
12 | private final String workingDirectory;
13 | private final int f;
14 | private final boolean isBFT;
15 | private final Properties testParameters;
16 |
17 | public RecoveryTest(String workingDirectory, int f, boolean isBFT) {
18 | this.workingDirectory = workingDirectory;
19 | this.f = f;
20 | this.isBFT = isBFT;
21 | this.testParameters = new Properties();
22 | testParameters.setProperty("experiment.f", String.valueOf(f));
23 | testParameters.setProperty("experiment.bft", Boolean.toString(isBFT));
24 | }
25 |
26 | @Override
27 | public String getControllerIP() {
28 | return "127.0.0.1";
29 | }
30 |
31 | @Override
32 | public int getControllerPort() {
33 | return 1200;
34 | }
35 |
36 | @Override
37 | public int getNWorkers() {
38 | return (isBFT) ? 3 * f + 2 : 2 * f + 2;
39 | }
40 |
41 | @Override
42 | public String getWorkingDirectory() {
43 | return workingDirectory;
44 | }
45 |
46 | @Override
47 | public String getBenchmarkStrategyClassName() {
48 | return "bftsmart.tests.recovery.RecoveryTestStrategy";
49 | }
50 |
51 | @Override
52 | public String getWorkerSetupClassName() {
53 | return "bftsmart.tests.common.BFTSMaRtSetup";
54 | }
55 |
56 | @Override
57 | public String getWorkerEventProcessClassName() {
58 | return "bftsmart.tests.recovery.RecoveryEventProcessor";
59 | }
60 |
61 | @Override
62 | public Properties getTestParameters() {
63 | return testParameters;
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/tests/util/ProcessExecutor.java:
--------------------------------------------------------------------------------
1 | package bftsmart.tests.util;
2 |
3 | import java.io.BufferedReader;
4 | import java.io.File;
5 | import java.io.IOException;
6 | import java.io.InputStreamReader;
7 |
8 | /**
9 | * @author robin
10 | */
11 | public class ProcessExecutor extends Thread {
12 | private final String workingDirectory;
13 | private final String command;
14 | private final boolean printOutputStream;
15 | private Process process;
16 | private ErrorPrinter errorPrinter;
17 |
18 | public ProcessExecutor(String workingDirectory, String command, boolean printOutputStream) {
19 | this.workingDirectory = workingDirectory;
20 | this.command = command;
21 | this.printOutputStream = printOutputStream;
22 | }
23 |
24 | @Override
25 | public void run() {
26 | try {
27 | process = Runtime.getRuntime().exec(command, null, new File(workingDirectory));
28 | errorPrinter = new ErrorPrinter(process.getErrorStream());
29 | errorPrinter.start();
30 | BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
31 | String line;
32 | while ((line = in.readLine()) != null) {
33 | if (printOutputStream)
34 | System.out.println(line);
35 | if (line.contains("Exiting BenchmarkController") || line.contains("Exiting Worker"))
36 | break;
37 | }
38 | } catch (IOException e) {
39 | e.printStackTrace();
40 | } finally {
41 | destroyProcess();
42 | }
43 | }
44 |
45 | private void destroyProcess() {
46 | if (process != null)
47 | process.destroy();
48 | if (errorPrinter != null) {
49 | errorPrinter.interrupt();
50 | }
51 | }
52 |
53 | @Override
54 | public void interrupt() {
55 | destroyProcess();
56 | super.interrupt();
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/statemanagement/durability/CSTRequest.java:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2007-2013 Alysson Bessani, Eduardo Alchieri, Paulo Sousa, and the authors indicated in the @author tags
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package bftsmart.statemanagement.durability;
17 |
18 | import java.io.Serializable;
19 |
20 | /**
21 | * This class is used to define the roles in the Collaborative State Transfer protocol.
22 | * The recovering replica uses this class to define which replicas should send the
23 | * checkpoint, log of opperations lower and higher portions
24 | *
25 | * @author Marcel Santos
26 | */
27 | public abstract class CSTRequest implements Serializable {
28 |
29 | private static final long serialVersionUID = 7463498141366035002L;
30 |
31 | protected int cid;
32 | /** id of the replica responsible for sending the checkpoint;*/
33 | protected int checkpointReplica;
34 |
35 | public CSTRequest(int cid) {
36 | this.cid = cid;
37 | }
38 |
39 | public int getCID() {
40 | return cid;
41 | }
42 |
43 | public int getCheckpointReplica() {
44 | return checkpointReplica;
45 | }
46 |
47 | public abstract void defineReplicas(int[] processes, int globalCkpPeriod, int replicaId);
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/reconfiguration/views/TestViewSerialization.java:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2007-2013 Alysson Bessani, Eduardo Alchieri, Paulo Sousa, and the authors indicated in the @author tags
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package bftsmart.reconfiguration.views;
17 |
18 | import java.net.InetSocketAddress;
19 |
20 | public class TestViewSerialization {
21 |
22 | /**
23 | * @param args the command line arguments
24 | */
25 | public static void main(String[] args) throws Exception {
26 | int[] ids = {1,2,3,4};
27 | InetSocketAddress[] in = new InetSocketAddress[4];
28 | in[0] = new InetSocketAddress("127.0.0.1",1234);
29 | in[1] = new InetSocketAddress("127.0.0.1",1234);
30 | in[2] = new InetSocketAddress("127.0.0.1",1234);
31 | in[3] = new InetSocketAddress("127.0.0.1",1234);
32 | View v = new View(10, ids,1,in);
33 |
34 | String path = System.getProperty("user.dir") + System.getProperty("file.separator") + "config";
35 |
36 | ViewStorage st = new DefaultViewStorage(path);
37 | st.storeView(v);
38 |
39 | View r = st.readView();
40 | System.out.println(r);
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/docs/javadoc/jquery/jszip-utils/dist/jszip-utils.min.js:
--------------------------------------------------------------------------------
1 | /*!
2 |
3 | JSZipUtils - A collection of cross-browser utilities to go along with JSZip.
4 |
5 |
6 | (c) 2014 Stuart Knightley, David Duponchel
7 | Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip-utils/master/LICENSE.markdown.
8 |
9 | */
10 | !function(a){"object"==typeof exports?module.exports=a():"function"==typeof define&&define.amd?define(a):"undefined"!=typeof window?window.JSZipUtils=a():"undefined"!=typeof global?global.JSZipUtils=a():"undefined"!=typeof self&&(self.JSZipUtils=a())}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g ");
13 | System.exit(-1);
14 | }
15 | int stateSize = Integer.parseInt(args[0]);
16 | int processId = Integer.parseInt(args[1]);
17 | new SimpleServiceServer(processId, stateSize);
18 | }
19 |
20 | public SimpleServiceServer(int processId, int stateSize) {
21 | state = new byte[stateSize];
22 | for (int i = 0; i < stateSize; i++) {
23 | state[i] = (byte) i;
24 | }
25 | new ServiceReplica(processId, this, this);
26 | }
27 | @Override
28 | public void installSnapshot(byte[] state) {
29 | this.state = state;
30 | }
31 |
32 | @Override
33 | public byte[] getSnapshot() {
34 | return state;
35 | }
36 |
37 | @Override
38 | public byte[] appExecuteOrdered(byte[] requestData, MessageContext msgCtx) {
39 | //verifying data
40 | for (int i = 0; i < requestData.length; i++) {
41 | if (requestData[i] != (byte) i) {
42 | throw new IllegalStateException("Received wrong data in put request");
43 | }
44 | }
45 |
46 | return state;
47 | }
48 |
49 | @Override
50 | public byte[] appExecuteUnordered(byte[] requestData, MessageContext msgCtx) {
51 | //verifying data
52 | for (int i = 0; i < requestData.length; i++) {
53 | if (requestData[i] != (byte) i) {
54 | throw new IllegalStateException("Received wrong data in put request");
55 | }
56 | }
57 |
58 | return state;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/tests/normal/SynchronousRequestClient.java:
--------------------------------------------------------------------------------
1 | package bftsmart.tests.normal;
2 |
3 | import bftsmart.tom.ServiceProxy;
4 | import bftsmart.tom.core.messages.TOMMessageType;
5 |
6 | public class SynchronousRequestClient {
7 |
8 | public static void main(String[] args) {
9 | if (args.length != 4) {
10 | System.out.println("USAGE: bftsmart.tests.normal.NormalRequestClient "
11 | + " ");
12 | System.exit(-1);
13 | }
14 |
15 | int clientId = Integer.parseInt(args[0]);
16 | TOMMessageType requestType = TOMMessageType.valueOf(args[1]);
17 | int nRequests = Integer.parseInt(args[2]);
18 | int requestSize = Integer.parseInt(args[3]);
19 |
20 | byte[] requestData = new byte[requestSize];
21 |
22 | for (int i = 0; i < requestSize; i++) {
23 | requestData[i] = (byte) i;
24 | }
25 |
26 | try (ServiceProxy proxy = new ServiceProxy(clientId)) {
27 | System.out.println("Executing experiment");
28 | byte[] response;
29 | while (nRequests-- > 0) {
30 | switch (requestType) {
31 | case ORDERED_REQUEST:
32 | response = proxy.invokeOrdered(requestData);
33 | break;
34 | case UNORDERED_REQUEST:
35 | response = proxy.invokeUnordered(requestData);
36 | break;
37 | case ORDERED_HASHED_REQUEST:
38 | response = proxy.invokeOrderedHashed(requestData);
39 | break;
40 | case UNORDERED_HASHED_REQUEST:
41 | response = proxy.invokeUnorderedHashed(requestData);
42 | break;
43 | default:
44 | throw new IllegalStateException("Unsupported request type");
45 | }
46 | for (int i = 0; i < response.length; i++) {
47 | if (response[i] != (byte) i) {
48 | throw new IllegalStateException("Server response is wrong");
49 | }
50 | }
51 | }
52 | }
53 | System.out.println("Experiment ended");
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/tom/client/NormalRequestHandler.java:
--------------------------------------------------------------------------------
1 | package bftsmart.tom.client;
2 |
3 | import bftsmart.tom.core.messages.TOMMessage;
4 | import bftsmart.tom.core.messages.TOMMessageType;
5 | import bftsmart.tom.util.Extractor;
6 |
7 | import java.util.*;
8 |
9 | public class NormalRequestHandler extends AbstractRequestHandler {
10 | private final Comparator comparator;
11 | private final Extractor responseExtractor;
12 |
13 | public NormalRequestHandler(int me, int session, int sequenceId, int operationId, int viewId,
14 | TOMMessageType requestType, int timeout, int[] replicas,
15 | int replyQuorumSize, Comparator comparator, Extractor responseExtractor) {
16 | super(me, session, sequenceId, operationId, viewId, requestType, timeout, replicas, replyQuorumSize);
17 | this.comparator = comparator;
18 | this.responseExtractor = responseExtractor;
19 | }
20 |
21 | @Override
22 | public TOMMessage createRequest(byte[] request) {
23 | return new TOMMessage(me, session, sequenceId, operationId, request, viewId, requestType);
24 | }
25 |
26 | @Override
27 | public TOMMessage processReply(TOMMessage reply, int lastSenderIndex) {
28 | //optimization - compare responses after having a quorum of replies
29 | if (replySenders.size() < replyQuorumSize) {
30 | return null;
31 | }
32 |
33 | int sameContent = 0;
34 | logger.debug("Comparing {} responses with response from {}", replySenders.size(), reply.getSender());
35 | for (TOMMessage msg : replies) {
36 | if (msg == null) {
37 | continue;
38 | }
39 | if (comparator.compare(msg.getContent(), reply.getContent()) == 0) {
40 | sameContent++;
41 | if (sameContent >= replyQuorumSize) {
42 | return responseExtractor.extractResponse(replies, sameContent, lastSenderIndex);
43 | }
44 | }
45 | }
46 |
47 | return null;
48 | }
49 |
50 | @Override
51 | public void printState() {
52 |
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/communication/client/netty/NettyClientServerSession.java:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2007-2013 Alysson Bessani, Eduardo Alchieri, Paulo Sousa, and the authors indicated in the @author tags
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package bftsmart.communication.client.netty;
17 |
18 | import io.netty.channel.Channel;
19 |
20 | import java.util.concurrent.locks.Lock;
21 | import java.util.concurrent.locks.ReentrantLock;
22 |
23 | import javax.crypto.Mac;
24 |
25 |
26 | /**
27 | *
28 | * @author Paulo Sousa
29 | */
30 | public class NettyClientServerSession {
31 | private Channel channel;
32 | private int replicaId;
33 | private Lock lock;
34 | private int lastMsgReceived;
35 |
36 | public NettyClientServerSession(Channel channel, int replicaId) {
37 | this.channel = channel;
38 | this.replicaId = replicaId;
39 | this.lock = new ReentrantLock();
40 | this.lastMsgReceived = -1;
41 | }
42 |
43 | public Channel getChannel() {
44 | return channel;
45 | }
46 |
47 | public int getReplicaId() {
48 | return replicaId;
49 | }
50 |
51 | public Lock getLock(){
52 | return lock;
53 | }
54 |
55 | public int getLastMsgReceived(){
56 | return lastMsgReceived;
57 | }
58 |
59 | public void setLastMsgReceived(int lastMsgReceived_){
60 | this.lastMsgReceived = lastMsgReceived_;
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/statemanagement/durability/StateSender.java:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2007-2013 Alysson Bessani, Eduardo Alchieri, Paulo Sousa, and the authors indicated in the @author tags
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package bftsmart.statemanagement.durability;
17 |
18 | import java.io.IOException;
19 | import java.io.ObjectOutputStream;
20 | import java.io.OutputStream;
21 | import java.net.Socket;
22 |
23 | import bftsmart.statemanagement.ApplicationState;
24 |
25 | import org.slf4j.Logger;
26 | import org.slf4j.LoggerFactory;
27 |
28 | public class StateSender implements Runnable {
29 |
30 | private Logger logger = LoggerFactory.getLogger(this.getClass());
31 |
32 | private final Socket socket;
33 | private ApplicationState state;
34 |
35 | public StateSender(Socket socket) {
36 | this.socket = socket;
37 | }
38 |
39 | public void setState(ApplicationState state) {
40 | this.state = state;
41 | }
42 |
43 | @Override
44 | public void run() {
45 | try {
46 | OutputStream os = socket.getOutputStream();
47 | ObjectOutputStream oos = new ObjectOutputStream(os);
48 | logger.debug("Sending state in different socket");
49 | oos.writeObject(state);
50 | logger.debug("Sent state in different socket");
51 | oos.close();
52 | socket.close();
53 | } catch (IOException e) {
54 | // TODO Auto-generated catch block
55 | logger.error("Could not send state",e);
56 | }
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/tests/recovery/RecoveryTestClient.java:
--------------------------------------------------------------------------------
1 | package bftsmart.tests.recovery;
2 |
3 | import bftsmart.tests.util.Operation;
4 | import bftsmart.tom.ServiceProxy;
5 |
6 | import java.nio.ByteBuffer;
7 |
8 | /**
9 | * @author robin
10 | */
11 | public class RecoveryTestClient {
12 | public static void main(String[] args) {
13 | if (args.length != 4) {
14 | System.out.println("USAGE: bftsmart.tests.recovery.RecoveryTestClient " +
15 | " ");
16 | System.exit(-1);
17 | }
18 | int clientId = Integer.parseInt(args[0]);
19 | int numOperations = Integer.parseInt(args[1]);
20 | int requestSize = Integer.parseInt(args[2]);
21 | boolean isWrite = Boolean.parseBoolean(args[3]);
22 |
23 | try (ServiceProxy proxy = new ServiceProxy(clientId)) {
24 | if (isWrite) {
25 | byte[] data = new byte[requestSize];
26 | for (int i = 0; i < requestSize; i++) {
27 | data[i] = (byte) i;
28 | }
29 | ByteBuffer buffer = ByteBuffer.allocate(1 + Integer.BYTES + requestSize);
30 | buffer.put((byte) Operation.PUT.ordinal());
31 | buffer.putInt(requestSize);
32 | buffer.put(data);
33 | byte[] serializedWriteRequest = buffer.array();
34 | System.out.println("Executing experiment");
35 | for (int i = 0; i < numOperations; i++) {
36 | proxy.invokeOrdered(serializedWriteRequest);
37 | }
38 | } else {
39 | ByteBuffer buffer = ByteBuffer.allocate(1);
40 | buffer.put((byte) Operation.GET.ordinal());
41 | byte[] serializedReadRequest = buffer.array();
42 | System.out.println("Executing experiment");
43 | for (int i = 0; i < numOperations; i++) {
44 | byte[] response = proxy.invokeUnordered(serializedReadRequest);
45 | for (int j = 0; j < requestSize; j++) {
46 | if (response[j] != (byte) j) {
47 | throw new IllegalStateException("The response is wrong");
48 | }
49 | }
50 | }
51 | }
52 | }
53 |
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/statemanagement/durability/CSTSMMessage.java:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2007-2013 Alysson Bessani, Eduardo Alchieri, Paulo Sousa, and the authors indicated in the @author tags
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package bftsmart.statemanagement.durability;
17 |
18 | import java.io.IOException;
19 | import java.io.ObjectInput;
20 | import java.io.ObjectOutput;
21 |
22 | import bftsmart.reconfiguration.views.View;
23 | import bftsmart.statemanagement.ApplicationState;
24 | import bftsmart.statemanagement.SMMessage;
25 |
26 | public class CSTSMMessage extends SMMessage {
27 |
28 | private CSTRequestF1 cstConfig;
29 |
30 | public CSTSMMessage(int sender, int cid, int type, CSTRequestF1 cstConfig, ApplicationState state, View view, int regency, int leader) {
31 | super(sender, cid, type, state, view, regency, leader);
32 | this.cstConfig = cstConfig;
33 | }
34 |
35 | public CSTSMMessage() {
36 | super();
37 | }
38 |
39 | public CSTRequestF1 getCstConfig() {
40 | return cstConfig;
41 | }
42 |
43 | @Override
44 | public void writeExternal(ObjectOutput out) throws IOException{
45 | super.writeExternal(out);
46 | out.writeObject(cstConfig);
47 | }
48 |
49 | @Override
50 | public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException{
51 | super.readExternal(in);
52 | cstConfig = (CSTRequestF1)in.readObject();
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/reconfiguration/VMMessage.java:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2007-2013 Alysson Bessani, Eduardo Alchieri, Paulo Sousa, and the authors indicated in the @author tags
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package bftsmart.reconfiguration;
17 |
18 | import java.io.IOException;
19 | import java.io.ObjectInput;
20 | import java.io.ObjectOutput;
21 |
22 | import bftsmart.communication.SystemMessage;
23 |
24 | /**
25 | *
26 | * @author eduardo
27 | */
28 | public class VMMessage extends SystemMessage{
29 | private ReconfigureReply reply;
30 |
31 | public VMMessage(){}
32 |
33 | public VMMessage(ReconfigureReply reply){
34 | super();
35 | this.reply = reply;
36 | }
37 |
38 | public VMMessage(int from, ReconfigureReply reply){
39 | super(from);
40 | this.reply = reply;
41 | }
42 |
43 |
44 | // Implemented method of the Externalizable interface
45 | @Override
46 | public void writeExternal(ObjectOutput out) throws IOException {
47 | super.writeExternal(out);
48 | out.writeObject(reply);
49 | }
50 |
51 | // Implemented method of the Externalizable interface
52 | @Override
53 | public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
54 | super.readExternal(in);
55 | this.reply = (ReconfigureReply) in.readObject();
56 | }
57 |
58 | public ReconfigureReply getReply() {
59 | return reply;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/tom/server/BatchExecutable.java:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2007-2013 Alysson Bessani, Eduardo Alchieri, Paulo Sousa, and the authors indicated in the @author tags
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package bftsmart.tom.server;
17 |
18 | import bftsmart.tom.MessageContext;
19 | import bftsmart.tom.core.messages.TOMMessage;
20 | import bftsmart.tom.util.TOMUtil;
21 |
22 | /**
23 | *
24 | * Executables that implement this interface will receive a batch of requests and
25 | * deliver them to the application in a deterministic way.
26 | *
27 | */
28 | public interface BatchExecutable extends Executable {
29 |
30 | /**
31 | * Execute a batch of requests.
32 | * @param command The batch of requests
33 | * @param msgCtx The context associated to each request
34 | * @return
35 | */
36 | public byte[][] executeBatch(byte[][] command, MessageContext[] msgCtx);
37 |
38 | public default TOMMessage[] executeBatch(int processID, int viewID,boolean[] isReplyHash, byte[][] command,
39 | MessageContext[] msgCtx) {
40 |
41 | TOMMessage[] replies = new TOMMessage[command.length];
42 |
43 | byte[][] results = executeBatch(command, msgCtx);
44 | byte[] result;
45 | for (int i = 0; i < results.length; i++) {
46 | if (isReplyHash[i]) {
47 | result = TOMUtil.computeHash(results[i]);
48 | } else {
49 | result = results[i];
50 | }
51 | replies[i] = getTOMMessage(processID, viewID, command[i], msgCtx[i], result);
52 | }
53 |
54 | return replies;
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/statemanagement/standard/StandardSMMessage.java:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2007-2013 Alysson Bessani, Eduardo Alchieri, Paulo Sousa, and the authors indicated in the @author tags
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package bftsmart.statemanagement.standard;
17 |
18 | import java.io.IOException;
19 | import java.io.ObjectInput;
20 | import java.io.ObjectOutput;
21 |
22 | import bftsmart.reconfiguration.views.View;
23 | import bftsmart.statemanagement.ApplicationState;
24 | import bftsmart.statemanagement.SMMessage;
25 |
26 | /**
27 | *
28 | * @author Marcel Santos
29 | *
30 | */
31 | public class StandardSMMessage extends SMMessage {
32 |
33 | private int replica;
34 |
35 | public StandardSMMessage(int sender, int cid, int type, int replica, ApplicationState state, View view, int regency, int leader) {
36 | super(sender, cid, type, state, view, regency, leader);
37 | this.replica = replica;
38 | }
39 |
40 | public StandardSMMessage() {
41 | super();
42 | }
43 |
44 | /**
45 | * Retrieves the replica that should send the state
46 | * @return The replica that should send the state
47 | */
48 | public int getReplica() {
49 | return replica;
50 | }
51 |
52 | @Override
53 | public void writeExternal(ObjectOutput out) throws IOException{
54 | super.writeExternal(out);
55 | out.writeInt(replica);
56 | }
57 |
58 | @Override
59 | public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException{
60 | super.readExternal(in);
61 | replica = in.readInt();
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/communication/server/TestSerialization.java:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2007-2013 Alysson Bessani, Eduardo Alchieri, Paulo Sousa, and the authors indicated in the @author tags
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package bftsmart.communication.server;
17 |
18 | import java.io.ByteArrayInputStream;
19 | import java.io.ByteArrayOutputStream;
20 | import java.io.DataInputStream;
21 | import java.io.DataOutputStream;
22 |
23 | import bftsmart.tom.core.messages.TOMMessage;
24 | import bftsmart.tom.core.messages.TOMMessageType;
25 |
26 |
27 |
28 | public class TestSerialization {
29 |
30 | /**
31 | * @param args the command line arguments
32 | */
33 | public static void main(String[] args) throws Exception {
34 | // TODO code application logic here
35 | TOMMessage tm = new TOMMessage(0,0,0,0, new String("abc").getBytes(),0, TOMMessageType.ORDERED_REQUEST);
36 |
37 | ByteArrayOutputStream baos = new ByteArrayOutputStream(4);
38 | DataOutputStream oos = new DataOutputStream(baos);
39 |
40 | tm.wExternal(oos);
41 | oos.flush();
42 | //oos.writeObject(tm);
43 |
44 |
45 | byte[] message = baos.toByteArray();
46 | System.out.println(message.length);
47 |
48 | ByteArrayInputStream bais = new ByteArrayInputStream(message);
49 | DataInputStream ois = new DataInputStream(bais);
50 |
51 | //TOMMessage tm2 = (TOMMessage) ois.readObject();
52 | TOMMessage tm2 = new TOMMessage();
53 | tm2.rExternal(ois);
54 |
55 | // System.out.println(new String(tm2.getContent()));
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/reconfiguration/ReconfigurationTest.java:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2007-2013 Alysson Bessani, Eduardo Alchieri, Paulo Sousa, and the authors indicated in the @author tags
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package bftsmart.reconfiguration;
17 |
18 | import bftsmart.reconfiguration.views.View;
19 |
20 | /**
21 | *
22 | * @author eduardo
23 | */
24 | public class ReconfigurationTest {
25 |
26 | public ReconfigurationTest() {
27 | }
28 |
29 | public void run(int id){
30 | /* ServiceProxy proxy = new ServiceProxy(id);
31 |
32 | ReconfigureRequest request = new ReconfigureRequest(id);
33 | request.setProperty("f","1");
34 |
35 | System.out.println("Going to send a reconf!!!");
36 |
37 | byte[] reply = proxy.invoke(TOMUtil.getBytes(request), ReconfigurationManager.TOM_RECONFIG_REQUEST, false);
38 |
39 | ReconfigureReply r = (ReconfigureReply)TOMUtil.getObject(reply);*/
40 |
41 | Reconfiguration rec = new Reconfiguration(id, "", null);
42 |
43 | //rec.setReconfiguration(ReconfigurationManager.CHANGE_F,"1");
44 | rec.setF(2);
45 |
46 | ReconfigureReply r = rec.execute();
47 |
48 |
49 |
50 | View v = r.getView();
51 |
52 | System.out.println("New view f: "+v.getF());
53 |
54 | rec.close();
55 | }
56 |
57 |
58 |
59 | public static void main(String[] args){
60 | new ReconfigurationTest().run(Integer.parseInt(args[0]));
61 | }
62 |
63 |
64 |
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/tests/normal/AbstractNormalTest.java:
--------------------------------------------------------------------------------
1 | package bftsmart.tests.normal;
2 |
3 | import bftsmart.tests.AbstractIntegrationTest;
4 | import bftsmart.tom.core.messages.TOMMessageType;
5 |
6 | import java.util.Properties;
7 |
8 | public abstract class AbstractNormalTest extends AbstractIntegrationTest {
9 | private final int nWorkers;
10 | private final String workingDirectory;
11 | private final Properties testParameters;
12 |
13 | public AbstractNormalTest(String workingDirectory, int f, boolean isBFT, boolean isUnorderedRequestEnabled,
14 | TOMMessageType requestType) {
15 | this.workingDirectory = workingDirectory;
16 | this.nWorkers = (isBFT ? 3 * f + 1 : 2 * f + 1) + 1;// +1 for a client
17 | this.testParameters = new Properties();
18 | String clientClass = getClientClass();
19 | testParameters.setProperty("experiment.clientClass", clientClass);
20 | testParameters.setProperty("experiment.requestType", requestType.name());
21 | testParameters.setProperty("experiment.f", String.valueOf(f));
22 | testParameters.setProperty("experiment.bft", Boolean.toString(isBFT));
23 | testParameters.setProperty("experiment.isUnorderedRequestEnabled", Boolean.toString(isUnorderedRequestEnabled));
24 | }
25 |
26 | public abstract String getClientClass();
27 |
28 | @Override
29 | public String getControllerIP() {
30 | return "127.0.0.1";
31 | }
32 |
33 | @Override
34 | public int getControllerPort() {
35 | return 12000;
36 | }
37 |
38 | @Override
39 | public int getNWorkers() {
40 | return nWorkers;
41 | }
42 |
43 | @Override
44 | public String getWorkingDirectory() {
45 | return workingDirectory;
46 | }
47 |
48 | @Override
49 | public String getBenchmarkStrategyClassName() {
50 | return "bftsmart.tests.normal.NormalRequestsTestStrategy";
51 | }
52 |
53 | @Override
54 | public String getWorkerSetupClassName() {
55 | return "bftsmart.tests.common.BFTSMaRtSetup";
56 | }
57 |
58 | @Override
59 | public String getWorkerEventProcessClassName() {
60 | return "bftsmart.tests.common.SimpleServiceEventProcessor";
61 | }
62 |
63 | @Override
64 | public Properties getTestParameters() {
65 | return testParameters;
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/benchmark/ThroughputEventProcessor.java:
--------------------------------------------------------------------------------
1 | package bftsmart.benchmark;
2 |
3 | import generic.DefaultMeasurementEventProcessor;
4 | import generic.IMeasurementEventProcessor;
5 | import generic.ResourcesMeasurementEventProcessor;
6 | import org.slf4j.Logger;
7 | import org.slf4j.LoggerFactory;
8 | import worker.IProcessingResult;
9 | import worker.IWorkerEventProcessor;
10 |
11 | public class ThroughputEventProcessor implements IWorkerEventProcessor {
12 | private final Logger logger = LoggerFactory.getLogger("benchmarking");
13 | private static final String SERVER_READY_PATTERN = "Ready to process operations";
14 | private static final String CLIENT_READY_PATTERN = "Executing experiment";
15 | private static final String SAR_READY_PATTERN = "%";
16 | private IMeasurementEventProcessor measurementEventProcessor;
17 |
18 | private boolean isReady;
19 | private boolean doMeasurement;
20 |
21 | public ThroughputEventProcessor() {}
22 |
23 | @Override
24 | public void process(String line) {
25 | logger.debug(line);
26 | if (!isReady) {
27 | if (line.contains(SERVER_READY_PATTERN)) {
28 | isReady = true;
29 | measurementEventProcessor = new DefaultMeasurementEventProcessor();
30 | } else if (line.contains(CLIENT_READY_PATTERN)) {
31 | isReady = true;
32 | measurementEventProcessor = new DefaultMeasurementEventProcessor();
33 | } else if (line.contains(SAR_READY_PATTERN)) {
34 | isReady = true;
35 | measurementEventProcessor = new ResourcesMeasurementEventProcessor();
36 | }
37 | }
38 | if (doMeasurement) {
39 | measurementEventProcessor.process(line);
40 | }
41 | }
42 |
43 | @Override
44 | public void startProcessing() {
45 | logger.debug("Measuring");
46 | measurementEventProcessor.reset();
47 | doMeasurement = true;
48 | }
49 |
50 | @Override
51 | public void stopProcessing() {
52 | logger.debug("Not Measuring");
53 | doMeasurement = false;
54 | }
55 |
56 | @Override
57 | public IProcessingResult getProcessingResult() {
58 | return measurementEventProcessor.getResult();
59 | }
60 |
61 | @Override
62 | public boolean isReady() {
63 | return isReady;
64 | }
65 |
66 | @Override
67 | public boolean ended() {
68 | return false;
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/communication/client/netty/NettyServerPipelineFactory.java:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2007-2013 Alysson Bessani, Eduardo Alchieri, Paulo Sousa, and the authors indicated in the @author tags
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package bftsmart.communication.client.netty;
17 |
18 | import io.netty.channel.SimpleChannelInboundHandler;
19 | import io.netty.handler.codec.ByteToMessageDecoder;
20 | import io.netty.handler.codec.MessageToByteEncoder;
21 |
22 | import java.util.HashMap;
23 | import java.util.concurrent.ConcurrentHashMap;
24 | import java.util.concurrent.locks.ReentrantReadWriteLock;
25 |
26 | import bftsmart.reconfiguration.ServerViewController;
27 |
28 | public class NettyServerPipelineFactory{
29 |
30 | NettyClientServerCommunicationSystemServerSide ncs;
31 | ConcurrentHashMap sessionTable;
32 | ServerViewController controller;
33 | ReentrantReadWriteLock rl;
34 |
35 | public NettyServerPipelineFactory(NettyClientServerCommunicationSystemServerSide ncs, ConcurrentHashMap sessionTable, ServerViewController controller, ReentrantReadWriteLock rl) {
36 | this.ncs = ncs;
37 | this.sessionTable = sessionTable;
38 | this.controller = controller;
39 | this.rl = rl;
40 | }
41 |
42 | public ByteToMessageDecoder getDecoder(){
43 | return new NettyTOMMessageDecoder(false, sessionTable,controller,rl);
44 | }
45 |
46 | public MessageToByteEncoder getEncoder(){
47 | return new NettyTOMMessageEncoder(false, sessionTable,rl);
48 | }
49 |
50 | public SimpleChannelInboundHandler getHandler(){
51 | return ncs;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/communication/client/netty/NettyClientPipelineFactory.java:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2007-2013 Alysson Bessani, Eduardo Alchieri, Paulo Sousa, and the authors indicated in the @author tags
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package bftsmart.communication.client.netty;
17 |
18 | import io.netty.channel.SimpleChannelInboundHandler;
19 | import io.netty.handler.codec.ByteToMessageDecoder;
20 | import io.netty.handler.codec.MessageToByteEncoder;
21 |
22 | import java.util.concurrent.ConcurrentHashMap;
23 | import java.util.concurrent.locks.ReentrantReadWriteLock;
24 |
25 |
26 | import bftsmart.reconfiguration.ClientViewController;
27 |
28 |
29 | public class NettyClientPipelineFactory{
30 |
31 | NettyClientServerCommunicationSystemClientSide ncs;
32 | ConcurrentHashMap sessionTable;
33 | ClientViewController controller;
34 | ReentrantReadWriteLock rl;
35 |
36 | public NettyClientPipelineFactory(NettyClientServerCommunicationSystemClientSide ncs,
37 | ConcurrentHashMap sessionTable, ClientViewController controller, ReentrantReadWriteLock rl) {
38 | this.ncs = ncs;
39 | this.sessionTable = sessionTable;
40 | this.rl = rl;
41 | this.controller = controller;
42 | }
43 |
44 |
45 | public ByteToMessageDecoder getDecoder(){
46 | return new NettyTOMMessageDecoder(true, sessionTable,
47 | controller,rl);
48 | }
49 |
50 | public MessageToByteEncoder getEncoder(){
51 | return new NettyTOMMessageEncoder(true, sessionTable,rl);
52 | }
53 |
54 | public SimpleChannelInboundHandler getHandler(){
55 | return ncs;
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/tom/server/SingleExecutable.java:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2007-2013 Alysson Bessani, Eduardo Alchieri, Paulo Sousa, and the authors indicated in the @author tags
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package bftsmart.tom.server;
17 |
18 | import bftsmart.tom.MessageContext;
19 | import bftsmart.tom.core.messages.TOMMessage;
20 | import bftsmart.tom.util.TOMUtil;
21 |
22 | /**
23 | * Executables that implement this interface will receive client requests individually.
24 | *
25 | */
26 | public interface SingleExecutable extends Executable {
27 |
28 | /**
29 | * Method called to execute a request totally ordered.
30 | *
31 | * The message context contains a lot of information about the request, such
32 | * as timestamp, nonces and sender. The code for this method MUST use the value
33 | * of timestamp instead of relying on its own local clock, and nonces instead
34 | * of trying to generated its own random values.
35 | *
36 | * This is important because this values are the same for all replicas, and
37 | * therefore, ensure the determinism required in a replicated state machine.
38 | *
39 | * @param command the command issue by the client
40 | * @param msgCtx information related with the command
41 | *
42 | * @return the reply for the request issued by the client
43 | */
44 | public byte[] executeOrdered(byte[] command, MessageContext msgCtx);
45 |
46 | public default TOMMessage executeOrdered(int processID, int viewID, boolean isReplyHash, byte[] command,
47 | MessageContext msgCtx) {
48 |
49 | byte[] result = executeOrdered(command, msgCtx);
50 |
51 | if (isReplyHash) {
52 | result = TOMUtil.computeHash(result);
53 | }
54 |
55 | return getTOMMessage(processID, viewID, command, msgCtx, result);
56 |
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/consensus/roles/Proposer.java:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2007-2013 Alysson Bessani, Eduardo Alchieri, Paulo Sousa, and the authors indicated in the @author tags
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package bftsmart.consensus.roles;
17 |
18 | import bftsmart.communication.ServerCommunicationSystem;
19 | import bftsmart.consensus.messages.MessageFactory;
20 | import bftsmart.reconfiguration.ServerViewController;
21 |
22 | /**
23 | * This class represents the proposer role in the consensus protocol.
24 | **/
25 | public class Proposer {
26 |
27 | private MessageFactory factory; // Factory for PaW messages
28 | private ServerCommunicationSystem communication; // Replicas comunication system
29 | private ServerViewController controller;
30 |
31 | /**
32 | * Creates a new instance of Proposer
33 | *
34 | * @param communication Replicas communication system
35 | * @param factory Factory for PaW messages
36 | * @param verifier Proof verifier
37 | * @param conf TOM configuration
38 | */
39 | public Proposer(ServerCommunicationSystem communication, MessageFactory factory,
40 | ServerViewController controller) {
41 | this.communication = communication;
42 | this.factory = factory;
43 | this.controller = controller;
44 | }
45 |
46 | /**
47 | * This method is called by the TOMLayer (or any other)
48 | * to start the consensus instance.
49 | *
50 | * @param cid ID for the consensus instance to be started
51 | * @param value Value to be proposed
52 | */
53 | public void startConsensus(int cid, byte[] value) {
54 | //******* EDUARDO BEGIN **************//
55 | communication.send(this.controller.getCurrentViewAcceptors(),
56 | factory.createPropose(cid, 0, value));
57 | //******* EDUARDO END **************//
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/tom/server/defaultservices/DefaultReplier.java:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2007-2013 Alysson Bessani, Eduardo Alchieri, Paulo Sousa, and the authors indicated in the @author tags
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package bftsmart.tom.server.defaultservices;
17 |
18 | import bftsmart.tom.MessageContext;
19 | import bftsmart.tom.ReplicaContext;
20 | import bftsmart.tom.core.messages.TOMMessage;
21 | import bftsmart.tom.server.Replier;
22 | import java.util.concurrent.locks.Condition;
23 | import java.util.concurrent.locks.Lock;
24 | import java.util.concurrent.locks.ReentrantLock;
25 | import org.slf4j.LoggerFactory;
26 |
27 | /**
28 | *
29 | * @author miguel
30 | */
31 | public class DefaultReplier implements Replier{
32 |
33 | private Lock replyLock = new ReentrantLock();
34 | private Condition contextSetted = replyLock.newCondition();
35 | private ReplicaContext rc;
36 |
37 | @Override
38 | public void manageReply(TOMMessage request, MessageContext msgCtx) {
39 |
40 |
41 | while (rc == null) {
42 |
43 | try {
44 |
45 | this.replyLock.lock();
46 |
47 | this.contextSetted.await();
48 |
49 | this.replyLock.unlock();
50 |
51 | } catch (InterruptedException ex) {
52 | LoggerFactory.getLogger(this.getClass()).error("Interruption while waiting/aquiring condition", ex);
53 | }
54 | }
55 |
56 | rc.getServerCommunicationSystem().send(new int[]{request.getSender()}, request.reply);
57 |
58 | }
59 |
60 | @Override
61 | public void setReplicaContext(ReplicaContext rc) {
62 |
63 | this.replyLock.lock();
64 |
65 | this.rc = rc;
66 |
67 | this.contextSetted.signalAll();
68 |
69 | this.replyLock.unlock();
70 | }
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/communication/SystemMessage.java:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2007-2013 Alysson Bessani, Eduardo Alchieri, Paulo Sousa, and the authors indicated in the @author tags
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package bftsmart.communication;
17 |
18 | import java.io.Externalizable;
19 | import java.io.IOException;
20 | import java.io.ObjectInput;
21 | import java.io.ObjectOutput;
22 |
23 | /**
24 | * This is the super-class for all other kinds of messages created by JBP
25 | *
26 | */
27 |
28 | public abstract class SystemMessage implements Externalizable {
29 |
30 | protected int sender; // ID of the process which sent the message
31 | public transient boolean authenticated; // set to TRUE if the message was received
32 | // with a (valid) mac, FALSE if no mac was given
33 | // note that if the message arrives with an
34 | // invalid MAC, it won't be delivered
35 |
36 | /**
37 | * Creates a new instance of SystemMessage
38 | */
39 | public SystemMessage(){}
40 |
41 | /**
42 | * Creates a new instance of SystemMessage
43 | * @param sender ID of the process which sent the message
44 | */
45 | public SystemMessage(int sender){
46 | this.sender = sender;
47 | }
48 |
49 | /**
50 | * Returns the ID of the process which sent the message
51 | * @return
52 | */
53 | public final int getSender() {
54 | return sender;
55 | }
56 |
57 | // This methods implement the Externalizable interface
58 | @Override
59 | public void writeExternal(ObjectOutput out) throws IOException {
60 | out.writeInt(sender);
61 | }
62 |
63 | @Override
64 | public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
65 | sender = in.readInt();
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/demo/map/MapInteractiveClient.java:
--------------------------------------------------------------------------------
1 | package bftsmart.demo.map;
2 |
3 | import java.io.Console;
4 | import java.util.Set;
5 |
6 | public class MapInteractiveClient {
7 |
8 | public static void main(String[] args) {
9 | if(args.length < 1) {
10 | System.out.println("Usage: demo.map.MapInteractiveClient ");
11 | }
12 |
13 | int clientId = Integer.parseInt(args[0]);
14 | MapClient map = new MapClient<>(clientId);
15 | Console console = System.console();
16 |
17 | boolean exit = false;
18 | String key, value, result;
19 | while(!exit) {
20 | System.out.println("Select an option:");
21 | System.out.println("0 - Terminate this client");
22 | System.out.println("1 - Insert value into the map");
23 | System.out.println("2 - Retrieve value from the map");
24 | System.out.println("3 - Removes value from the map");
25 | System.out.println("4 - Retrieve the size of the map");
26 | System.out.println("5 - List all keys available in the table");
27 |
28 | int cmd = Integer.parseInt(console.readLine("Option:"));
29 |
30 | switch (cmd) {
31 | case 0:
32 | map.close();
33 | exit = true;
34 | break;
35 | case 1:
36 | System.out.println("Putting value in the map");
37 | key = console.readLine("Enter the key:");
38 | value = console.readLine("Enter the value:");
39 | result = map.put(key, value);
40 | System.out.println("Previous value: " + result);
41 | break;
42 | case 2:
43 | System.out.println("Reading value from the map");
44 | key = console.readLine("Enter the key:");
45 | result = map.get(key);
46 | System.out.println("Value read: " + result);
47 | break;
48 | case 3:
49 | System.out.println("Removing value in the map");
50 | key = console.readLine("Enter the key:");
51 | result = map.remove(key);
52 | System.out.println("Value removed: " + result);
53 | break;
54 | case 4:
55 | System.out.println("Getting the map size");
56 | int size = map.size();
57 | System.out.println("Map size: " + size);
58 | break;
59 | case 5:
60 | System.out.println("Getting all keys");
61 | Set keys = map.keySet();
62 | System.out.println("Total number of keys found: " + keys.size());
63 | for (String k : keys)
64 | System.out.println("---> " + k);
65 | break;
66 | default:
67 | break;
68 | }
69 | }
70 | }
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/statemanagement/durability/StateSenderServer.java:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2007-2013 Alysson Bessani, Eduardo Alchieri, Paulo Sousa, and the authors indicated in the @author tags
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package bftsmart.statemanagement.durability;
17 |
18 | import java.io.IOException;
19 | import java.net.ServerSocket;
20 | import java.net.Socket;
21 |
22 | import bftsmart.statemanagement.ApplicationState;
23 | import bftsmart.tom.server.Recoverable;
24 | import bftsmart.tom.server.durability.DurabilityCoordinator;
25 |
26 | import org.slf4j.Logger;
27 | import org.slf4j.LoggerFactory;
28 |
29 | public class StateSenderServer implements Runnable {
30 |
31 | private Logger logger = LoggerFactory.getLogger(this.getClass());
32 |
33 | private ServerSocket server;
34 | private ApplicationState state;
35 | private Recoverable recoverable;
36 | private DurabilityCoordinator coordinator;
37 | private CSTRequest request;
38 |
39 | public void setState(ApplicationState state) {
40 | this.state = state;
41 | }
42 |
43 | public void setRecoverable(Recoverable recoverable) {
44 | this.recoverable = recoverable;
45 | coordinator = (DurabilityCoordinator)(recoverable);
46 | }
47 |
48 | public void setRequest(CSTRequest request) {
49 | this.request = request;
50 | }
51 |
52 | public StateSenderServer(int port) {
53 | try {
54 | server = new ServerSocket(port);
55 | } catch (IOException e) {
56 | // TODO Auto-generated catch block
57 | logger.error("Could not open server socket",e);
58 | }
59 | }
60 |
61 | @Override
62 | public void run() {
63 | try {
64 | Socket socket = server.accept();
65 | StateSender sender = new StateSender(socket);
66 | state = coordinator.getState(request);
67 | sender.setState(state);
68 | new Thread(sender).start();
69 | } catch (IOException e) {
70 | logger.error("Problem executing StateSenderServer thread",e);
71 | }
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/tom/server/Executable.java:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2007-2013 Alysson Bessani, Eduardo Alchieri, Paulo Sousa, and the authors indicated in the @author tags
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package bftsmart.tom.server;
17 |
18 | import bftsmart.tom.MessageContext;
19 | import bftsmart.tom.core.messages.TOMMessage;
20 | import bftsmart.tom.util.TOMUtil;
21 |
22 | /**
23 | *
24 | * Executables that implement this interface can received unordered client requests.
25 | * To support ordered requests, objects that implement this interface must also implement
26 | * either 'FIFOExecutable', 'BatchExecutable' or 'SingleExecutable'.
27 | *
28 | */
29 | public interface Executable {
30 |
31 | /**
32 | * Method called to execute a request totally ordered.
33 | *
34 | * The message context contains some useful information such as the command
35 | * sender.
36 | *
37 | * @param command the command issue by the client
38 | * @param msgCtx information related with the command
39 | *
40 | * @return the reply for the request issued by the client
41 | */
42 | public byte[] executeUnordered(byte[] command, MessageContext msgCtx);
43 |
44 | default TOMMessage getTOMMessage(int processID, int viewID, byte[] command, MessageContext msgCtx, byte[] result) {
45 |
46 | TOMMessage reply = msgCtx.recreateTOMMessage(command);
47 | reply.reply = new TOMMessage(processID, reply.getSession(), reply.getSequence(), reply.getOperationId(),
48 | result, viewID, reply.getReqType());
49 |
50 | return reply;
51 | }
52 |
53 | public default TOMMessage executeUnordered(int processID, int viewID, boolean isReplyHash, byte[] command, MessageContext msgCtx) {
54 |
55 | byte[] result = executeUnordered(command, msgCtx);
56 |
57 | if (isReplyHash) result = TOMUtil.computeHash(result);
58 |
59 | return getTOMMessage(processID, viewID, command, msgCtx, result);
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/reconfiguration/View.java:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2007-2013 Alysson Bessani, Eduardo Alchieri, Paulo Sousa, and the authors indicated in the @author tags
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package bftsmart.reconfiguration;
17 |
18 | import java.io.Serializable;
19 | import java.util.Arrays;
20 | import java.net.InetSocketAddress;
21 | import java.util.HashMap;
22 | import java.util.Map;
23 |
24 | /**
25 | *
26 | * @author eduardo
27 | */
28 | public class View implements Serializable {
29 |
30 | private static final long serialVersionUID = 1466870385442069307L;
31 |
32 | private int id;
33 | private int f;
34 | private int[] processes;
35 | private Map addresses;
36 |
37 | public View(int id, int[] processes, int f, InetSocketAddress[] addresses){
38 | this.id = id;
39 | this.processes = processes;
40 | this.addresses = new HashMap();
41 |
42 | for(int i = 0; i < this.processes.length;i++)
43 | this.addresses.put(processes[i],addresses[i]);
44 | Arrays.sort(this.processes);
45 | this.f = f;
46 | }
47 |
48 | public boolean isMember(int id){
49 | for(int i = 0; i < this.processes.length;i++){
50 | if(this.processes[i] == id){
51 | return true;
52 | }
53 | }
54 | return false;
55 | }
56 |
57 |
58 | public int getPos(int id){
59 | for(int i = 0; i < this.processes.length;i++){
60 | if(this.processes[i] == id){
61 | return i;
62 | }
63 | }
64 | return -1;
65 | }
66 |
67 | public int getId() {
68 | return id;
69 | }
70 |
71 | public int getF() {
72 | return f;
73 | }
74 |
75 | public int getN(){
76 | return this.processes.length;
77 | }
78 |
79 | public int[] getProcesses() {
80 | return processes;
81 | }
82 |
83 | @Override
84 | public String toString(){
85 | String ret = "ID:"+id+"; F:"+f+"; Processes:";
86 | for(int i = 0; i < processes.length;i++){
87 | ret = ret+processes[i]+"("+addresses.get(processes[i])+"),";
88 | }
89 |
90 | return ret;
91 | }
92 | public InetSocketAddress getAddress(int id) {
93 | return addresses.get(id);
94 | }
95 |
96 | }
97 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/tom/core/messages/ForwardedMessage.java:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2007-2013 Alysson Bessani, Eduardo Alchieri, Paulo Sousa, and the authors indicated in the @author tags
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package bftsmart.tom.core.messages;
17 |
18 | import java.io.IOException;
19 | import java.io.ObjectInput;
20 | import java.io.ObjectOutput;
21 |
22 | import bftsmart.communication.SystemMessage;
23 |
24 |
25 |
26 | /**
27 | * Message used to forward a client request to the current leader when the first
28 | * timeout for this request is triggered (see RequestTimer).
29 | *
30 | */
31 | public final class ForwardedMessage extends SystemMessage {
32 |
33 | private TOMMessage request;
34 |
35 | public ForwardedMessage() {
36 | }
37 |
38 | public ForwardedMessage(int senderId, TOMMessage request) {
39 | super(senderId);
40 | this.request = request;
41 | }
42 |
43 | public TOMMessage getRequest() {
44 | return request;
45 | }
46 |
47 | @Override
48 | public void writeExternal(ObjectOutput out) throws IOException {
49 | super.writeExternal(out);
50 |
51 | out.writeInt(request.serializedMessage.length);
52 | out.write(request.serializedMessage);
53 | out.writeBoolean(request.signed);
54 |
55 | if (request.signed) {
56 | out.writeInt(request.serializedMessageSignature.length);
57 | out.write(request.serializedMessageSignature);
58 | }
59 | }
60 |
61 | @Override
62 | public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
63 | super.readExternal(in);
64 |
65 | byte[] serReq = new byte[in.readInt()];
66 | in.readFully(serReq);
67 |
68 | request = TOMMessage.bytesToMessage(serReq);
69 | request.serializedMessage = serReq;
70 |
71 | boolean signed = in.readBoolean();
72 |
73 | if (signed) {
74 |
75 | byte[] serReqSign = new byte[in.readInt()];
76 | in.readFully(serReqSign);
77 | request.serializedMessageSignature = serReqSign;
78 |
79 | }
80 | }
81 |
82 | }
83 |
--------------------------------------------------------------------------------
/docs/javadoc/jquery/jszip-utils/dist/jszip-utils-ie.js:
--------------------------------------------------------------------------------
1 | /*!
2 |
3 | JSZipUtils - A collection of cross-browser utilities to go along with JSZip.
4 |
5 |
6 | (c) 2014 Stuart Knightley, David Duponchel
7 | Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip-utils/master/LICENSE.markdown.
8 |
9 | */
10 | ;(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o\r\n"+
18 | "\r\n";
32 |
33 | // inject VBScript
34 | document.write(IEBinaryToArray_ByteStr_Script);
35 |
36 | global.JSZipUtils._getBinaryFromXHR = function (xhr) {
37 | var binary = xhr.responseBody;
38 | var byteMapping = {};
39 | for ( var i = 0; i < 256; i++ ) {
40 | for ( var j = 0; j < 256; j++ ) {
41 | byteMapping[ String.fromCharCode( i + (j << 8) ) ] =
42 | String.fromCharCode(i) + String.fromCharCode(j);
43 | }
44 | }
45 | var rawBytes = IEBinaryToArray_ByteStr(binary);
46 | var lastChr = IEBinaryToArray_ByteStr_Last(binary);
47 | return rawBytes.replace(/[\s\S]/g, function( match ) {
48 | return byteMapping[match];
49 | }) + lastChr;
50 | };
51 |
52 | // enforcing Stuk's coding style
53 | // vim: set shiftwidth=4 softtabstop=4:
54 |
55 | },{}]},{},[1])
56 | ;
57 |
--------------------------------------------------------------------------------
/config/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
7 |
8 |
9 |
10 |
11 |
12 | System.out
13 |
14 | INFO
15 | ACCEPT
16 | NEUTRAL
17 |
18 |
19 | DEBUG
20 | ACCEPT
21 | DENY
22 |
23 |
24 | -- %msg%n
25 |
26 |
27 |
28 |
29 | System.err
30 |
31 | WARN
32 |
33 |
34 | -- %msg%n
35 |
36 |
37 |
38 |
39 |
40 |
41 | 1000
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
75 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/tom/ReplicaContext.java:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2007-2013 Alysson Bessani, Eduardo Alchieri, Paulo Sousa, and the authors indicated in the @author tags
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package bftsmart.tom;
17 |
18 | import bftsmart.communication.ServerCommunicationSystem;
19 | import bftsmart.reconfiguration.ServerViewController;
20 | import bftsmart.reconfiguration.util.TOMConfiguration;
21 | import bftsmart.reconfiguration.views.View;
22 |
23 | /**
24 | * This class contains information related to the replica.
25 | *
26 | */
27 | public class ReplicaContext {
28 |
29 | private ServerCommunicationSystem cs; // Server side comunication system
30 | private ServerViewController SVController;
31 |
32 | /**
33 | * Constructor
34 | *
35 | * @param cs
36 | * @param SVController
37 | */
38 | public ReplicaContext(ServerCommunicationSystem cs,
39 | ServerViewController SVController) {
40 | this.cs = cs;
41 | this.SVController = SVController;
42 | }
43 |
44 | /**
45 | * Returns the controller of the replica's view
46 | * @return The controller of the replica's view
47 | */
48 | public ServerViewController getSVController() {
49 | return SVController;
50 | }
51 |
52 | //TODO: implement a method that allow the replica to send a message with
53 | //total order to all other replicas
54 |
55 | /**
56 | * Returns the static configuration of this replica.
57 | *
58 | * @return the static configuration of this replica
59 | */
60 | public TOMConfiguration getStaticConfiguration() {
61 | return SVController.getStaticConf();
62 | }
63 |
64 | /**
65 | * Returns the current view of the replica group.
66 | *
67 | * @return the current view of the replica group.
68 | */
69 | public View getCurrentView() {
70 | return SVController.getCurrentView();
71 | }
72 |
73 | /**
74 | * Returns the replica's communication system
75 | * @return The replica's communication system
76 | */
77 | public ServerCommunicationSystem getServerCommunicationSystem() {
78 | return cs;
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/demo/counter/CounterClient.java:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright (c) 2007-2013 Alysson Bessani, Eduardo Alchieri, Paulo Sousa, and the authors indicated in the @author tags
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | */
16 | package bftsmart.demo.counter;
17 |
18 | import java.io.ByteArrayInputStream;
19 | import java.io.ByteArrayOutputStream;
20 | import java.io.DataInputStream;
21 | import java.io.DataOutputStream;
22 | import java.io.IOException;
23 |
24 | import bftsmart.tom.ServiceProxy;
25 |
26 | /**
27 | * Example client that updates a BFT replicated service (a counter).
28 | *
29 | * @author alysson
30 | */
31 | public class CounterClient {
32 |
33 | public static void main(String[] args) throws IOException {
34 | if (args.length < 2) {
35 | System.out.println("Usage: java ... CounterClient []");
36 | System.out.println(" if equals 0 the request will be read-only");
37 | System.out.println(" default equals 1000");
38 | System.exit(-1);
39 | }
40 |
41 | try (ServiceProxy counterProxy = new ServiceProxy(Integer.parseInt(args[0]))) {
42 | int inc = Integer.parseInt(args[1]);
43 | int numberOfOps = (args.length > 2) ? Integer.parseInt(args[2]) : 1000;
44 |
45 | for (int i = 0; i < numberOfOps; i++) {
46 |
47 | ByteArrayOutputStream out = new ByteArrayOutputStream(4);
48 | new DataOutputStream(out).writeInt(inc);
49 |
50 | System.out.print("Invocation " + i);
51 | byte[] reply = (inc == 0)?
52 | counterProxy.invokeUnordered(out.toByteArray()):
53 | counterProxy.invokeOrdered(out.toByteArray()); //magic happens here
54 |
55 | if(reply != null) {
56 | int newValue = new DataInputStream(new ByteArrayInputStream(reply)).readInt();
57 | System.out.println(", returned value: " + newValue);
58 | } else {
59 | System.out.println(", ERROR! Exiting.");
60 | break;
61 | }
62 | }
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/tom/client/HashedRequestHandler.java:
--------------------------------------------------------------------------------
1 | package bftsmart.tom.client;
2 |
3 | import bftsmart.tom.core.messages.TOMMessage;
4 | import bftsmart.tom.core.messages.TOMMessageType;
5 | import bftsmart.tom.util.TOMUtil;
6 |
7 | import java.util.ArrayList;
8 | import java.util.Arrays;
9 | import java.util.List;
10 |
11 | public class HashedRequestHandler extends AbstractRequestHandler {
12 | private final int replyServer;
13 | private final List hashReplies;
14 | private byte[] replyServerResponseHash;
15 | private int fullResponseIndex;
16 |
17 | public HashedRequestHandler(int me, int session, int sequenceId, int operationId, int viewId,
18 | TOMMessageType requestType, int timeout, int[] replicas,
19 | int replyQuorumSize, int replyServer) {
20 | super(me, session, sequenceId, operationId, viewId, requestType, timeout, replicas, replyQuorumSize);
21 | this.replyServer = replyServer;
22 | this.hashReplies = new ArrayList<>(replicas.length);
23 | this.fullResponseIndex = -1;
24 | }
25 |
26 | @Override
27 | public TOMMessage createRequest(byte[] request) {
28 | TOMMessage requestMessage = new TOMMessage(me, session, sequenceId, operationId, request, viewId, requestType);
29 | requestMessage.setReplyServer(replyServer);
30 | return requestMessage;
31 | }
32 |
33 | @Override
34 | public TOMMessage processReply(TOMMessage reply, int lastSenderIndex) {
35 | byte[] replyContentHash;
36 | if (reply.getSender() == replyServer) {
37 | fullResponseIndex = lastSenderIndex;
38 | replyContentHash = TOMUtil.computeHash(reply.getContent());
39 | replyServerResponseHash = replyContentHash;
40 | } else {
41 | replyContentHash = reply.getContent();
42 | }
43 |
44 | hashReplies.add(replyContentHash);
45 | logger.debug("hash of reply from {}: {}", reply.getSender(), Arrays.toString(replyContentHash));
46 |
47 | //optimization - compare responses after having a quorum of replies and response from reply server
48 | if (replyServerResponseHash == null || replySenders.size() < replyQuorumSize) {
49 | return null;
50 | }
51 | logger.debug("Comparing {} hash responses with response from {}", replySenders.size(), replyServer);
52 | int sameContent = 0;
53 | for (byte[] hash : hashReplies) {
54 | if (Arrays.equals(hash, replyServerResponseHash)) {
55 | sameContent++;
56 | if (sameContent >= replyQuorumSize) {
57 | return replies[fullResponseIndex];
58 | }
59 | }
60 | }
61 |
62 | return null;
63 | }
64 |
65 | @Override
66 | public void printState() {
67 | for (int i = 0; i < hashReplies.size(); i++) {
68 | logger.info("hash of reply from {}: {} | {}", i, Arrays.hashCode(hashReplies.get(i)),
69 | Arrays.toString(hashReplies.get(i)));
70 | }
71 | logger.info("Have received response from reply server {}: {}", replyServer, replyServerResponseHash != null);
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/src/main/java/bftsmart/tests/AbstractIntegrationTest.java:
--------------------------------------------------------------------------------
1 | package bftsmart.tests;
2 |
3 | import bftsmart.tests.util.ProcessExecutor;
4 | import controller.BenchmarkControllerStartup;
5 |
6 | import java.io.File;
7 | import java.util.Map;
8 | import java.util.Properties;
9 |
10 | public abstract class AbstractIntegrationTest {
11 |
12 | public AbstractIntegrationTest() {}
13 |
14 | public void executeTest() throws Exception {
15 | Properties testParameters = getTestParameters();
16 | Properties properties = new Properties();
17 | for (Map.Entry