Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Simonstrator
PeerfactSim.KOM
Commits
64668537
Commit
64668537
authored
Oct 20, 2015
by
Björn Richerzhagen
Browse files
Metrics: Minor API change, Refactored SiS Output
parent
0df91479
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/analyzer/metric/filter/IntervalDeltaFilter.java
View file @
64668537
...
...
@@ -104,7 +104,7 @@ public class IntervalDeltaFilter extends
if
(
input
.
isOverallMetric
())
{
inputMv
=
input
.
getOverallMetric
();
}
else
{
inputMv
=
input
.
getPerHostMetric
(
host
);
inputMv
=
input
.
getPerHostMetric
(
host
.
getId
()
);
}
if
(
inputMv
==
null
)
{
return
null
;
...
...
src/de/tud/kom/p2psim/impl/analyzer/metric/filter/OnChurnFilter.java
View file @
64668537
...
...
@@ -135,7 +135,7 @@ public class OnChurnFilter extends AbstractFilter<MetricValue<?>> {
protected
MetricValue
getDerivedMetricValueFor
(
Metric
<?>
derivedMetric
,
List
<
Metric
<?>>
inputs
,
Host
host
)
{
assert
inputs
.
size
()
==
1
;
MetricValue
mvIn
=
inputs
.
get
(
0
).
getPerHostMetric
(
host
);
MetricValue
mvIn
=
inputs
.
get
(
0
).
getPerHostMetric
(
host
.
getId
()
);
if
(
mvIn
!=
null
)
{
OnChurnMV
mv
=
new
OnChurnMV
(
mvIn
,
host
);
host
.
getNetworkComponent
().
getNetworkInterfaces
().
iterator
().
next
()
...
...
src/de/tud/kom/p2psim/impl/analyzer/metric/filter/PeriodicSamplingFilter.java
View file @
64668537
...
...
@@ -106,7 +106,7 @@ public class PeriodicSamplingFilter extends
if
(
input
.
isOverallMetric
())
{
inputMv
=
input
.
getOverallMetric
();
}
else
{
inputMv
=
input
.
getPerHostMetric
(
host
);
inputMv
=
input
.
getPerHostMetric
(
host
.
getId
()
);
}
if
(
inputMv
==
null
)
{
return
null
;
...
...
src/de/tud/kom/p2psim/impl/analyzer/metric/filter/RatioFilter.java
View file @
64668537
...
...
@@ -129,12 +129,12 @@ public abstract class RatioFilter extends AbstractFilter<MetricValue<Double>>
if
(
nominator
.
isOverallMetric
())
{
nominatorValue
=
nominator
.
getOverallMetric
();
}
else
{
nominatorValue
=
nominator
.
getPerHostMetric
(
host
);
nominatorValue
=
nominator
.
getPerHostMetric
(
host
.
getId
()
);
}
if
(
denominator
.
isOverallMetric
())
{
denominatorValue
=
denominator
.
getOverallMetric
();
}
else
{
denominatorValue
=
denominator
.
getPerHostMetric
(
host
);
denominatorValue
=
denominator
.
getPerHostMetric
(
host
.
getId
()
);
}
if
(
nominatorValue
==
null
||
denominatorValue
==
null
)
{
return
null
;
...
...
src/de/tud/kom/p2psim/impl/analyzer/metric/output/MetricOutputDAO.java
View file @
64668537
...
...
@@ -140,7 +140,7 @@ public class MetricOutputDAO extends AbstractOutput {
}
else
{
// per-host metric
for
(
SimHost
host
:
hosts
)
{
MetricValue
mv
=
metric
.
getPerHostMetric
(
host
);
MetricValue
mv
=
metric
.
getPerHostMetric
(
host
.
getId
()
);
if
(
mv
!=
null
)
{
Object
val
=
mv
.
getValue
();
if
(
mv
.
isValid
())
{
...
...
src/de/tud/kom/p2psim/impl/analyzer/metric/output/MetricOutputSiS.java
View file @
64668537
...
...
@@ -20,11 +20,16 @@
package
de.tud.kom.p2psim.impl.analyzer.metric.output
;
import
java.util.LinkedHashMap
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
de.tudarmstadt.maki.simonstrator.api.Host
;
import
de.tudarmstadt.maki.simonstrator.api.Oracle
;
import
de.tudarmstadt.maki.simonstrator.api.common.graph.INode
;
import
de.tudarmstadt.maki.simonstrator.api.common.graph.INodeID
;
import
de.tudarmstadt.maki.simonstrator.api.common.metric.Metric
;
import
de.tudarmstadt.maki.simonstrator.api.common.metric.Metric.MetricValue
;
import
de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException
;
...
...
@@ -46,7 +51,7 @@ import de.tudarmstadt.maki.simonstrator.api.component.sis.type.aggregation.Abstr
*/
public
class
MetricOutputSiS
extends
AbstractOutput
{
List
<
MetricSiSHost
>
hosts
=
new
LinkedList
<
MetricOutputSiS
.
MetricSiSHos
t
>();
protected
Map
<
INodeID
,
SiSComponent
>
hosts
=
new
LinkedHashMap
<
INodeID
,
SiSComponen
t
>();
@Override
public
void
onStop
()
{
...
...
@@ -56,10 +61,11 @@ public class MetricOutputSiS extends AbstractOutput {
@Override
public
void
onInitialize
(
List
<
Metric
>
metrics
)
{
List
<
INodeID
>
ids
=
new
LinkedList
<>();
for
(
Host
host
:
Oracle
.
getAllHosts
())
{
try
{
SiSComponent
sis
=
host
.
getComponent
(
SiSComponent
.
class
);
hosts
.
add
(
new
MetricSiSHost
(
host
,
sis
)
)
;
hosts
.
put
(
host
.
getId
()
,
sis
);
}
catch
(
ComponentNotAvailableException
e
)
{
continue
;
}
...
...
@@ -71,7 +77,10 @@ public class MetricOutputSiS extends AbstractOutput {
if
(
metric
.
isOverallMetric
())
{
continue
;
}
for
(
MetricSiSHost
host
:
hosts
)
{
MetricSiSDataCallback
callback
=
new
MetricSiSDataCallback
(
metric
);
for
(
SiSComponent
hostSiS
:
hosts
.
values
())
{
// FIXME metric type cannot be resolved programmatically
SiSType
<
Double
>
sisType
=
SiSTypes
.
getType
(
metric
.
getName
(),
Double
.
class
);
...
...
@@ -82,10 +91,7 @@ public class MetricOutputSiS extends AbstractOutput {
sisType
=
SiSTypes
.
getType
(
metric
.
getName
(),
Double
.
class
);
assert
sisType
!=
null
;
}
host
.
sis
.
provide
().
localNodeState
(
sisType
,
new
MetricSiSDataCallback
(
metric
.
getPerHostMetric
(
host
.
host
)));
hostSiS
.
provide
().
nodeState
(
sisType
,
callback
);
}
}
...
...
@@ -94,18 +100,20 @@ public class MetricOutputSiS extends AbstractOutput {
private
class
MetricSiSDataCallback
implements
SiSDataCallback
<
Double
>
{
private
final
Metric
Value
<
Double
>
mv
;
private
final
Metric
<?>
metric
;
private
final
SiSInfoProperties
info
=
new
SiSInfoProperties
()
.
setScope
(
SiSScope
.
NODE_LOCAL
);
public
MetricSiSDataCallback
(
Metric
Value
<?>
mv
)
{
this
.
m
v
=
(
M
etric
Value
<
Double
>)
mv
;
public
MetricSiSDataCallback
(
Metric
<?>
metric
)
{
this
.
m
etric
=
m
etric
;
}
@Override
public
Double
getValue
(
SiSProviderHandle
providerHandle
)
public
Double
getValue
(
INodeID
nodeId
,
SiSProviderHandle
providerHandle
)
throws
InformationNotAvailableException
{
@SuppressWarnings
(
"unchecked"
)
MetricValue
<
Double
>
mv
=
(
MetricValue
<
Double
>)
metric
.
getPerHostMetric
(
nodeId
);
Double
value
=
mv
.
getValue
();
if
(
mv
.
isValid
())
{
return
value
;
...
...
@@ -117,25 +125,11 @@ public class MetricOutputSiS extends AbstractOutput {
public
SiSInfoProperties
getInfoProperties
()
{
return
info
;
}
}
/**
* Tuple: Host <-> SiS
*
* @author Bjoern Richerzhagen
* @version 1.0, Sep 28, 2015
*/
private
class
MetricSiSHost
{
public
final
Host
host
;
public
final
SiSComponent
sis
;
public
MetricSiSHost
(
Host
host
,
SiSComponent
sis
)
{
this
.
host
=
host
;
this
.
sis
=
sis
;
@Override
public
Set
<
INodeID
>
getObservedNodes
()
{
return
hosts
.
keySet
();
}
}
}
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