Skip to content

Commit

Permalink
JENKINS-45963 (FreeBSD): if collect fails for one node, continue with…
Browse files Browse the repository at this point in the history
… others
  • Loading branch information
evernat committed Aug 6, 2017
1 parent aeaa026 commit 6de6ddf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
7 changes: 2 additions & 5 deletions src/main/java/net/bull/javamelody/NodesController.java
Expand Up @@ -25,7 +25,6 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
Expand Down Expand Up @@ -180,8 +179,7 @@ private void writeMessage(HttpServletResponse resp, String message, String partT
}

private void doPdf(HttpServletRequest req, HttpServletResponse resp,
MonitoringController monitoringController)
throws IOException, InterruptedException, ExecutionException, ServletException {
MonitoringController monitoringController) throws IOException, ServletException {
if (HttpPart.PROCESSES.isPart(req)) {
monitoringController.addPdfContentTypeAndDisposition(req, resp);
final Map<String, List<ProcessInformations>> processInformationsByNodeName = getRemoteCallHelper()
Expand Down Expand Up @@ -242,8 +240,7 @@ private void doJmxValue(HttpServletResponse resp, List<String> jmxValues) throws
}

private void doPart(HttpServletRequest req, HttpServletResponse resp,
MonitoringController monitoringController)
throws IOException, InterruptedException, ExecutionException, ServletException {
MonitoringController monitoringController) throws IOException, ServletException {
// ici, ni web.xml ni pom.xml
if (HttpPart.MBEANS.isPart(req)) {
final Map<String, List<MBeanNode>> mbeanNodesByNodeName = getRemoteCallHelper()
Expand Down
22 changes: 10 additions & 12 deletions src/main/java/net/bull/javamelody/RemoteCallHelper.java
Expand Up @@ -24,7 +24,6 @@
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

Expand Down Expand Up @@ -152,7 +151,7 @@ public T call() throws Throwable {
}

private <T> Map<String, T> collectDataByNodeName(Callable<T, Throwable> task)
throws IOException, InterruptedException, ExecutionException {
throws IOException {
final Jenkins jenkins = Jenkins.getInstance();
if (jenkins == null) {
return Collections.emptyMap();
Expand All @@ -178,33 +177,32 @@ private <T> Map<String, T> collectDataByNodeName(Callable<T, Throwable> task)
result.put(node, future.get(timeout, TimeUnit.MILLISECONDS));
} catch (final TimeoutException e) {
continue;
} catch (final Throwable e) {
// JENKINS-45963 (FreeBSD): if collect fails for one node, continue with others
continue;
}
}
return result;
}

Map<String, JavaInformations> collectJavaInformationsListByName()
throws IOException, InterruptedException, ExecutionException {
Map<String, JavaInformations> collectJavaInformationsListByName() throws IOException {
return collectDataByNodeName(JAVA_INFORMATIONS_TASK);
}

List<String> collectJmxValues(String jmxValueParameter)
throws IOException, InterruptedException, ExecutionException {
List<String> collectJmxValues(String jmxValueParameter) throws IOException {
return new ArrayList<>(collectDataByNodeName(new JmxValueTask(jmxValueParameter)).values());
}

Map<String, List<MBeanNode>> collectMBeanNodesByNodeName()
throws IOException, InterruptedException, ExecutionException {
Map<String, List<MBeanNode>> collectMBeanNodesByNodeName() throws IOException {
return collectDataByNodeName(MBEANS_TASK);
}

Map<String, List<ProcessInformations>> collectProcessInformationsByNodeName()
throws IOException, InterruptedException, ExecutionException {
throws IOException {
return collectDataByNodeName(PROCESS_INFORMATIONS_TASK);
}

HeapHistogram collectGlobalHeapHistogram()
throws IOException, InterruptedException, ExecutionException {
HeapHistogram collectGlobalHeapHistogram() throws IOException {
final Map<String, HeapHistogram> heapHistograms = collectDataByNodeName(
HEAP_HISTOGRAM_TASK);
HeapHistogram heapHistoTotal = null;
Expand All @@ -222,7 +220,7 @@ HeapHistogram collectGlobalHeapHistogram()
}

String forwardAction(String actionName, String sessionId, String threadId, String jobId,
String cacheId) throws IOException, InterruptedException, ExecutionException {
String cacheId) throws IOException {
final ActionTask task = new ActionTask(actionName, sessionId, threadId, jobId, cacheId);
final Map<String, String> messagesByNodeName = collectDataByNodeName(task);
final StringBuilder sb = new StringBuilder();
Expand Down

0 comments on commit 6de6ddf

Please sign in to comment.