|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbcds.phison.io.ZoneMap<V,E>
public class ZoneMap<V,E>
Reads and writes a zone map (.zmap) file. A zone map is essentially a cluster of nodes and their links that share some common attributes.
A "zone" is simply an id that tie together (currently) three reliability-related data: node availability, link mean-time-to-failure (float, in unit of 1 KM) and link time-to-repair (float).
After zones are defined, nodes and links can be asssigned to them. An example of a .zmap file is:
# Zone definition and assignment for topology metro.sgf @zone_types # type node avail fiber MTBF(1km) fiber MTTR default 0.99994 5500000 9 flooding 0.99970 2500000 15 other=flooding # artificially "bad" values construction 0.99980 2410000 16 @node_assignment construction 24 flooding 5 18 0 heat 29 2 25 1 other 31 15 34 @link_assignment flooding 0-7 "Lavapies"-"Retiro" 1-3
This is a line-oriented file format, divided into sections which start with @section_name.
id=some_other_id
is used to introduce different zones
without really caring for the zone attributes. For example,
this can be used by a clustering algorithm to save
its output, which can later be read by other classes.
NOTES
Field Summary | |
---|---|
static java.lang.String |
DEFAULT_ZONE
Id of the default zone. |
Constructor Summary | |
---|---|
ZoneMap(SimGraph<V,E> g)
Creates a ZoneMap and automatically assign all nodes and links to a default "perfect" zone. |
|
ZoneMap(java.lang.String fname,
SimGraph<V,E> g,
java.util.Map<java.lang.String,java.lang.String> label_to_id,
java.util.Map<java.lang.String,V> id_to_node)
Creates a ZoneMap that will be populated from the contents of the file fname . |
Method Summary | |
---|---|
ZoneInfo<V,E> |
getDefaultZone()
Returns the default zone. |
java.lang.String |
getDefaultZoneId()
Returns the id of the default zone. |
ZoneInfo<V,E> |
getLinkZone(E e)
Returns the ZoneInfo to which the link e belongs. |
ZoneInfo<V,E> |
getNodeZone(V v)
Returns the ZoneInfo to which the node v belongs. |
java.util.Map<java.lang.String,ZoneInfo<V,E>> |
getZonesMap()
Returns an unmodifiable view to the internal map used to hold the zones (and the elements in them). |
ZoneInfo<V,E> |
newDefaultZone()
Returns a new ZoneInfo instance with the default zone id and "perfect" reliability data. |
void |
read()
Reads the file in full and saves the data into internal variables so that they can be retrieved later through calls to other methods. |
void |
register(ZoneInfo<V,E> zinf)
Registers a given zone, whose id zinf.id . |
void |
reset()
Reinitializes internal data structures. |
void |
setInputStream(java.io.Reader ips)
Changes the input stream to ips . |
void |
setLinkZone(E e,
java.lang.String id)
Assigns the link e to the zone identified by id . |
void |
setNodeZone(V v,
java.lang.String id)
|
void |
unregister(java.lang.String id)
Moves all nodes and links assigned to the zone with the given id to the default zone and then removes it. |
void |
write(java.lang.String fname,
java.lang.String headerComment)
Writes a zonemap file. |
void |
write(java.io.Writer out,
java.lang.String headerComment)
Writes a zonemap file to the given Writer object out . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String DEFAULT_ZONE
Constructor Detail |
---|
public ZoneMap(java.lang.String fname, SimGraph<V,E> g, java.util.Map<java.lang.String,java.lang.String> label_to_id, java.util.Map<java.lang.String,V> id_to_node)
fname
.
fname
- the file containing the zone map to read.
stdin is represented by "-". Must not be null.g
- a non-null topology to which nodes and links in the file refer.label_to_id
- must provide an id for
any node referenced in the file by label.id_to_node
- must provide a reference to a node in g
for
any node referenced in the file.
AnyException
- wrapping an IOException if an IO error
occurs in the instantiation of the DataFileReader object.
a call to the DataFileReader
constructor.public ZoneMap(SimGraph<V,E> g)
As the maps "label to id" and "id to node" are set to null,
read()
cannot succeed on this instance (a
NullPointerException will be thrown).
Method Detail |
---|
public void setInputStream(java.io.Reader ips) throws java.io.IOException
ips
. The interal
DataFileReader
object created in the constructor is replace with a new
one pointing to ips
.
java.io.IOException
- when the DataFileReader
constructor
detects any error.public void reset()
public java.lang.String getDefaultZoneId()
public ZoneInfo<V,E> getDefaultZone()
public ZoneInfo<V,E> newDefaultZone()
public java.util.Map<java.lang.String,ZoneInfo<V,E>> getZonesMap()
TreeMap
so that it is kept sorted by
zone id.
public ZoneInfo<V,E> getNodeZone(V v)
v
belongs.
public void setNodeZone(V v, java.lang.String id)
public ZoneInfo<V,E> getLinkZone(E e)
e
belongs.
public void setLinkZone(E e, java.lang.String id)
e
to the zone identified by id
.
java.lang.IllegalArgumentException
- if the given zone does not exist.public void register(ZoneInfo<V,E> zinf)
zinf.id
. If there was
already a zone registered with that id, it is replaced.
public void unregister(java.lang.String id)
id
to the default zone and then removes it.
Any attempt to remove the default zone is silently ignored.
java.lang.IllegalArgumentException
- if the given zone does not exist.public void read()
public void write(java.lang.String fname, java.lang.String headerComment)
fname
is "-", the output goes
to stdout.
public void write(java.io.Writer out, java.lang.String headerComment)
out
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |