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

PAYARA-1694-Healthcheck-still-prints-out-error-in-log #1626

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
@@ -1,6 +1,6 @@
/*
*
* Copyright (c) 2016 Payara Foundation and/or its affiliates. All rights reserved.
* Copyright (c) 2016-2017 Payara Foundation and/or its affiliates. All rights reserved.
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
Expand Down Expand Up @@ -105,14 +105,15 @@ public HistoricHealthCheckEvent[] getTraces() {
}

public HistoricHealthCheckEvent[] getTraces(Integer limit) {
HistoricHealthCheckEvent[] result;
HistoricHealthCheckEvent[] historicEvents = historicStore.toArray(new HistoricHealthCheckEvent[historicStore.size()]);
if (limit < historicEvents.length) {
result = new HistoricHealthCheckEvent[limit];
System.arraycopy(historicEvents, 0, result, 0, limit);
}
else {
result = historicEvents;
HistoricHealthCheckEvent[] result = null;
if (historicStore != null) {
HistoricHealthCheckEvent[] historicEvents = historicStore.toArray(new HistoricHealthCheckEvent[historicStore.size()]);
if (limit < historicEvents.length) {
result = new HistoricHealthCheckEvent[limit];
System.arraycopy(historicEvents, 0, result, 0, limit);
} else {
result = historicEvents;
}
}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,7 @@

import javax.inject.Inject;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Properties;
import java.util.*;

/**
* @author mertcaliskan
Expand Down Expand Up @@ -110,11 +105,6 @@ public void execute(AdminCommandContext context) {
actionReport.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
if (!service.isHistoricalTraceEnabled()) {
actionReport.setMessage("Health Check Historical Trace is not enabled!");
actionReport.setActionExitCode(ActionReport.ExitCode.FAILURE);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct me if I'm being dumb, but would it have worked to just change this line to a success code? Only because I like it returning a 'disabled' message when it's disabled. It's more of a question than a review really, so feel free to disregard it!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MattGill98 this is being consumed from admin console and if we return failure, it throws out an error while opening the historic configuration page.

return;
}
else {
if (server.isDas()) {
if (targetUtil.getConfig(target).isDas()) {
Expand All @@ -135,18 +125,21 @@ private void generateReport(ActionReport actionReport) {

ColumnFormatter columnFormatter = new ColumnFormatter(headers);
Properties extrasProps = new Properties();
ArrayList historic = new ArrayList<Map>();

for (HistoricHealthCheckEvent historicHealthCheckEvent : traces) {
LinkedHashMap<String, String> messages = new LinkedHashMap<String, String>();
Object values[] = new Object[2];
values[0] = new Date(historicHealthCheckEvent.getOccurringTime());
values[1] = constructMessage(historicHealthCheckEvent);
messages.put("dateTime",values[0].toString());
messages.put("message", (String) values[1]);
historic.add(messages);
columnFormatter.addRow(values);
List historic = new ArrayList<>();

if (traces != null) {
for (HistoricHealthCheckEvent historicHealthCheckEvent : traces) {
LinkedHashMap<String, String> messages = new LinkedHashMap<String, String>();
Object values[] = new Object[2];
values[0] = new Date(historicHealthCheckEvent.getOccurringTime());
values[1] = constructMessage(historicHealthCheckEvent);
messages.put("dateTime",values[0].toString());
messages.put("message", (String) values[1]);
historic.add(messages);
columnFormatter.addRow(values);
}
}

actionReport.setMessage(columnFormatter.toString());
extrasProps.put("historicmessages", historic);
actionReport.setExtraProperties(extrasProps);
Expand Down