private static void completeNodeInfo(DistributedAnswer<ProtobufSystemInfo.SystemInfo> distributedAnswer, Member member, NodeInfo nodeInfo) { Optional<ProtobufSystemInfo.SystemInfo> nodeAnswer = distributedAnswer.getAnswer(member); Optional<Exception> failure = distributedAnswer.getFailed(member); if (distributedAnswer.hasTimedOut(member)) { nodeInfo.setErrorMessage("Failed to retrieve information on time"); } else if (failure.isPresent()) { nodeInfo.setErrorMessage("Failed to retrieve information: " + failure.get().getMessage()); } else if (nodeAnswer.isPresent()) { nodeAnswer.get().getSectionsList().forEach(nodeInfo::addSection); } } }
@Override public void write(JsonWriter json) { writeHealth(json); List<ProtobufSystemInfo.Section> sections = stream(systemInfoSections) .map(SystemInfoSection::toProtobuf) .collect(MoreCollectors.toArrayList()); ceHttpClient.retrieveSystemInfo() .ifPresent(ce -> sections.addAll(ce.getSectionsList())); writeSections(sections, json); writeTelemetry(json); }
@Test public void remove_global_sections_from_results() { ProcessInfoProvider underTest = new ProcessInfoProvider(new SystemInfoSection[]{ new TestGlobalSystemInfoSection("foo"), new TestSystemInfoSection("bar")}); underTest.start(); List<ProtobufSystemInfo.Section> sections = ProcessInfoProvider.provide().getSectionsList(); assertThat(sections).extracting(ProtobufSystemInfo.Section::getName).containsExactly("bar"); underTest.stop(); }
private static void completeNodeInfo(DistributedAnswer<ProtobufSystemInfo.SystemInfo> distributedAnswer, Member member, NodeInfo nodeInfo) { Optional<ProtobufSystemInfo.SystemInfo> nodeAnswer = distributedAnswer.getAnswer(member); Optional<Exception> failure = distributedAnswer.getFailed(member); if (distributedAnswer.hasTimedOut(member)) { nodeInfo.setErrorMessage("Failed to retrieve information on time"); } else if (failure.isPresent()) { nodeInfo.setErrorMessage("Failed to retrieve information: " + failure.get().getMessage()); } else if (nodeAnswer.isPresent()) { nodeAnswer.get().getSectionsList().forEach(nodeInfo::addSection); } } }
@Override public void write(JsonWriter json) { writeHealth(json); List<ProtobufSystemInfo.Section> sections = stream(systemInfoSections) .map(SystemInfoSection::toProtobuf) .collect(MoreCollectors.toArrayList()); ceHttpClient.retrieveSystemInfo() .ifPresent(ce -> sections.addAll(ce.getSectionsList())); writeSections(sections, json); writeTelemetry(json); }
@Test public void merge_sections() { ProcessInfoProvider underTest = new ProcessInfoProvider(new SystemInfoSection[]{ new TestSystemInfoSection("foo"), new TestSystemInfoSection("bar")}); underTest.start(); List<ProtobufSystemInfo.Section> sections = ProcessInfoProvider.provide().getSectionsList(); assertThat(sections).extracting(ProtobufSystemInfo.Section::getName) .containsExactlyInAnyOrder("foo", "bar"); underTest.stop(); }