File tree 2 files changed +11
-1
lines changed
simulator/src/main/java/byzzbench/simulator
2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -166,6 +166,15 @@ public synchronized Node getNode(String nodeId) {
166
166
@ Override
167
167
public final void setupScenario () {
168
168
this .setup ();
169
+
170
+ // sample f replicas to be faulty at start
171
+ List <String > replicaIds = new ArrayList <>(this .getReplicas ().keySet ());
172
+ Collections .shuffle (replicaIds );
173
+ int f = this .maxFaultyReplicas ();
174
+ for (int i = 0 ; i < f ; i ++) {
175
+ this .markReplicaFaulty (replicaIds .get (i ));
176
+ }
177
+
169
178
this .getClients ().values ().forEach (Client ::initialize );
170
179
this .getNodes ().values ().forEach (Node ::initialize );
171
180
this .scheduler .initializeScenario (this );
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ public List<Fault> generateFaults(FaultContext input) {
37
37
int d = scheduler .getNumRoundsWithNetworkFaults ();
38
38
int r = scheduler .getNumRoundsWithFaults ();
39
39
Set <String > replicaIds = scenario .getReplicas ().keySet ();
40
+ Set <String > faultyReplicaIds = scenario .getFaultyReplicaIds ();
40
41
41
42
// Create network faults
42
43
for (int i = 1 ; i <= d ; i ++) {
@@ -49,7 +50,7 @@ public List<Fault> generateFaults(FaultContext input) {
49
50
// Create process faults
50
51
for (int i = 1 ; i <= c ; i ++) {
51
52
int round = rand .nextInt (r ) + 1 ;
52
- String sender = replicaIds . stream ().skip (rand .nextInt (replicaIds .size ())).findFirst ().orElseThrow ();
53
+ String sender = input . getScenario (). getFaultyReplicaIds (). stream ().skip (rand .nextInt (faultyReplicaIds .size ())).findFirst ().orElseThrow ();
53
54
Set <String > recipientIds = SetSubsets .getRandomNonEmptySubset (replicaIds );
54
55
55
56
// generate process fault
You can’t perform that action at this time.
0 commit comments