Skip to content

Commit

Permalink
Sums are now stored as custom graph
Browse files Browse the repository at this point in the history
  • Loading branch information
fbacchella committed Sep 20, 2011
1 parent 595f1b0 commit caa9d4d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 34 deletions.
51 changes: 18 additions & 33 deletions src/jrds/HostsList.java
Expand Up @@ -55,7 +55,6 @@ public static final class Stats {
public Date lastCollect;
}

private RdsHost sumhost = null;
private RdsHost customhost = null;

private final Set<RdsHost> hostList = new HashSet<RdsHost>();
Expand Down Expand Up @@ -99,13 +98,8 @@ public HostsList(PropertiesManager pm) {
}

private void init() {
addTree(Filter.SUM.getName(), GraphTree.SUMROOT);
filters.put(Filter.SUM.getName(), Filter.SUM);
sumhost = new RdsHost("SumHost");

addTree(Filter.CUSTOM.getName(), Filter.CUSTOM.getName());
filters.put(Filter.CUSTOM.getName(), Filter.CUSTOM);
customhost = new RdsHost("CustomHost");
customhost = new RdsHost("CustomGraphHost");
customhost.setParent(this);

filters.put(Filter.EVERYTHING.getName(), Filter.EVERYTHING);

Expand All @@ -120,9 +114,6 @@ private void init() {
filters.put(Filter.ALLSERVICES.getName(), Filter.ALLSERVICES);

addTree("All tags", GraphTree.TAGSROOT);

sumhost.setParent(this);
customhost.setParent(this);
}

public void configure(PropertiesManager pm) {
Expand Down Expand Up @@ -222,22 +213,7 @@ public void configure(PropertiesManager pm) {
}
allTabs.add(filterTab);

//Let's build the tab with all the sums
Tab sumsTab = null;
Map<String, SumProbe> sums = conf.setSumMap();
if(sums.size() > 0) {
sumsTab = new Tab.DynamicTree("All sums", PropertiesManager.SUMSTAB);
for(SumProbe s: sums.values()) {
addVirtual(s, sumhost, Filter.SUM.getName());
GraphNode sum = s.getGraphList().iterator().next();
//String id = Integer.toString(sum.hashCode());
graphMap.put(sum.getQualifieName().hashCode(), sum);
sumsTab.add(sum.getQualifieName(), Collections.singletonList(s.getName()));
}
allTabs.add(sumsTab);
}

//Let's build all the custom tabs
//Let's build all the custom graph tabs
Map<String, Tab> customTabMap = conf.setTabMap();
logger.debug(jrds.Util.delayedFormatString("Tabs to add: %s", customTabMap.values()));
for(Tab t: customTabMap.values()) {
Expand All @@ -251,21 +227,31 @@ public void configure(PropertiesManager pm) {
logger.debug("Parsing graphs configuration");
Map<String, GraphDesc> graphs = conf.setGrapMap();
//Let's build the tab with all the custom graphs
Tab customGraphsTab = null;
Tab customGraphsTab = new Tab.DynamicTree("Custom graphs", PropertiesManager.CUSTOMGRAPHTAB);
ContainerProbe cp = new ContainerProbe(customhost.getName());
if(! graphs.isEmpty()) {
customGraphsTab = new Tab.DynamicTree("Custom graphs", PropertiesManager.CUSTOMGRAPHTAB);
ContainerProbe cp = new ContainerProbe(customhost.getName());
for(GraphDesc gd: graphs.values()) {
logger.trace("Adding graph: " + gd.getGraphTitle());
cp.addGraph(gd);
}
addVirtual(cp, customhost, Filter.CUSTOM.getName());
addVirtual(cp, customhost);
for(GraphNode gn: cp.getGraphList()) {
customGraphsTab.add(gn.getQualifieName(), gn.getGraphDesc().getHostTree(gn));
}
allTabs.add(customGraphsTab);
}

//Let's build the tab with all the sums
Map<String, SumProbe> sums = conf.setSumMap();
if(sums.size() > 0) {
for(SumProbe s: sums.values()) {
addVirtual(s, customhost);
GraphNode sum = s.getGraphList().iterator().next();
graphMap.put(sum.getQualifieName().hashCode(), sum);
customGraphsTab.add(sum.getQualifieName(), "Sums", s.getName());
}
}

makeTabs(pm, conf, allTabs, customTabMap);

//Hosts list adopts all tabs
Expand Down Expand Up @@ -584,13 +570,12 @@ public Collection<String> getAllFiltersNames() {
return filters.keySet();
}

private void addVirtual(VirtualProbe vprobe, RdsHost vhost, String root) {
private void addVirtual(VirtualProbe vprobe, RdsHost vhost) {
try {
vhost.getProbes().add(vprobe);
vprobe.setHost(vhost);
for(GraphNode currGraph: vprobe.getGraphList()) {
logger.trace("adding virtual graph: " + currGraph);
treeMap.get(root).addGraphByPath(currGraph.getTreePathByHost(), currGraph);
graphMap.put(currGraph.hashCode(), currGraph);
}
logger.debug("adding virtual probe " + vprobe.getName());
Expand Down
7 changes: 6 additions & 1 deletion src/jrds/Tab.java
@@ -1,5 +1,6 @@
package jrds;

import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -36,7 +37,7 @@ public boolean isFilters() {
}
}
public static final class StaticTree extends Tab {
GraphTree gt;
private final GraphTree gt;
public StaticTree(String name, GraphTree gt) {
super(name);
this.gt = gt;
Expand Down Expand Up @@ -96,6 +97,10 @@ public void add(String filter) {
throw new RuntimeException("Not implemented");
}

public void add(String id, String... path) {
add(id, Arrays.asList(path));
}

public void add(String id, List<String> path) {
throw new RuntimeException("Not implemented");
}
Expand Down

0 comments on commit caa9d4d

Please sign in to comment.