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-3419: Support deploying timers to deployment group and non-persistent timer service #3853

Merged
merged 5 commits into from
Mar 25, 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 @@ -39,6 +39,7 @@
holder.

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

<!-- configuration/ejbContainerTimerSettings.jsf -->

Expand Down Expand Up @@ -98,13 +99,9 @@
<sun:staticText id="msecs" style="padding: 8pt" text="$resource{i18n.common.Milliseconds}"/>
</sun:property>
<sun:property id="persistenceServiceProp" labelAlign="left" noWrap="#{true}" overlapLabel="#{false}" label="$resource{i18n_ejb.ejbTimerSettings.persistenceServiceLabel}" helpText="$resource{i18n_ejb.ejbTimerSettings.persistenceServiceHelp}" visible="#{true}" >
<sun:dropDown id="EjbTimerService" selected="#{pageSession.valueMap['ejbTimerService']}" required="#{false}" value="#{pageSession.valueMap['ejbTimerService']}" labels={"Database","DataGrid"} values={"Database","DataGrid"} >
<sun:dropDown id="EjbTimerService" selected="#{pageSession.valueMap['ejbTimerService']}" required="#{false}" value="#{pageSession.valueMap['ejbTimerService']}" labels={"Database","DataGrid","None"} values={"Database","DataGrid","None"} >
Copy link
Contributor Author

Choose a reason for hiding this comment

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

image

</sun:dropDown>
</sun:property>
<sun:property id="clusterFiringModeProp" labelAlign="left" noWrap="#{true}" overlapLabel="#{false}" label="$resource{i18n_ejb.ejbTimerSettings.clusterFiringModeLabel}" helpText="$resource{i18n_ejb.ejbTimerSettings.clusterFiringModeHelp}" visible="#{true}" >
<sun:dropDown id="ClusterFiringMode" selected="#{pageSession.valueMap['clusterFiringMode']}" required="#{false}" value="#{pageSession.valueMap['clusterFiringMode']}" labels={"One Per Data Grid","One Per Deployment Group","All Instances"} values={"OnePerCluster","OnePerDeploymentGroup","AllInstances"} >
</sun:dropDown>
</sun:property>
</sun:property>
<sun:property id="TimerDatasourceProp" labelAlign="left" noWrap="#{true}" overlapLabel="#{false}" label="$resource{i18n_ejb.ejbTimerSettings.timerDatasourceLabel}" helpText="$resource{i18n_ejb.ejbTimerSettings.timerDatasourceLabelHelp}">
<sun:textField id="TimerDatasource" columns="$int{50}" maxLength="#{sessionScope.fieldLengths['maxLength.ejbTimerSettings.timerDatasource']}" text="#{pageSession.valueMap['timerDatasource']}" />
</sun:property>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
# only if the new code is made subject to such option by the copyright
# holder.
#
# Portions Copyright [2018-2019] [Payara Foundation and/or its affiliates]


ejb.NumBeans=Number of beans
Expand Down Expand Up @@ -65,7 +66,7 @@ ejbTimerSettings.redeliveryIntrHelp=Time between redelivery attempts
ejbTimerSettings.timerDatasourceLabel=Timer Datasource:
ejbTimerSettings.timerDatasourceLabelHelp=JNDI name of the JDBC resource that will be used as the timer datasource when Database is selected as the Persistence Service
ejbTimerSettings.persistenceServiceLabel=Persistence Service
ejbTimerSettings.persistenceServiceHelp=Persistence Service for storing Persistent EJB Timers. Database stores in the specified datasource, DataGrid stores timers in-memory in the Data Grid. In Data Grid mode if all Data Grid instances are shutdown persistent timers will be lost
ejbTimerSettings.persistenceServiceHelp=Persistence Service for storing Persistent EJB Timers. Database stores in the specified datasource, DataGrid stores timers in-memory in the Data Grid. In Data Grid mode if all Data Grid instances are shutdown persistent timers will be lost. When mode is None, all timers are non-persistent.
ejbTimerSettings.clusterFiringModeLabel=Clustered Timer Firing Mode
ejbTimerSettings.clusterFiringModeHelp=Determines how clustered timers fire. One Per Data Grid - only one timer will be active in the data grid. One Per Deployment Group - only one timer will be active within the targeted deployment group. All Instances - Timer will be active on all instances where the application is deployed.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2016-2018] [Payara Foundation]
// Portions Copyright [2016-2019] [Payara Foundation]

