From d6b5683b855460a737dc3e2ad0415b119fdc7ed9 Mon Sep 17 00:00:00 2001 From: Matt Gill Date: Tue, 13 Jun 2017 06:44:02 +0100 Subject: [PATCH] Payara 1322 application deployment time (#1585) * Added property in application to store the time taken to deploy. * Added deployment time column to application table as well as property under application properties in admin console, and changed deployment time to be millisecond accurate. Fixed failing test on application class due to new interface. * Added portuguese and spanish translations * Changed datatype of deployment time to string to prevent errors * Added copyright notices to changed files * Removed default value and added double validator * Moved class ApplicationDeploymentTime into payara folder * Used already built in Deployment Time variable * Updated osgi.bundle to accept new package * Changed strings to say milliseconds from seconds * fix for license plate --- .../common/handlers/ApplicationHandlers.java | 2 +- .../resources/applications/deployTable.inc | 4 ++ .../src/main/resources/applications/edit.inc | 7 +- .../admingui/core/Strings_es.properties | 6 +- .../admingui/core/Strings_pt_BR.properties | 5 +- .../admingui/core/Strings.properties | 3 + .../config/serverbeans/Application.java | 5 +- nucleus/common/glassfish-api/osgi.bundle | 1 + .../config/ApplicationDeploymentTime.java | 68 +++++++++++++++++++ .../deployment/admin/DeployCommand.java | 9 ++- .../admin/DeploymentCommandUtils.java | 1 + .../admin/ListComponentsCommandTest.java | 4 +- .../versioning/VersioningUtilsTest.java | 9 +++ 13 files changed, 115 insertions(+), 9 deletions(-) create mode 100644 nucleus/common/glassfish-api/src/main/java/fish/payara/api/admin/config/ApplicationDeploymentTime.java diff --git a/appserver/admingui/common/src/main/java/org/glassfish/admingui/common/handlers/ApplicationHandlers.java b/appserver/admingui/common/src/main/java/org/glassfish/admingui/common/handlers/ApplicationHandlers.java index dc514ad87c1..945f27c9845 100644 --- a/appserver/admingui/common/src/main/java/org/glassfish/admingui/common/handlers/ApplicationHandlers.java +++ b/appserver/admingui/common/src/main/java/org/glassfish/admingui/common/handlers/ApplicationHandlers.java @@ -37,7 +37,6 @@ * only if the new code is made subject to such option by the copyright * holder. */ - // Portions Copyright [2016-2017] [Payara Foundation and/or its affiliates] /* @@ -125,6 +124,7 @@ public static void getDeployedAppsInfo(HandlerContext handlerCtx) { oneRow.put("enableURL", DeployUtil.getTargetEnableInfo(oneAppName, true, true)); oneRow.put("sniffers", engines); oneRow.put("deploymentOrder", RestUtil.getAttributesMap(prefix+encodedName).get("deploymentOrder")); + oneRow.put("deploymentTime", RestUtil.getAttributesMap(prefix+encodedName).get("deploymentTime")); List sniffersList = GuiUtil.parseStringList(engines, ","); oneRow.put("sniffersList", sniffersList); diff --git a/appserver/admingui/common/src/main/resources/applications/deployTable.inc b/appserver/admingui/common/src/main/resources/applications/deployTable.inc index 6bdc8e77120..fa23d03ba98 100644 --- a/appserver/admingui/common/src/main/resources/applications/deployTable.inc +++ b/appserver/admingui/common/src/main/resources/applications/deployTable.inc @@ -76,6 +76,10 @@ + + + + diff --git a/appserver/admingui/common/src/main/resources/applications/edit.inc b/appserver/admingui/common/src/main/resources/applications/edit.inc index 5e2f9541f85..4766fd4b808 100644 --- a/appserver/admingui/common/src/main/resources/applications/edit.inc +++ b/appserver/admingui/common/src/main/resources/applications/edit.inc @@ -40,6 +40,8 @@ --> + + @@ -109,10 +111,13 @@ + + + + - diff --git a/appserver/admingui/core-l10n/src/main/resources/org/glassfish/admingui/core/Strings_es.properties b/appserver/admingui/core-l10n/src/main/resources/org/glassfish/admingui/core/Strings_es.properties index a402373a036..b30ff570456 100644 --- a/appserver/admingui/core-l10n/src/main/resources/org/glassfish/admingui/core/Strings_es.properties +++ b/appserver/admingui/core-l10n/src/main/resources/org/glassfish/admingui/core/Strings_es.properties @@ -37,7 +37,7 @@ # only if the new code is made subject to such option by the copyright # holder. # -# Portions Copyright [2016] [Payara Foundation and/or its affiliates] +# Portions Copyright [2016-2017] [Payara Foundation and/or its affiliates] TODO= TBD=TBD versionImage.description=Consola de Administraci\u00f3n de Payara Server @@ -541,6 +541,7 @@ common.Instance=Instancia common.resource.deploymentOrder=Orden de Despliegue: common.resource.deploymentOrderHelp=Especifica el orden de carga del recurso al iniciar el servidor. Los n\u00fameros inferiores se cargan en primer lugar. + # this is used as the tab name or a section of the screen, to indicate for configurating some advanced attributes of an object. common.Advanced=Avanzada @@ -781,6 +782,7 @@ deployTable.colLoadOrder=Orden de Carga deployTable.classnameCol=Nombre de Clase deployTable.colJavaWebStart=Java Web Start deployTable.colDeploymentOrder=Orden de Despliegue +deployTable.colDeploymentTime=Tiempo de Despliegue (Milisegundos) ## this is the column name of the table that lists out the deployed applications. This column shows the sniffer engineer of this application ## eg. web, ejb, appclient etc. @@ -909,6 +911,8 @@ deploy.compatibility=Compatibilidad: deploy.compatibilityHelp=Soporta la compatibilidad con versiones anteriores respecto a la visibilidad JAR en v2 en lugar de los requisitos m\u00e1s estrictos de Java EE 6 implantados en v3. deploy.deploymentOrder=Orden de Despliegue: deploy.deploymentOrderHelp=N\u00famero que determina el orden de carga de la aplicaci\u00f3n al iniciar el servidor. Los n\u00fameros inferiores se cargan en primer lugar. El valor por defecto es 100. +deploy.deploymentTime=Tiempo de Despliegue: +deploy.deploymentTimeHelp=El tiempo necesario para desplegar la aplicaci\u00f3n en milisegundos. deploy.type=Tipo de Aplicaci\u00f3n: deploy.chooseLocal=Archivo empaquetado local o directorio accesible desde Payara Server deploy.warning=El despliegue se ha realizado correctamente con una advertencia. Consulte el archivo log para obtener m\u00e1s informaci\u00f3n. diff --git a/appserver/admingui/core-l10n/src/main/resources/org/glassfish/admingui/core/Strings_pt_BR.properties b/appserver/admingui/core-l10n/src/main/resources/org/glassfish/admingui/core/Strings_pt_BR.properties index 139fc125b7b..28874a99fa7 100644 --- a/appserver/admingui/core-l10n/src/main/resources/org/glassfish/admingui/core/Strings_pt_BR.properties +++ b/appserver/admingui/core-l10n/src/main/resources/org/glassfish/admingui/core/Strings_pt_BR.properties @@ -37,7 +37,7 @@ # only if the new code is made subject to such option by the copyright # holder. # -# Portions Copyright [2016] [Payara Foundation and/or its affiliates] +# Portions Copyright [2016-2017] [Payara Foundation and/or its affiliates] TODO= TBD=TBD versionImage.description=Console de Administra\u00e7\u00e3o do Payara Server @@ -781,6 +781,7 @@ deployTable.colLoadOrder=Ordem de Carga deployTable.classnameCol=Nome de classe deployTable.colJavaWebStart=Iniciar Java Web deployTable.colDeploymentOrder=Ordem de Implanta\u00e7\u00e3o +deployTable.colDeploymentTime=Tempo de implanta\u00e7\u00e3o (Milisegundos) ## this is the column name of the table that lists out the deployed applications. This column shows the sniffer engineer of this application ## eg. web, ejb, appclient etc. @@ -909,6 +910,8 @@ deploy.compatibility=Compatibilidade: deploy.compatibilityHelp=Oferece suporte \u00e0 compatibilidade com vers\u00f5es anteriores da visibilidade JAR na v2, em vez dos estritos requisitos do Java EE 6 implementados na v3. deploy.deploymentOrder=Ordem de Implanta\u00e7\u00e3o: deploy.deploymentOrderHelp=Um n\u00famero que determina a ordem de carregamento da aplica\u00e7\u00e3o na inicializa\u00e7\u00e3o do servidor. N\u00fameros mais baixos s\u00e3o carregados antes. O default \u00e9 100. +deploy.deploymentTime=Tempo de implanta\u00e7\u00e3oi: +deploy.deploymentTimeHelp=O tempo necess\u00e1rio para implementar o aplicativo em milisegundos. deploy.type=Tipo de Aplica\u00e7\u00e3o: deploy.chooseLocal=Diret\u00f3rio ou arquivo local encapsulado que pode ser acessado a partir do Payara Server deploy.warning=A implanta\u00e7\u00e3o foi bem-sucedida mas gerou uma advert\u00eancia, consulte o arquivo de log para obter os detalhes. diff --git a/appserver/admingui/core/src/main/resources/org/glassfish/admingui/core/Strings.properties b/appserver/admingui/core/src/main/resources/org/glassfish/admingui/core/Strings.properties index 25fa2f978c1..b077e1f5719 100644 --- a/appserver/admingui/core/src/main/resources/org/glassfish/admingui/core/Strings.properties +++ b/appserver/admingui/core/src/main/resources/org/glassfish/admingui/core/Strings.properties @@ -794,6 +794,7 @@ deployTable.colLoadOrder=Load Order deployTable.classnameCol=Classname deployTable.colJavaWebStart=Java Web Start deployTable.colDeploymentOrder=Deployment Order +deployTable.colDeploymentTime=Deployment Time (Milliseconds) ## this is the column name of the table that lists out the deployed applications. This column shows the sniffer engineer of this application ## eg. web, ejb, appclient etc. @@ -922,6 +923,8 @@ deploy.compatibility=Compatibility: deploy.compatibilityHelp=Supports the backward compatibility of JAR visibility in v2 instead of the stricter Java EE 6 requirements implemented in v3. deploy.deploymentOrder=Deployment Order: deploy.deploymentOrderHelp=A number that determines the loading order of the application at server startup. Lower numbers are loaded first. The default is 100. +deploy.deploymentTime=Deployment Time: +deploy.deploymentTimeHelp=The time taken to deploy the application in milliseconds. deploy.implicitCdi=Implicit CDI deploy.implicitCdiHelp=Implicit discovery of CDI beans deploy.type=Application Type: diff --git a/nucleus/admin/config-api/src/main/java/com/sun/enterprise/config/serverbeans/Application.java b/nucleus/admin/config-api/src/main/java/com/sun/enterprise/config/serverbeans/Application.java index 31151300657..d3c7d02c52b 100644 --- a/nucleus/admin/config-api/src/main/java/com/sun/enterprise/config/serverbeans/Application.java +++ b/nucleus/admin/config-api/src/main/java/com/sun/enterprise/config/serverbeans/Application.java @@ -37,6 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ +// Portions Copyright [2017] [Payara Foundation and/or its affiliates] package com.sun.enterprise.config.serverbeans; import java.beans.PropertyVetoException; @@ -62,7 +63,7 @@ import org.jvnet.hk2.config.Element; import com.sun.enterprise.config.serverbeans.customvalidators.ContextRootCheck; - +import fish.payara.api.admin.config.ApplicationDeploymentTime; @Configured @RestRedirects({ @@ -70,7 +71,7 @@ @RestRedirect(opType = RestRedirect.OpType.POST, commandName = "redeploy") }) @ContextRootCheck(message="{contextroot.duplicate}", payload=Application.class) -public interface Application extends ApplicationName, PropertyBag { +public interface Application extends ApplicationName, ApplicationDeploymentTime, PropertyBag { public static final String APP_LOCATION_PROP_NAME = "appLocation"; public static final String DEPLOYMENT_PLAN_LOCATION_PROP_NAME = "deploymentPlanLocation"; diff --git a/nucleus/common/glassfish-api/osgi.bundle b/nucleus/common/glassfish-api/osgi.bundle index 56fc842c0e8..5b38929ea99 100644 --- a/nucleus/common/glassfish-api/osgi.bundle +++ b/nucleus/common/glassfish-api/osgi.bundle @@ -45,6 +45,7 @@ org.glassfish.api.admin; \ org.glassfish.api.admin.cli; \ org.glassfish.api.admin.config; \ + fish.payara.api.admin.config; \ org.glassfish.api.admin.progress; \ org.glassfish.api.admingui; \ org.glassfish.api.amx; \ diff --git a/nucleus/common/glassfish-api/src/main/java/fish/payara/api/admin/config/ApplicationDeploymentTime.java b/nucleus/common/glassfish-api/src/main/java/fish/payara/api/admin/config/ApplicationDeploymentTime.java new file mode 100644 index 00000000000..26f3046890a --- /dev/null +++ b/nucleus/common/glassfish-api/src/main/java/fish/payara/api/admin/config/ApplicationDeploymentTime.java @@ -0,0 +1,68 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) [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 + * 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://github.com/payara/Payara/blob/master/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 glassfish/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * The Payara Foundation designates this particular file as subject to the "Classpath" + * exception as provided by the Payara Foundation in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ +package fish.payara.api.admin.config; + +import org.jvnet.hk2.config.Attribute; +import org.jvnet.hk2.config.Configured; +import org.jvnet.hk2.config.ConfigBeanProxy; + +import java.beans.PropertyVetoException; +import javax.validation.Payload; + +/** + * An configured element which shows the time taken to deploy the application in + * seconds + * + * @author Matt Gill + */ +@Configured +public interface ApplicationDeploymentTime extends ConfigBeanProxy, Payload { + + /** + * Time taken to deploy the application. + * + * @return deployment time + */ + @Attribute(dataType = Integer.class) + String getDeploymentTime(); + + void setDeploymentTime(String value) throws PropertyVetoException; + +} diff --git a/nucleus/deployment/admin/src/main/java/org/glassfish/deployment/admin/DeployCommand.java b/nucleus/deployment/admin/src/main/java/org/glassfish/deployment/admin/DeployCommand.java index 1fe43151222..dfc3950b97a 100644 --- a/nucleus/deployment/admin/src/main/java/org/glassfish/deployment/admin/DeployCommand.java +++ b/nucleus/deployment/admin/src/main/java/org/glassfish/deployment/admin/DeployCommand.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -// Portions Copyright [2016] [Payara Foundation] +// Portions Copyright [2016-2017] [Payara Foundation and/or its affiliates] package org.glassfish.deployment.admin; import java.net.URI; @@ -339,6 +339,7 @@ public Collection getAccessChecks() { */ @Override public void execute(AdminCommandContext context) { + long timeTakenToDeploy = 0; try { // needs to be fixed in hk2, we don't generate the right innerclass index. it should use $ Collection interceptors = habitat.getAllServices(Interceptor.class); @@ -506,6 +507,10 @@ public void execute(AdminCommandContext context) { downloadableArtifacts.record(appProps); generatedArtifacts.record(appProps); + // Set the application deploy time + timeTakenToDeploy = timing.elapsed(); + deploymentContext.getTransientAppMetaData("application", Application.class).setDeploymentTime(Long.toString(timeTakenToDeploy)); + // register application information in domain.xml deployment.registerAppInDomainXML(appInfo, deploymentContext, t); if (tracing != null) { @@ -563,7 +568,7 @@ public void execute(AdminCommandContext context) { "deploy.done", "Deployment of {0} done is {1} ms", name, - timing.elapsed())); + timeTakenToDeploy)); } else if (report.getActionExitCode().equals(ActionReport.ExitCode.FAILURE)) { String errorMessage = report.getMessage(); Throwable cause = report.getFailureCause(); diff --git a/nucleus/deployment/admin/src/main/java/org/glassfish/deployment/admin/DeploymentCommandUtils.java b/nucleus/deployment/admin/src/main/java/org/glassfish/deployment/admin/DeploymentCommandUtils.java index 035462e3dd0..ec5952c8518 100644 --- a/nucleus/deployment/admin/src/main/java/org/glassfish/deployment/admin/DeploymentCommandUtils.java +++ b/nucleus/deployment/admin/src/main/java/org/glassfish/deployment/admin/DeploymentCommandUtils.java @@ -37,6 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ +// Portions Copyright [2017] [Payara Foundation and/or its affiliates] package org.glassfish.deployment.admin; diff --git a/nucleus/deployment/admin/src/test/java/org/glassfish/deployment/admin/ListComponentsCommandTest.java b/nucleus/deployment/admin/src/test/java/org/glassfish/deployment/admin/ListComponentsCommandTest.java index 15ae9e5a470..a75261bd2a4 100644 --- a/nucleus/deployment/admin/src/test/java/org/glassfish/deployment/admin/ListComponentsCommandTest.java +++ b/nucleus/deployment/admin/src/test/java/org/glassfish/deployment/admin/ListComponentsCommandTest.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ - +// Portions Copyright [2017] [Payara Foundation and/or its affiliates] package org.glassfish.deployment.admin; import java.io.File; @@ -222,6 +222,8 @@ public void setDirectoryDeployed(String value) throws PropertyVetoException{} public void setDescription(String value) throws PropertyVetoException{} public String getDeploymentOrder() { return "100"; } public void setDeploymentOrder(String value) throws PropertyVetoException {} + public String getDeploymentTime() { return "0"; } + public void setDeploymentTime(String value) throws PropertyVetoException {} public List getEngine(){ return null;} public List getProperty(){ return null;} public T getApplicationConfig(Class type) {return null;} diff --git a/nucleus/deployment/common/src/test/java/org/glassfish/deployment/versioning/VersioningUtilsTest.java b/nucleus/deployment/common/src/test/java/org/glassfish/deployment/versioning/VersioningUtilsTest.java index d00f319b377..0e24d8d3749 100644 --- a/nucleus/deployment/common/src/test/java/org/glassfish/deployment/versioning/VersioningUtilsTest.java +++ b/nucleus/deployment/common/src/test/java/org/glassfish/deployment/versioning/VersioningUtilsTest.java @@ -37,6 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ +// Portions Copyright [2017] [Payara Foundation and/or its affiliates] package org.glassfish.deployment.versioning; @@ -697,6 +698,14 @@ public String getDeploymentOrder() { public void setDeploymentOrder(String value) throws PropertyVetoException{ throw new UnsupportedOperationException("Not supported yet."); } + + public String getDeploymentTime() { + throw new UnsupportedOperationException("Not supported yet."); + } + + public void setDeploymentTime(String value) throws PropertyVetoException{ + throw new UnsupportedOperationException("Not supported yet."); + } @Override public List getModule() {