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
6976e2d2
Commit
6976e2d2
authored
Mar 05, 2017
by
Nils Richerzhagen
Browse files
Merge branch 'master' into 'nr/monitoring-model'
Merge Master into nr/monitoring-model See merge request !4
parents
f6a12e49
2ac40564
Changes
12
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/analyzer/metric/filter/AbstractFilter.java
View file @
6976e2d2
...
...
@@ -38,8 +38,8 @@ import de.tudarmstadt.maki.simonstrator.api.common.metric.MetricFilter;
* @author Bjoern Richerzhagen
* @version 1.0, 08.08.2012
*/
public
abstract
class
AbstractFilter
<
M
extends
MetricValue
<?>>
implements
MetricFilter
{
public
abstract
class
AbstractFilter
<
M
extends
MetricValue
<?>>
implements
MetricFilter
{
private
final
String
name
;
...
...
@@ -67,6 +67,20 @@ public abstract class AbstractFilter<M extends MetricValue<?>> implements
if
(
metric
.
getName
().
equals
(
string
))
{
return
true
;
}
if
(
string
.
endsWith
(
"*"
))
{
// prefix matching
String
mName
=
metric
.
getName
();
if
(
mName
.
startsWith
(
string
.
substring
(
0
,
string
.
length
()-
1
)))
{
return
true
;
}
}
if
(
string
.
startsWith
(
"*"
))
{
// postfix matching
String
mName
=
metric
.
getName
();
if
(
mName
.
endsWith
(
string
.
substring
(
1
,
string
.
length
())))
{
return
true
;
}
}
}
return
false
;
}
...
...
@@ -83,7 +97,9 @@ public abstract class AbstractFilter<M extends MetricValue<?>> implements
incomingMetrics
.
add
(
metric
);
}
if
(
incomingMetrics
.
isEmpty
())
{
throw
new
AssertionError
(
"No incoming metrics configured! Available metrics are: "
+
metrics
.
toString
());
throw
new
AssertionError
(
"No incoming metrics configured! Available metrics are: "
+
metrics
.
toString
());
}
onInitialize
(
incomingMetrics
);
...
...
@@ -233,8 +249,8 @@ public abstract class AbstractFilter<M extends MetricValue<?>> implements
* @author Bjoern Richerzhagen
* @version 1.0, 13.08.2012
*/
private
class
DerivedActiveMetric
extends
DerivedMetric
implements
ActiveMetric
<
M
>
{
private
class
DerivedActiveMetric
extends
DerivedMetric
implements
ActiveMetric
<
M
>
{
private
final
List
<
ActiveMetricListener
>
listeners
;
...
...
src/de/tud/kom/p2psim/impl/analyzer/metric/filter/ActiveComponentFilter.java
0 → 100644
View file @
6976e2d2
/*
* Copyright (c) 2005-2010 KOM – Multimedia Communications Lab
*
* This file is part of PeerfactSim.KOM.
*
* PeerfactSim.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package
de.tud.kom.p2psim.impl.analyzer.metric.filter
;
import
java.util.List
;
import
de.tudarmstadt.maki.simonstrator.api.Host
;
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
;
import
de.tudarmstadt.maki.simonstrator.api.component.LifecycleComponent
;
import
de.tudarmstadt.maki.simonstrator.api.util.XMLConfigurableConstructor
;
/**
* Filter a metric usign a {@link LifecycleComponent}s isActive method.
*
* @author Bjoern Richerzhagen
* @version 1.0, Feb 7, 2017
*/
public
class
ActiveComponentFilter
extends
AbstractFilter
<
MetricValue
<?>>
{
private
Class
<?
extends
LifecycleComponent
>
compClass
;
private
String
description
;
private
String
prefix
;
@SuppressWarnings
(
"unchecked"
)
@XMLConfigurableConstructor
({
"clazz"
,
"prefix"
})
public
ActiveComponentFilter
(
String
clazz
,
String
prefix
)
{
super
(
"active"
);
this
.
prefix
=
prefix
;
description
=
"only active "
+
clazz
.
substring
(
clazz
.
lastIndexOf
(
"."
)
+
1
);
// Find class
try
{
compClass
=
(
Class
<?
extends
LifecycleComponent
>)
Class
.
forName
(
clazz
);
}
catch
(
ClassNotFoundException
e
)
{
throw
new
AssertionError
();
}
}
@Override
protected
String
getNameForDerivedMetric
(
List
<
Metric
<?>>
inputs
)
{
assert
inputs
.
size
()
==
1
;
return
prefix
+
"_"
+
inputs
.
get
(
0
).
getName
();
}
@Override
protected
void
onInitialize
(
List
<
Metric
<?>>
incomingMetrics
)
{
for
(
Metric
metric
:
incomingMetrics
)
{
if
(
metric
.
isOverallMetric
())
{
continue
;
}
createDerivedMetric
(
metric
,
false
,
metric
.
getUnit
(),
description
+
" of "
+
metric
.
getName
(),
false
);
}
}
@Override
public
void
onStop
()
{
// nothing to do
}
@Override
protected
MetricValue
<?>
getDerivedMetricValueFor
(
Metric
<?>
derivedMetric
,
List
<
Metric
<?>>
inputs
,
Host
host
)
{
assert
inputs
.
size
()
==
1
;
assert
host
!=
null
;
Metric
<?>
input
=
inputs
.
get
(
0
);
if
(
input
.
isOverallMetric
())
{
throw
new
AssertionError
(
"Only available for per-host input metrics."
);
}
try
{
LifecycleComponent
comp
=
host
.
getComponent
(
compClass
);
MetricValue
mvIn
=
input
.
getPerHostMetric
(
host
.
getId
());
if
(
mvIn
!=
null
)
{
return
new
ActiveHostMetricValue
(
input
.
getPerHostMetric
(
host
.
getId
()),
comp
);
}
}
catch
(
ComponentNotAvailableException
e
)
{
//
}
return
null
;
// no derived metric
}
/**
* Computes statistics such as svg, sum, std...
*
* @author Bjoern Richerzhagen
* @version 1.0, 08.08.2012
*/
private
class
ActiveHostMetricValue
implements
MetricValue
{
private
final
MetricValue
input
;
private
final
LifecycleComponent
comp
;
public
ActiveHostMetricValue
(
MetricValue
input
,
LifecycleComponent
comp
)
{
this
.
input
=
input
;
this
.
comp
=
comp
;
}
@Override
public
Object
getValue
()
{
return
input
.
getValue
();
}
@Override
public
boolean
isValid
()
{
return
comp
.
isActive
()
&&
input
.
isValid
();
}
}
}
src/de/tud/kom/p2psim/impl/analyzer/metric/output/AbstractOutput.java
View file @
6976e2d2
...
...
@@ -46,6 +46,20 @@ public abstract class AbstractOutput implements MetricOutput {
if
(
metric
.
getName
().
equals
(
string
))
{
return
true
;
}
if
(
string
.
endsWith
(
"*"
))
{
// prefix matching
String
mName
=
metric
.
getName
();
if
(
mName
.
startsWith
(
string
.
substring
(
0
,
string
.
length
()-
1
)))
{
return
true
;
}
}
if
(
string
.
startsWith
(
"*"
))
{
// postfix matching
String
mName
=
metric
.
getName
();
if
(
mName
.
endsWith
(
string
.
substring
(
1
,
string
.
length
())))
{
return
true
;
}
}
}
return
false
;
}
...
...
src/de/tud/kom/p2psim/impl/analyzer/metric/output/MetricOutputDAO.java
View file @
6976e2d2
...
...
@@ -25,6 +25,7 @@ import java.util.LinkedHashSet;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.Set
;
import
org.apache.commons.math.stat.descriptive.DescriptiveStatistics
;
...
...
@@ -56,6 +57,8 @@ public class MetricOutputDAO extends AbstractOutput {
protected
Set
<
String
>
metricsToAggregate
=
new
LinkedHashSet
<>();
protected
List
<
MetricDaoAdapter
>
daoAdapters
=
new
LinkedList
<>();
/**
*
* @param table
...
...
@@ -93,6 +96,29 @@ public class MetricOutputDAO extends AbstractOutput {
this
.
metricsToAggregate
.
add
(
metric
);
}
}
public
boolean
isToAggregate
(
Metric
metric
)
{
for
(
String
string
:
metricsToAggregate
)
{
if
(
metric
.
getName
().
equals
(
string
))
{
return
true
;
}
if
(
string
.
endsWith
(
"*"
))
{
// prefix matching
String
mName
=
metric
.
getName
();
if
(
mName
.
startsWith
(
string
.
substring
(
0
,
string
.
length
()-
1
)))
{
return
true
;
}
}
if
(
string
.
startsWith
(
"*"
))
{
// postfix matching
String
mName
=
metric
.
getName
();
if
(
mName
.
endsWith
(
string
.
substring
(
1
,
string
.
length
())))
{
return
true
;
}
}
}
return
false
;
}
@Override
public
void
onInitialize
(
List
<
Metric
>
metrics
)
{
...
...
@@ -103,13 +129,18 @@ public class MetricOutputDAO extends AbstractOutput {
*/
if
(
metric
instanceof
ActiveMetric
)
{
ActiveMetric
am
=
(
ActiveMetric
)
metric
;
am
.
addActiveMetricListener
(
new
MetricDaoAdapter
(
am
));
MetricDaoAdapter
adapter
=
new
MetricDaoAdapter
(
am
);
am
.
addActiveMetricListener
(
adapter
);
daoAdapters
.
add
(
adapter
);
}
}
}
@Override
public
void
onStop
()
{
for
(
MetricDaoAdapter
adapter
:
daoAdapters
)
{
adapter
.
onStop
();
}
/*
* Commit missing values
*/
...
...
@@ -135,7 +166,9 @@ public class MetricOutputDAO extends AbstractOutput {
private
final
boolean
writeAggregates
;
private
final
Map
<
String
,
List
<
SimHost
>>
hostsByGroup
;
private
final
Map
<
String
,
DescriptiveStatistics
>
globalStatsByGroup
;
private
long
timestampLastEvent
=
-
1
;
public
MetricDaoAdapter
(
ActiveMetric
metric
)
{
...
...
@@ -144,17 +177,33 @@ public class MetricOutputDAO extends AbstractOutput {
metric
.
getName
(),
metric
.
getDescription
(),
metric
.
getUnit
().
toString
());
this
.
hosts
=
GlobalOracle
.
getHosts
();
writeAggregates
=
metric
sToAggregate
.
contains
(
metric
.
getName
()
);
this
.
writeAggregates
=
i
sToAggregate
(
metric
);
this
.
hostsByGroup
=
new
LinkedHashMap
<>();
this
.
globalStatsByGroup
=
new
LinkedHashMap
<>();
for
(
SimHost
simHost
:
hosts
)
{
String
groupId
=
simHost
.
getProperties
().
getGroupID
();
if
(!
this
.
hostsByGroup
.
containsKey
(
groupId
))
{
this
.
hostsByGroup
.
put
(
groupId
,
new
LinkedList
<>());
this
.
globalStatsByGroup
.
put
(
groupId
,
new
DescriptiveStatistics
());
}
this
.
hostsByGroup
.
get
(
groupId
).
add
(
simHost
);
}
}
public
void
onStop
()
{
if
(
writeAggregates
)
{
for
(
Entry
<
String
,
DescriptiveStatistics
>
groupData
:
globalStatsByGroup
.
entrySet
())
{
MeasurementDAO
.
storeGroupStatisticsMeasurement
(
md
,
groupData
.
getKey
(),
Time
.
getCurrentTime
(),
groupData
.
getValue
(),
Time
.
getCurrentTime
()
-
timeEnableDao
,
true
);
}
globalStatsByGroup
.
clear
();
}
}
@Override
public
void
onMetricUpdate
(
ActiveMetric
metric
)
{
long
time
=
Time
.
getCurrentTime
();
...
...
@@ -184,6 +233,8 @@ public class MetricOutputDAO extends AbstractOutput {
// Iterate over groups
for
(
String
group
:
hostsByGroup
.
keySet
())
{
DescriptiveStatistics
stats
=
new
DescriptiveStatistics
();
DescriptiveStatistics
globalStats
=
globalStatsByGroup
.
get
(
group
);
for
(
SimHost
host
:
hostsByGroup
.
get
(
group
))
{
MetricValue
mv
=
metric
.
getPerHostMetric
(
host
.
getId
());
...
...
@@ -198,14 +249,17 @@ public class MetricOutputDAO extends AbstractOutput {
}
// Add value
stats
.
addValue
(
vd
);
globalStats
.
addValue
(
vd
);
}
}
}
}
// Write Group stats
long
observationDuration
=
Time
.
getCurrentTime
()
-
timestampLastEvent
;
long
observationDuration
=
Time
.
getCurrentTime
()
-
timestampLastEvent
;
if
(
timestampLastEvent
==
-
1
)
{
observationDuration
=
Time
.
getCurrentTime
()
-
timeEnableDao
;
observationDuration
=
Time
.
getCurrentTime
()
-
timeEnableDao
;
}
MeasurementDAO
.
storeGroupStatisticsMeasurement
(
md
,
group
,
time
,
stats
,
observationDuration
,
false
);
...
...
src/de/tud/kom/p2psim/impl/common/DefaultMonitor.java
View file @
6976e2d2
...
...
@@ -85,7 +85,9 @@ public class DefaultMonitor implements MonitorComponent, EventHandler,
@Override
public
<
A
extends
Analyzer
>
void
registerAnalyzer
(
A
analyzer
)
{
analyzers
.
add
(
analyzer
);
if
(!
analyzers
.
contains
(
analyzer
))
{
analyzers
.
add
(
analyzer
);
}
}
@Override
...
...
src/de/tud/kom/p2psim/impl/topology/DefaultTopologyComponent.java
View file @
6976e2d2
...
...
@@ -91,6 +91,8 @@ public class DefaultTopologyComponent implements TopologyComponent {
private
MovementModel
movementModel
;
private
PlacementModel
placementModel
;
private
final
boolean
registerAsInformationProviderInSiS
;
/**
* Create a TopologyComponent for the current host.
...
...
@@ -100,7 +102,7 @@ public class DefaultTopologyComponent implements TopologyComponent {
* @param movementModel
*/
public
DefaultTopologyComponent
(
SimHost
host
,
Topology
topology
,
MovementModel
movementModel
,
PlacementModel
placementModel
)
{
MovementModel
movementModel
,
PlacementModel
placementModel
,
boolean
registerAsInformationProviderInSiS
)
{
this
.
topology
=
topology
;
this
.
host
=
host
;
this
.
position
=
new
PositionVector
(
0
,
0
);
...
...
@@ -114,6 +116,7 @@ public class DefaultTopologyComponent implements TopologyComponent {
if
(
this
.
placementModel
!=
null
)
{
this
.
placementModel
.
addComponent
(
this
);
}
this
.
registerAsInformationProviderInSiS
=
registerAsInformationProviderInSiS
;
}
@Override
...
...
@@ -132,52 +135,54 @@ public class DefaultTopologyComponent implements TopologyComponent {
position
.
set
(
placementModel
.
place
(
this
));
}
try
{
final
SiSComponent
sis
=
host
.
getComponent
(
SiSComponent
.
class
);
sis
.
provide
().
nodeState
(
SiSTypes
.
PHY_LOCATION
,
new
SiSDataCallback
<
Location
>()
{
Set
<
INodeID
>
localID
=
INodeID
.
getSingleIDSet
(
getHost
().
getId
());
@Override
public
Location
getValue
(
INodeID
nodeID
,
SiSProviderHandle
providerHandle
)
throws
InformationNotAvailableException
{
if
(
nodeID
.
equals
(
getHost
().
getId
()))
{
return
getLastLocation
();
}
else
{
throw
new
InformationNotAvailableException
();
if
(
registerAsInformationProviderInSiS
)
{
try
{
final
SiSComponent
sis
=
host
.
getComponent
(
SiSComponent
.
class
);
sis
.
provide
().
nodeState
(
SiSTypes
.
PHY_LOCATION
,
new
SiSDataCallback
<
Location
>()
{
Set
<
INodeID
>
localID
=
INodeID
.
getSingleIDSet
(
getHost
().
getId
());
@Override
public
Location
getValue
(
INodeID
nodeID
,
SiSProviderHandle
providerHandle
)
throws
InformationNotAvailableException
{
if
(
nodeID
.
equals
(
getHost
().
getId
()))
{
return
getLastLocation
();
}
else
{
throw
new
InformationNotAvailableException
();
}
}
@Override
public
Set
<
INodeID
>
getObservedNodes
()
{
return
localID
;
}
@Override
public
SiSInfoProperties
getInfoProperties
()
{
return
new
SiSInfoProperties
();
}
});
// Provide Underlay topology
Event
.
scheduleImmediately
(
new
EventHandler
()
{
@Override
public
void
eventOccurred
(
Object
content
,
int
type
)
{
if
(
getHost
().
getLinkLayer
().
hasPhy
(
PhyType
.
WIFI
))
{
new
SiSTopologyProvider
(
sis
,
SiSTypes
.
NEIGHBORS_WIFI
,
DefaultTopologyComponent
.
this
,
getTopologyID
(
NetInterfaceName
.
WIFI
,
true
),
DefaultTopologyComponent
.
class
);
}
@Override
public
Set
<
INodeID
>
getObservedNodes
()
{
return
localID
;
}
@Override
public
SiSInfoProperties
getInfoProperties
()
{
return
new
SiSInfoProperties
();
}
});
// Provide Underlay topology
Event
.
scheduleImmediately
(
new
EventHandler
()
{
@Override
public
void
eventOccurred
(
Object
content
,
int
type
)
{
if
(
getHost
().
getLinkLayer
().
hasPhy
(
PhyType
.
WIFI
))
{
new
SiSTopologyProvider
(
sis
,
SiSTypes
.
NEIGHBORS_WIFI
,
DefaultTopologyComponent
.
this
,
getTopologyID
(
NetInterfaceName
.
WIFI
,
true
),
DefaultTopologyComponent
.
class
);
}
}
},
null
,
0
);
}
catch
(
ComponentNotAvailableException
e
)
{
// OK
}
,
null
,
0
);
}
catch
(
ComponentNotAvailableException
e
)
{
// OK
}
}
}
...
...
src/de/tud/kom/p2psim/impl/topology/TopologyFactory.java
View file @
6976e2d2
...
...
@@ -71,6 +71,8 @@ public class TopologyFactory implements HostComponentFactory {
private
WaypointModel
waypointModel
;
private
ObstacleModel
obstacleModel
;
private
boolean
registerAsInformationProviderInSiS
=
false
;
private
static
NetMeasurementDB
measurementDB
=
null
;
...
...
@@ -125,7 +127,7 @@ public class TopologyFactory implements HostComponentFactory {
* movement model.
*/
TopologyComponent
toCo
=
new
DefaultTopologyComponent
(
host
,
topo
,
movement
,
placement
);
movement
,
placement
,
registerAsInformationProviderInSiS
);
/*
* Need to register TopoViews as movement listeners, as they might need
...
...
@@ -227,6 +229,17 @@ public class TopologyFactory implements HostComponentFactory {
public
void
setUseRegionGroups
(
boolean
useRegionGroups
)
{
TopologyFactory
.
useRegionGroups
=
useRegionGroups
;
}
/**
* Option to disable the default behavior of nodes registering as
* topology providers.
*
* @param registerAsLocationProviderInSiS
*/
public
void
setRegisterAsInformationProviderInSiS
(
boolean
registerAsInformationProviderInSiS
)
{
this
.
registerAsInformationProviderInSiS
=
registerAsInformationProviderInSiS
;
}
/**
* Allows GNP-based strategies to retrieve the unique
...
...
src/de/tud/kom/p2psim/impl/topology/movement/local/RealWorldStreetsMovement.java
View file @
6976e2d2
...
...
@@ -22,6 +22,7 @@ package de.tud.kom.p2psim.impl.topology.movement.local;
import
java.util.HashMap
;
import
java.util.Locale
;
import
java.util.UUID
;
import
com.graphhopper.GHRequest
;
import
com.graphhopper.GHResponse
;
...
...
@@ -38,6 +39,8 @@ import de.tud.kom.p2psim.impl.topology.movement.modularosm.GPSCalculation;
import
de.tud.kom.p2psim.impl.util.Either
;
import
de.tud.kom.p2psim.impl.util.Left
;
import
de.tudarmstadt.maki.simonstrator.api.Binder
;
import
de.tudarmstadt.maki.simonstrator.api.Monitor
;
import
de.tudarmstadt.maki.simonstrator.api.Monitor.Level
;
/**
* This movement strategy uses the data from osm and navigates the nodes throught streets to the destination
...
...
@@ -61,6 +64,7 @@ public class RealWorldStreetsMovement extends AbstractLocalMovementStrategy {
private
double
latRight
;
//Values from -90 to 90
private
double
lonLeft
;
//Values from -180 to 180; Always smaller than lonRight
private
double
lonRight
;
//Values from -180 to 180
private
boolean
uniqueFolders
;
/**
* Tolerance in meters (if the node reached a waypoint up to "tolerance"
...
...
@@ -81,7 +85,16 @@ public class RealWorldStreetsMovement extends AbstractLocalMovementStrategy {
hopper
=
new
GraphHopper
().
forServer
();
hopper
.
setOSMFile
(
osmFileLocation
);
// where to store graphhopper files?
hopper
.
setGraphHopperLocation
(
graphFolderFiles
+
"/"
+
osmFileLocation
.
hashCode
()+
movementType
);
if
(
uniqueFolders
)
{
Monitor
.
log
(
RealWorldStreetsMovement
.
class
,
Level
.
WARN
,
"Using per-simulation unique folders for GraphHopper temporary data in %s. Remember to delete them to prevent your disk from filling up."
,
graphFolderFiles
);
hopper
.
setGraphHopperLocation
(
graphFolderFiles
+
"/"
+
UUID
.
randomUUID
().
toString
());
}
else
{
hopper
.
setGraphHopperLocation
(
graphFolderFiles
+
"/"
+
osmFileLocation
.
hashCode
()
+
movementType
);
}
hopper
.
setEncodingManager
(
new
EncodingManager
(
movementType
));
hopper
.
importOrLoad
();
init
=
true
;
...
...
@@ -190,4 +203,16 @@ public class RealWorldStreetsMovement extends AbstractLocalMovementStrategy {
public
void
setWaypointTolerance
(
double
tolerance
)
{
this
.
tolerance
=
tolerance
;
}
/**
* For large batch simulations, we need to prevent same-time access to
* garphhopper temp data. Therefore, this flag creates unique folders for
* each run (which, obviously, wastes a lot of space and comp-resources and
* should not be used in standalone, single-threaded demo mode...)
*
* @param uniqueFolders
*/
public
void
setCreateUniqueFolders
(
boolean
uniqueFolders
)
{
this
.
uniqueFolders
=
uniqueFolders
;
}
}
src/de/tud/kom/p2psim/impl/topology/movement/modularosm/ModularMovementModel.java
View file @
6976e2d2
...
...
@@ -240,14 +240,18 @@ public class ModularMovementModel implements MovementModel, EventHandler, Attrac
*/
PositionVector
attractionCenter
=
(
PositionVector
)
newAssignment
;
PositionVector
destination
=
null
;
/*
* Even if an AP does not have a radius, we slightly offset
*/
double
apRadius
=
Math
.
max
(
newAssignment
.
getRadius
(),
25.0
);
int
tries
=
0
;
do
{
destination
=
new
PositionVector
(
attractionCenter
);
// Gaussian with std = 1 --> >99% of nodes
PositionVector
offset
=
new
PositionVector
(
rand
.
nextGaussian
()
*
newAssignment
.
get
Radius
()
/
3
,
rand
.
nextGaussian
()
*
newAssignment
.
get
Radius
()
/
3
);
rand
.
nextGaussian
()
*
ap
Radius
/
3
,
rand
.
nextGaussian
()
*
ap
Radius
/
3
);
destination
.
add
(
offset
);
// Check constraints
if
(
destination
.
getX
()
<
0.0
...
...
src/de/tud/kom/p2psim/impl/transport/modular/ModularTransLayer.java
View file @
6976e2d2
...
...
@@ -260,7 +260,11 @@ public class ModularTransLayer implements SimHostComponent, TransportComponent,
* FIXME add @Override lateron, as soon as the API is updated globally.
*/
public
void
removeTransportMessageListener
()
{
assert
listener
!=
null
;
// assert listener != null;
if
(
listener
==
null
)
{
Monitor
.
log
(
ModularTransLayer
.
class
,
Level
.
DEBUG
,
"Trying tor remove a non-existing transport message listener."
);
return
;
}
removeTransMsgListener
(
listener
,
localPort
);
listener
=
null
;
}
...
...
src/de/tud/kom/p2psim/impl/util/db/dao/metric/MeasurementDAO.java
View file @
6976e2d2
...
...
@@ -168,6 +168,41 @@ public class MeasurementDAO extends DAO {
groupMetric
,
observationDuration
,
describesWholeSimulation
);
addToPersistQueue
(
measurement
);
}
/**
* Stores a statistical description of a series of values for group of
* hosts and a given spatial coordinate.
*
* @param metricDesc
* The {@link MetricDescription} which describes the metric.
* @param groupName
* The host group
* @param time
* A time for the measurement in simulation time
* @param stats
* the {@link DescriptiveStatistics} object used as input
* @param observationDuration
* duration of this observation in simulation time
* @param describesWholeSimulation
* true, if this measurement is a description of the WHOLE
* simulation
* @param locationX
* x coordinate for spatial sampling
* @param locationY
* y coordinate for spatial sampling
*/
public
static
void
storeSpatialGroupStatisticsMeasurement
(
MetricDescription
metricDesc
,
String
groupName
,
long
time
,
DescriptiveStatistics
stats
,
long
observationDuration
,
boolean
describesWholeSimulation
,
int
locationX
,
int
locationY
)
{
Metric
metric
=
MetricDAO
.
lookupStatisticsMetric
(
metricDesc
);
GroupMetric
groupMetric
=
GroupMetricDAO
.
lookupGroupMetric
(
metric
,
groupName
);
MeasurementStatistic
measurement
=
new
MeasurementStatistic
(
time
,
stats
,
groupMetric
,
observationDuration
,
describesWholeSimulation
,
locationX
,
locationY
);
addToPersistQueue
(
measurement
);
}
/**
* Store a list-based measurement with a key (i.e., as a
...
...
src/de/tud/kom/p2psim/impl/util/db/metric/MeasurementStatistic.java
View file @
6976e2d2
...
...
@@ -73,6 +73,9 @@ public class MeasurementStatistic implements GroupMetricBound {
*/
@Column
(
nullable
=
true
,
name
=
"[values]"
)
private
Double
values
;
@Column
(
nullable
=
true
,
name
=
"[std]"
)
private
Double
std
;
@Column
(
nullable
=
true
,
name
=
"[sum]"
)
private
Double
sum
;
...
...
@@ -115,12 +118,15 @@ public class MeasurementStatistic implements GroupMetricBound {
@Column
(
nullable
=
true
,
name
=
"[perc5]"
)
private
Double
perc5
;
// 5
@Column
(
nullable
=
true
,
name
=
"[skewness]"
)
private
Double
skewness
;
@Column
(
nullable
=
true
,
name
=
"[kurtosis]"
)
private
Double
kurtosis
;
@Column
(
nullable
=
true
,
name
=
"[locationX]"
)
private
Integer
locationX
;
@Column
(
nullable
=
true
,
name
=
"[locationY]"
)
private
Integer
locationY
;
@Column
(
nullable
=
true
,
name
=
"[isSpatial]"
)
private
boolean
isSpatial
;
/**
* Mapping to group metric
...
...
@@ -152,6 +158,36 @@ public class MeasurementStatistic implements GroupMetricBound {
this
.
groupMetric
=
groupMetric
;
}
/**
* Creates a {@link Measurement}-Object using the provided
* {@link DescriptiveStatistics} object, with spatial data attached.
*
* @param time
* The simulation time for to this measurement as Date
* @param stats
* the {@link DescriptiveStatistics} object
* @param hostMetric
* The reference to the {@link HostMetric}-Object, which
* describes this metric. Is used for the mapping.
* @param observationDuration
* duration of the observation
* @param describesWholeSimulation
* true, if this measurement describes the whole simulation
* @param locationX
* x coordinate for spatial sampling
* @param locationY
* y coordinate for spatial sampling
*/
public
MeasurementStatistic
(
long
time
,
DescriptiveStatistics
stats
,
GroupMetric
groupMetric
,
long
observationDuration
,
boolean
describesWholeSimulation
,
int
locationX
,
int
locationY
)
{
this
(
time
,
stats
,
observationDuration
,
describesWholeSimulation
);
this
.
groupMetric
=
groupMetric
;
this
.
locationX
=
locationX
;
this
.
locationY
=
locationY
;
this
.
isSpatial
=
true
;
}
/**
* Internal - write statistics
*
...
...
@@ -179,8 +215,8 @@ public class MeasurementStatistic implements GroupMetricBound {
this
.
perc97
=
checkForSpecialNumbers
(
stats
.
getPercentile
(
97.7
));
this
.
perc5
=
checkForSpecialNumbers
(
stats
.
getPercentile
(
5
));
this
.
perc95
=
checkForSpecialNumbers
(
stats
.
getPercentile
(
95
));
this
.
s
kewness
=
checkForSpecialNumbers
(
stats
.
getS
kewness
());
this
.
kurtosis
=
checkForSpecialNumbers
(
stats
.
getKurtosis
())
;
this
.
s
td
=
checkForSpecialNumbers
(
stats
.
getS
tandardDeviation
());
this
.
isSpatial
=
false
;
}
/**
...
...
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