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

Change collector status data from a map to a set of objects #4886

Merged
merged 1 commit into from
Jul 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public boolean test(Sidecar sidecar) {
// Sidecars with not known status are in an UNKNOWN status
return Status.UNKNOWN.equals(status);
}
return collectorStatusList.collectors().entrySet().stream()
.anyMatch(entry -> Status.fromStatusCode(entry.getValue().status()).equals(status));
return collectorStatusList.collectors().stream()
.anyMatch(status -> Status.fromStatusCode(status.status()).equals(this.status));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,19 @@
@AutoValue
@JsonAutoDetect
public abstract class CollectorStatus {
@JsonProperty("name")
public abstract String name();

@JsonProperty("status")
public abstract int status();

@JsonProperty("message")
public abstract String message();

@JsonCreator
public static CollectorStatus create(@JsonProperty("status") int status,
public static CollectorStatus create(@JsonProperty("name") String name,
@JsonProperty("status") int status,
@JsonProperty("message") String message) {
return new AutoValue_CollectorStatus(status, message);
return new AutoValue_CollectorStatus(name, status, message);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableSet;

import java.util.HashMap;
import java.util.Set;

@AutoValue
@JsonAutoDetect
Expand All @@ -33,11 +34,11 @@ public abstract class CollectorStatusList {
public abstract String message();

@JsonProperty("collectors")
public abstract HashMap<String, CollectorStatus> collectors();
public abstract ImmutableSet<CollectorStatus> collectors();

@JsonCreator
public static CollectorStatusList create(@JsonProperty("status") int status,
@JsonProperty("message") String message,
@JsonProperty("collectors") HashMap<String, CollectorStatus> collectors) {
return new AutoValue_CollectorStatusList(status, message, collectors);
@JsonProperty("collectors") Set<CollectorStatus> collectors) {
return new AutoValue_CollectorStatusList(status, message, ImmutableSet.copyOf(collectors));
}}
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,10 @@ const CollectorsAdministration = createReactClass({
const configuration = configurations.find(config => config.id === configAssignment.configuration_id);
let collectorStatus;
try {
collectorStatus = sidecar.node_details.status.collectors[collector.name].status;
const result = sidecar.node_details.status.collectors.find(c => c.name === collector.name);
if (result) {
collectorStatus = result.status;
}
} catch (e) {
// Do nothing
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ const SidecarStatus = createReactClass({
return <p>Did not receive collectors status, set the option <code>send_status: true</code> in the sidecar configuration to see this information.</p>;
}

const collectors = Object.keys(details.status.collectors);
const collectors = details.status.collectors;
if (collectors.length === 0) {
return <p>There are no collectors configured in this sidecar.</p>;
}

const statuses = [];
collectors.forEach((collector) => {
const status = details.status.collectors[collector];
collectors.forEach((status) => {
const collector = status.name;

let statusMessage;
let statusBadge;
Expand Down