public class AutoReplication extends Object implements PeerMapChangeListener, ReplicationFactor
| Constructor and Description |
|---|
AutoReplication(Peer peer)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
static double |
bestSmoothingFactor(ArrayList<Integer> x,
ArrayList<Double> y)
The interval length which results in maximum value of R squared is
considered to be the best solution for the smoothing factor.
|
static double |
choose(int n,
int k)
nCR (ohne Zurücklegen, ohne Beachtung der Reihenfolge)
http://stackoverflow.com/questions/1678690/what-is-a-good-way-to-
implement-choose-notation-in-java
|
static double |
ema(ArrayList<Integer> observations,
ArrayList<Double> emas)
Exponential Moving Average with Dynamic Smoothing Factor
|
static double |
linearRegression(ArrayList<Integer> x,
ArrayList<Double> y,
int n)
LinearRegression, adapted from:
http://introcs.cs.princeton.edu/java/97data/LinearRegression.java.html
|
int |
maxReplicationFactor() |
AutoReplication |
maxReplicationFactor(int maxReplicationFactor) |
int |
minReplicationFactor() |
AutoReplication |
minReplicationFactor(int minReplicationFactor) |
int |
observationLength() |
AutoReplication |
observationLength(int observationLength) |
void |
peerInserted(PeerAddress peerAddress,
boolean verified) |
int |
peerMapSize() |
void |
peerRemoved(PeerAddress peerAddress,
PeerStatistic storedPeerAddress) |
void |
peerUpdated(PeerAddress peerAddress,
PeerStatistic storedPeerAddress) |
static int |
predictedValue(ArrayList<Integer> observations,
double currentAverage)
Exponential Moving Average with Dynamic Smoothing Factor plus Deviation
|
double |
reliability() |
AutoReplication |
reliability(double reliability) |
int |
replicationFactor() |
static int |
replicationFactor(int m,
int n,
double r,
int minReplicationFactor,
int maxReplicationFactor)
Calculate the replication factor given the reliability within a churn
interval and the (predicted) number of peers that left the system.
|
static int |
replicationFactor2(int m,
int n,
double r,
int minReplicationFactor,
int maxReplicationFactor)
Calculate the replication factor given the reliability within a churn
interval and the (predicted) number of peers that left the system.
|
AutoReplication |
shutdown() |
static double |
standardDeviation(ArrayList<Integer> range,
double average)
Calculation of sample standard deviation for a set of values.
|
AutoReplication |
start() |
public AutoReplication(Peer peer)
reliability - The reliabilitypeerMap - The map of my neighborspublic AutoReplication start()
public AutoReplication shutdown()
public void peerInserted(PeerAddress peerAddress, boolean verified)
peerInserted in interface PeerMapChangeListenerpublic void peerUpdated(PeerAddress peerAddress, PeerStatistic storedPeerAddress)
peerUpdated in interface PeerMapChangeListenerpublic void peerRemoved(PeerAddress peerAddress, PeerStatistic storedPeerAddress)
peerRemoved in interface PeerMapChangeListenerpublic AutoReplication reliability(double reliability)
public double reliability()
public AutoReplication minReplicationFactor(int minReplicationFactor)
public int minReplicationFactor()
public AutoReplication maxReplicationFactor(int maxReplicationFactor)
public int maxReplicationFactor()
public AutoReplication observationLength(int observationLength)
public int observationLength()
public int peerMapSize()
public int replicationFactor()
replicationFactor in interface ReplicationFactorpublic static int replicationFactor(int m,
int n,
double r,
int minReplicationFactor,
int maxReplicationFactor)
m - (predicted) number of peers that left the systemn - number of all peersr - reliabilityminReplicationFactor - the minimal replication factor, not considering the
reliabilitymaxReplicationFactor - the maximal replication factor, not considering the
reliabilitypublic static double choose(int n,
int k)
n - k - public static int replicationFactor2(int m,
int n,
double r,
int minReplicationFactor,
int maxReplicationFactor)
m - (predicted) number of peers that left the systemn - number of all peersr - reliabilityminReplicationFactor - the minimal replication factor, not considering the
reliabilitymaxReplicationFactor - the maximal replication factor, not considering the
reliabilitypublic static double bestSmoothingFactor(ArrayList<Integer> x, ArrayList<Double> y)
x - The array of independent values, i.e. observationsy - The array of dependent values, i.e. averagespublic static double linearRegression(ArrayList<Integer> x, ArrayList<Double> y, int n)
x - The array of independent values, i.e. observationsy - The array of dependent values, i.e. averagesinterval - How much values should be consideredpublic static double ema(ArrayList<Integer> observations, ArrayList<Double> emas)
observations - Array that contains peer departures numbers.emas - Array that contains values of exponential moving averagesinterval - The length of interval that is used to calculate smoothing
factorpublic static double standardDeviation(ArrayList<Integer> range, double average)
range - A set of valuescurrentAverage - Average value for the setpublic static int predictedValue(ArrayList<Integer> observations, double currentAverage)
observations - Array that contains recent peer departures numbers.currentAverage - Current exponential moving averageinterval - The length of interval that is used to calculate deviationCopyright © 2014. All rights reserved.