Skip to content

Commit

Permalink
Merge pull request #1031 from smillidge/payara-blue
Browse files Browse the repository at this point in the history
Payara blue merge prior to release 163
  • Loading branch information
smillidge authored Aug 13, 2016
2 parents 77eb91a + 794470d commit 554f21e
Show file tree
Hide file tree
Showing 37 changed files with 1,722 additions and 553 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
mapPut(map="#{pageSession.valueMap}" key="dynamic" value="#{pageSession.dynamic}");
mapPut(map="#{pageSession.valueMap}" key="notifierDynamic" value="#{pageSession.notifierDynamic}");
prepareSuccessfulMsg();
gf.updateEntity(endpoint="#{sessionScope.REST_URL}/set-notification" attrs="#{pageSession.valueMap}" convertToFalse="#{pageSession.convertToFalseList}");
gf.updateEntity(endpoint="#{sessionScope.REST_URL}/set-notification-configuration" attrs="#{pageSession.valueMap}" convertToFalse="#{pageSession.convertToFalseList}");
/>
</sun:button>
</sun:panelGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
mapPut(map="#{pageSession.valueMap}" key="dynamic" value="#{pageSession.dynamic}");
mapPut(map="#{pageSession.valueMap}" key="notifierDynamic" value="#{pageSession.notifierDynamic}");
prepareSuccessfulMsg();
gf.updateEntity(endpoint="#{sessionScope.REST_URL}/set-requesttracing" attrs="#{pageSession.valueMap}" convertToFalse="#{pageSession.convertToFalseList}");
gf.updateEntity(endpoint="#{sessionScope.REST_URL}/set-requesttracing-configuration" attrs="#{pageSession.valueMap}" convertToFalse="#{pageSession.convertToFalseList}");
/>
</sun:button>
</sun:panelGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright (c) 2016 C2B2 Consulting Limited. All rights reserved.
The contents of this file are subject to the terms of the Common Development
and Distribution License("CDDL") (collectively, the "License"). You
may not use this file except in compliance with the License. You can
obtain a copy of the License at
https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
or packager/legal/LICENSE.txt. See the License for the specific
language governing permissions and limitations under the License.
When distributing the software, include this License Header Notice in each
file and include the License file at packager/legal/LICENSE.txt.
*/
package fish.payara.jmx.monitoring.admin;

import com.sun.enterprise.config.serverbeans.Domain;
import fish.payara.jmx.monitoring.MonitoringService;
import java.util.Properties;
import javax.inject.Inject;
import org.glassfish.api.ActionReport;
import org.glassfish.api.I18n;
import org.glassfish.api.Param;
import org.glassfish.api.admin.AdminCommand;
import org.glassfish.api.admin.AdminCommandContext;
import org.glassfish.api.admin.CommandLock;
import org.glassfish.api.admin.ExecuteOn;
import org.glassfish.api.admin.RestEndpoint;
import org.glassfish.api.admin.RestEndpoints;
import org.glassfish.api.admin.RuntimeType;
import org.glassfish.config.support.CommandTarget;
import org.glassfish.config.support.TargetType;
import org.glassfish.hk2.api.PerLookup;
import org.jvnet.hk2.annotations.Service;

