use of org.apache.geode.distributed.internal.deadlock.DependencyGraph in project geode by apache.
the class MiscellaneousCommands method showDeadlock.
@CliCommand(value = CliStrings.SHOW_DEADLOCK, help = CliStrings.SHOW_DEADLOCK__HELP)
@CliMetaData(shellOnly = false, relatedTopic = { CliStrings.TOPIC_GEODE_DEBUG_UTIL })
@ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ)
public Result showDeadlock(@CliOption(key = CliStrings.SHOW_DEADLOCK__DEPENDENCIES__FILE, help = CliStrings.SHOW_DEADLOCK__DEPENDENCIES__FILE__HELP, mandatory = true) String filename) {
Result result = null;
try {
if (!filename.endsWith(".txt")) {
return ResultBuilder.createUserErrorResult(CliStrings.format(CliStrings.INVALID_FILE_EXTENSION, ".txt"));
}
InternalCache cache = getCache();
Set<DistributedMember> allMembers = CliUtil.getAllMembers(cache);
GemFireDeadlockDetector gfeDeadLockDetector = new GemFireDeadlockDetector(allMembers);
DependencyGraph dependencyGraph = gfeDeadLockDetector.find();
Collection<Dependency> deadlock = dependencyGraph.findCycle();
DependencyGraph deepest = null;
if (deadlock == null) {
deepest = dependencyGraph.findLongestCallChain();
if (deepest != null) {
deadlock = deepest.getEdges();
}
}
Set<Dependency> dependencies = (Set<Dependency>) dependencyGraph.getEdges();
InfoResultData resultData = ResultBuilder.createInfoResultData();
if (deadlock != null) {
if (deepest != null) {
resultData.addLine(CliStrings.SHOW_DEADLOCK__DEEPEST_FOUND);
} else {
resultData.addLine(CliStrings.SHOW_DEADLOCK__DEADLOCK__DETECTED);
}
resultData.addLine(DeadlockDetector.prettyFormat(deadlock));
} else {
resultData.addLine(CliStrings.SHOW_DEADLOCK__NO__DEADLOCK);
}
resultData.addAsFile(filename, DeadlockDetector.prettyFormat(dependencies), MessageFormat.format(CliStrings.SHOW_DEADLOCK__DEPENDENCIES__REVIEW, filename), false);
result = ResultBuilder.buildResult(resultData);
} catch (Exception e) {
result = ResultBuilder.createGemFireErrorResult(CliStrings.SHOW_DEADLOCK__ERROR + " : " + e.getMessage());
}
return result;
}
Aggregations