improve build, components should not do non-component things

This commit is contained in:
Jonathan Shook
2023-09-29 17:39:09 -05:00
parent 9b39e2abc3
commit 7e2ddc745a
5 changed files with 15 additions and 10 deletions

View File

@@ -202,7 +202,7 @@ public class SimpleActivity extends NBBaseComponent implements Activity {
}
public String toString() {
return getAlias() + ':' + this.runState + ':' + this.tally;
return activityDef.getAlias() + ':' + this.runState + ':' + this.tally;
}
@Override

View File

@@ -41,13 +41,15 @@ public class TestComponent extends NBBaseComponent {
@Override
public NBComponent attach(NBComponent... children) {
System.out.println("attaching children:" + Arrays.toString(children));
System.out.println("attaching children:" +
Arrays.stream(children).map(c -> c.getLabels().linearizeAsMetrics()).toList());
return super.attach(children);
}
@Override
public NBComponent detach(NBComponent... children) {
System.out.println("detaching children:" + Arrays.toString(children));
System.out.println("detaching children:" +
Arrays.stream(children).map(c -> c.getLabels().linearizeAsMetrics()).toList());
return super.detach(children);
}
}

View File

@@ -31,8 +31,12 @@ public class NBBaseComponent extends NBBaseComponentMetrics implements NBCompone
public NBBaseComponent(NBComponent parentComponent, NBLabels componentSpecificLabelsOnly) {
this.labels = componentSpecificLabelsOnly;
this.parent = parentComponent;
if (this.parent!=null) { parentComponent.attach(this);}
if (parentComponent!=null) {
parent = parentComponent;
parent.attach(this);
} else {
parent=null;
}
}
@Override
public NBComponent getParent() {

View File

@@ -19,7 +19,6 @@ package io.nosqlbench.api.labels;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.*;
class NBLabelsRenderingTest {
@@ -38,7 +37,7 @@ class NBLabelsRenderingTest {
public void testLinearizeOpenMetricsFormat() {
var l1 = NBLabels.forKV("a","b","c","d","e","f");
String oml1 = l1.linearizeAsMetrics();
assertThat(oml1).isEqualTo("{a:\"b\",c:\"d\",e:\"f\"}");
assertThat(oml1).isEqualTo("{a=\"b\",c=\"d\",e=\"f\"}");
}
}

View File

@@ -31,11 +31,11 @@ class NBMetricsQueryTest {
private final static TestComponent root_c2 = new TestComponent(root,"c2","c2");
private final static TestComponent root_c3 = new TestComponent(root,"c3","c3");
private final static NBMetric m1 = new NBBaseMetric("m1","m1");
private final String m1Handle = root.addMetric(m1);
private final static String m1Handle = root.addMetric(m1);
private final static NBMetric m2 = new NBBaseMetric("m2","m2");
private final String m2Handle = root_c2.addMetric(m2);
private final static String m2Handle = root_c2.addMetric(m2);
private final static NBMetric m3 = new NBBaseMetric("m3","m3");
private final String m3Handle = root_c3.addMetric(m3);
private final static String m3Handle = root_c3.addMetric(m3);
@Test
public void testFindInTree() {