Class LayeredNetwork

java.lang.Object
jline.lang.Model
jline.lang.Ensemble
jline.lang.layered.LayeredNetwork
All Implemented Interfaces:
Serializable, Copyable

public class LayeredNetwork extends Ensemble implements Copyable
LayeredNetwork represents a layered queueing network (LQN) model for performance analysis of distributed and multi-tiered software systems.

Layered queueing networks extend traditional queueing networks by modeling software systems where processes can both serve requests and make requests to other processes, creating a layered architecture. This is particularly useful for analyzing:

  • Multi-tier web applications (web server, application server, database)
  • Service-oriented architectures and microservices
  • Client-server systems with nested service calls
  • Cloud computing and distributed systems

The network consists of:

  • Hosts: Physical or virtual processors that execute tasks
  • Tasks: Software processes that can serve requests and make calls
  • Entries: Service interfaces exposed by tasks
  • Activities: Individual processing steps within tasks
  • Precedences: Execution order and control flow relationships

LayeredNetwork supports both open models (with external arrivals) and closed models (with fixed population), and can model complex interactions including synchronous calls, asynchronous messaging, fork-join parallelism, and probabilistic routing.

The model can be solved using various algorithms including Mean Value Analysis (MVA), simulation, and matrix-analytic methods to obtain performance metrics such as response times, throughputs, and resource utilizations.

