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-4171 Monitoring data of an Instance is not visible if it is in a Deployment Group #4305

Merged
merged 2 commits into from
Nov 11, 2019
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 @@ -37,33 +37,29 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2018] Payara Foundation and/or affiliates
// Portions Copyright [2018-2019] Payara Foundation and/or affiliates

package org.glassfish.admingui.common.handlers;

import java.io.UnsupportedEncodingException;
import org.glassfish.admingui.common.util.GuiUtil;

import com.sun.jsftemplating.annotation.Handler;
import com.sun.jsftemplating.annotation.HandlerInput;
import com.sun.jsftemplating.annotation.HandlerOutput;
import com.sun.jsftemplating.layout.descriptors.handler.HandlerContext;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.net.URLEncoder;

import java.util.List;
import java.util.HashMap;
import java.util.Map;
import java.util.ArrayList;
import java.text.DateFormat;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Locale;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.ListIterator;
import java.util.Locale;
import java.util.Map;
import java.util.StringJoiner;
import java.util.logging.Level;

import org.glassfish.admingui.common.util.RestResponse;
import org.glassfish.admingui.common.util.GuiUtil;
import org.glassfish.admingui.common.util.RestUtil;

/**
Expand Down Expand Up @@ -406,18 +402,33 @@ public static void getStats(HandlerContext handlerCtx) {
@Handler(id = "updateMonitorLevels",
input = {
@HandlerInput(name = "allRows", type = List.class, required = true),
@HandlerInput(name = "endpoint", type = String.class)})
@HandlerInput(name = "config", type = String.class, required = true)})
public static void updateMonitorLevels(HandlerContext handlerCtx) {
String endpoint = (String) handlerCtx.getInputValue("endpoint");
String config = (String) handlerCtx.getInputValue("config");
List<Map> allRows = (List<Map>) handlerCtx.getInputValue("allRows");
Map payload = new HashMap();

StringJoiner moduelNames = new StringJoiner(":");
StringJoiner moduellevels = new StringJoiner(":");

for (Map<String, String> oneRow : allRows) {
payload.put(oneRow.get("attrName"), oneRow.get("level"));
String moduleName = oneRow.get("attrName");
String level = oneRow.get("level");

if (moduleName.length() > 0 && level.length() > 0) {
moduelNames.add(moduleName);
moduellevels.add(level);
}
}
try{
RestUtil.restRequest( endpoint , payload, "post" , null, false);
}catch (Exception ex){
GuiUtil.getLogger().severe(GuiUtil.getCommonMessage("msg.error.save.monitor.modules" , new Object[]{endpoint, payload}));

String endpoint = (String) GuiUtil.getSessionValue("REST_URL") + "/set-monitoring-level.json";
payload.put("module", moduelNames.toString());
payload.put("level", moduellevels.toString());
payload.put("target", config);
try {
RestUtil.restRequest(endpoint, payload, "POST", null, false, true);
} catch (Exception ex) {
GuiUtil.getLogger().severe(GuiUtil.getCommonMessage("msg.error.save.monitor.modules", new Object[]{endpoint, payload}));
GuiUtil.handleError(handlerCtx, GuiUtil.getMessage("msg.error.checkLog"));
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
holder.

-->
<!-- Portions Copyright [2018] Payara Foundation and/or affiliates -->
<!-- Portions Copyright [2018-2019] Payara Foundation and/or affiliates -->

<!initPage
setResourceBundle(key="common" bundle="org.glassfish.common.admingui.Strings")
Expand All @@ -51,18 +51,44 @@
<!define name="content">
<event>
<!beforeCreate
setSessionAttribute(key="monitoringConfigTab" value="monitoringGeneralTab");
setSessionAttribute(key="monitoringConfigTab" value="monitoringGeneralTab");
getRequestValue(key="configName" value=>$page{configName} default="server-config");
urlencode(value="#{pageSession.configName}" encoding="UTF-8" result="#{pageSession.encodedConfigName}");
setPageSessionAttribute(key="childType" value="monitoring-service");
setPageSessionAttribute(key="parentUrl", value="#{sessionScope.REST_URL}/configs/config/#{pageSession.encodedConfigName}");
setPageSessionAttribute(key="selfUrl", value="#{pageSession.parentUrl}/#{pageSession.childType}");
setPageSessionAttribute(key="amxUrl", value="#{pageSession.parentUrl}/amx-configuration");
setPageSessionAttribute(key="rest-api" value="true");
gf.getEntityAttrs(endpoint="#{pageSession.selfUrl}", valueMap="#{pageSession.valueMap}");

gf.restRequest(endpoint="#{sessionScope.REST_URL}/get-monitoring-service-configuration?target=#{pageSession.encodedConfigName}"
method="GET" result="#{requestScope.resp}");

setPageSessionAttribute(key="valueMap", value="#{requestScope.resp.data.extraProperties.getMonitoringServiceConfiguration}");
mapPut(map="#{pageSession.valueMap}" key="target" value="#{pageSession.encodedConfigName}");

setPageSessionAttribute(key="convertToFalseList" value={"dtraceEnabled", "monitoringEnabled", "mbeanEnabled", "enabled", "dynamic"});
if (#{pageSession.valueMap['monitoringEnabled']}=true) {
setPageSessionAttribute(key="monitoringEnabledSelected", value="true");
}

if (#{pageSession.valueMap['mbeanEnabled']}=true) {
setPageSessionAttribute(key="mbeanEnabledSelected", value="true");
}

if (#{pageSession.valueMap['dtraceEnabled']}=true) {
setPageSessionAttribute(key="dtraceEnabledSelected", value="true");
}

mapRemove(map="#{pageSession.valueMap}" key="amxEnabled");

setPageSessionAttribute(key="amxUrl", value="#{pageSession.parentUrl}/amx-configuration");
gf.getEntityAttrs(endpoint="#{pageSession.amxUrl}", valueMap="#{pageSession.amxMap}");
setPageSessionAttribute(key="convertToFalseList" value={"dtraceEnabled", "monitoringEnabled", "mbeanEnabled", "enabled"});
setPageSessionAttribute(key="skipAttrsList" value={"amxSelected"});
mapPut(map="#{pageSession.amxMap}" key="target" value="#{pageSession.encodedConfigName}");
setPageSessionAttribute(key="enabledSelected", value="false");
if (#{pageSession.amxMap['enabled']}=true) {
setPageSessionAttribute(key="enabledSelected", value="true");
}
setPageSessionAttribute(key="dynamic", value="true");
setPageSessionAttribute(key="skipAttrsList" value={"amxEnabled"});
gf.getMonitorLevels(endpoint="#{pageSession.parentUrl}" monitorCompList="#{requestScope.tableList}")

/>
Expand All @@ -75,16 +101,26 @@
<!facet pageButtonsTop>
<sun:panelGroup id="topButtons">
<sun:button id="saveButton" text="$resource{i18n.button.Save}" >
onClick="if (guiValidate('#{reqMsg}','#{reqInt}','#{reqPort}')) {submitAndDisable(this, '$resource{i18n.button.Processing}');}; return false;" >
<!command
mapPut(map="#{pageSession.valueMap}" key="monitoringEnabled" value="#{pageSession.monitoringEnabledSelected}");
mapPut(map="#{pageSession.valueMap}" key="mbeanEnabled" value="#{pageSession.mbeanEnabledSelected}");
mapPut(map="#{pageSession.valueMap}" key="dtraceEnabled" value="#{pageSession.dtraceEnabledSelected}");
mapPut(map="#{pageSession.amxMap}" key="enabled" value="#{pageSession.enabledSelected}");
mapPut(map="#{pageSession.amxMap}" key="dynamic" value="#{pageSession.dynamic}");
getUIComponent(clientId="$pageSession{tableRowGroupId}", component=>$attribute{tableRowGroup});
getAllSingleMapRows(TableRowGroup="${tableRowGroup}" Rows=>$attribute{allRows});
updateMonitorLevels(endpoint="#{pageSession.selfUrl}/module-monitoring-levels", allRows="#{requestScope.allRows}")
gf.updateEntity(endpoint="#{pageSession.selfUrl}" attrs="#{pageSession.valueMap}"
updateMonitorLevels(allRows="#{requestScope.allRows}" config="#{pageSession.configName}");

gf.updateEntity(endpoint="#{sessionScope.REST_URL}/set-monitoring-service-configuration"
skipAttrs="#{pageSession.skipAttrsList}"
attrs="#{pageSession.valueMap}"
convertToFalse="#{pageSession.convertToFalseList}"
onlyUseAttrs="#{pageSession.onlyUseAttrs}"
);
gf.updateEntity(endpoint="#{pageSession.amxUrl}" attrs="#{pageSession.amxMap}"

gf.updateEntity(endpoint="#{sessionScope.REST_URL}/set-amx-enabled"
attrs="#{pageSession.amxMap}"
convertToFalse="#{pageSession.convertToFalseList}"
);
prepareSuccessfulMsg();
Expand All @@ -102,13 +138,19 @@
/>

<sun:property id="monServiceProp" labelAlign="left" noWrap="#{true}" overlapLabel="#{false}" label="$resource{common.monitoring.monService}" helpText="$resource{common.monitoring.monServiceHelp}">
<sun:checkbox id="momServiceCheckbox" label="$resource{i18n.common.Enabled}" selected="#{pageSession.valueMap['monitoringEnabled']}" selectedValue="true" />
<sun:checkbox id="momServiceCheckbox" label="$resource{i18n.common.Enabled}" selected="#{pageSession.monitoringEnabledSelected}" selectedValue="true" />
</sun:property>
<sun:property id="monMbeansProp" labelAlign="left" noWrap="#{true}" overlapLabel="#{false}" label="$resource{common.monitoring.monMbeans}" helpText="$resource{common.monitoring.monMbeansHelp}">
<sun:checkbox id="momBbeanCheckbox" label="$resource{i18n.common.Enabled}" selected="#{pageSession.valueMap['mbeanEnabled']}" selectedValue="true" />
<sun:checkbox id="momBbeanCheckbox" label="$resource{i18n.common.Enabled}" selected="#{pageSession.mbeanEnabledSelected}" selectedValue="true" />
</sun:property>
<sun:property id="monDtraceProp" labelAlign="left" noWrap="#{true}" overlapLabel="#{false}" label="$resource{common.monitoring.monDtrace}" helpText="$resource{common.monitoring.monDtraceHelp}">
<sun:checkbox id="momDtraceCheckbox" label="$resource{i18n.common.Enabled}" selected="#{pageSession.dtraceEnabledSelected}" selectedValue="true" />
</sun:property>
<sun:property id="amxProp" labelAlign="left" noWrap="#{true}" overlapLabel="#{false}" label="$resource{common.monitoring.AMXEnabled}" helpText="$resource{common.monitoring.AMXEnabledHelp}">
<sun:checkbox id="amx" label="$resource{i18n.common.Enabled}" selected="#{pageSession.amxMap['enabled']}" selectedValue="true"/>
<sun:checkbox id="amx" label="$resource{i18n.common.Enabled}" selected="#{pageSession.enabledSelected}" selectedValue="true"/>
</sun:property>
<sun:property id="amxDynamicProp" labelAlign="left" noWrap="#{true}" overlapLabel="#{false}" label="$resource{common.monitoring.AMXDynamic}" helpText="$resource{common.monitoring.AMXDynamicHelp}">
<sun:checkbox id="amxDynamic" label="$resource{i18n.common.Enabled}" selected="#{pageSession.dynamic}" selectedValue="true"/>
</sun:property>
"<br />
</sun:propertySheetSection>
Expand Down Expand Up @@ -173,4 +215,4 @@
"<br/>
#include "/common/shared/changeButtonsJS.inc"
</define>
</composition>
</composition>
Original file line number Diff line number Diff line change
Expand Up @@ -658,9 +658,13 @@ monitoring.monService=Monitoring Service:
monitoring.monServiceHelp=Enable monitoring for Payara Server
monitoring.monMbeans=Monitoring MBeans:
monitoring.monMbeansHelp=Deploy all MBeans needed for monitoring
monitoring.monDtrace=DTrace Monitoring:
monitoring.monDtraceHelp=Enable or disable DTrace Monitoring
monitoringInfo.pageHelp=View and manage the monitoring information for Payara Server instances.
monitoring.AMXEnabled=AMX Enabled
monitoring.AMXEnabledHelp=Whether or not AMX beans are enabled on startup
monitoring.AMXEnabled=AMX:
monitoring.AMXEnabledHelp=Enable or disable AMX. If enabled AMX will boot on server startup
monitoring.AMXDynamic=AMX Dynamic:
monitoring.AMXDynamicHelp=Amx can be enabled dynamically but disabling will require the server to be restarted.

#monitoring Service page, Module name
monitoring.module.Jvm=Jvm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@
import fish.payara.enterprise.config.serverbeans.DGServerRef;
import fish.payara.enterprise.config.serverbeans.DeploymentGroup;
import fish.payara.enterprise.config.serverbeans.DeploymentGroups;
import java.beans.PropertyVetoException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.validation.constraints.NotNull;
import org.glassfish.api.admin.config.ApplicationName;
import org.glassfish.api.admin.config.PropertiesDesc;
import org.glassfish.api.admin.config.PropertyDesc;
Expand All @@ -61,16 +70,6 @@
import org.jvnet.hk2.config.types.Property;
import org.jvnet.hk2.config.types.PropertyBag;

import javax.validation.constraints.NotNull;
import java.beans.PropertyVetoException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;


/**
* Top level Domain Element that includes applications, resources, configs,
Expand Down Expand Up @@ -917,7 +916,7 @@ public static List<String> getAllTargets(Domain d) {
// only add non-clustered servers as the cluster
// targets will be separately added
for (Server server : d.getServers().getServer()) {
if (server.getCluster() == null && server.getDeploymentGroup().isEmpty()) {
if (server.getCluster() == null) {
targets.add(server.getName());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
package org.glassfish.config.support;

import com.sun.enterprise.config.serverbeans.*;


import org.glassfish.hk2.api.ServiceLocator;

/**
Expand Down Expand Up @@ -140,7 +138,7 @@ public String getDescription() {
}
},
/**
* a cluster configuration change
* a Deployment Group configuration change
*/
DEPLOYMENT_GROUP {
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2018 Payara Foundation and/or its affiliates. All rights reserved.
* Copyright (c) 2018-2019 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 @@ -67,6 +67,20 @@ public final class Constants {
"thread-pool",
"transaction-service",
"web-container",
"web-services-container"
"web-services-container",
"cloudElasticity",
"cloudOrchestrator",
"cloudTenantManager",
"cloudVirtAssemblyService",
"connectorConnectionPool",
"connectorService",
"ejbContainer",
"jdbcConnectionPool",
"jmsService",
"threadPool",
"transactionService",
"webContainer",
"webServicesContainer",
"httpService"
};
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2018 Payara Foundation and/or its affiliates. All rights reserved.
* Copyright (c) 2018-2019 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 @@ -103,16 +103,18 @@ public void execute(AdminCommandContext context) {
AMXConfiguration amxConfiguration = config.getExtensionByType(AMXConfiguration.class);

final ActionReport actionReport = context.getActionReport();
final String[] headers= {"Enabled", "AMX Enabled", "MBeans Enabled"};
final String[] headers= {"Monitoring Enabled", "AMX Enabled", "MBeans Enabled", "DTrace Enabled"};

ColumnFormatter columnFormatter = new ColumnFormatter(headers);
columnFormatter.addRow(new Object[]{monitoringService.getMonitoringEnabled(), amxConfiguration.getEnabled(), monitoringService.getMbeanEnabled()});
columnFormatter.addRow(new Object[]{monitoringService.getMonitoringEnabled(), amxConfiguration.getEnabled(),
monitoringService.getMbeanEnabled(), monitoringService.getDtraceEnabled()});
actionReport.appendMessage(columnFormatter.toString());

Map<String, Object> extraPropertiesMap = new HashMap<>();
extraPropertiesMap.put("enabled", monitoringService.getMonitoringEnabled());
extraPropertiesMap.put("monitoringEnabled", monitoringService.getMonitoringEnabled());
extraPropertiesMap.put("amxEnabled", amxConfiguration.getEnabled());
extraPropertiesMap.put("mbeansEnabled", monitoringService.getMbeanEnabled());
extraPropertiesMap.put("mbeanEnabled", monitoringService.getMbeanEnabled());
extraPropertiesMap.put("dtraceEnabled", monitoringService.getDtraceEnabled());

Properties extraProperties = new Properties();
extraProperties.put("getMonitoringServiceConfiguration", extraPropertiesMap);
Expand Down
Loading