Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(discovery): port discovery types from cryostat #152

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
nodeType as String
  • Loading branch information
andrewazores committed Aug 8, 2022
commit eaba2f75585dc861d67aadb9858ba95b8306de97
10 changes: 3 additions & 7 deletions src/main/java/io/cryostat/core/discovery/AbstractNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ public abstract class AbstractNode implements Comparable<AbstractNode> {

protected final String name;

protected final NodeType nodeType;
protected final String nodeType;

protected final Map<String, String> labels;

protected AbstractNode(AbstractNode other) {
this(other.name, other.nodeType, other.labels);
}

protected AbstractNode(String name, NodeType nodeType, Map<String, String> labels) {
protected AbstractNode(String name, String nodeType, Map<String, String> labels) {
this.name = name;
this.nodeType = nodeType;
this.labels = new HashMap<>(labels);
Expand All @@ -66,7 +66,7 @@ public String getName() {
return name;
}

public NodeType getNodeType() {
public String getNodeType() {
return nodeType;
}

Expand All @@ -76,10 +76,6 @@ public Map<String, String> getLabels() {

@Override
public int compareTo(AbstractNode other) {
int type = nodeType.ordinal() - other.nodeType.ordinal();
if (type != 0) {
return type;
}
return name.compareTo(other.name);
}

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/io/cryostat/core/discovery/BaseNodeType.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
*/
package io.cryostat.core.discovery;

public enum BaseNodeType implements NodeType {
public enum BaseNodeType {
// represents the entire deployment scenario Cryostat finds itself in
UNIVERSE("Universe"),
// represents a division of the deployment scenario - the universe may consist of a
Expand All @@ -54,7 +54,6 @@ public enum BaseNodeType implements NodeType {
this.kind = kind;
}

@Override
public String getKind() {
return kind;
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/io/cryostat/core/discovery/EnvironmentNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ public EnvironmentNode(EnvironmentNode other) {
this(other.name, other.nodeType, other.labels, other.children);
}

public EnvironmentNode(String name, NodeType nodeType) {
public EnvironmentNode(String name, String nodeType) {
this(name, nodeType, Collections.emptyMap());
}

public EnvironmentNode(String name, NodeType nodeType, Map<String, String> labels) {
public EnvironmentNode(String name, String nodeType, Map<String, String> labels) {
this(name, nodeType, labels, Collections.emptySortedSet());
}

public EnvironmentNode(
String name,
NodeType nodeType,
String nodeType,
Map<String, String> labels,
Collection<? extends AbstractNode> children) {
super(name, nodeType, labels);
Expand Down
44 changes: 0 additions & 44 deletions src/main/java/io/cryostat/core/discovery/NodeType.java

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/java/io/cryostat/core/discovery/ServiceRef.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public ServiceRef(ServiceRef sr) {
this.annotations = new Annotations(sr.annotations);
}

public URI getServiceUri() {
public URI getConnectUrl() {
return connectUrl;
}

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/io/cryostat/core/discovery/TargetNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ public TargetNode(TargetNode other) {
this(other.nodeType, other.target, other.labels);
}

public TargetNode(NodeType nodeType, ServiceRef target) {
super(target.getServiceUri().toString(), nodeType, Collections.emptyMap());
public TargetNode(String nodeType, ServiceRef target) {
super(target.getConnectUrl().toString(), nodeType, Collections.emptyMap());
this.target = new ServiceRef(target);
}

public TargetNode(NodeType nodeType, ServiceRef target, Map<String, String> labels) {
super(target.getServiceUri().toString(), nodeType, labels);
public TargetNode(String nodeType, ServiceRef target, Map<String, String> labels) {
super(target.getConnectUrl().toString(), nodeType, labels);
this.target = new ServiceRef(target);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class ServiceRefTest {
@Test
void testConstruct() {
ServiceRef sr = new ServiceRef(EXAMPLE_URI, EXAMPLE_ALIAS);
MatcherAssert.assertThat(sr.getServiceUri(), Matchers.equalTo(EXAMPLE_URI));
MatcherAssert.assertThat(sr.getConnectUrl(), Matchers.equalTo(EXAMPLE_URI));
MatcherAssert.assertThat(sr.getAlias(), Matchers.equalTo(Optional.of(EXAMPLE_ALIAS)));
}

Expand Down