Class LayeredNetwork

  • All Implemented Interfaces:
    java.io.Serializable , jline.lang.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.

    • Constructor Detail

      • LayeredNetwork

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

      • load

         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

         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

         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

         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

         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

         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

         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

         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

         void generateGraph()

        Generates the graph representation of the layered network. This method is currently not implemented.

      • getEnsemble

         List<Network> getEnsemble()

        Gets the list of network models in this ensemble.

        Returns:

        the list of network models

      • getLayers

         List<Network> getLayers()

        Gets the list of network layers in this layered network.

        Returns:

        the list of network layers

      • getNodeByName

         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

         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

         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

         int getNumberOfLayers()

        Gets the number of layers in the layered network.

        Returns:

        the number of layers

      • getNumberOfModels

         int getNumberOfModels()

        Gets the number of models in the layered network ensemble.

        Returns:

        the number of models

      • getStruct

         LayeredNetworkStruct getStruct()

        Gets the structural representation of the layered network.

        Returns:

        the LayeredNetworkStruct containing the network structure

      • getStruct

         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

         void init()

        Initializes the layered network by generating the graph and setting default parameters.

      • initDefault

         void initDefault()

        Initializes the layered network with default settings. Currently this method contains placeholder implementation.

      • reset

         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

         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

         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

         void summary()

        Prints a summary of the layered network structure to standard output.

      • view

         void view()

        Views the layered network model by creating a temporary JLQN file and opening it.

      • writeJLQN

         void writeJLQN(String filename)

        Writes the layered network to a JLQN file with default naming.

        Parameters:
        filename - the path to write the JLQN file
      • writeJLQN

         void writeJLQN(String filename, boolean abstractNames)

        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
      • writeXML

         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

         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

         void initUsedFeatures()

        Initialize the used features for each model in the ensemble

      • setUsedFeatures

         void setUsedFeatures(String feature)

        Set a language feature as used

        Parameters:
        feature - the name of the feature to mark as used
      • getUsedLangFeatures

         FeatureSet getUsedLangFeatures()

        Get the used language features by analyzing the layered network structure

        Returns:

        FeatureSet containing all features used in this layered network

      • sanitize

         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.

      • reconstructDistribution

         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

         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