Class ServiceChainMSLevelService
java.lang.Object
edu.university.ecs.lab.detection.antipatterns.services.ServiceChainMSLevelService
ServiceChainMSLevelService detects service chains in a microservice architecture using DFS.
-
Field Summary
Modifier and TypeFieldDescriptionprivate final int
protected static final int
Default chain length to consider as an anti-pattern.private ServiceDependencyGraph
private boolean
-
Constructor Summary
ConstructorDescriptionConstructs the service with the default chain length of 3.ServiceChainMSLevelService
(int CHAIN_LENGTH) Constructs the service with a specified chain length. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
dfs
(Microservice currentNode, Set<Microservice> pathVisited) Depth-first search (DFS) to explore and detect service chains starting from the currentNode.Retrieves all service chains from the given network graph.
-
Field Details
-
DEFAULT_CHAIN_LENGTH
protected static final int DEFAULT_CHAIN_LENGTHDefault chain length to consider as an anti-pattern.- See Also:
-
CHAIN_LENGTH
private final int CHAIN_LENGTH -
allChains
-
graph
-
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
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
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).
-