public class DemandProfile extends AbstractDemandProfile
AbstractDemandProfile maintains
the demand profile for a single name and returns it as a JSONObject
via its getStats() method. The specification of its methods is in the
documentation of AbstractDemandProfile.| Modifier and Type | Class and Description |
|---|---|
protected static class |
DemandProfile.Keys |
| Modifier and Type | Field and Description |
|---|---|
protected double |
interArrivalTime |
protected DemandProfile |
lastReconfiguredProfile |
protected long |
lastRequestTime |
protected static long |
minReconfigurationInterval
The minimum amount of time (ms) that must elapse since the previous
reconfiguration before the next reconfiguration can happen.
|
protected static int |
minRequestsBeforeDemandReport
The minimum number of requests after which a demand report will be sent
to reconfigurators.
|
protected static long |
minRequestsBeforeReconfiguration
The minimum number of requests between two successive reconfigurations.
|
protected int |
numRequests |
protected int |
numTotalRequests |
name| Constructor and Description |
|---|
DemandProfile(DemandProfile dp)
Deep copy constructor.
|
DemandProfile(org.json.JSONObject json)
All
AbstractDemandProfile instances must be constructible from a
JSONObject. |
DemandProfile(java.lang.String name)
The string argument
name is the service name for which this
demand profile is being maintained. |
| Modifier and Type | Method and Description |
|---|---|
void |
combine(AbstractDemandProfile dp)
Combine the new information in
update into this. |
static DemandProfile |
createDemandProfile(java.lang.String name) |
org.json.JSONObject |
getDemandStats()
All relevant stats must be serializable into JSONObject.
|
double |
getNumRequests() |
double |
getNumTotalRequests() |
double |
getRequestRate() |
void |
justReconfigured()
Tells
this that the current demand profile was just used to
perform reconfiguration. |
static void |
main(java.lang.String[] args) |
java.util.Set<java.lang.String> |
reconfigure(java.util.Set<java.lang.String> curActives,
ReconfigurableAppInfo nodeConfig)
The main reconfiguration policy invoked at reconfigurators (not active
replicas).
|
boolean |
shouldReportDemandStats(Request request,
java.net.InetAddress sender,
ReconfigurableAppInfo nodeConfig)
This method is used to inform the reconfiguration policy that
request received from a client at IP address sender. |
clone, createDemandProfile, createDemandProfile, getName, resetprotected static int minRequestsBeforeDemandReport
protected static long minReconfigurationInterval
protected static long minRequestsBeforeReconfiguration
protected double interArrivalTime
protected long lastRequestTime
protected int numRequests
protected int numTotalRequests
protected DemandProfile lastReconfiguredProfile
public DemandProfile(java.lang.String name)
name is the service name for which this
demand profile is being maintained.name - public DemandProfile(DemandProfile dp)
dp such that the newly
constructed DemandProfile instance dpCopy != dp but dpCopy.equals(dp).dp - public DemandProfile(org.json.JSONObject json)
throws org.json.JSONException
AbstractDemandProfile instances must be constructible from a
JSONObject.json - org.json.JSONExceptionpublic static DemandProfile createDemandProfile(java.lang.String name)
name - AbstractDemandProfile instances must support a single
String argument constructor that is the underlying service name.public boolean shouldReportDemandStats(Request request, java.net.InetAddress sender, ReconfigurableAppInfo nodeConfig)
request received from a client at IP address sender. The
parameter nodeConfig provides the list of all active replica
locations. The reconfiguration policy may use this information to
assimilate a demand distribution and use that to determine whether and
how to reconfigure the current set of replicas.
The simplistic example below ignores the sender information that
in general is needed to determine the geo-distribution of demand.shouldReportDemandStats in class AbstractDemandProfilepublic double getRequestRate()
public double getNumRequests()
public double getNumTotalRequests()
public org.json.JSONObject getDemandStats()
AbstractDemandProfileAbstractDemandProfile.reconfigure(Set, ReconfigurableAppInfo)
that is invoked at reconfigurators (not active replicas).getDemandStats in class AbstractDemandProfilepublic void combine(AbstractDemandProfile dp)
AbstractDemandProfileupdate into this. This
method is used at reconfigurators to combine a newly received demand
report with an existing demand report.combine in class AbstractDemandProfilepublic java.util.Set<java.lang.String> reconfigure(java.util.Set<java.lang.String> curActives,
ReconfigurableAppInfo nodeConfig)
AbstractDemandProfilereconfigure in class AbstractDemandProfileReconfigurationConfig.RC.RECONFIGURE_IN_PLACE is set to false.public void justReconfigured()
AbstractDemandProfilethis that the current demand profile was just used to
perform reconfiguration. This information is useful for implementing
policies based on the difference between the current demand profile and
the one at the time of the most recent reconfiguration, e.g., reconfigure
only if the demand from some region has changed by more than 10%.justReconfigured in class AbstractDemandProfilepublic static void main(java.lang.String[] args)
args -