Commit 91048727 authored by Björn Richerzhagen's avatar Björn Richerzhagen
Browse files

Config-Flag to disable TopologyComp as SiSDataProvider

parent bccf15b5
......@@ -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
}
}
}
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment