Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Lucas Cavalcante
cloudsimplus
Commits
0a361921
Commit
0a361921
authored
Jul 19, 2018
by
Lucas Cavalcante
Browse files
allocation -> utilization
parent
dcab0f07
Changes
1
Hide whitespace changes
Inline
Side-by-side
cloudsim-plus/src/main/java/org/cloudsimplus/slametrics/SlaMonitor.java
View file @
0a361921
...
...
@@ -24,36 +24,41 @@ public class SlaMonitor {
private
Map
<
Integer
,
Boolean
>
violations
;
private
Map
<
Integer
,
Double
>
credits
;
private
int
lastElement
;
private
int
lastUtilization
;
public
SlaMonitor
(
Vm
vm
)
{
this
.
vm
=
vm
;
this
.
credits
=
new
HashMap
<
Integer
,
Double
>();
this
.
lastElement
=
0
;
this
.
lastUtilization
=
0
;
}
public
double
getCumulativeCredit
(
double
time
)
{
double
availability
=
vm
.
getContract
().
getAvailabilityMetric
().
getMinDimension
().
getValue
();
List
<
VmStateHistoryEntry
>
stateList
=
vm
.
getStateHistory
();
List
<
VmStateHistoryEntry
>
stateList
=
vm
.
getStateHistory
();
List
<
Double
>
utilizationList
=
vm
.
getUtilizationHistory
().
getHistory
();
double
cumulativeCredit
=
0
;
ListIterator
<
VmStateHistoryEntry
>
it
=
vm
.
getStateHistory
().
listIterator
(
lastElement
);
ListIterator
<
VmStateHistoryEntry
>
it
=
stateList
.
listIterator
(
lastElement
);
ListIterator
<
Double
>
ut
=
utilizationList
.
listIterator
(
lastUtilization
);
if
((
int
)
time
<=
0
)
{
return
0
;
}
while
(
it
.
hasNext
())
{
while
(
it
.
hasNext
()
&&
ut
.
hasNext
()
)
{
VmStateHistoryEntry
state
=
it
.
next
();
double
provis
ion
ed
=
vm
.
getContract
().
getIopsProvisioned
().
getMinDimension
().
getValue
();
double
utilizat
ion
=
ut
.
next
();
if
((
int
)
state
.
getTime
()
<
(
int
)
time
)
{
if
(
credits
.
containsKey
((
int
)
time
))
{
cumulativeCredit
=
credits
.
get
((
int
)
time
);
}
else
{
double
dif
=
calculateMissingCredit
((
int
)
state
.
getTime
(),
availability
,
provisioned
);
cumulativeCredit
=
putCredits
(
state
,
provisioned
,
dif
,
availability
);
lastElement
=
it
.
nextIndex
();
double
dif
=
calculateMissingCredit
((
int
)
state
.
getTime
(),
availability
,
utilization
);
cumulativeCredit
=
putCredits
(
state
,
utilization
,
dif
,
availability
);
lastElement
=
it
.
nextIndex
();
lastUtilization
=
ut
.
nextIndex
();
}
}
...
...
@@ -61,9 +66,10 @@ public double getCumulativeCredit(double time) {
if
(
credits
.
containsKey
((
int
)
time
))
{
cumulativeCredit
=
credits
.
get
((
int
)
time
);
}
else
{
double
dif
=
calculateMissingCredit
((
int
)
state
.
getTime
(),
availability
,
provisioned
);
cumulativeCredit
=
putCredits
(
state
,
provisioned
,
dif
,
availability
);
lastElement
=
it
.
nextIndex
();
double
dif
=
calculateMissingCredit
((
int
)
state
.
getTime
(),
availability
,
utilization
);
cumulativeCredit
=
putCredits
(
state
,
utilization
,
dif
,
availability
);
lastElement
=
it
.
nextIndex
();
lastUtilization
=
ut
.
nextIndex
();
}
}
}
...
...
@@ -82,9 +88,9 @@ public double getCumulativeCredit(double time) {
return
cumulativeCredit
;
}
private
Double
putCredits
(
VmStateHistoryEntry
state
,
double
provis
ion
ed
,
double
dif
,
double
availability
)
{
private
Double
putCredits
(
VmStateHistoryEntry
state
,
double
utilizat
ion
,
double
dif
,
double
availability
)
{
Double
cumulativeCredit
;
if
(
state
.
getAllocatedIops
()
<
provis
ion
ed
)
{
if
(
state
.
getAllocatedIops
()
<
utilizat
ion
)
{
credits
.
put
((
int
)
state
.
getTime
(),
dif
-
(
1
/
availability
));
}
else
{
...
...
@@ -94,7 +100,7 @@ public double getCumulativeCredit(double time) {
return
cumulativeCredit
;
}
private
double
calculateMissingCredit
(
int
time
,
double
availability
,
double
provis
ion
ed
)
{
private
double
calculateMissingCredit
(
int
time
,
double
availability
,
double
utilizat
ion
)
{
double
prevTime
;
VmStateHistoryEntry
state
;
if
(
lastElement
-
1
>
0
)
{
...
...
@@ -116,7 +122,7 @@ public double getCumulativeCredit(double time) {
return
previous
;
}
if
(
state
.
getAllocatedIops
()
>
provis
ion
ed
)
if
(
state
.
getAllocatedIops
()
>
=
utilizat
ion
)
dif
=
previous
+
(
1
/
availability
)
*
(
int
)(
time
-
prevTime
-
1
);
else
dif
=
previous
-
(
1
/
availability
)
*
(
int
)(
time
-
prevTime
-
1
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment