mirror of
https://github.com/codex-storage/das-research.git
synced 2025-02-21 15:28:09 +00:00
adding failureModes with special erasure patterns
Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
parent
3e822ab6ca
commit
91050ca19a
@ -3,11 +3,12 @@
|
||||
class Shape:
|
||||
"""This class represents a set of parameters for a specific simulation."""
|
||||
|
||||
def __init__(self, blockSize, numberNodes, failureRate, class1ratio, chi, vpn1, vpn2, netDegree, bwUplinkProd, bwUplink1, bwUplink2, run):
|
||||
def __init__(self, blockSize, numberNodes, failureModel, failureRate, class1ratio, chi, vpn1, vpn2, netDegree, bwUplinkProd, bwUplink1, bwUplink2, run):
|
||||
"""Initializes the shape with the parameters passed in argument."""
|
||||
self.run = run
|
||||
self.numberNodes = numberNodes
|
||||
self.blockSize = blockSize
|
||||
self.failureModel = failureModel
|
||||
self.failureRate = failureRate
|
||||
self.netDegree = netDegree
|
||||
self.class1ratio = class1ratio
|
||||
@ -24,6 +25,7 @@ class Shape:
|
||||
shastr = ""
|
||||
shastr += "bs-"+str(self.blockSize)
|
||||
shastr += "-nn-"+str(self.numberNodes)
|
||||
shastr += "-fm-"+str(self.failureModel)
|
||||
shastr += "-fr-"+str(self.failureRate)
|
||||
shastr += "-c1r-"+str(self.class1ratio)
|
||||
shastr += "-chi-"+str(self.chi)
|
||||
|
@ -122,10 +122,54 @@ class Validator:
|
||||
self.logger.warning("I am not a block proposer", extra=self.format)
|
||||
else:
|
||||
self.logger.debug("Creating block...", extra=self.format)
|
||||
order = [i for i in range(self.shape.blockSize * self.shape.blockSize)]
|
||||
order = random.sample(order, int((1 - self.shape.failureRate/100) * len(order)))
|
||||
for i in order:
|
||||
self.block.data[i] = 1
|
||||
if self.shape.failureModel == "random":
|
||||
order = [i for i in range(self.shape.blockSize * self.shape.blockSize)]
|
||||
order = random.sample(order, int((1 - self.shape.failureRate/100) * len(order)))
|
||||
for i in order:
|
||||
self.block.data[i] = 1
|
||||
elif self.shape.failureModel == "sequential":
|
||||
order = order[:int((1 - self.shape.failureRate/100) * len(order))]
|
||||
for i in order:
|
||||
self.block.data[i] = 1
|
||||
elif self.shape.failureModel == "MEP": # Minimal size non-recoverable Erasure Pattern
|
||||
for r in range(self.shape.blockSize):
|
||||
for c in range(self.shape.blockSize):
|
||||
k = self.shape.blockSize/2
|
||||
if r > k or c > k:
|
||||
self.block.setSegment(r,c)
|
||||
elif self.shape.failureModel == "MEP+1": # MEP +1 segment to make it recoverable
|
||||
for r in range(self.shape.blockSize):
|
||||
for c in range(self.shape.blockSize):
|
||||
k = self.shape.blockSize/2
|
||||
if r > k or c > k:
|
||||
self.block.setSegment(r,c)
|
||||
self.block.setSegment(0, 0)
|
||||
elif self.shape.failureModel == "DEP":
|
||||
for r in range(self.shape.blockSize):
|
||||
for c in range(self.shape.blockSize):
|
||||
k = self.shape.blockSize/2
|
||||
if (r+c) % self.shape.blockSize > k:
|
||||
self.block.setSegment(r,c)
|
||||
elif self.shape.failureModel == "DEP+1":
|
||||
for r in range(self.shape.blockSize):
|
||||
for c in range(self.shape.blockSize):
|
||||
k = self.shape.blockSize/2
|
||||
if (r+c) % self.shape.blockSize > k:
|
||||
self.block.setSegment(r,c)
|
||||
self.block.setSegment(0, 0)
|
||||
elif self.shape.failureModel == "MREP": # Minimum size Recoverable Erasure Pattern
|
||||
for r in range(self.shape.blockSize):
|
||||
for c in range(self.shape.blockSize):
|
||||
k = self.shape.blockSize/2
|
||||
if r < k and c < k:
|
||||
self.block.setSegment(r,c)
|
||||
elif self.shape.failureModel == "MREP-1": # make MREP non-recoverable
|
||||
for r in range(self.shape.blockSize):
|
||||
for c in range(self.shape.blockSize):
|
||||
k = self.shape.blockSize/2
|
||||
if r < k and c < k:
|
||||
self.block.setSegment(r,c)
|
||||
self.block.setSegment(0, 0, 0)
|
||||
|
||||
nbFailures = self.block.data.count(0)
|
||||
measuredFailureRate = nbFailures * 100 / (self.shape.blockSize * self.shape.blockSize)
|
||||
|
@ -39,6 +39,9 @@ runs = range(2)
|
||||
# Number of validators
|
||||
numberNodes = range(256, 513, 128)
|
||||
|
||||
# select failure model between: "random, sequential, MEP, MEP+1, DEP, DEP+1, MREP, MREP-1"
|
||||
failureModels = ["random"]
|
||||
|
||||
# Percentage of block not released by producer
|
||||
failureRates = range(10, 91, 40)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user