Class ServiceChainMSLevelService

java.lang.Object
edu.university.ecs.lab.detection.antipatterns.services.ServiceChainMSLevelService

public class ServiceChainMSLevelService extends Object
ServiceChainMSLevelService detects service chains in a microservice architecture using DFS.
  • Field Details

    • DEFAULT_CHAIN_LENGTH

      protected static final int DEFAULT_CHAIN_LENGTH
      Default chain length to consider as an anti-pattern.
      See Also:
    • CHAIN_LENGTH

      private final int CHAIN_LENGTH
    • allChains

      private List<List<String>> allChains
    • graph

      private ServiceDependencyGraph graph
    • currentPath

      private List<String> currentPath
    • hasCycle

      private boolean hasCycle
  • Constructor Details

    • ServiceChainMSLevelService

      public ServiceChainMSLevelService()
      Constructs the service with the default chain length of 3.
    • ServiceChainMSLevelService

      public ServiceChainMSLevelService(int CHAIN_LENGTH)
      Constructs the service with a specified chain length.
      Parameters:
      CHAIN_LENGTH - the length of the chain to consider an anti-pattern.
  • Method Details

    • getServiceChains

      public ServiceChain getServiceChains(ServiceDependencyGraph graph)
      Retrieves all service chains from the given network graph.
      Parameters:
      graph - the network graph to analyze.
      Returns:
      a ServiceChain object representing all detected service chains.
    • dfs

      private void dfs(Microservice currentNode, Set<Microservice> pathVisited)
      Depth-first search (DFS) to explore and detect service chains starting from the currentNode. Detects cycles by ensuring that the current node is not already in the current DFS path.
      Parameters:
      currentNode - the current node being visited in the DFS.
      pathVisited - a set to track nodes visited in the current DFS path (for cycle detection).