package org.glassfish.ejb.config;

Expand Down Expand Up @@ -68,6 +68,8 @@

@Configured
public interface EjbTimerService extends ConfigBeanProxy, PropertyBag {
String TYPE_NONE = "None";
String TYPE_DATABASE = "Database";
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps TYPE_DATAGRID constant can be added to list all timer types.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason I included these two was, that these are special -- one is default, the other has special behaviour. There's nothing else in the code that would actually match against value DataGrid in the code, and changing the value would not affect the behavior of the server. Therefore I believe it would be misleading to bake it into API.


/**
* Gets the value of the minimumDeliveryIntervalInMillis property.
Expand Down Expand Up @@ -160,11 +162,16 @@ public interface EjbTimerService extends ConfigBeanProxy, PropertyBag {
* Gets the value of the EJB Timer Service property.
*
* The EJB Timer Service type to use in Payara.
* Supported values:
* <ul>
* <li>{@value #TYPE_DATABASE} for database-backed persistence</li>
* <li>"DataGrid" for DataGrid-backed persistence</li>
Copy link
Contributor

Choose a reason for hiding this comment

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

Replace "DataGrid" with {@value #TYPE_DATAGRID}

* <li>{@value #TYPE_NONE} for non-persistent timer service</li>
* </ul>
*
* @return possible object is
* {@link String }
* @return One of the options above
*/
@Attribute (defaultValue="Database")
@Attribute (defaultValue=TYPE_DATABASE)
String getEjbTimerService();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2016-2018] [Payara Foundation and/or its affiliates]
// Portions Copyright [2016-2019] [Payara Foundation and/or its affiliates]
package com.sun.ejb.containers;

import java.io.Serializable;
Expand Down Expand Up @@ -391,9 +391,11 @@ private static synchronized void initNonPersistentTimerService(String target, bo

private static synchronized void initPersistentTimerService(String target, boolean force) {
if (persistentTimerService == null) {
EjbContainerUtil ejbContainerUtil = EjbContainerUtilImpl.getInstance();
String serviceType = ejbContainerUtil.getEjbContainer().getEjbTimerService().getEjbTimerService();
List<PersistentTimerService> persistentTSList
= EjbContainerUtilImpl.getInstance().getServices().getAllServices(PersistentTimerService.class);
if (persistentTSList.isEmpty()) {
if (persistentTSList.isEmpty() || EjbTimerService.TYPE_NONE.equals(serviceType)) {
try {
persistentTimerService = new NonPersistentEJBTimerService();
persistentTimerServiceVerified = true;
Expand All @@ -403,8 +405,6 @@ private static synchronized void initPersistentTimerService(String target, boole
} else {
synchronized (LOCK) {
// choose service based on the configuration setting
EjbContainerUtil ejbContainerUtil = EjbContainerUtilImpl.getInstance();
String serviceType = ejbContainerUtil.getEjbContainer().getEjbTimerService().getEjbTimerService();
PersistentTimerService persistentTS = null;
for (PersistentTimerService pts : persistentTSList) {
if (pts.getClass().getSimpleName().startsWith(serviceType)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,11 +469,15 @@ public void event(Event event) {
}

boolean createTimers = true;
if (!(opsparams.origin.isDeploy() || opsparams.origin.isCreateAppRef()) || env.getInstanceName().equals(dcp.target)) {
// Do real work only on deploy for a cluster or create-application-ref (the latter will
boolean isDeploymentGroup = domain.getDeploymentGroupNamed(dcp.target) != null;
boolean isDeployment = opsparams.origin.isDeploy() || opsparams.origin.isCreateAppRef();
boolean isDirectTarget = env.getInstanceName().equals(dcp.target);
// Create timers on DAS only if this condition is not met
if (!isDeployment || isDirectTarget || isDeploymentGroup) {
// Create them on deploy for a cluster or create-application-ref (the latter will
// check if it's the 1st ref being added or a subsequent one (timers with this unique id are present
// or not)
// Timers will be created by the BaseContainer if it's a single instance deploy
// Otherwise, timers will be created by the BaseContainer if it's a single instance deploy
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "EjbDeployer ... will only set the timeout application flag if any");
}
Expand Down