29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/mosaik/commands/evaluate.rb', line 29
def call
info "Evaluating microservice candidates (#{options.map { |k, v| "#{k}: #{v}" }.join(', ')})"
graph.clusters.delete_if { |_, cluster| cluster.vertices.size < 2 }
options[:metrics].each do |metric|
Metrics
.const_get(metric.to_s.camelize)
.new(options, graph)
.evaluate
end
graph.clusters.each_value do |cluster|
info "Cluster #{cluster.id} (#{options[:metrics].map { |m| "#{m}: #{cluster.attributes[m].round(2)}" }.join(', ')})"
next unless options[:debug]
debug "Cluster #{cluster.id}: #{cluster.vertices.map(&:id).join(', ')}"
end
info "Graph (#{options[:metrics].map { |m| "#{m}: #{graph.attributes[m].round(2)}" }.join(', ')})"
write_graph
visualize_graph
return unless options[:statistics]
statistics = Graph::Statistics
.new(options, graph)
.call
File.write(options[:statistics], statistics.to_yaml)
info "Statistics written to #{options[:statistics]}"
end
|