Skip to content

Commit

Permalink
Merge pull request #3066 from MeroRai/PAYARA-2871-payara4
Browse files Browse the repository at this point in the history
PAYARA-2871 Improve listing batch jobs memory usage in admin console - Payara4
  • Loading branch information
Pandrex247 authored Aug 20, 2018
2 parents bcf3efd + 5c1e641 commit cf65c48
Show file tree
Hide file tree
Showing 17 changed files with 1,113 additions and 282 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2018 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.full.admingui.handlers;

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 org.glassfish.admingui.common.util.GuiUtil;

/**
*
* @author Susan Rai
*/
public class BatchHandlers {

private static final int DEFAULT_OFFSET_INCREMENT = 20;

@Handler(id = "py.addToOffSetValue",
input = {
@HandlerInput(name = "offset", type = String.class)},
output = {
@HandlerOutput(name = "result", type = String.class)})
public static void addToOffSetValue(HandlerContext handlerCtx) {

String offsetValue = (String) handlerCtx.getInputValue("offset");
int result = 0;

try {
result = Integer.parseInt(offsetValue) + DEFAULT_OFFSET_INCREMENT;
} catch (NumberFormatException ex) {
GuiUtil.getLogger().info("Value isn't a valid integer " + ex);
}

handlerCtx.setOutputValue("result", result);
}

@Handler(id = "py.subtractFromOffSetValue",
input = {
@HandlerInput(name = "offset", type = String.class)},
output = {
@HandlerOutput(name = "result", type = String.class)})
public static void subtractFromOffSetValue(HandlerContext handlerCtx) {

String offsetValue = (String) handlerCtx.getInputValue("offset");
int result = 0;

try {
result = Integer.parseInt(offsetValue);
if (result >= DEFAULT_OFFSET_INCREMENT) {
result = result - DEFAULT_OFFSET_INCREMENT;
} else {
result = 0;
}
} catch (NumberFormatException ex) {
GuiUtil.getLogger().info("Value isn't a valid integer " + ex);
}

handlerCtx.setOutputValue("result", result);
}

@Handler(id = "py.getPageNumber",
input = {
@HandlerInput(name = "offset", type = String.class)},
output = {
@HandlerOutput(name = "result", type = String.class)})
public static void getPageNumber(HandlerContext handlerCtx) {

String offsetValue = (String) handlerCtx.getInputValue("offset");
int result = 0;

try {
int offSet = Integer.parseInt(offsetValue);
result = (offSet + DEFAULT_OFFSET_INCREMENT) / DEFAULT_OFFSET_INCREMENT;
} catch (NumberFormatException ex) {
GuiUtil.getLogger().info("Value isn't a valid integer " + ex);
}

handlerCtx.setOutputValue("result", result);
}

@Handler(id = "py.getSpecifiedPageNumber",
input = {
@HandlerInput(name = "pageNumber", type = String.class)},
output = {
@HandlerOutput(name = "result", type = String.class)})
public static void getSpecifiedPageNumber(HandlerContext handlerCtx) {

String pageNumberValue = (String) handlerCtx.getInputValue("pageNumber");
int result = 0;

try {
int pageNumber = Integer.parseInt(pageNumberValue);
if (pageNumber > 0) {
result = (pageNumber * DEFAULT_OFFSET_INCREMENT) - DEFAULT_OFFSET_INCREMENT;
}
} catch (NumberFormatException ex) {
GuiUtil.getLogger().info("Value isn't a valid integer " + ex);
}

handlerCtx.setOutputValue("result", result);
}

@Handler(id = "py.getPageCount",
input = {
@HandlerInput(name = "jobCount", type = String.class)},
output = {
@HandlerOutput(name = "result", type = String.class)})
public static void getPageCount(HandlerContext handlerCtx) {

String jobCountValue = (String) handlerCtx.getInputValue("jobCount");
int result = 1;

try {
int jobCount = Integer.parseInt(jobCountValue);
if (jobCount > 0) {
result = (jobCount + DEFAULT_OFFSET_INCREMENT - 1) / DEFAULT_OFFSET_INCREMENT;
}
} catch (NumberFormatException ex) {
GuiUtil.getLogger().info("Value isn't a valid integer " + ex);
}

handlerCtx.setOutputValue("result", result);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2018 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.
*/

<f:verbatim>
<script type="text/javascript">
addCSS('/resource/batch/assets/skins/payara_theme/batch-styles.css');
function addCSS(filename){
var head = document.getElementsByTagName('head')[0];
var style = document.createElement('link');
style.href = filename;
style.type = 'text/css';
style.rel = 'stylesheet';
head.appendChild(style);
}
</script>
</f:verbatim>
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2018 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.
*/
/*
Created on : Jul 13, 2018, 5:51:48 PM
Author : Susan Rai
*/

input[id$="previousJobsButton"], input[id$="nextJobsButton"] {
width: 100px;
height: 30px;
padding: 0px;
color:#000000;
font-weight: bold;
background-color: transparent;
}

input:hover[id$="previousJobsButton"],
input:hover[id$="nextJobsButton"],
input:hover[id$="goButton"]{
background-color: #cbced0 !important;
}

span[id$=":paginationButtons"] {
background-color: #eeeeee;
border-radius: 5px;
padding: 10px;
display:block;
width : 350px;
margin: 0 0 20px 23%;
}

input[id$="nextJobsButton"] {
float: right;
}

input[id$="pageNumber"]{
float: left;
margin: -25px 0 0 135px;
width: 30px;
text-align: center;
}

label[id$="totalNumberOfPages_label"] {
color: #333333;
float: right;
width: 60px;
font-weight:100;
margin: -22px 110px 0 0;
}
label[for$="pageNumber"] {
color: #333333;
font-weight:100;
float: left;
width: 35px;
margin: -22px 0 0 100px;
}

input[id$="goButton"]{
width: 35px;
height: 25px;
padding: 0px;
color: #333333;
font-weight: bold;
background-color: transparent;
float: right;
margin: -27px 95px 0 0;
}
29 changes: 28 additions & 1 deletion appserver/admingui/full/src/main/resources/batch/batchJobs_1.inc
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,39 @@
#include "/full/batch/batchRequestParam.inc"
setSessionAttribute(key="#{pageSession.tabSetName}" value="batchJobs");
createMap(result="#{requestScope.attrsMap}");
mapPut(map="#{requestScope.attrsMap}" key="target" value="#{pageSession.encodedTarget}");
py.getPageNumber(offset="#{pageSession.offsetValue}" result="#{pageSession.pageNumber}");
mapPut(map="#{requestScope.attrsMap}" key="target" value="#{pageSession.encodedTarget}");
mapPut(map="#{requestScope.attrsMap}" key="output" value="executionid,jobname,batchstatus,exitstatus,instanceid,starttime,endtime");
mapPut(map="#{requestScope.attrsMap}" key="offset" value="#{pageSession.offsetValue}");
mapPut(map="#{requestScope.attrsMap}" key="limit" value="$int{20}");
gf.restRequest(endpoint="#{sessionScope.REST_URL}/list-batch-jobs" attrs="#{requestScope.attrsMap}" method="GET" result="#{requestScope.resp}");
setAttribute(key="listOfRows", value="#{requestScope.resp.data.extraProperties.listBatchJobs}");
setPageSessionAttribute(key="size" value="#{requestScope.listOfRows.size()}");
setPageSessionAttribute(key="valueMap", value="#{requestScope.resp.data.extraProperties.listJobsCount}");
py.getPageCount(jobCount="#{pageSession.valueMap['allJobsCount']}" result="#{pageSession.pageCount}");
setPageSessionAttribute(key="showJobExecutions" value="#{true}");
setPageSessionAttribute(key="displayNoJobsMessage" value="#{false}");

if (#{pageSession.size}<$int{1}){
setPageSessionAttribute(key="showJobExecutions" value="#{false}");
setPageSessionAttribute(key="displayNoJobsMessage" value="#{true}");
}

if (#{pageSession.pageNumber}<$int{1}){
setPageSessionAttribute(key="pageNumber" value="$int{1}");
}

if(#{pageSession.pageNumber}=#{pageSession.pageCount}){
setPageSessionAttribute(key="disableNextButton" value="#{true}");
}

if(#{pageSession.pageNumber}=$int{1}){
setPageSessionAttribute(key="disablePreviousButton" value="#{true}");
}

setPageSessionAttribute(key="tableTitle" value="$resource{i18nf.batch.batchJobsTableTitle}");
setPageSessionAttribute(key="editLink" value="#{request.contextPath}/full/batch/batchJobExecution.jsf?target=#{pageSession.target}&isCluster=#{pageSession.isCluster}&tabSetName=#{pageSession.encodedTabSetName}");
/>
</event>
#include"/batch/assets/js/batch.js"
<sun:form id="propertyForm">
Loading

0 comments on commit cf65c48

Please sign in to comment.