bcds.phison.multfailures
Class SequencerFromFile<V,E>

java.lang.Object
  extended by bcds.phison.multfailures.ElemsSequencerBase<V,E>
      extended by bcds.phison.multfailures.SequencerFromFile<V,E>
All Implemented Interfaces:
ElemsSequencer<V,E>, WithEnvParams

public class SequencerFromFile<V,E>
extends ElemsSequencerBase<V,E>

This class returns nodes and links in the order they appear in files (one file for nodes, and another for links). Filenames are passed through environment parameters. Note that, contrary to other sequencers, this class may not return all the nodes or links in the topology; it returns those found in the provided files.

Author:
Juan Segovia S.

Field Summary
 java.lang.String LINKS_FILENAME
          See getEnvParams().
 java.lang.String NODES_FILENAME
          See getEnvParams().
 
Constructor Summary
SequencerFromFile()
          Default constructor.
SequencerFromFile(TED<V,E> ted, Environ env)
          Creates a new instance and calls setup to complete the initialization.
 
Method Summary
 java.util.List<E> arrangeDirectedLinks(java.util.Random rnd)
          Returns a list of links, just as arrangeUndirectedLinks(java.util.Random), but links are treated as directed, that is, only the links that effectively appear in the file are returned.
 java.util.List<V> arrangeNodes(java.util.Random rnd)
          Returns a list of nodes read from the file whose name is given in the environment parameter SequencerFromFile.nodes_filename.
 java.util.List<E> arrangeUndirectedLinks(java.util.Random rnd)
          Returns a list of links read from the file whose name is given in the environment parameter SequencerFromFile.links_filename.
 java.lang.Object[] getEnvParams()
          Returns the list of environment parameters and default values of this class.
 
Methods inherited from class bcds.phison.multfailures.ElemsSequencerBase
getEnviron, getName, setup
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NODES_FILENAME

public final java.lang.String NODES_FILENAME
See getEnvParams().


LINKS_FILENAME

public final java.lang.String LINKS_FILENAME
See getEnvParams().

Constructor Detail

SequencerFromFile

public SequencerFromFile()
Default constructor.


SequencerFromFile

public SequencerFromFile(TED<V,E> ted,
                         Environ env)
Creates a new instance and calls setup to complete the initialization.

Method Detail

arrangeNodes

public java.util.List<V> arrangeNodes(java.util.Random rnd)
Returns a list of nodes read from the file whose name is given in the environment parameter SequencerFromFile.nodes_filename. The file is read through DataFileReader. Node ids must appear one per line. The parameter rnd is ignored; it may be null.

Specified by:
arrangeNodes in interface ElemsSequencer<V,E>
Overrides:
arrangeNodes in class ElemsSequencerBase<V,E>
Throws:
IOException - wrapped in AnyException if the file cannot be read, or any exception is thrown while reading it.
java.lang.IllegalArgumentException - if a given node id cannot be found in the topology, or a node appears more than once in the file.

arrangeUndirectedLinks

public java.util.List<E> arrangeUndirectedLinks(java.util.Random rnd)
Returns a list of links read from the file whose name is given in the environment parameter SequencerFromFile.links_filename. The file is read through DataFileReader. Links are given by a pair of node ids, one pair per line, and are considered "undirected" in the sense that the pair of nodes a b implies the pair b a.

If preserving link directionality is important, use arrangeDirectedLinks(java.util.Random) instead. Note, however, that that method is not part of the ElemsSequencer interface. The parameter rnd is ignored; it may be null.

Specified by:
arrangeUndirectedLinks in interface ElemsSequencer<V,E>
Overrides:
arrangeUndirectedLinks in class ElemsSequencerBase<V,E>
Throws:
IOException - wrapped in AnyException if the file cannot be read, or any exception is thrown while reading it.
java.lang.IllegalArgumentException - if the environment parameter links_filename is empty, a given link cannot be found in the topology, or a link appears more than once in the file.

arrangeDirectedLinks

public java.util.List<E> arrangeDirectedLinks(java.util.Random rnd)
Returns a list of links, just as arrangeUndirectedLinks(java.util.Random), but links are treated as directed, that is, only the links that effectively appear in the file are returned.

Specified by:
arrangeDirectedLinks in interface ElemsSequencer<V,E>
Overrides:
arrangeDirectedLinks in class ElemsSequencerBase<V,E>

getEnvParams

public java.lang.Object[] getEnvParams()
Returns the list of environment parameters and default values of this class. They are prefixed by "SequencerFromFile and are:

Specified by:
getEnvParams in interface WithEnvParams
Overrides:
getEnvParams in class ElemsSequencerBase<V,E>