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
97c0ed5e
Commit
97c0ed5e
authored
Dec 15, 2018
by
Tobias Meuser
Browse files
Working version for attacker scenario
parent
345fec46
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/vehicular/caching/DefaultCachingComponent.java
View file @
97c0ed5e
...
...
@@ -28,11 +28,10 @@ import java.util.Map.Entry;
import
java.util.Set
;
import
de.tudarmstadt.maki.simonstrator.api.Host
;
import
de.tudarmstadt.maki.simonstrator.api.
Time
;
import
de.tudarmstadt.maki.simonstrator.api.
common.graph.INodeID
;
import
de.tudarmstadt.maki.simonstrator.api.component.ComponentNotAvailableException
;
import
de.tudarmstadt.maki.simonstrator.api.component.network.NetInterface
;
import
de.tudarmstadt.maki.simonstrator.api.component.network.NetworkComponent.NetInterfaceName
;
import
de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.RoadProperty
;
import
de.tudarmstadt.maki.simonstrator.api.component.transition.TransitionEngine
;
import
de.tudarmstadt.maki.simonstrator.api.component.transport.ConnectivityListener
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.VehicleInformationComponent
;
...
...
@@ -50,7 +49,6 @@ import de.tudarmstadt.maki.simonstrator.api.component.vehicular.information.Road
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetwork
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkEdge
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.RoadNetworkRoute
;
import
de.tudresden.sumo.cmd.Simulation
;
public
class
DefaultCachingComponent
implements
CachingComponent
,
ConnectivityListener
{
...
...
@@ -158,45 +156,52 @@ public class DefaultCachingComponent implements CachingComponent, ConnectivityLi
@Override
public
<
T
extends
PointInformation
>
List
<
T
>
getDecidedCacheEntries
(
Class
<
T
>
pCacheEntryClass
,
Class
<?>
pCacheValueClass
,
RoadNetworkEdge
pEdge
)
{
CacheDecisionStrategy
decisionStrategy
=
getCacheDecisionStrategy
(
pCacheEntryClass
);
Set
<
RoadNetworkEdge
>
allEverActiveEdges
=
RoadNetwork
.
CURRENT_ROAD_NETWORK
.
getAllEverActiveEdges
();
return
getDecidedCacheEntries
(
pCacheEntryClass
,
pCacheValueClass
,
pEdge
,
null
);
}
if
(!
allEverActiveEdges
.
contains
(
pEdge
))
{
return
null
;
}
@Override
public
<
T
extends
PointInformation
>
List
<
T
>
getDecidedCacheEntries
(
Class
<
T
>
pCacheEntryClass
,
Class
<?>
pCacheValueClass
,
RoadNetworkEdge
pEdge
,
INodeID
pWithoutID
)
{
CacheDecisionStrategy
decisionStrategy
=
getCacheDecisionStrategy
(
pCacheEntryClass
);
Set
<
RoadNetworkEdge
>
allEverActiveEdges
=
RoadNetwork
.
CURRENT_ROAD_NETWORK
.
getAllEverActiveEdges
();
List
<
T
>
cacheEntries
=
getCacheEntries
(
pCacheEntryClass
);
if
(!
allEverActiveEdges
.
contains
(
pEdge
))
{
return
null
;
}
if
(
cacheEntries
==
null
)
{
return
null
;
}
List
<
T
>
cacheEntries
=
getCacheEntries
(
pCacheEntryClass
);
Map
<
Class
<?
extends
Object
>,
List
<
PointInformation
>>
similarCacheEntries
=
new
HashMap
<>();
if
(
cacheEntries
==
null
)
{
return
null
;
}
for
(
T
t
:
cacheEntries
)
{
Object
position
=
getEdgeOrPosition
(
t
);
Map
<
Class
<?
extends
Object
>,
List
<
PointInformation
>>
similarCacheEntries
=
new
HashMap
<>();
if
(
position
.
equals
(
pEdge
)
&&
(
pCacheValueClass
==
null
||
t
.
getValue
().
getClass
().
equals
(
pCacheValueClass
)))
{
if
(!
similarCacheEntries
.
containsKey
(
t
.
getValue
().
getClass
()))
{
similarCacheEntries
.
put
(
t
.
getValue
().
getClass
(),
new
ArrayList
<
PointInformation
>());
}
similarCacheEntries
.
get
(
t
.
getValue
().
getClass
()).
add
(
t
);
}
for
(
T
t
:
cacheEntries
)
{
if
(
pWithoutID
==
null
||
!
t
.
getAttribute
(
AvailableInformationAttributes
.
OWNER
).
equals
(
pWithoutID
))
{
Object
position
=
getEdgeOrPosition
(
t
);
}
if
(
position
.
equals
(
pEdge
)
&&
(
pCacheValueClass
==
null
||
t
.
getValue
().
getClass
().
equals
(
pCacheValueClass
)))
{
if
(!
similarCacheEntries
.
containsKey
(
t
.
getValue
().
getClass
()))
{
similarCacheEntries
.
put
(
t
.
getValue
().
getClass
(),
new
ArrayList
<
PointInformation
>());
}
similarCacheEntries
.
get
(
t
.
getValue
().
getClass
()).
add
(
t
);
}
}
}
List
<
T
>
decidedInformation
=
new
ArrayList
<>();
List
<
T
>
decidedInformation
=
new
ArrayList
<>();
for
(
List
<
PointInformation
>
similarInformation
:
similarCacheEntries
.
values
())
{
if
(
similarInformation
.
size
()
>=
_minObservations
)
{
PointInformation
correctInformation
=
decisionStrategy
.
decideOnCorrectInformation
(
similarInformation
);
for
(
List
<
PointInformation
>
similarInformation
:
similarCacheEntries
.
values
())
{
if
(
similarInformation
.
size
()
>=
_minObservations
)
{
PointInformation
correctInformation
=
decisionStrategy
.
decideOnCorrectInformation
(
similarInformation
);
decidedInformation
.
add
((
T
)
correctInformation
);
}
}
decidedInformation
.
add
((
T
)
correctInformation
);
}
}
return
decidedInformation
;
return
decidedInformation
;
}
private
<
T
extends
PointInformation
>
CacheDecisionStrategy
getCacheDecisionStrategy
(
Class
<
T
>
pCacheEntryClass
)
...
...
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