/**
*
* @author savage
*/
@Service(name = "__enable-monitoring-service-on-das")
@PerLookup
@CommandLock(CommandLock.LockType.NONE)
@I18n("__enable-monitoring-service-on-das")
@ExecuteOn(RuntimeType.DAS)
@TargetType(value = {CommandTarget.DAS, CommandTarget.STANDALONE_INSTANCE, CommandTarget.CLUSTER, CommandTarget.CLUSTERED_INSTANCE, CommandTarget.CONFIG})
@RestEndpoints({
@RestEndpoint(configBean = Domain.class,
opType = RestEndpoint.OpType.GET,
path = "__enable-monitoring-service-on-das",
description = "Enables the JMX Monitoring Service on the DAS")
})
public class EnableMonitoringServiceOnDas implements AdminCommand {

@Inject
MonitoringService monitoringService;

@Param(name = "enabled", optional = false)
private Boolean enabled;

@Param(name = "target", optional = true, defaultValue = "server")
protected String target;

@Override
public void execute(AdminCommandContext context) {

final ActionReport actionReport = context.getActionReport();
Properties extraProperties = actionReport.getExtraProperties();
if (extraProperties == null) {
extraProperties = new Properties();
actionReport.setExtraProperties(extraProperties);
}

monitoringService.setEnabled(enabled);
actionReport.appendMessage("The JMX Monitoring Service status set to " + enabled + " on " + target);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright (c) 2016 C2B2 Consulting Limited. All rights reserved.
The contents of this file are subject to the terms of the Common Development
and Distribution License("CDDL") (collectively, the "License"). You
may not use this file except in compliance with the License. You can
obtain a copy of the License at
https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
or packager/legal/LICENSE.txt. See the License for the specific
language governing permissions and limitations under the License.
When distributing the software, include this License Header Notice in each
file and include the License file at packager/legal/LICENSE.txt.
*/
package fish.payara.jmx.monitoring.admin;

import com.sun.enterprise.config.serverbeans.Domain;
import fish.payara.jmx.monitoring.MonitoringService;
import java.util.Properties;
import javax.inject.Inject;
import org.glassfish.api.ActionReport;
import org.glassfish.api.I18n;
import org.glassfish.api.Param;
import org.glassfish.api.admin.AdminCommand;
import org.glassfish.api.admin.AdminCommandContext;
import org.glassfish.api.admin.CommandLock;
import org.glassfish.api.admin.ExecuteOn;
import org.glassfish.api.admin.RestEndpoint;
import org.glassfish.api.admin.RestEndpoints;
import org.glassfish.api.admin.RuntimeType;
import org.glassfish.config.support.CommandTarget;
import org.glassfish.config.support.TargetType;
import org.glassfish.hk2.api.PerLookup;
import org.jboss.logging.Logger;
import org.jvnet.hk2.annotations.Service;

/**
*
* @author savage
*/
@Service(name = "__enable-monitoring-service-on-instance")
@PerLookup
@CommandLock(CommandLock.LockType.NONE)
@I18n("__enable-monitoring-service-on-instance")
@ExecuteOn(RuntimeType.INSTANCE)
@TargetType(value = {CommandTarget.DAS, CommandTarget.STANDALONE_INSTANCE, CommandTarget.CLUSTER, CommandTarget.CLUSTERED_INSTANCE, CommandTarget.CONFIG})
@RestEndpoints({
@RestEndpoint(configBean = Domain.class,
opType = RestEndpoint.OpType.GET,
path = "__enable-monitoring-service-on-instance",
description = "Enables the JMX Monitoring Service on Instance")
})
public class EnableMonitoringServiceOnInstance implements AdminCommand {

@Inject
MonitoringService monitoringService;

@Param(name = "enabled", optional = false)
private Boolean enabled;

@Param(name = "target", optional = true, defaultValue = "server")
protected String target;

@Override
public void execute(AdminCommandContext context) {

final ActionReport actionReport = context.getActionReport();
Properties extraProperties = actionReport.getExtraProperties();
if (extraProperties == null) {
extraProperties = new Properties();
actionReport.setExtraProperties(extraProperties);
}

monitoringService.setEnabled(enabled);
actionReport.appendMessage("The JMX Monitoring Service status set to " + enabled + " on " + target);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and Distribution License("CDDL") (collectively, the "License"). You
import com.sun.enterprise.config.serverbeans.Domain;
import com.sun.enterprise.util.ColumnFormatter;
import com.sun.enterprise.util.StringUtils;
import com.sun.enterprise.util.SystemPropertyConstants;
import fish.payara.jmx.monitoring.configuration.MonitoringServiceConfiguration;
import javax.inject.Inject;
import org.glassfish.api.ActionReport;
Expand Down Expand Up @@ -46,7 +47,7 @@ and Distribution License("CDDL") (collectively, the "License"). You
@CommandLock(CommandLock.LockType.NONE)
@I18n("get.monitoring.configuration")
@ExecuteOn(value = {RuntimeType.DAS})
@TargetType(value = {CommandTarget.DAS, CommandTarget.STANDALONE_INSTANCE, CommandTarget.CLUSTER})
@TargetType(value = {CommandTarget.DAS, CommandTarget.STANDALONE_INSTANCE, CommandTarget.CLUSTER, CommandTarget.CLUSTERED_INSTANCE, CommandTarget.CONFIG})
@RestEndpoints({
@RestEndpoint(configBean = Domain.class,
opType = RestEndpoint.OpType.GET,
Expand All @@ -63,7 +64,7 @@ public class GetMonitoringConfiguration implements AdminCommand {
@Param(name = "pretty", defaultValue = "false", optional = true)
private Boolean pretty;

@Param(name = "target", defaultValue = "server", optional = true)
@Param(name = "target", defaultValue = SystemPropertyConstants.DAS_SERVER_NAME, optional = true)
private String target;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ and Distribution License("CDDL") (collectively, the "License"). You
import org.glassfish.api.admin.AdminCommand;
import org.glassfish.api.admin.AdminCommandContext;
import org.glassfish.api.admin.CommandLock;
import org.glassfish.api.admin.CommandRunner;
import org.glassfish.api.admin.ExecuteOn;
import org.glassfish.api.admin.ParameterMap;
import org.glassfish.api.admin.RestEndpoint;
import org.glassfish.api.admin.RestEndpoints;
import org.glassfish.api.admin.RuntimeType;
Expand All @@ -52,8 +54,8 @@ and Distribution License("CDDL") (collectively, the "License"). You
@PerLookup
@CommandLock(CommandLock.LockType.NONE)
@I18n("set.monitoring.configuration")
@ExecuteOn(RuntimeType.INSTANCE)
@TargetType(value = {CommandTarget.DAS, CommandTarget.STANDALONE_INSTANCE, CommandTarget.CLUSTER})
@ExecuteOn(RuntimeType.DAS)
@TargetType(value = {CommandTarget.DAS, CommandTarget.STANDALONE_INSTANCE, CommandTarget.CLUSTER, CommandTarget.CLUSTERED_INSTANCE, CommandTarget.CONFIG})
@RestEndpoints({
@RestEndpoint(configBean = Domain.class,
opType = RestEndpoint.OpType.GET,
Expand All @@ -63,7 +65,7 @@ and Distribution License("CDDL") (collectively, the "License"). You
public class SetMonitoringConfiguration implements AdminCommand {

@Inject
ServiceLocator habitat;
ServiceLocator serviceLocator;

@Inject
protected Target targetUtil;
Expand Down Expand Up @@ -100,7 +102,7 @@ public void execute(AdminCommandContext context) {
final ActionReport actionReport = context.getActionReport();
Config config = targetUtil.getConfig(target);

final MonitoringService service = habitat.getService(MonitoringService.class);
final MonitoringService service = serviceLocator.getService(MonitoringService.class);
if (service == null) {
actionReport.appendMessage("Could not find a monitoring service.");
actionReport.setActionExitCode(ActionReport.ExitCode.FAILURE);
Expand All @@ -118,9 +120,9 @@ public Object run(final MonitoringServiceConfiguration monitoringConfigProxy) th
return monitoringConfigProxy;
}
}, monitoringConfig);

if (dynamic) {
monitoringService.setEnabled(enabled);
enableOnTarget(actionReport, context, enabled);
}

} catch (TransactionFailure ex) {
Expand Down Expand Up @@ -153,6 +155,25 @@ private void updateConfiguration(MonitoringServiceConfiguration monitoringConfig
}
}

private void enableOnTarget(ActionReport actionReport, AdminCommandContext context, Boolean enabled) {
CommandRunner runner = serviceLocator.getService(CommandRunner.class);
ActionReport subReport = context.getActionReport().addSubActionsReport();
CommandRunner.CommandInvocation invocation;

if (target.equals("server-config")) {
invocation = runner.getCommandInvocation("__enable-monitoring-service-on-das", subReport, context.getSubject());
} else {
invocation = runner.getCommandInvocation("__enable-monitoring-service-on-instance", subReport, context.getSubject());
}

// Build the parameters
ParameterMap params = new ParameterMap();
params.add("enabled", enabled.toString());
params.add("target", target);
invocation.parameters(params);
invocation.execute();
}

/**
* Updates monitoring attributes through adding a new property and/or deleting an existing one.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// Portions Copyright [2016] [C2B2 Consulting Limited and/or its affiliates]
package org.apache.catalina.fileupload;

import org.apache.catalina.Globals;
Expand Down Expand Up @@ -739,6 +739,24 @@ private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException {
// read values
in.defaultReadObject();

// PAYARA-953 protect against null byte attacks
if (repository != null) {
if (repository.getPath().contains("\0")) {
throw new IOException("Repository path cannot contain a null byte");
}

if (!repository.isDirectory()) {
throw new IOException("Repository path " + repository.getPath() + " is not a directory ");
}
}

if (dfosFile != null) {
if (dfosFile.getPath().contains("\0")) {
throw new IOException("File path cannot contain a null byte");
}
}
// END PAYARA-953

OutputStream output = getOutputStream();
if (cachedContent != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,12 @@ public void shutdownHealthCheck() {
Logger.getLogger(HealthCheckService.class.getName()).log(Level.INFO, "Payara Health Check Service is shutdown.");
}
}

public BaseHealthCheck getCheck(String serviceName) {
return registeredTasks.get(serviceName).getCheck();
}

public HealthCheckServiceConfiguration getConfiguration() {
return configuration;
}
}
Loading

0 comments on commit 554f21e

Please sign in to comment.