See Also:
  • Field Details

  • Constructor Details

    • LayeredNetwork

      public LayeredNetwork(String name)
      Creates a new layered queueing network with the specified name.
      Parameters:
      name - the name of the layered network
  • Method Details

    • getHosts

      public Map<Integer,Host> getHosts()
    • getTasks

      public Map<Integer,Task> getTasks()
    • getEntries

      public Map<Integer,Entry> getEntries()
    • getActivities

      public Map<Integer,Activity> getActivities()
    • load

      public static LayeredNetwork load(String filename, boolean verbose)
      Loads a layered queueing network from an XML file.
      Parameters:
      filename - the path to the XML file to load
      verbose - if true, enables verbose output during loading
      Returns:
      the loaded LayeredNetwork instance
    • load

      public static LayeredNetwork load(String filename)
      Loads a layered queueing network from an XML file with default verbose setting.
      Parameters:
      filename - the path to the XML file to load
      Returns:
      the loaded LayeredNetwork instance
    • parseXML

      public static LayeredNetwork parseXML(String filename)
      Parses a layered queueing network from an XML file with default verbose setting.
      Parameters:
      filename - the path to the XML file to parse
      Returns:
      the parsed LayeredNetwork instance
    • parseXML

      public static LayeredNetwork parseXML(String filename, boolean verbose)
      Parses a layered queueing network from an XML file.
      Parameters:
      filename - the path to the XML file to parse
      verbose - if true, enables verbose output during parsing
      Returns:
      the parsed LayeredNetwork instance
    • readXML

      public static LayeredNetwork readXML(String filename)
      Reads a layered queueing network from an XML file with default verbose setting.
      Parameters:
      filename - the path to the XML file to read
      Returns:
      the read LayeredNetwork instance
    • readXML

      public static LayeredNetwork readXML(String filename, boolean verbose)
      Reads a layered queueing network from an XML file.
      Parameters:
      filename - the path to the XML file to read
      verbose - if true, enables verbose output during reading
      Returns:
      the read LayeredNetwork instance
    • viewModel

      public static void viewModel(String filename)
      Views a layered queueing network model using the default JLQN path.
      Parameters:
      filename - the path to the model file to view
    • viewModel

      public static void viewModel(String jlqnPath, String filename)
      Views a layered queueing network model using the specified JLQN path.
      Parameters:
      jlqnPath - the path to the JLQN executable
      filename - the path to the model file to view
    • generateGraph

      public void generateGraph()
      Generates the graph representation of the layered network. This method is currently not implemented.
    • getEnsemble

      public List<Network> getEnsemble()
      Description copied from class: Ensemble
      Gets the list of network models in this ensemble.
      Overrides:
      getEnsemble in class Ensemble
      Returns:
      the list of network models
    • getLayers

      public List<Network> getLayers()
      Gets the list of network layers in this layered network.
      Returns:
      the list of network layers
    • getNodeByName

      public LayeredNetworkElement getNodeByName(String nodeName)
      Retrieves a network element by its name.
      Parameters:
      nodeName - the name of the node to find
      Returns:
      the LayeredNetworkElement with the specified name, or null if not found
    • getNodeIndex

      public Integer getNodeIndex(LayeredNetworkElement node)
      Gets the index of a network element in the node collection.
      Parameters:
      node - the network element to find the index for
      Returns:
      the index of the node, or -1 if not found
    • getNodeNames

      public List<String> getNodeNames()
      Gets the names of all network elements (hosts, tasks, entries, activities).
      Returns:
      a list containing all node names in the network
    • getNumberOfLayers

      public int getNumberOfLayers()
      Gets the number of layers in the layered network.
      Returns:
      the number of layers
    • getNumberOfModels

      public int getNumberOfModels()
      Gets the number of models in the layered network ensemble.
      Returns:
      the number of models
    • getStruct

      public LayeredNetworkStruct getStruct()
      Gets the structural representation of the layered network.
      Returns:
      the LayeredNetworkStruct containing the network structure
    • getStruct

      public LayeredNetworkStruct getStruct(boolean regenerate)
      Gets the structural representation of the layered network.
      Parameters:
      regenerate - if true, forces regeneration of the structure
      Returns:
      the LayeredNetworkStruct containing the network structure
    • init

      public void init()
      Initializes the layered network by generating the graph and setting default parameters.
    • initDefault

      public void initDefault()
      Initializes the layered network with default settings. Currently this method contains placeholder implementation.
    • reset

      public void reset(boolean isHard)
      Resets the layered network to its initial state.
      Parameters:
      isHard - if true, performs a hard reset clearing all network elements; if false, performs a soft reset clearing only the ensemble
    • sendModel

      public void sendModel(String outputPath, String portNumber)
      Sends the model to a local server using the default IP address (127.0.0.1).
      Parameters:
      outputPath - the path where the model output should be stored
      portNumber - the port number for the server connection
    • sendModel

      public void sendModel(String outputPath, String ipNumber, String portNumber)
      Sends the model to a server at the specified IP address and port.
      Parameters:
      outputPath - the path where the model output should be stored
      ipNumber - the IP address of the server
      portNumber - the port number for the server connection
    • summary

      public void summary()
      Prints a summary of the layered network structure to standard output.
    • view

      public void view()
      Views the layered network model using ModelVisualizer.
    • plot

      public void plot()
      Displays an interactive graph visualization of this layered network using JUNG.

      The visualization shows:

      • Hosts as red pyramids
      • Tasks as red parallelograms
      • Entries as red rectangles
      • Activities as red circles

      The window includes menus for:

      • Switching between different layout algorithms (Hierarchical, Circle, Force-Directed, etc.)
      • Switching mouse modes (Pan/Zoom vs Pick/Move)
    • plot

      public void plot(String title)
      Displays an interactive graph visualization with custom title.
      Parameters:
      title - the window title
    • plot

      public void plot(String title, int width, int height)
      Displays an interactive graph visualization with custom title and dimensions.
      Parameters:
      title - the window title
      width - the window width in pixels
      height - the window height in pixels
    • writeJLQN

      public void writeJLQN(String filename) throws Exception
      Writes the layered network to a JLQN file with default naming.
      Parameters:
      filename - the path to write the JLQN file
      Throws:
      Exception - if there's an error writing the file
    • writeJLQN

      public void writeJLQN(String filename, boolean abstractNames) throws Exception
      Writes the layered network to a JLQN file.
      Parameters:
      filename - the path to write the JLQN file
      abstractNames - if true, uses abstract names in the output
      Throws:
      Exception - if there's an error writing the file
    • writeXML

      public void writeXML(String filename)
      Writes the layered network to an XML file with default naming.
      Parameters:
      filename - the path to write the XML file
    • writeXML

      public void writeXML(String filename, boolean abstractNames)
      Writes the layered network to an XML file.
      Parameters:
      filename - the path to write the XML file
      abstractNames - if true, uses abstract names in the output
    • initUsedFeatures

      public void initUsedFeatures()
      Initialize the used features for each model in the ensemble
    • setUsedFeatures

      public void setUsedFeatures(String feature)
      Set a language feature as used
      Parameters:
      feature - the name of the feature to mark as used
    • getUsedLangFeatures

      public FeatureSet getUsedLangFeatures()
      Get the used language features by analyzing the layered network structure
      Returns:
      FeatureSet containing all features used in this layered network
    • sanitize

      public void sanitize()
      Validates the LayeredNetwork configuration. Ensures that if entries are defined, activities are also defined to serve those entries. An entry without a bound activity is not a functional LQN model.
      Throws:
      RuntimeException - if entries exist but no activities are defined
    • reconstructDistribution

      public static Distribution reconstructDistribution(ProcessType type, Matrix params, Double mean, Double scv, MatrixCell proc)
      Reconstruct a Distribution object from primitive parameters. This is the inverse of extractDistParams and enables migration away from storing Distribution objects in LayeredNetworkStruct.
      Parameters:
      type - The ProcessType of the distribution
      params - The distribution parameters (may be null for some types)
      mean - The mean of the distribution
      scv - The squared coefficient of variation
      proc - The process representation (for PH, MAP types)
      Returns:
      A Distribution object reconstructed from the primitives
    • reconstructDiscreteDistribution

      public static DiscreteDistribution reconstructDiscreteDistribution(ProcessType type, Matrix params, Double mean)
      Reconstruct a DiscreteDistribution object from primitive parameters.
      Parameters:
      type - The ProcessType of the distribution
      params - The distribution parameters (may be null for some types)
      mean - The mean of the distribution
      Returns:
      A DiscreteDistribution object reconstructed from the primitives