diff --git a/appserver/admin/gf_template/src/main/resources/config/domain.xml b/appserver/admin/gf_template/src/main/resources/config/domain.xml index a719b9421e2..d1886958ec6 100644 --- a/appserver/admin/gf_template/src/main/resources/config/domain.xml +++ b/appserver/admin/gf_template/src/main/resources/config/domain.xml @@ -43,6 +43,7 @@ + @@ -119,7 +120,6 @@ - @@ -127,7 +127,8 @@ - + + @@ -377,13 +378,13 @@ - + diff --git a/appserver/admin/payara_template/src/main/resources/config/domain.xml b/appserver/admin/payara_template/src/main/resources/config/domain.xml index 707e2d5b1df..0cc09a6e975 100644 --- a/appserver/admin/payara_template/src/main/resources/config/domain.xml +++ b/appserver/admin/payara_template/src/main/resources/config/domain.xml @@ -16,6 +16,7 @@ --> + @@ -86,12 +87,12 @@ + - @@ -340,7 +341,7 @@ - + diff --git a/appserver/admingui/payara-console-extras/src/main/resources/META-INF/admingui/console-config.xml b/appserver/admingui/payara-console-extras/src/main/resources/META-INF/admingui/console-config.xml index 210f6c461e8..6a04db79cdf 100644 --- a/appserver/admingui/payara-console-extras/src/main/resources/META-INF/admingui/console-config.xml +++ b/appserver/admingui/payara-console-extras/src/main/resources/META-INF/admingui/console-config.xml @@ -39,28 +39,29 @@ holder. --> + - + - - - - - \ -
Hazelcast must be enabled to use the Hazelcast Web and EJB session persistence type in the Availability Service.\ -
Hazelcast must be enabled to use JCache (JSR 107) capabilities and apis in your applications. \ -
Hazelcast does not need to be enabled to use the legacy GlassFish Shoal based GMS and replicated session persistence type. \ -
Set a unique Cluster Name and Cluster Password for each Development, Preproduction and Production Environment. +hazelcast.configurationTitle=Domain Wide Data Grid Configuration +hazelcast.configurationTitleHelp=Enable and configure the settings for the embedded Domain wide Data Grid within Payara.
\ +
Data Grid must be enabled to use the Hazelcast Web and EJB session persistence type in the Availability Service.\ +
Data Grid must be enabled to use JCache (JSR 107) capabilities and apis in your applications. +hazelcast.local.configurationTitle=Configuration Specific Data Grid Configuration +hazelcast.local.configurationTitleHelp=Data Grid configuration specified here applies to all server instances that use this configuation \ +These configuration options in combination with the Domain Data Grid configuration determines how a server instance joins the cluster. hazelcast.configuration.enabled=Enabled -hazelcast.configuration.enabledHelp=If enabled, Hazelcast will start when the server starts. Hazelcast will start immediately if both this and the 'Dynamic' boxes are checked +hazelcast.configuration.enabledHelp=If enabled, the Data Grid will start when the server starts. Data Grid will start immediately if both this and the 'Dynamic' boxes are checked.\ +The Data Grid is always enabled on the DAS. hazelcast.configuration.configFile=Override configuration file -hazelcast.configuration.configFileHelp=Path to the Hazelcast configuration file (relative to the domain config directory) which overrides all the settings on this page\ +hazelcast.configuration.configFileHelp=Path to the Data Grid configuration file (relative to the domain config directory) which overrides all the settings on this page\ If this is set, and the file exists, all the settings below are ignored and are taken from the specified configuration file. hazelcast.configuration.startPort=Start Port -hazelcast.configuration.startPortHelp=Default port Hazelcast will listen on. Hazelcast will increment this number until it finds a valid port. +hazelcast.configuration.startPortHelp=Default port the Data Grid member will listen on. The member will increment this number until it finds a valid port. hazelcast.configuration.multicastPort=Multicast Port -hazelcast.configuration.multicastPortHelp=The multicast port for group communications in the Hazelcast cluster +hazelcast.configuration.multicastPortHelp=The multicast port for group communications in the Data Grid if multicast cluster discovery mode is selected hazelcast.configuration.multicastGroup=Multicast Group -hazelcast.configuration.multicastGroupHelp=The multicast group for communications in the Hazelcast cluster -hazelcast.configuration.clusterName=Cluster Group Name -hazelcast.configuration.clusterNameHelp=Cluster Group Name. For Hazelcast to cluster the cluster name and password must be identical. -hazelcast.configuration.clusterPassword=Cluster Group Password -hazelcast.configuration.clusterPasswordHelp=Cluster Group Password. The password must be the same on all cluster group members. -hazelcast.configuration.jndiName=JNDI Name +hazelcast.configuration.multicastGroupHelp=The multicast group for communications in the Data Grid if multicast cluster discovery mode is selected +hazelcast.configuration.tcpipMembers=TCP/IP Members +hazelcast.configuration.tcpipMembersHelp=The list of other data grid members to connect to when Cluster discovery mode is set to tcpip +hazelcast.configuration.discoveryMode=Cluster Discovery Mode +hazelcast.configuration.discoveryModeHelp=How should the DAS discovery other server instances in the Data Grid +hazelcast.configuration.interfaces=Network Interfaces +hazelcast.configuration.interfacesHelp=The list of network interfaces the Data Grid should bind to +hazelcast.configuration.dasPublicAddress=DAS Public Address +hazelcast.configuration.dasPublicAddressHelp=The network address that other members should use to connect to the DAS. If left blank the value for Public Bind Address will be used. +hazelcast.configuration.dasBindAddress=DAS Bind Address +hazelcast.configuration.dasBindAddressHelp=The network interface address the DAS Data Grid should bind to +hazelcast.configuration.dasPort=DAS Start Port +hazelcast.configuration.dasPortHelp=Default port the DAS member will listen on. The member will increment this number until it finds a valid port. +hazelcast.configuration.clusterName=Data Grid Group Name +hazelcast.configuration.clusterNameHelp=Data Grid Group Name. For members to form a Data Grid the name and password must be identical. +hazelcast.configuration.clusterPassword=Data Grid Group Password +hazelcast.configuration.clusterPasswordHelp=Data Grid Group Password. The password must be the same on all data grid members. +hazelcast.configuration.jndiName=Hazelcast Instance JNDI Name hazelcast.configuration.jndiNameHelp=JNDI Name to bind the Hazelcast Instance to hazelcast.configuration.licenseKey=License Key hazelcast.configuration.licenseKeyHelp=The License Key for Hazelcast Enterprise hazelcast.configuration=Configuration -hazelcast.configurationTip=Hazelcast Configuration +hazelcast.configurationTip=Data Grid Configuration hazelcast.membersTab=Cluster Members -hazelcast.membersTabTip=View the Hazelcast Cluster Members -hazelcast.hazelcastTabs=Hazelcast -hazelcast.membersTitle=Hazelcast Cluster Members -hazelcast.membersTitleHelp=A list of the Hazelcast Cluster Members visible to this instance -hazelcast.domainMembersTitleHelp=A list of the Hazelcast Cluster Members visible to this domain -hazelcast.members.members =Cluster Members -hazelcast.members.membersHelp=The Hazelcast Cluster Members -hazelcast.configuration.dynamic=Dynamic -hazelcast.configuration.dynamicHelp=Applies the configuration change immediately, without needing a restart. -hazelcast.configuration.lite =Lite Cluster Member -hazelcast.configuration.liteHelp=If set to true this member is a lite cluster member. i.e. It clusters but stores no cluster data within its heap. +hazelcast.membersTabTip=View the Data Grid Cluster Members +hazelcast.hazelcastTabs=Data Grid +hazelcast.membersTitle=Data Grid Members +hazelcast.membersTitleHelp=A list of the Data Grid Members visible to this instance +hazelcast.domainMembersTitleHelp=A list of the Data Grid Members visible to this domain +hazelcast.members.members =Data Grid Members +hazelcast.members.membersHelp=The Data Grid Cluster Members +hazelcast.configuration.dynamic=Restart Data Grid +hazelcast.configuration.dynamicHelp=Applies the cluster configuration change immediately, without needing a restart of the Server.
WARNING this can cause cluster wide data loss if a large number of instances restart their clustering immediately. +hazelcast.configuration.lite =Lite Data Grid Member +hazelcast.configuration.liteHelp=If set to true this member is a lite Data Grid member. i.e. It joins the grid but stores no data within its heap. hazelcast.configuration.hostaware =Host Aware Partitioning -hazelcast.configuration.hostawareHelp =When enabled cluster backups will not be stored on members with the same IP Address. All members of the cluster including Payara Micro members must have Host Aware Partitioning enabled. -tree.hazelcast=Hazelcast +hazelcast.configuration.hostawareHelp =When enabled data backups will not be stored on members with the same IP Address. All members of the data grid including Payara Micro members must have Host Aware Partitioning enabled. +hazelcast.configuration.memberGroup=Member Group +hazelcast.configuration.memberGroupHelp=The member group for all server instances using this configuration +hazelcast.configuration.cacheManagerJndiName=JCache Cache Manager JNDI Name +hazelcast.configuration.cacheManagerJndiNameHelp=JNDI Name to bind the JCache Cache Manager to +hazelcast.configuration.cachingProviderJndiName=JCache Caching Provider JNDI Name +hazelcast.configuration.cachingProviderJndiNameHelp=JNDI Name to bind the JCache Caching Provider to +hazelcast.configuration.executorPoolSize=Executor Pool Size +hazelcast.configuration.executorPoolSizeHelp=Thread Pool Size for the Data Grid Executor Service +hazelcast.configuration.scheduledExecutorPoolSize=Scheduled Executor Pool Size +hazelcast.configuration.scheduledExecutorPoolSizeHelp=Thread Pool Size for the Data Grid Scheduled Executor Service +hazelcast.configuration.executorQueueCapacity=Executor Queue Capacity +hazelcast.configuration.scheduledExecutorQueueCapacity=Scheduled Executor Queue Capacity +hazelcast.configuration.executorQueueCapacityHelp=Queue Capacity of the Data Grid Executor Service. Executions are queued until a thread is available +hazelcast.configuration.scheduledExecutorQueueCapacityHelp=Queue Capacity of the Data Grid Scheduled Executor Service. Executions are queued until a thread is available +tree.hazelcast=Data Grid environmentWarning.environmentWarningTab=Environment Warning environmentWarning.environmentWarningTabTip=Environment Warning Tab diff --git a/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcast.jsf b/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcast.jsf index a324f978be5..ccc6266ec5e 100644 --- a/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcast.jsf +++ b/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcast.jsf @@ -28,44 +28,31 @@ #include "/common/shared/alertMsg_1.inc" +#include "/hazelcast/hazelcastTabs.inc" @@ -74,14 +61,24 @@ -#include "/common/shared/configNameSection.inc" - - - - + + + + + + + + + + + + + + + @@ -94,24 +91,27 @@ + + + + + + + + + + + + - - - - - + + - - - - - - diff --git a/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastCachesTab.jsf b/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastCachesTab.jsf new file mode 100644 index 00000000000..10a0b911ebf --- /dev/null +++ b/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastCachesTab.jsf @@ -0,0 +1,69 @@ + + + + +#include "/cluster/shared/instancesExtraButtons.inc" +#include "/cluster/shared/handlers.inc" + + + + + + + + +#include "/common/shared/alertMsg.inc" +#include "/hazelcast/hazelcastTabs.inc" + + + +"
+ +"
+#include "allInstancesTable.inc" +"
+#include "serverInstancesTable.inc" +"
+#include "microInstancesTable.inc" +"
+ +
+ + diff --git a/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastConfigLink.jsf b/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastConfigLink.jsf index cae940128fb..736b247cade 100644 --- a/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastConfigLink.jsf +++ b/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastConfigLink.jsf @@ -20,7 +20,7 @@ diff --git a/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastConfigurationCluster.jsf b/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastConfigurationCluster.jsf deleted file mode 100644 index 57349519099..00000000000 --- a/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastConfigurationCluster.jsf +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - - - - - - - -#include "/cluster/cluster/clusterTabs.inc" - -#include "/common/shared/alertMsg_1.inc" - - - - - - - - - - -#include "/common/shared/nameSection.inc" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastConfigurationDomain.jsf b/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastConfigurationDomain.jsf deleted file mode 100644 index 3c419d68db7..00000000000 --- a/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastConfigurationDomain.jsf +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - - - - - - - -#include "/common/appServer/domainTabs.inc" -#include "/common/shared/alertMsg_1.inc" - - - - - - - - - - -#include "/common/shared/nameSection.inc" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastConfigurationStandalone.jsf b/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastConfigurationStandalone.jsf deleted file mode 100644 index 7836eec891a..00000000000 --- a/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastConfigurationStandalone.jsf +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - - - - - - - -#include "/cluster/standalone/standaloneInstanceTabs.inc" -#include "/common/shared/alertMsg_1.inc" - - - - - - - - - - -#include "/common/shared/nameSection.inc" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastLocal.jsf b/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastLocal.jsf new file mode 100644 index 00000000000..4cd7f5b4403 --- /dev/null +++ b/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastLocal.jsf @@ -0,0 +1,110 @@ + + + + + + + + + + + + +#include "/common/shared/alertMsg_1.inc" + + + + + + + + + + +#include "/common/shared/configNameSection.inc" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastMembersCluster.jsf b/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastMembersCluster.jsf deleted file mode 100644 index 917d7e12808..00000000000 --- a/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastMembersCluster.jsf +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - - - - - -#include "/cluster/cluster/clusterTabs.inc" -#include "/common/shared/alertMsg_1.inc" - - - -#include "/common/shared/nameSection.inc" - - - - - - - - - - diff --git a/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastMembersDomain.jsf b/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastMembersDomain.jsf index 87614667fb7..10a0b911ebf 100644 --- a/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastMembersDomain.jsf +++ b/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastMembersDomain.jsf @@ -30,7 +30,7 @@ #include "/common/shared/alertMsg.inc" -#include "/common/appServer/domainTabs.inc" +#include "/hazelcast/hazelcastTabs.inc" diff --git a/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastMembersStandalone.jsf b/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastMembersStandalone.jsf deleted file mode 100644 index 49e5870f38d..00000000000 --- a/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastMembersStandalone.jsf +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - - - - - -#include "/cluster/standalone/standaloneInstanceTabs.inc" -#include "/common/shared/alertMsg_1.inc" - - - -#include "/common/shared/nameSection.inc" - - - - - - - - - - diff --git a/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastTabsCluster.jsf b/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastTabs.inc similarity index 55% rename from appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastTabsCluster.jsf rename to appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastTabs.inc index b1136337602..1f5b91bdf5f 100644 --- a/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastTabsCluster.jsf +++ b/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastTabs.inc @@ -15,27 +15,18 @@ When distributing the software, include this License Header Notice in each file and include the License file at packager/legal/LICENSE.txt. --> - - - - + - \ No newline at end of file + diff --git a/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastTabsDomain.jsf b/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastTabsDomain.jsf index 0324ff9844b..04b3ae338ef 100644 --- a/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastTabsDomain.jsf +++ b/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastTabsDomain.jsf @@ -15,27 +15,26 @@ When distributing the software, include this License Header Notice in each file and include the License file at packager/legal/LICENSE.txt. --> - - + - \ No newline at end of file + \ No newline at end of file diff --git a/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastTabsStandalone.jsf b/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastTabsStandalone.jsf deleted file mode 100644 index a1e93e2c13d..00000000000 --- a/appserver/admingui/payara-console-extras/src/main/resources/hazelcast/hazelcastTabsStandalone.jsf +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/appserver/admingui/payara-console-extras/src/main/resources/pluginTreeNodeHazelcast.jsf b/appserver/admingui/payara-console-extras/src/main/resources/pluginTreeNodeHazelcast.jsf index 504914e750e..7c8049828f5 100644 --- a/appserver/admingui/payara-console-extras/src/main/resources/pluginTreeNodeHazelcast.jsf +++ b/appserver/admingui/payara-console-extras/src/main/resources/pluginTreeNodeHazelcast.jsf @@ -22,7 +22,7 @@ + + + + + + + diff --git a/appserver/extras/payara-micro/payara-micro-boot/src/main/resources/MICRO-INF/domain/domain.xml b/appserver/extras/payara-micro/payara-micro-boot/src/main/resources/MICRO-INF/domain/domain.xml index 4e004eaacd5..ebb2cd823ff 100644 --- a/appserver/extras/payara-micro/payara-micro-boot/src/main/resources/MICRO-INF/domain/domain.xml +++ b/appserver/extras/payara-micro/payara-micro-boot/src/main/resources/MICRO-INF/domain/domain.xml @@ -41,6 +41,7 @@ Portions Copyright [2016-2017] [Payara Foundation and/or its affiliates] --> + @@ -67,6 +68,7 @@ Portions Copyright [2016-2017] [Payara Foundation and/or its affiliates] + @@ -155,7 +157,6 @@ Portions Copyright [2016-2017] [Payara Foundation and/or its affiliates] - diff --git a/appserver/extras/payara-micro/payara-micro-core/src/main/java/fish/payara/micro/cmd/options/DirectoryValidator.java b/appserver/extras/payara-micro/payara-micro-core/src/main/java/fish/payara/micro/cmd/options/DirectoryValidator.java index eee536a1326..c8bb705e045 100644 --- a/appserver/extras/payara-micro/payara-micro-core/src/main/java/fish/payara/micro/cmd/options/DirectoryValidator.java +++ b/appserver/extras/payara-micro/payara-micro-core/src/main/java/fish/payara/micro/cmd/options/DirectoryValidator.java @@ -39,9 +39,6 @@ */ package fish.payara.micro.cmd.options; -import java.io.File; -import java.text.MessageFormat; - /** * @author steve */ diff --git a/appserver/extras/payara-micro/payara-micro-core/src/main/java/fish/payara/micro/cmd/options/MulticastValidator.java b/appserver/extras/payara-micro/payara-micro-core/src/main/java/fish/payara/micro/cmd/options/MulticastValidator.java index ab51160c515..6f4084cda4e 100644 --- a/appserver/extras/payara-micro/payara-micro-core/src/main/java/fish/payara/micro/cmd/options/MulticastValidator.java +++ b/appserver/extras/payara-micro/payara-micro-core/src/main/java/fish/payara/micro/cmd/options/MulticastValidator.java @@ -42,8 +42,6 @@ import java.net.InetAddress; import java.net.UnknownHostException; import java.text.MessageFormat; -import java.util.logging.Level; -import java.util.logging.Logger; /** * diff --git a/appserver/extras/payara-micro/payara-micro-core/src/main/java/fish/payara/micro/cmd/options/PrefixStringListValidator.java b/appserver/extras/payara-micro/payara-micro-core/src/main/java/fish/payara/micro/cmd/options/PrefixStringListValidator.java new file mode 100644 index 00000000000..5b8357b8383 --- /dev/null +++ b/appserver/extras/payara-micro/payara-micro-core/src/main/java/fish/payara/micro/cmd/options/PrefixStringListValidator.java @@ -0,0 +1,65 @@ +/* + * 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.micro.cmd.options; + +/** + * + * @author steve + */ +public class PrefixStringListValidator extends Validator { + + private String allowedValues[]; + + public PrefixStringListValidator(String ... allowedValues) { + this.allowedValues = allowedValues; + } + + @Override + boolean validate(String optionValue) throws ValidationException { + boolean result = false; + for (String allowedValue : allowedValues) { + if (optionValue.startsWith(allowedValue)) { + result = true; + break; + } + } + return result; + } +} diff --git a/appserver/extras/payara-micro/payara-micro-core/src/main/java/fish/payara/micro/cmd/options/RUNTIME_OPTION.java b/appserver/extras/payara-micro/payara-micro-core/src/main/java/fish/payara/micro/cmd/options/RUNTIME_OPTION.java index 9f8652b3725..f02f1e052dd 100644 --- a/appserver/extras/payara-micro/payara-micro-core/src/main/java/fish/payara/micro/cmd/options/RUNTIME_OPTION.java +++ b/appserver/extras/payara-micro/payara-micro-core/src/main/java/fish/payara/micro/cmd/options/RUNTIME_OPTION.java @@ -57,6 +57,7 @@ public enum RUNTIME_OPTION { clustername(true), clusterpassword(true), hostaware(false), + nohostaware(false), startport(true, new PortValidator()), addlibs(true, new SeparatedFilesValidator(true, true, false, true, true)), addjars(true, new SeparatedFilesValidator(true, true, false, true, true)), @@ -91,6 +92,8 @@ public enum RUNTIME_OPTION { postdeploycommandfile(true, new FileValidator(true,true,false)), nested(false), unpackdir(true, new DirectoryValidator(true, true, true)), + clustermode(true,new PrefixStringListValidator("tcpip","domain","multicast")), + interfaces(true), help(false); private RUNTIME_OPTION(boolean value) { @@ -110,6 +113,8 @@ boolean getValue() { return value; } private final Validator validator; + + // Indicates the runtime option requires a value private final boolean value; } diff --git a/appserver/extras/payara-micro/payara-micro-core/src/main/java/fish/payara/micro/cmd/options/StringListValidator.java b/appserver/extras/payara-micro/payara-micro-core/src/main/java/fish/payara/micro/cmd/options/StringListValidator.java new file mode 100644 index 00000000000..e928184bb49 --- /dev/null +++ b/appserver/extras/payara-micro/payara-micro-core/src/main/java/fish/payara/micro/cmd/options/StringListValidator.java @@ -0,0 +1,66 @@ +/* + * 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.micro.cmd.options; + +/** + * A validator that checks whether an option is in a list of allowed values + * @since 5.0 + * @author steve + */ +public class StringListValidator extends Validator { + + private String allowedValues[]; + + public StringListValidator(String ... allowedValues) { + this.allowedValues = allowedValues; + } + + @Override + boolean validate(String optionValue) throws ValidationException { + boolean result = false; + for (String allowedValue : allowedValues) { + if (allowedValue.equals(optionValue)) { + result = true; + break; + } + } + return result; + } +} diff --git a/appserver/extras/payara-micro/payara-micro-core/src/main/java/fish/payara/micro/impl/PayaraMicroImpl.java b/appserver/extras/payara-micro/payara-micro-core/src/main/java/fish/payara/micro/impl/PayaraMicroImpl.java index 2addd1b5287..bd86174659f 100644 --- a/appserver/extras/payara-micro/payara-micro-core/src/main/java/fish/payara/micro/impl/PayaraMicroImpl.java +++ b/appserver/extras/payara-micro/payara-micro-core/src/main/java/fish/payara/micro/impl/PayaraMicroImpl.java @@ -129,7 +129,7 @@ public class PayaraMicroImpl implements PayaraMicroBoot { private GlassFish gf; private PayaraMicroRuntimeImpl runtime; private boolean noCluster = false; - private boolean hostAware = false; + private boolean hostAware = true; private boolean autoBindHttp = false; private boolean autoBindSsl = false; private boolean liteMember = false; @@ -167,7 +167,9 @@ public class PayaraMicroImpl implements PayaraMicroBoot { private String postBootFileName; private String postDeployFileName; private RuntimeDirectory runtimeDir = null; - + private String clustermode; + private String interfaces; + /** * Runs a Payara Micro server used via java -jar payara-micro.jar * @@ -1114,6 +1116,10 @@ private void scanArgs(String[] args) { hostAware = true; break; } + case nohostaware: { + hostAware = false; + break; + } case mcport: { hzPort = Integer.parseInt(value); break; @@ -1306,6 +1312,12 @@ else if (requestTracing[0].matches("\\D+")) { case postdeploycommandfile: postDeployFileName = value; break; + case clustermode: + clustermode = value; + break; + case interfaces: + interfaces = value; + break; default: break; } @@ -1731,44 +1743,72 @@ private void configurePhoneHome() { private void configureHazelcast() { // check hazelcast cluster overrides if (noCluster) { - preBootCommands.add(new BootCommand("set", "configs.config.server-config.hazelcast-runtime-configuration.enabled=false")); + preBootCommands.add(new BootCommand("set", "configs.config.server-config.hazelcast-config-specific-configuration.enabled=false")); preBootCommands.add(new BootCommand("set", "configs.config.server-config.ejb-container.ejb-timer-service.ejb-timer-service=Dummy")); } else { if (hzPort > Integer.MIN_VALUE) { - preBootCommands.add(new BootCommand("set", "configs.config.server-config.hazelcast-runtime-configuration.multicast-port=" + hzPort)); + preBootCommands.add(new BootCommand("set", "hazelcast-runtime-configuration.multicast-port=" + hzPort)); } if (hzStartPort > Integer.MIN_VALUE) { - preBootCommands.add(new BootCommand("set", "configs.config.server-config.hazelcast-runtime-configuration.start-port=" + hzStartPort)); + preBootCommands.add(new BootCommand("set", "hazelcast-runtime-configuration.start-port=" + hzStartPort)); } if (hzMulticastGroup != null) { - preBootCommands.add(new BootCommand("set", "configs.config.server-config.hazelcast-runtime-configuration.multicast-group=" + hzMulticastGroup)); + preBootCommands.add(new BootCommand("set", "hazelcast-runtime-configuration.multicast-group=" + hzMulticastGroup)); } if (alternateHZConfigFile != null) { - preBootCommands.add(new BootCommand("set", "configs.config.server-config.hazelcast-runtime-configuration.hazelcast-configuration-file=" + alternateHZConfigFile.getName())); + preBootCommands.add(new BootCommand("set", "hazelcast-runtime-configuration.hazelcast-configuration-file=" + alternateHZConfigFile.getName())); } - preBootCommands.add(new BootCommand("set", "configs.config.server-config.hazelcast-runtime-configuration.lite=" + liteMember)); + preBootCommands.add(new BootCommand("set", "configs.config.server-config.hazelcast-config-specific-configuration.lite=" + liteMember)); if (hzClusterName != null) { - preBootCommands.add(new BootCommand("set", "configs.config.server-config.hazelcast-runtime-configuration.cluster-group-name=" + hzClusterName)); + preBootCommands.add(new BootCommand("set", "hazelcast-runtime-configuration.cluster-group-name=" + hzClusterName)); } if (hzClusterPassword != null) { - preBootCommands.add(new BootCommand("set", "configs.config.server-config.hazelcast-runtime-configuration.cluster-group-password=" + hzClusterPassword)); + preBootCommands.add(new BootCommand("set", "hazelcast-runtime-configuration.cluster-group-password=" + hzClusterPassword)); } if (instanceName != null) { - preBootCommands.add(new BootCommand("set", "configs.config.server-config.hazelcast-runtime-configuration.member-name=" + instanceName)); - preBootCommands.add(new BootCommand("set", "configs.config.server-config.hazelcast-runtime-configuration.generate-names=false")); + preBootCommands.add(new BootCommand("set", "configs.config.server-config.hazelcast-config-specific-configuration.member-name=" + instanceName)); + preBootCommands.add(new BootCommand("set", "hazelcast-runtime-configuration.generate-names=false")); } if (instanceGroup != null) { - preBootCommands.add(new BootCommand("set", "configs.config.server-config.hazelcast-runtime-configuration.member-group=" + instanceGroup)); + preBootCommands.add(new BootCommand("set", "configs.config.server-config.hazelcast-config-specific-configuration.member-group=" + instanceGroup)); + } + preBootCommands.add(new BootCommand("set", "hazelcast-runtime-configuration.host-aware-partitioning=" + hostAware)); + + if (clustermode != null) { + if (clustermode.startsWith("tcpip:")) { + String tcpipmembers = clustermode.substring(6); + preBootCommands.add(new BootCommand("set", "hazelcast-runtime-configuration.tcpip-members=" + tcpipmembers)); + preBootCommands.add(new BootCommand("set", "hazelcast-runtime-configuration.discovery-mode=tcpip")); + } else if (clustermode.startsWith("multicast:")) { + String hostPort[] = clustermode.split(":"); + if (hostPort.length == 3) { + preBootCommands.add(new BootCommand("set", "hazelcast-runtime-configuration.multicast-group=" + hostPort[1])); + preBootCommands.add(new BootCommand("set", "hazelcast-runtime-configuration.multicast-port=" + hostPort[2])); + preBootCommands.add(new BootCommand("set", "hazelcast-runtime-configuration.discovery-mode=multicast")); + } + } else if (clustermode.startsWith("domain:")) { + String hostPort[] = clustermode.split(":"); + if (hostPort.length == 3) { + preBootCommands.add(new BootCommand("set", "hazelcast-runtime-configuration.das-public-address=" + hostPort[1])); + preBootCommands.add(new BootCommand("set", "hazelcast-runtime-configuration.das-port=" + hostPort[2])); + preBootCommands.add(new BootCommand("set", "hazelcast-runtime-configuration.discovery-mode=domain")); + } + } + } else { + preBootCommands.add(new BootCommand("set", "hazelcast-runtime-configuration.discovery-mode=multicast")); + } + + if (interfaces != null) { + preBootCommands.add(new BootCommand("set", "hazelcast-runtime-configuration.interface=" + interfaces)); } - preBootCommands.add(new BootCommand("set", "configs.config.server-config.hazelcast-runtime-configuration.host-aware-partitioning=" + hostAware)); } } @@ -1967,7 +2007,7 @@ private void setArgumentsFromSystemProperties() { sslPort = getIntegerProperty("payaramicro.sslPort", Integer.MIN_VALUE); hzMulticastGroup = getProperty("payaramicro.mcAddress"); hzPort = getIntegerProperty("payaramicro.mcPort", Integer.MIN_VALUE); - hostAware = getBooleanProperty("payaramicro.hostAware"); + hostAware = getBooleanProperty("payaramicro.hostAware","true"); hzStartPort = getIntegerProperty("payaramicro.startPort", Integer.MIN_VALUE); hzClusterName = getProperty("payaramicro.clusterName"); hzClusterPassword = getProperty("payaramicro.clusterPassword"); @@ -1979,6 +2019,8 @@ private void setArgumentsFromSystemProperties() { enableRequestTracing = getBooleanProperty("payaramicro.enableRequestTracing"); requestTracingThresholdUnit = getProperty("payaramicro.requestTracingThresholdUnit", "SECONDS"); requestTracingThresholdValue = getLongProperty("payaramicro.requestTracingThresholdValue", 30L); + clustermode = getProperty("payaramicro.clusterMode"); + interfaces = getProperty("payaramicro.interfaces"); // Set the rootDir file String rootDirFileStr = getProperty("payaramicro.rootDir"); @@ -2102,6 +2144,14 @@ private void packageUberJar() { if (hzClusterPassword != null) { props.setProperty("payaramicro.clusterPassword", hzClusterPassword); } + + if (clustermode != null) { + props.setProperty("payaramicro.clusterMode", clustermode); + } + + if (interfaces != null) { + props.setProperty("payaramicro.interfaces", interfaces); + } props.setProperty("payaramicro.autoBindHttp", Boolean.toString(autoBindHttp)); props.setProperty("payaramicro.autoBindSsl", Boolean.toString(autoBindSsl)); @@ -2348,6 +2398,19 @@ private Boolean getBooleanProperty(String value) { } return "true".equals(property); } + + private Boolean getBooleanProperty(String value, String defaultValue) { + String property; + property = System.getProperty(value); + if (property == null) { + property = System.getenv(value.replace('.', '_')); + if (property == null) { + property = defaultValue; + } + } + return "true".equals(property); + } + private Integer getIntegerProperty(String value, Integer defaultValue) { String property; diff --git a/appserver/extras/payara-micro/payara-micro-core/src/main/resources/commandlogstrings.properties b/appserver/extras/payara-micro/payara-micro-core/src/main/resources/commandlogstrings.properties index 54c9b06d3db..c2ca8790699 100644 --- a/appserver/extras/payara-micro/payara-micro-core/src/main/resources/commandlogstrings.properties +++ b/appserver/extras/payara-micro/payara-micro-core/src/main/resources/commandlogstrings.properties @@ -49,4 +49,5 @@ fileIsDirectory=File {0} is a directory notValidMC={0} is not a valid multicast address notValidPort={0} is not a valid port number it must be > 1 and < 65535 integerIncorrect={0} must be a valid integer -integerRangeIncorrect={0} must be a valid integer > {1} and < {2} \ No newline at end of file +integerRangeIncorrect={0} must be a valid integer > {1} and < {2} +valueIsNotAllowed={0} must be one of {1} \ No newline at end of file diff --git a/appserver/extras/payara-micro/payara-micro-core/src/main/resources/commandoptions.properties b/appserver/extras/payara-micro/payara-micro-core/src/main/resources/commandoptions.properties index 63422de16e2..e82b18ea2ee 100644 --- a/appserver/extras/payara-micro/payara-micro-core/src/main/resources/commandoptions.properties +++ b/appserver/extras/payara-micro/payara-micro-core/src/main/resources/commandoptions.properties @@ -44,7 +44,8 @@ mcaddress= sets the cluster multicast group mcport= sets the cluster multicast port clustername= sets the Cluster Group Name clusterpassword= sets the Cluster Group Password -hostaware=Enable Host Aware Partitioning. When enabled cluster backups will not be stored on members with the same IP Address +hostaware=Enable Host Aware Partitioning. When enabled cluster backups will not be stored on members with the same IP Address (This is the default) +nohostaware=Disable Host Aware Partitioning startport= sets the cluster start port number name= sets the instance name rootdir= Sets the root configuration directory and saves the configuration across restarts @@ -85,3 +86,5 @@ instancegroup=Sets the instance group group=Sets the instance group nested=Do not unpack the Nested Jars when booting the server. This is generally slower than unpacking the runtime. unpackdir=Unpack the Nested Jar runtime jars to the specified directory. Default behaviour is to unpack to java.io.tmpdir +clustermode=Modifies the cluster discovery mode of Payara Micro when finding members of the cluster. Options are multicast:group:port, tcpip:host:port, domain:dashost:port +interfaces=Specifies the Interfaces that the data grid discovery mode should use to listen can be comma separated e.g. 127.0.0.1,192,168,0,* diff --git a/nucleus/admin/rest/rest-service/src/main/java/org/glassfish/admin/rest/utils/JsonUtil.java b/nucleus/admin/rest/rest-service/src/main/java/org/glassfish/admin/rest/utils/JsonUtil.java index 86f9f22f42c..653080f8ddd 100644 --- a/nucleus/admin/rest/rest-service/src/main/java/org/glassfish/admin/rest/utils/JsonUtil.java +++ b/nucleus/admin/rest/rest-service/src/main/java/org/glassfish/admin/rest/utils/JsonUtil.java @@ -45,6 +45,7 @@ import java.lang.reflect.Method; import java.math.BigDecimal; import java.math.BigInteger; +import java.net.InetAddress; import java.util.Collection; import java.util.Iterator; import java.util.Locale; @@ -140,7 +141,9 @@ public static JsonValue getJsonValue(Object object, boolean hideConfidentialProp result = Json.createValue((BigDecimal) object); } else if (object.getClass().isEnum()){ result = Json.createValue(object.toString()); - } else { + } else if (object instanceof InetAddress) { + result = Json.createValue(object.toString()); + }else { Class clazz = object.getClass(); if (clazz.isArray()) { JsonArrayBuilder array = Json.createArrayBuilder(); diff --git a/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/DomainDiscoveryService.java b/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/DomainDiscoveryService.java new file mode 100644 index 00000000000..ed68723f91d --- /dev/null +++ b/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/DomainDiscoveryService.java @@ -0,0 +1,190 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) [2016-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.nucleus.hazelcast; + +import com.hazelcast.nio.Address; +import com.hazelcast.spi.discovery.DiscoveryNode; +import com.hazelcast.spi.discovery.SimpleDiscoveryNode; +import com.hazelcast.spi.discovery.integration.DiscoveryService; +import com.sun.enterprise.config.serverbeans.Domain; +import com.sun.enterprise.config.serverbeans.Node; +import com.sun.enterprise.util.io.InstanceDirs; +import java.io.FileInputStream; +import java.io.IOException; +import java.net.Inet4Address; +import java.net.InetAddress; +import java.net.InterfaceAddress; +import java.net.NetworkInterface; +import java.net.SocketException; +import java.net.UnknownHostException; +import java.util.Collections; +import java.util.Enumeration; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.glassfish.api.admin.ServerEnvironment; +import org.glassfish.internal.api.Globals; +import org.glassfish.internal.api.ServerContext; + +/** + * Provides a Discovery SPI implementation for Hazelcast that uses knowledge + * of the domain topology to build out the cluster and discover members + * @since 5.0 + * @author steve + */ +public class DomainDiscoveryService implements DiscoveryService { + + private static Logger logger = Logger.getLogger(DomainDiscoveryService.class.getName()); + + @Override + public void start() { + // + } + + @Override + public Iterable discoverNodes() { + logger.fine("Starting Domain Node Discovery"); + List nodes = new LinkedList<>(); + Domain domain = Globals.getDefaultHabitat().getService(Domain.class); + ServerContext ctxt = Globals.getDefaultHabitat().getService(ServerContext.class); + ServerEnvironment env = Globals.getDefaultHabitat().getService(ServerEnvironment.class); + // add the DAS + HazelcastRuntimeConfiguration hzConfig = domain.getExtensionByType(HazelcastRuntimeConfiguration.class); + + if (!env.isDas()) { + try { + // first get hold of the DAS host + logger.fine("This is a Standalone Instance"); + String dasHost = hzConfig.getDASPublicAddress(); + if (dasHost == null || dasHost.isEmpty()) { + dasHost = hzConfig.getDASBindAddress(); + } + + if (dasHost.isEmpty()) { + // ok drag it off the properties file + logger.fine("Neither DAS Public Address or Bind Address is set in the configuration"); + InstanceDirs instance = new InstanceDirs(env.getInstanceRoot()); + Properties dasProps = new Properties(); + dasProps.load(new FileInputStream(instance.getDasPropertiesFile())); + logger.fine("Loaded the das.properties file from the agent directory"); + dasHost = dasProps.getProperty("agent.das.host"); + // then do an IP lookup + dasHost = InetAddress.getByName(dasHost).getHostAddress(); + logger.log(Level.FINE, "Loaded the das.properties file from the agent directory and found DAS IP {0}", dasHost); + } + + if (dasHost.isEmpty() || dasHost.equals("127.0.0.1") || dasHost.equals("localhost")) { + logger.fine("Looks like the DAS IP is loopback or empty let's find the actual IP of this machine as that is where the DAS is"); + addLocalNodes(nodes, Integer.valueOf(hzConfig.getDasPort())); + } else { + logger.log(Level.FINE, "DAS should be listening on {0}", dasHost); + nodes.add(new SimpleDiscoveryNode(new Address(dasHost, Integer.valueOf(hzConfig.getDasPort())))); + } + + // also add all nodes we are aware of in the domain to see if we can get in using start port + logger.fine("Also adding all known domain nodes and start ports in case the DAS is down"); + for (Node node : domain.getNodes().getNode()) { + InetAddress address = InetAddress.getByName(node.getNodeHost()); + if (!address.isLoopbackAddress()) { + logger.log(Level.FINE, "Adding Node {0}", address); + nodes.add(new SimpleDiscoveryNode(new Address(address.getHostAddress(), Integer.valueOf(hzConfig.getStartPort())))); + } + } + } catch (IOException ex) { + Logger.getLogger(DomainDiscoveryService.class.getName()).log(Level.SEVERE, null, ex); + } + + } else if (env.isMicro()) { + try { + logger.log(Level.FINE, "We are Payara Micro therefore adding DAS {0}", hzConfig.getDASPublicAddress()); + nodes.add(new SimpleDiscoveryNode(new Address(InetAddress.getByName(hzConfig.getDASPublicAddress()), Integer.valueOf(hzConfig.getDasPort())))); + } catch (UnknownHostException ex) { + Logger.getLogger(DomainDiscoveryService.class.getName()).log(Level.SEVERE, null, ex); + } + } else { + // ok this is the DAS + logger.fine("We are the DAS therefore we will add all known nodes with start port as IP addresses to connect to"); + for (Node node : domain.getNodes().getNode()) { + try { + InetAddress address = InetAddress.getByName(node.getNodeHost()); + if (!address.isLoopbackAddress()) { + logger.log(Level.FINE, "Adding Node {0}", address); + nodes.add(new SimpleDiscoveryNode(new Address(address.getHostAddress(), Integer.valueOf(hzConfig.getStartPort())))); + } else { + // we need to add our IP address so add each interface address with the start port + addLocalNodes(nodes, Integer.valueOf(hzConfig.getStartPort())); + } + } catch (IOException ex) { + Logger.getLogger(DomainDiscoveryService.class.getName()).log(Level.SEVERE, null, ex); + } + } + } + return nodes; + } + + private void addLocalNodes(List nodes, int port) throws SocketException, NumberFormatException { + Enumeration e = NetworkInterface.getNetworkInterfaces(); + while (e.hasMoreElements()) { + NetworkInterface ni = (NetworkInterface) e.nextElement(); + if (!ni.isLoopback()) { + for (InterfaceAddress ia : ni.getInterfaceAddresses()) { + if (ia.getAddress() instanceof Inet4Address && !ia.getAddress().isLoopbackAddress()) { + logger.log(Level.FINE, "Adding network interface {0}", ia.getAddress()); + nodes.add(new SimpleDiscoveryNode(new Address(ia.getAddress(), port))); + } + } + } + } + } + + @Override + public void destroy() { + // + } + + @Override + public Map discoverLocalMetadata() { + return Collections.EMPTY_MAP; + } + +} diff --git a/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/DomainDiscoveryServiceProvider.java b/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/DomainDiscoveryServiceProvider.java new file mode 100644 index 00000000000..423040db3e0 --- /dev/null +++ b/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/DomainDiscoveryServiceProvider.java @@ -0,0 +1,60 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) [2016-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.nucleus.hazelcast; + +import com.hazelcast.spi.discovery.integration.DiscoveryService; +import com.hazelcast.spi.discovery.integration.DiscoveryServiceProvider; +import com.hazelcast.spi.discovery.integration.DiscoveryServiceSettings; + +/** + * + * @author steve + */ +public class DomainDiscoveryServiceProvider implements DiscoveryServiceProvider { + + public DomainDiscoveryServiceProvider() { + } + + @Override + public DiscoveryService newDiscoveryService(DiscoveryServiceSettings dss) { + return new DomainDiscoveryService(); + } + +} diff --git a/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/HazelcastConfigSpecificConfiguration.java b/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/HazelcastConfigSpecificConfiguration.java new file mode 100644 index 00000000000..8deb90d3181 --- /dev/null +++ b/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/HazelcastConfigSpecificConfiguration.java @@ -0,0 +1,99 @@ +/* + * 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.nucleus.hazelcast; + +import org.glassfish.api.admin.config.ConfigExtension; +import org.jvnet.hk2.config.Attribute; +import org.jvnet.hk2.config.ConfigBeanProxy; +import org.jvnet.hk2.config.Configured; + +/** + * This class holds the config level configuration required by Hazelcast + * @author Steve Millidge (Payara Foundation) + */ +@Configured +public interface HazelcastConfigSpecificConfiguration extends ConfigBeanProxy, ConfigExtension{ + + + @Attribute(defaultValue = "true", dataType = Boolean.class) + String getEnabled(); + public void setEnabled(String value); + + @Attribute(defaultValue = "payara") + String getMemberName(); + public void setMemberName(String value); + + @Attribute(defaultValue = "MicroShoal") + String getMemberGroup(); + public void setMemberGroup(String value); + + @Attribute(defaultValue = "payara/Hazelcast") + String getJNDIName(); + public void setJNDIName(String value); + + @Attribute(defaultValue = "payara/CacheManager") + String getCacheManagerJNDIName(); + public void setCacheManagerJNDIName(String value); + + @Attribute(defaultValue = "payara/CachingProvider") + String getCachingProviderJNDIName(); + public void setCachingProviderJNDIName(String value); + + @Attribute(defaultValue = "4") + String getExecutorPoolSize(); + public void setExecutorPoolSize(String value); + + @Attribute(defaultValue = "20") + String getExecutorQueueCapacity(); + public void setExecutorQueueCapacity(String value); + + @Attribute(defaultValue = "4") + String getScheduledExecutorPoolSize(); + public void setScheduledExecutorPoolSize(String value); + + @Attribute(defaultValue = "20") + String getScheduledExecutorQueueCapacity(); + public void setScheduledExecutorQueueCapacity(String value); + + @Attribute(defaultValue = "false", dataType = Boolean.class) + String getLite(); + public void setLite(String value); + +} diff --git a/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/HazelcastCore.java b/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/HazelcastCore.java index 945fb84ad6f..391d8752c57 100644 --- a/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/HazelcastCore.java +++ b/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/HazelcastCore.java @@ -45,10 +45,13 @@ import com.hazelcast.config.ExecutorConfig; import com.hazelcast.config.GlobalSerializerConfig; import com.hazelcast.config.GroupConfig; +import com.hazelcast.config.MemberAddressProviderConfig; import com.hazelcast.config.MulticastConfig; +import com.hazelcast.config.NetworkConfig; import com.hazelcast.config.PartitionGroupConfig; import com.hazelcast.config.ScheduledExecutorConfig; import com.hazelcast.config.SerializationConfig; +import com.hazelcast.config.TcpIpConfig; import com.hazelcast.core.Hazelcast; import com.hazelcast.core.HazelcastInstance; import com.hazelcast.nio.serialization.Serializer; @@ -56,6 +59,7 @@ import com.sun.enterprise.util.Utility; import fish.payara.nucleus.events.HazelcastEvents; import fish.payara.nucleus.hazelcast.contextproxy.CachingProviderProxy; +import java.beans.PropertyChangeEvent; import java.io.File; import java.io.IOException; import java.net.MalformedURLException; @@ -83,6 +87,9 @@ import org.glassfish.internal.deployment.Deployment; import org.jvnet.hk2.annotations.Optional; import org.jvnet.hk2.annotations.Service; +import org.jvnet.hk2.config.ConfigListener; +import org.jvnet.hk2.config.Transactions; +import org.jvnet.hk2.config.UnprocessedChangeEvents; /** * The core class for using Hazelcast in Payara @@ -91,7 +98,7 @@ */ @Service(name = "hazelcast-core") @RunLevel(StartupRunLevel.VAL) -public class HazelcastCore implements EventListener { +public class HazelcastCore implements EventListener, ConfigListener { public final static String INSTANCE_ATTRIBUTE = "GLASSFISH-INSTANCE"; public final static String INSTANCE_GROUP_ATTRIBUTE = "GLASSFISH_INSTANCE_GROUP"; @@ -117,14 +124,21 @@ public class HazelcastCore implements EventListener { ServerEnvironment env; @Inject - @Named(ServerEnvironment.DEFAULT_INSTANCE_NAME) HazelcastRuntimeConfiguration configuration; + + @Inject + @Named(ServerEnvironment.DEFAULT_INSTANCE_NAME) + HazelcastConfigSpecificConfiguration nodeConfig; @Inject private ClassLoaderHierarchy clh; @Inject @Optional private JavaEEContextUtil ctxUtil; + + // Provides ability to register a configuration listener + @Inject + Transactions transactions; /** * Returns the version of the object that has been instantiated. @@ -138,7 +152,9 @@ public static HazelcastCore getCore() { public void postConstruct() { theCore = this; events.register(this); - enabled = Boolean.valueOf(configuration.getEnabled()); + enabled = Boolean.valueOf(nodeConfig.getEnabled()); + transactions.addListenerForType(HazelcastConfigSpecificConfiguration.class, this); + transactions.addListenerForType(HazelcastRuntimeConfiguration.class, this); } /** @@ -307,15 +323,13 @@ private Config buildConfiguration() { setPayaraSerializerConfig(serializationConfig); config.setSerializationConfig(serializationConfig); } - MulticastConfig mcConfig = config.getNetworkConfig().getJoin().getMulticastConfig(); - config.getNetworkConfig().setPortAutoIncrement(true); - mcConfig.setEnabled(true); // check Payara micro overrides - - mcConfig.setMulticastGroup(configuration.getMulticastGroup()); - mcConfig.setMulticastPort(Integer.valueOf(configuration.getMulticastPort())); - config.getNetworkConfig().setPort(Integer.valueOf(configuration.getStartPort())); + + buildNetworkConfiguration(config); + config.setLicenseKey(configuration.getLicenseKey()); - config.setLiteMember(Boolean.parseBoolean(configuration.getLite())); + config.setLiteMember(Boolean.parseBoolean(nodeConfig.getLite())); + + // set group config GroupConfig gc = config.getGroupConfig(); gc.setName(configuration.getClusterGroupName()); @@ -331,13 +345,13 @@ private Config buildConfiguration() { // build the executor config ExecutorConfig executorConfig = config.getExecutorConfig(CLUSTER_EXECUTOR_SERVICE_NAME); executorConfig.setStatisticsEnabled(true); - executorConfig.setPoolSize(Integer.valueOf(configuration.getExecutorPoolSize())); - executorConfig.setQueueCapacity(Integer.valueOf(configuration.getExecutorQueueCapacity())); + executorConfig.setPoolSize(Integer.valueOf(nodeConfig.getExecutorPoolSize())); + executorConfig.setQueueCapacity(Integer.valueOf(nodeConfig.getExecutorQueueCapacity())); ScheduledExecutorConfig scheduledExecutorConfig = config.getScheduledExecutorConfig(SCHEDULED_CLUSTER_EXECUTOR_SERVICE_NAME); scheduledExecutorConfig.setDurability(1); - scheduledExecutorConfig.setCapacity(Integer.valueOf(configuration.getScheduledExecutorQueueCapacity())); - scheduledExecutorConfig.setPoolSize(Integer.valueOf(configuration.getScheduledExecutorPoolSize())); + scheduledExecutorConfig.setCapacity(Integer.valueOf(nodeConfig.getScheduledExecutorQueueCapacity())); + scheduledExecutorConfig.setPoolSize(Integer.valueOf(nodeConfig.getScheduledExecutorPoolSize())); config.setProperty("hazelcast.jmx", "true"); } @@ -358,6 +372,50 @@ private void setPayaraSerializerConfig(SerializationConfig serConfig) { .setOverrideJavaSerialization(true)); } + private void buildNetworkConfiguration(Config config) throws NumberFormatException { + NetworkConfig nConfig = config.getNetworkConfig(); + + + MemberAddressProviderConfig memberAddressProviderConfig = nConfig.getMemberAddressProviderConfig(); + memberAddressProviderConfig.setEnabled(enabled); + memberAddressProviderConfig.setImplementation(new MemberAddressPicker(env, configuration, nodeConfig)); + + + if (!configuration.getInterface().isEmpty()) { + // add an interfaces configuration + String[] interfaceNames = configuration.getInterface().split(","); + for (String interfaceName : interfaceNames) { + nConfig.getInterfaces().addInterface(interfaceName); + } + nConfig.getInterfaces().setEnabled(true); + } + + String discoveryMode = configuration.getDiscoveryMode(); + if (discoveryMode.startsWith("tcpip")) { + TcpIpConfig tConfig = config.getNetworkConfig().getJoin().getTcpIpConfig(); + tConfig.setEnabled(true); + tConfig.addMember(configuration.getTcpipMembers()); + config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false); + } else if (discoveryMode.startsWith("multicast")) { + // build networking + MulticastConfig mcConfig = config.getNetworkConfig().getJoin().getMulticastConfig(); + config.getNetworkConfig().setPortAutoIncrement(true); + mcConfig.setEnabled(true); + mcConfig.setMulticastGroup(configuration.getMulticastGroup()); + mcConfig.setMulticastPort(Integer.valueOf(configuration.getMulticastPort())); + } else { + //build the domain discovery config + config.setProperty("hazelcast.discovery.enabled", "true"); + config.getNetworkConfig().getJoin().getDiscoveryConfig().setDiscoveryServiceProvider(new DomainDiscoveryServiceProvider()); + config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false); + } + int port = Integer.valueOf(configuration.getStartPort()); + if (env.isDas() && !env.isMicro()) { + port = Integer.valueOf(configuration.getDasPort()); + } + config.getNetworkConfig().setPort(port); + } + private void shutdownHazelcast() { if (theInstance != null) { enabled = false; @@ -380,8 +438,8 @@ private synchronized void bootstrapHazelcast() { Config config = buildConfiguration(); theInstance = Hazelcast.newHazelcastInstance(config); if (env.isMicro()) { - memberName = configuration.getMemberName(); - memberGroup = configuration.getMemberGroup(); + memberName = nodeConfig.getMemberName(); + memberGroup = nodeConfig.getMemberGroup(); if (Boolean.valueOf(configuration.getGenerateNames()) || memberName == null) { NameGenerator gen = new NameGenerator(); memberName = gen.generateName(); @@ -429,12 +487,12 @@ private void bindToJNDI() { try { InitialContext ctx; ctx = new InitialContext(); - ctx.bind(configuration.getJNDIName(), theInstance); - ctx.bind(configuration.getCachingProviderJNDIName(), hazelcastCachingProvider); - ctx.bind(configuration.getCacheManagerJNDIName(), hazelcastCachingProvider.getCacheManager()); - Logger.getLogger(HazelcastCore.class.getName()).log(Level.INFO, "Hazelcast Instance Bound to JNDI at {0}", configuration.getJNDIName()); - Logger.getLogger(HazelcastCore.class.getName()).log(Level.INFO, "JSR107 Caching Provider Bound to JNDI at {0}", configuration.getCachingProviderJNDIName()); - Logger.getLogger(HazelcastCore.class.getName()).log(Level.INFO, "JSR107 Default Cache Manager Bound to JNDI at {0}", configuration.getCacheManagerJNDIName()); + ctx.bind(nodeConfig.getJNDIName(), theInstance); + ctx.bind(nodeConfig.getCachingProviderJNDIName(), hazelcastCachingProvider); + ctx.bind(nodeConfig.getCacheManagerJNDIName(), hazelcastCachingProvider.getCacheManager()); + Logger.getLogger(HazelcastCore.class.getName()).log(Level.INFO, "Hazelcast Instance Bound to JNDI at {0}", nodeConfig.getJNDIName()); + Logger.getLogger(HazelcastCore.class.getName()).log(Level.INFO, "JSR107 Caching Provider Bound to JNDI at {0}", nodeConfig.getCachingProviderJNDIName()); + Logger.getLogger(HazelcastCore.class.getName()).log(Level.INFO, "JSR107 Default Cache Manager Bound to JNDI at {0}", nodeConfig.getCacheManagerJNDIName()); } catch (NamingException ex) { Logger.getLogger(HazelcastCore.class.getName()).log(Level.SEVERE, null, ex); } @@ -444,12 +502,12 @@ private void unbindFromJNDI() { try { InitialContext ctx; ctx = new InitialContext(); - ctx.unbind(configuration.getJNDIName()); - ctx.unbind(configuration.getCacheManagerJNDIName()); - ctx.unbind(configuration.getCachingProviderJNDIName()); - Logger.getLogger(HazelcastCore.class.getName()).log(Level.INFO, "Hazelcast Instance Unbound from JNDI at {0}", configuration.getJNDIName()); - Logger.getLogger(HazelcastCore.class.getName()).log(Level.INFO, "JSR107 Caching Provider Unbound from JNDI at {0}", configuration.getCachingProviderJNDIName()); - Logger.getLogger(HazelcastCore.class.getName()).log(Level.INFO, "JSR107 Cache Manager Unbound from JNDI at {0}", configuration.getCacheManagerJNDIName()); + ctx.unbind(nodeConfig.getJNDIName()); + ctx.unbind(nodeConfig.getCacheManagerJNDIName()); + ctx.unbind(nodeConfig.getCachingProviderJNDIName()); + Logger.getLogger(HazelcastCore.class.getName()).log(Level.INFO, "Hazelcast Instance Unbound from JNDI at {0}", nodeConfig.getJNDIName()); + Logger.getLogger(HazelcastCore.class.getName()).log(Level.INFO, "JSR107 Caching Provider Unbound from JNDI at {0}", nodeConfig.getCachingProviderJNDIName()); + Logger.getLogger(HazelcastCore.class.getName()).log(Level.INFO, "JSR107 Cache Manager Unbound from JNDI at {0}", nodeConfig.getCacheManagerJNDIName()); } catch (NamingException ex) { Logger.getLogger(HazelcastCore.class.getName()).log(Level.SEVERE, null, ex); } @@ -462,4 +520,9 @@ private void unbindFromJNDI() { public int getPort() { return theInstance.getCluster().getLocalMember().getSocketAddress().getPort(); } + + @Override + public UnprocessedChangeEvents changed(PropertyChangeEvent[] pces) { + return null; + } } diff --git a/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/HazelcastRuntimeConfiguration.java b/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/HazelcastRuntimeConfiguration.java index dfe4b892c91..1005074a331 100644 --- a/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/HazelcastRuntimeConfiguration.java +++ b/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/HazelcastRuntimeConfiguration.java @@ -39,7 +39,7 @@ */ package fish.payara.nucleus.hazelcast; -import org.glassfish.api.admin.config.ConfigExtension; +import com.sun.enterprise.config.serverbeans.DomainExtension; import org.jvnet.hk2.config.Attribute; import org.jvnet.hk2.config.ConfigBeanProxy; import org.jvnet.hk2.config.Configured; @@ -50,11 +50,7 @@ */ @Configured public interface HazelcastRuntimeConfiguration - extends ConfigBeanProxy, ConfigExtension { - - @Attribute(defaultValue = "false", dataType = Boolean.class) - String getEnabled(); - public void setEnabled(String value); + extends ConfigBeanProxy, DomainExtension { @Attribute(defaultValue = "hazelcast-config.xml") String getHazelcastConfigurationFile(); @@ -63,25 +59,47 @@ public interface HazelcastRuntimeConfiguration @Attribute(defaultValue = "5900") String getStartPort(); public void setStartPort(String value); + + @Attribute(defaultValue = "") + String getDASPublicAddress(); + public void setDASPublicAddress(String value); + + @Attribute(defaultValue = "") + String getDASBindAddress(); + public void setDASBindAddress(String value); + + @Attribute(defaultValue = "4900") + String getDasPort(); + public void setDasPort(String value); @Attribute(defaultValue = "224.2.2.3") String getMulticastGroup(); public void setMulticastGroup(String value); + + @Attribute(defaultValue = "54327") + String getMulticastPort(); + public void setMulticastPort(String value); + @Attribute(defaultValue = "127.0.0.1:5900") + String getTcpipMembers(); + public void setTcpipMembers(String value); + + // valid discovery modes + // domain + // multicast + // tcpip + @Attribute(defaultValue = "domain") + String getDiscoveryMode(); + public void setDiscoveryMode(String value); @Attribute(defaultValue = "false", dataType = Boolean.class) String getGenerateNames(); public void setGenerateNames(String value); - - @Attribute(defaultValue = "payara") - String getMemberName(); - public void setMemberName(String value); - - @Attribute(defaultValue = "MicroShoal") - String getMemberGroup(); - public void setMemberGroup(String value); - + // can be commaseparated value + @Attribute(defaultValue = "") + String getInterface(); + public void setInterface(String value); @Attribute(defaultValue = "development") String getClusterGroupName(); @@ -90,48 +108,13 @@ public interface HazelcastRuntimeConfiguration @Attribute(defaultValue = "D3v3l0pm3nt") String getClusterGroupPassword(); public void setClusterGroupPassword(String value); - - @Attribute(defaultValue = "54327") - String getMulticastPort(); - public void setMulticastPort(String value); - - @Attribute(defaultValue = "payara/Hazelcast") - String getJNDIName(); - public void setJNDIName(String value); - - @Attribute(defaultValue = "payara/CacheManager") - String getCacheManagerJNDIName(); - public void setCacheManagerJNDIName(String value); - - @Attribute(defaultValue = "payara/CachingProvider") - String getCachingProviderJNDIName(); - public void setCachingProviderJNDIName(String value); - @Attribute(defaultValue = "false", dataType = Boolean.class) + @Attribute(defaultValue = "true", dataType = Boolean.class) String getHostAwarePartitioning(); public void setHostAwarePartitioning(String value); - @Attribute(defaultValue = "4") - String getExecutorPoolSize(); - public void setExecutorPoolSize(String value); - - @Attribute(defaultValue = "20") - String getExecutorQueueCapacity(); - public void setExecutorQueueCapacity(String value); - - @Attribute(defaultValue = "4") - String getScheduledExecutorPoolSize(); - public void setScheduledExecutorPoolSize(String value); - - @Attribute(defaultValue = "20") - String getScheduledExecutorQueueCapacity(); - public void setScheduledExecutorQueueCapacity(String value); - @Attribute(defaultValue = "") String getLicenseKey(); public void setLicenseKey(String value); - - @Attribute(defaultValue = "false", dataType = Boolean.class) - String getLite(); - public void setLite(String value); + } diff --git a/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/MemberAddressPicker.java b/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/MemberAddressPicker.java new file mode 100644 index 00000000000..958305032a7 --- /dev/null +++ b/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/MemberAddressPicker.java @@ -0,0 +1,158 @@ +/* + * 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.nucleus.hazelcast; + +import com.hazelcast.spi.MemberAddressProvider; +import java.net.Inet4Address; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.NetworkInterface; +import java.net.SocketException; +import java.util.Enumeration; +import java.util.HashSet; +import java.util.logging.Level; +import org.glassfish.api.admin.ServerEnvironment; +import java.util.logging.Logger; + +/** + * This class tries to work out which interface to choose as the address of the member + * broadcast within Hazelcast + * @author Steve Millidge (Payara Foundation) + */ +public class MemberAddressPicker implements MemberAddressProvider { + + private final ServerEnvironment env; + private final HazelcastRuntimeConfiguration config; + private final HazelcastConfigSpecificConfiguration localConfig; + private InetSocketAddress bindAddress; + private InetSocketAddress publicAddress; + private static final Logger logger = Logger.getLogger(MemberAddressPicker.class.getName()); + + MemberAddressPicker(ServerEnvironment env, HazelcastRuntimeConfiguration config, HazelcastConfigSpecificConfiguration localConfig) { + this.env = env; + this.config = config; + this.localConfig = localConfig; + + // determine public address and bind address + findAppropriateInterfaces(); + } + + @Override + public InetSocketAddress getBindAddress() { + return bindAddress; + } + + @Override + public InetSocketAddress getPublicAddress() { + if (publicAddress != null) { + return publicAddress; + } else { + return bindAddress; + } + } + + /** + * This method picks an interface using the following rules + * If there is only one interface that is not loopback choose that + * If there is an interfaces element use that + * For the DAS if there is a bind address specified use that + * If none of those choose the one that isn't the default docker one + * For a standalone if the DAS specifies a Bind or Public address choose the interface on the same net or subnet + * If none of those choose the one that is not the default docker interface + * For micro if domain discovery mode choose the network on the same subnet + * If tcpip mode choose the interface which matches a subnet in the tcpip list + * If none of those choose the first interface that is not the default docker one + */ + private void findAppropriateInterfaces() { + + // + logger.fine("Finding an appropriate address for Hazelcast to use"); + int port = 0; + if (env.isDas() && !env.isMicro()) { + port = new Integer(config.getDasPort()); + if (config.getDASPublicAddress() != null && !config.getDASPublicAddress().isEmpty()) { + publicAddress = new InetSocketAddress(config.getDASPublicAddress(), port); + } + + if (config.getDASBindAddress() != null && !config.getDASBindAddress().isEmpty()) { + bindAddress = new InetSocketAddress(config.getDASBindAddress(), port); + logger.log(Level.FINE, "Bind address is specified in the configuration so we will use that {0}", bindAddress); + return; + } + } + + //add to list filtering out docker0 + HashSet possibleInterfaces = new HashSet<>(); + try { + logger.fine("No address in configuration so let's find one"); + Enumeration interfaces = NetworkInterface.getNetworkInterfaces(); + while (interfaces.hasMoreElements()) { + NetworkInterface intf = interfaces.nextElement(); + logger.log(Level.FINE, "Found Network Interface {0} Address {1}", new Object[]{intf.getName(), intf.getInetAddresses().nextElement()}); + if (!intf.isLoopback() && !intf.getName().contains("docker0")) { + logger.log(Level.FINE, "Adding interface {0} as a possible interface", intf.getName()); + possibleInterfaces.add(intf); + } else { + logger.fine("Ignoring docker or loopback interface " + intf.getName()); + } + } + } catch (SocketException socketException) { + logger.log(Level.WARNING,"There was a problem determining the network interfaces on this machine", socketException); + } + + if (possibleInterfaces.size() >= 1) { + // this is our interface + // get first address on the interface + NetworkInterface intf = possibleInterfaces.iterator().next(); + Enumeration addresses = intf.getInetAddresses(); + InetAddress chosenAddress = null; + while (addresses.hasMoreElements()) { + chosenAddress = addresses.nextElement(); + if (chosenAddress instanceof Inet4Address) { + // prefer Inet4Address + break; + } + } + logger.log(Level.FINE, "Picked address {0}", chosenAddress); + bindAddress = new InetSocketAddress(chosenAddress,port); + } + } + +} diff --git a/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/admin/ClearCache.java b/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/admin/ClearCache.java index 2412ca6de5b..10e70dc654c 100644 --- a/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/admin/ClearCache.java +++ b/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/admin/ClearCache.java @@ -1,19 +1,41 @@ /* - - DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - - Copyright (c) 2016 Payara Foundation. 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. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) [2016-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.nucleus.hazelcast.admin; @@ -71,6 +93,9 @@ public class ClearCache implements AdminCommand { @Param(name = "name", defaultValue = "") protected String cacheName; + + @Param(name = "key", optional = true) + protected String cacheKey; @Override public void execute(AdminCommandContext context) { @@ -83,9 +108,15 @@ public void execute(AdminCommandContext context) { for (DistributedObject dobject : instance.getDistributedObjects()) { if (cacheName.equals(dobject.getName())) { if (dobject instanceof IMap) { - ((IMap) dobject).clear(); + IMap cache = (IMap) dobject; + if (cacheKey != null) { + ((IMap) dobject).remove(cacheKey); + actionReport.setMessage("Cleared Cache Key " + cacheKey + "in cache " + cacheName); + } else { + ((IMap) dobject).clear(); + actionReport.setMessage("Cleared Cache " + cacheName); + } actionReport.setActionExitCode(ActionReport.ExitCode.SUCCESS); - actionReport.setMessage("Cleared Cache " + cacheName); return; } } @@ -94,7 +125,11 @@ public void execute(AdminCommandContext context) { CacheManager cm = hazelcast.getCachingProvider().getCacheManager(); Cache cache = cm.getCache(cacheName); if (cache != null) { - cache.clear(); + if (cacheKey != null) { + cache.remove(cacheKey); + } else { + cache.clear(); + } actionReport.setActionExitCode(ActionReport.ExitCode.SUCCESS); } diff --git a/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/admin/EnableHazelcastInternalOnDas.java b/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/admin/EnableHazelcastInternalOnDas.java deleted file mode 100644 index c91483437a3..00000000000 --- a/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/admin/EnableHazelcastInternalOnDas.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - - DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - - Copyright (c) 2016 Payara Foundation. 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.nucleus.hazelcast.admin; - -import com.sun.enterprise.config.serverbeans.Domain; -import com.sun.enterprise.util.SystemPropertyConstants; -import fish.payara.nucleus.hazelcast.HazelcastCore; -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; - - -/** - * Internal Admin command to enable or disable Hazelcast on demand - * Used by the set-hazelcast-configuration command to dynamically boot or shutdown hazelcast - * @author Susan Rai - */ -@Service(name = "__enable-hazelcast-internal-on-das") -@PerLookup -@CommandLock(CommandLock.LockType.NONE) -@I18n("__enable-hazelcast-internal-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-hazelcast-internal-on-das", - description = "Enables Hazelcast On DAS") -}) -public class EnableHazelcastInternalOnDas implements AdminCommand { - - @Inject - HazelcastCore hazelcast; - - @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); - } - - hazelcast.setEnabled(enabled); - actionReport.appendMessage("Hazelcast status set to " + enabled + " on " + target); - } - -} diff --git a/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/admin/EnableHazelcastInternalOnInstance.java b/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/admin/EnableHazelcastInternalOnInstance.java deleted file mode 100644 index 40ba74e7661..00000000000 --- a/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/admin/EnableHazelcastInternalOnInstance.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - - DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - - Copyright (c) 2016 Payara Foundation. 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.nucleus.hazelcast.admin; - -import com.sun.enterprise.config.serverbeans.Domain; -import com.sun.enterprise.util.SystemPropertyConstants; -import fish.payara.nucleus.hazelcast.HazelcastCore; -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; - - -/** - * Internal Admin command to enable or disable Hazelcast on demand - * Used by the set-hazelcast-configuration command to dynamically boot or shutdown hazelcast - * @author steve - */ -@Service(name = "__enable-hazelcast-internal-on-instance") -@PerLookup -@CommandLock(CommandLock.LockType.NONE) -@I18n("__enable-hazelcast-internal-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-hazelcast-internal-on-instance", - description = "Enables Hazelcast On Instance") -}) -public class EnableHazelcastInternalOnInstance implements AdminCommand { - - @Inject - HazelcastCore hazelcast; - - @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); - } - - hazelcast.setEnabled(enabled); - actionReport.appendMessage("Hazelcast status set to " + enabled + " on " + target); - } - -} diff --git a/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/admin/GetHazelcastConfiguration.java b/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/admin/GetHazelcastConfiguration.java index a0c62c76f59..994fe3763f8 100644 --- a/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/admin/GetHazelcastConfiguration.java +++ b/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/admin/GetHazelcastConfiguration.java @@ -43,6 +43,7 @@ import com.sun.enterprise.config.serverbeans.Domain; import com.sun.enterprise.util.ColumnFormatter; import com.sun.enterprise.util.SystemPropertyConstants; +import fish.payara.nucleus.hazelcast.HazelcastConfigSpecificConfiguration; import fish.payara.nucleus.hazelcast.HazelcastRuntimeConfiguration; import java.util.HashMap; import java.util.Map; @@ -58,8 +59,6 @@ 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.glassfish.internal.api.Target; import org.jvnet.hk2.annotations.Service; @@ -73,7 +72,6 @@ @CommandLock(CommandLock.LockType.NONE) @I18n("get.hazelcast.configuration") @ExecuteOn(value = {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, @@ -81,12 +79,16 @@ description = "List Hazelcast Configuration") }) public class GetHazelcastConfiguration implements AdminCommand { + @Inject + private Domain domain; + @Inject private Target targetUtil; @Param(name = "target", optional = true, defaultValue = SystemPropertyConstants.DAS_SERVER_NAME) String target; + @Override public void execute(AdminCommandContext context) { @@ -97,25 +99,45 @@ public void execute(AdminCommandContext context) { return; } - HazelcastRuntimeConfiguration runtimeConfiguration = config.getExtensionByType(HazelcastRuntimeConfiguration.class); + HazelcastConfigSpecificConfiguration nodeConfiguration = config.getExtensionByType(HazelcastConfigSpecificConfiguration.class); + + HazelcastRuntimeConfiguration runtimeConfiguration = domain.getExtensionByType(HazelcastRuntimeConfiguration.class); final ActionReport actionReport = context.getActionReport(); - String headers[] = {"Configuration File","Enabled","Start Port","MulticastGroup","MulticastPort","JNDIName","Lite Member","Cluster Name","Cluster Password", "License Key", "Host Aware Paritioning"}; + String headers[] = {"Configuration File","Enabled","Start Port","MulticastGroup","MulticastPort","JNDIName","Lite Member", + "Cluster Name","Cluster Password", "License Key", "Host Aware Paritioning","Das Public Address","DAS Bind Address","Das Port","Tcpip Members", + "Cluster Mode", "Member Name", "Member Group", "Interfaces", "Cache Manager JNDI Name", "Caching Provider JNDI Name", + "Executor Pool Size", "Executor Queue Capacity", "Scheduled Executor Pool Size", "Scheduled Executor Queue Capacity"}; ColumnFormatter columnFormatter = new ColumnFormatter(headers); - Object values[] = new Object[11]; + Object values[] = new Object[25]; values[0] = runtimeConfiguration.getHazelcastConfigurationFile(); - values[1] = runtimeConfiguration.getEnabled(); + values[1] = nodeConfiguration.getEnabled(); values[2] = runtimeConfiguration.getStartPort(); values[3] = runtimeConfiguration.getMulticastGroup(); values[4] = runtimeConfiguration.getMulticastPort(); - values[5] = runtimeConfiguration.getJNDIName(); - values[6] = runtimeConfiguration.getLite(); + values[5] = nodeConfiguration.getJNDIName(); + values[6] = nodeConfiguration.getLite(); values[7] = runtimeConfiguration.getClusterGroupName(); values[8] = runtimeConfiguration.getClusterGroupPassword(); values[9] = runtimeConfiguration.getLicenseKey(); values[10] = runtimeConfiguration.getHostAwarePartitioning(); + values[11] = runtimeConfiguration.getDASPublicAddress(); + values[12] = runtimeConfiguration.getDASBindAddress(); + values[13] = runtimeConfiguration.getDasPort(); + values[14] = runtimeConfiguration.getTcpipMembers(); + values[15] = runtimeConfiguration.getDiscoveryMode(); + values[16] = nodeConfiguration.getMemberName(); + values[17] = nodeConfiguration.getMemberGroup(); + values[18] = runtimeConfiguration.getInterface(); + values[19] = nodeConfiguration.getCacheManagerJNDIName(); + values[20] = nodeConfiguration.getCachingProviderJNDIName(); + values[21] = nodeConfiguration.getExecutorPoolSize(); + values[22] = nodeConfiguration.getExecutorQueueCapacity(); + values[23] = nodeConfiguration.getScheduledExecutorPoolSize(); + values[24] = nodeConfiguration.getScheduledExecutorQueueCapacity(); + columnFormatter.addRow(values); - Map map = new HashMap<>(10); + Map map = new HashMap<>(25); Properties extraProps = new Properties(); map.put("hazelcastConfigurationFile", values[0]); map.put("enabled", values[1]); @@ -128,6 +150,21 @@ public void execute(AdminCommandContext context) { map.put("clusterPassword", values[8]); map.put("licenseKey", values[9]); map.put("hostAwareParitioning", values[10]); + map.put("dasPublicAddress", values[11]); + map.put("dasBindAddress", values[12]); + map.put("dasPort", values[13]); + map.put("tcpipMembers", values[14]); + map.put("clusterMode", values[15]); + map.put("memberName", values[16]); + map.put("memberGroup", values[17]); + map.put("interfaces", values[18]); + map.put("cacheManagerJndiName", values[19]); + map.put("cachingProviderJndiName", values[20]); + map.put("executorPoolSize", values[21]); + map.put("executorQueueCapacity", values[22]); + map.put("scheduledExecutorPoolSize", values[23]); + map.put("scheduledExecutorQueueCapacity", values[24]); + extraProps.put("getHazelcastConfiguration",map); actionReport.setExtraProperties(extraProps); diff --git a/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/admin/ListCacheKeys.java b/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/admin/ListCacheKeys.java index 0cca703f7c2..46dedcbc6ec 100644 --- a/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/admin/ListCacheKeys.java +++ b/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/admin/ListCacheKeys.java @@ -1,19 +1,41 @@ /* - - DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - - Copyright (c) 2016 Payara Foundation. 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. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) [2016-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.nucleus.hazelcast.admin; diff --git a/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/admin/ListCaches.java b/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/admin/ListCaches.java index 3bccda58d49..97aed722f70 100644 --- a/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/admin/ListCaches.java +++ b/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/admin/ListCaches.java @@ -1,19 +1,41 @@ /* - - DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - - Copyright (c) 2016 Payara Foundation. 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. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) [2016-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.nucleus.hazelcast.admin; diff --git a/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/admin/ListHazelcastMembers.java b/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/admin/ListHazelcastMembers.java index f6922a84c6b..6e3ab9e9b9a 100644 --- a/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/admin/ListHazelcastMembers.java +++ b/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/admin/ListHazelcastMembers.java @@ -1,19 +1,40 @@ /* - - DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - - Copyright (c) 2016 Payara Foundation. 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. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) [2016-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 */ package fish.payara.nucleus.hazelcast.admin; diff --git a/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/admin/RestartHazelcast.java b/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/admin/RestartHazelcast.java index 608ed5f271c..9df4173ea0a 100644 --- a/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/admin/RestartHazelcast.java +++ b/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/admin/RestartHazelcast.java @@ -1,19 +1,41 @@ /* - - DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - - Copyright (c) 2016 Payara Foundation. 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. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) [2016-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.nucleus.hazelcast.admin; @@ -50,7 +72,7 @@ and Distribution License("CDDL") (collectively, the "License"). You @CommandLock(CommandLock.LockType.NONE) @I18n("restart-hazelcast") @ExecuteOn(RuntimeType.INSTANCE) -@TargetType(value = {CommandTarget.DAS, CommandTarget.STANDALONE_INSTANCE, CommandTarget.CLUSTER, CommandTarget.CLUSTERED_INSTANCE, CommandTarget.CONFIG}) +@TargetType(value = {CommandTarget.DAS, CommandTarget.STANDALONE_INSTANCE, CommandTarget.CLUSTER, CommandTarget.CLUSTERED_INSTANCE, CommandTarget.CONFIG, CommandTarget.DOMAIN}) @RestEndpoints({ @RestEndpoint(configBean = Domain.class, opType = RestEndpoint.OpType.GET, @@ -67,7 +89,7 @@ public class RestartHazelcast implements AdminCommand { @Param(name = "target", optional = true, defaultValue = "server") protected String target; - + @Inject private ServerEnvironment serverEnv; @@ -118,6 +140,8 @@ private boolean isThisForMe() { } } + } else if (target.equals("domain")) { + result = true; } return result; } diff --git a/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/admin/SetHazelcastConfiguration.java b/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/admin/SetHazelcastConfiguration.java index c532affcd60..42e363a0d5d 100644 --- a/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/admin/SetHazelcastConfiguration.java +++ b/nucleus/payara-modules/hazelcast-bootstrap/src/main/java/fish/payara/nucleus/hazelcast/admin/SetHazelcastConfiguration.java @@ -1,29 +1,55 @@ /* - - DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - - Copyright (c) 2014-2016 Payara Foundation. 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. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) [2016-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.nucleus.hazelcast.admin; import com.sun.enterprise.config.serverbeans.Config; import com.sun.enterprise.config.serverbeans.Domain; +import com.sun.enterprise.config.serverbeans.Server; +import com.sun.enterprise.util.SystemPropertyConstants; +import fish.payara.nucleus.hazelcast.HazelcastConfigSpecificConfiguration; import fish.payara.nucleus.hazelcast.HazelcastCore; import fish.payara.nucleus.hazelcast.HazelcastRuntimeConfiguration; import java.beans.PropertyVetoException; import java.net.InetAddress; import java.net.UnknownHostException; +import java.util.List; import java.util.Properties; import java.util.logging.Level; import java.util.logging.Logger; @@ -40,6 +66,7 @@ and Distribution License("CDDL") (collectively, the "License"). You import org.glassfish.api.admin.RestEndpoint; import org.glassfish.api.admin.RestEndpoints; import org.glassfish.api.admin.RuntimeType; +import org.glassfish.api.admin.ServerEnvironment; import org.glassfish.config.support.CommandTarget; import org.glassfish.config.support.TargetType; import org.glassfish.hk2.api.PerLookup; @@ -58,8 +85,8 @@ and Distribution License("CDDL") (collectively, the "License"). You @PerLookup @CommandLock(CommandLock.LockType.NONE) @I18n("set.hazelcast.configuration") -@ExecuteOn(value = {RuntimeType.DAS}) -@TargetType(value = {CommandTarget.DAS, CommandTarget.STANDALONE_INSTANCE, CommandTarget.CLUSTER, CommandTarget.CLUSTERED_INSTANCE, CommandTarget.CONFIG}) +@TargetType(value = {CommandTarget.CONFIG, CommandTarget.DOMAIN}) +@ExecuteOn(value = {RuntimeType.ALL}) @RestEndpoints({ @RestEndpoint(configBean = Domain.class, opType = RestEndpoint.OpType.POST, @@ -75,11 +102,14 @@ public class SetHazelcastConfiguration implements AdminCommand { protected HazelcastCore hazelcast; @Inject - protected Target targetUtil; - - @Param(name = "target", optional = true, defaultValue = "server") - protected String target; - + private Domain domain; + + @Inject + private Target targetUtil; + + @Param(name = "target", optional = true, defaultValue = SystemPropertyConstants.DAS_SERVER_NAME) + String target; + @Param(name = "enabled", optional = false) private Boolean enabled; @@ -92,38 +122,84 @@ public class SetHazelcastConfiguration implements AdminCommand { @Param(name = "startPort", optional = true) private String startPort; + @Param(name = "dasPublicAddress", optional = true) + private String dasPublicAddress; + + @Param(name = "dasBindAddress", optional = true) + private String dasBindAddress; + + @Param(name = "dasPort", optional = true) + private String dasPort; + + @Param(name = "clusterMode", optional = true) + private String clusterMode; + + @Param(name = "tcpIpMembers", optional = true) + private String tcpipMembers; + + @Param(name = "interfaces", optional = true) + private String interfaces; + @Param(name = "multicastGroup", shortName = "g", optional = true) private String multiCastGroup; @Param(name = "multicastPort", optional = true) private String multicastPort; - + @Param(name = "clusterName", optional = true) private String hzClusterName; @Param(name = "clusterPassword", optional = true) - private String hzClusterPassword; + private String hzClusterPassword; @Param(name = "jndiName", shortName = "j", optional = true) private String jndiName; - + + @Param(name = "cacheManagerJndiName", optional = true) + private String cacheManagerJndiName; + + @Param(name = "cachingProviderJndiName", optional = true) + private String cachingProviderJndiName; + + @Param(name = "executorPoolSize", optional = true) + private String executorPoolSize; + + @Param(name = "executorQueueCapacity", optional = true) + private String executorQueueCapacity; + + @Param(name = "scheduledExecutorPoolSize", optional = true) + private String scheduledExecutorPoolSize; + + @Param(name = "scheduledExecutorQueueCapacity", optional = true) + private String scheduledExecutorQueueCapacity; + @Param(name = "licenseKey", shortName = "lk", optional = true) private String licenseKey; - + @Param(name = "lite", optional = true, defaultValue = "false") private Boolean lite; @Param(name = "hostawareParitioning", optional = true, defaultValue = "false") - private Boolean hostawarePartitioning; - + private Boolean hostawarePartitioning; + + @Param(name = "memberName", optional = true) + private String memberName; + + @Param(name = "memberGroup", optional = true) + private String memberGroup; + @Inject ServiceLocator serviceLocator; + @Inject + ServerEnvironment server; + @Override public void execute(AdminCommandContext context) { final AdminCommandContext theContext = context; final ActionReport actionReport = context.getActionReport(); + Config config = targetUtil.getConfig(target); Properties extraProperties = actionReport.getExtraProperties(); if (extraProperties == null) { extraProperties = new Properties(); @@ -134,8 +210,7 @@ public void execute(AdminCommandContext context) { return; } - Config config = targetUtil.getConfig(target); - HazelcastRuntimeConfiguration hazelcastRuntimeConfiguration = config.getExtensionByType(HazelcastRuntimeConfiguration.class); + HazelcastRuntimeConfiguration hazelcastRuntimeConfiguration = domain.getExtensionByType(HazelcastRuntimeConfiguration.class); if (hazelcastRuntimeConfiguration != null) { try { ConfigSupport.apply(new SingleConfigCode() { @@ -150,37 +225,95 @@ public Object run(final HazelcastRuntimeConfiguration hazelcastRuntimeConfigurat if (multicastPort != null) { hazelcastRuntimeConfigurationProxy.setMulticastPort(multicastPort); } - if (jndiName != null) { - hazelcastRuntimeConfigurationProxy.setJNDIName(jndiName); - } - if (enabled != null) { - hazelcastRuntimeConfigurationProxy.setEnabled(enabled.toString()); - } + if (configFile != null) { hazelcastRuntimeConfigurationProxy.setHazelcastConfigurationFile(configFile); } - if (lite != null) { - hazelcastRuntimeConfigurationProxy.setLite(lite.toString()); - } - + if (hostawarePartitioning != null) { hazelcastRuntimeConfigurationProxy.setHostAwarePartitioning(hostawarePartitioning.toString()); } - + if (hzClusterName != null) { hazelcastRuntimeConfigurationProxy.setClusterGroupName(hzClusterName); } if (hzClusterPassword != null) { hazelcastRuntimeConfigurationProxy.setClusterGroupPassword(hzClusterPassword); } - if (licenseKey != null){ + if (licenseKey != null) { hazelcastRuntimeConfigurationProxy.setLicenseKey(licenseKey); } + if (dasPublicAddress != null) { + hazelcastRuntimeConfigurationProxy.setDASPublicAddress(dasPublicAddress); + } + if (dasBindAddress != null) { + hazelcastRuntimeConfigurationProxy.setDASBindAddress(dasBindAddress); + } + if (dasPort != null) { + hazelcastRuntimeConfigurationProxy.setDasPort(dasPort); + } + if (clusterMode != null) { + hazelcastRuntimeConfigurationProxy.setDiscoveryMode(clusterMode); + } + if (tcpipMembers != null) { + hazelcastRuntimeConfigurationProxy.setTcpipMembers(tcpipMembers); + } + if (interfaces != null) { + hazelcastRuntimeConfigurationProxy.setInterface(interfaces); + } actionReport.setActionExitCode(ActionReport.ExitCode.SUCCESS); return null; } }, hazelcastRuntimeConfiguration); + + // get the local config to be applied to + + if (config != null) { + HazelcastConfigSpecificConfiguration nodeConfiguration = config.getExtensionByType(HazelcastConfigSpecificConfiguration.class); + + ConfigSupport.apply(new SingleConfigCode() { + @Override + public Object run(final HazelcastConfigSpecificConfiguration hazelcastRuntimeConfigurationProxy) throws PropertyVetoException, TransactionFailure { + if (jndiName != null) { + hazelcastRuntimeConfigurationProxy.setJNDIName(jndiName); + } + if (enabled != null) { + hazelcastRuntimeConfigurationProxy.setEnabled(enabled.toString()); + } + if (lite != null) { + hazelcastRuntimeConfigurationProxy.setLite(lite.toString()); + } + if (cacheManagerJndiName != null) { + hazelcastRuntimeConfigurationProxy.setCacheManagerJNDIName(cacheManagerJndiName); + } + if (cachingProviderJndiName != null) { + hazelcastRuntimeConfigurationProxy.setCachingProviderJNDIName(cachingProviderJndiName); + } + if (executorPoolSize != null) { + hazelcastRuntimeConfigurationProxy.setExecutorPoolSize(executorPoolSize); + } + if (executorQueueCapacity != null) { + hazelcastRuntimeConfigurationProxy.setExecutorQueueCapacity(executorQueueCapacity); + } + if (scheduledExecutorPoolSize != null) { + hazelcastRuntimeConfigurationProxy.setScheduledExecutorPoolSize(scheduledExecutorPoolSize); + } + if (scheduledExecutorQueueCapacity != null) { + hazelcastRuntimeConfigurationProxy.setScheduledExecutorQueueCapacity(scheduledExecutorQueueCapacity); + } + if (memberName != null) { + hazelcastRuntimeConfigurationProxy.setMemberName(memberName); + } + if (memberGroup != null) { + hazelcastRuntimeConfigurationProxy.setMemberGroup(memberGroup); + } + actionReport.setActionExitCode(ActionReport.ExitCode.SUCCESS); + return null; + } + }, nodeConfiguration); + } + } catch (TransactionFailure ex) { logger.log(Level.WARNING, "Exception during command ", ex); actionReport.setMessage(ex.getCause().getMessage()); @@ -189,7 +322,16 @@ public Object run(final HazelcastRuntimeConfiguration hazelcastRuntimeConfigurat } if (dynamic) { - enableOnTarget(actionReport, theContext, enabled); + // this command runs on all instances so they can update their configuration. + if ("domain".equals(target)) { + hazelcast.setEnabled(enabled); + } else { + for (Server targetServer : targetUtil.getInstances(target) ) { + if (server.getInstanceName().equals(targetServer.getName())) { + hazelcast.setEnabled(enabled); + } + } + } } } @@ -197,26 +339,25 @@ public Object run(final HazelcastRuntimeConfiguration hazelcastRuntimeConfigurat } private void enableOnTarget(ActionReport actionReport, AdminCommandContext context, Boolean enabled) { + + // for all affected targets restart hazelcast. + // However do in turn to prevent a major data loss CommandRunner runner = serviceLocator.getService(CommandRunner.class); ActionReport subReport = context.getActionReport().addSubActionsReport(); CommandRunner.CommandInvocation inv; - - if (target.equals("server-config")) { - inv = runner.getCommandInvocation("__enable-hazelcast-internal-on-das", subReport, context.getSubject()); - } else { - inv = runner.getCommandInvocation("__enable-hazelcast-internal-on-instance", subReport, context.getSubject()); - } - - ParameterMap params = new ParameterMap(); - params.add("enabled", enabled.toString()); - params.add("target", target); - inv.parameters(params); - inv.execute(); - // swallow the offline warning as it is not a problem - if (subReport.hasWarnings()) { - subReport.setMessage(""); + inv = runner.getCommandInvocation("restart-hazelcast", subReport, context.getSubject()); + + List serversAffected = targetUtil.getInstances(target); + for (Server server : serversAffected) { + ParameterMap params = new ParameterMap(); + params.add("target", server.getName()); + inv.parameters(params); + inv.execute(); + // swallow the offline warning as it is not a problem + if (subReport.hasWarnings()) { + subReport.setMessage(""); + } } - } private boolean validate(ActionReport actionReport) { @@ -225,7 +366,7 @@ private boolean validate(ActionReport actionReport) { try { int port = Integer.parseInt(startPort); if (port < 0 || port > Short.MAX_VALUE * 2) { - actionReport.failure(logger, "start port must be greater than zero or less than " + Short.MAX_VALUE*2+1); + actionReport.failure(logger, "start port must be greater than zero or less than " + Short.MAX_VALUE * 2 + 1); return result; } } catch (NumberFormatException nfe) { @@ -238,7 +379,7 @@ private boolean validate(ActionReport actionReport) { try { int port = Integer.parseInt(multicastPort); if (port < 0 || port > Short.MAX_VALUE * 2) { - actionReport.failure(logger, "multicast port must be greater than zero or less than " + Short.MAX_VALUE*2+1); + actionReport.failure(logger, "multicast port must be greater than zero or less than " + Short.MAX_VALUE * 2 + 1); return result; } } catch (NumberFormatException nfe) { @@ -255,7 +396,7 @@ private boolean validate(ActionReport actionReport) { return result; } } catch (UnknownHostException ex) { - actionReport.failure(logger, multiCastGroup+" is not a valid multicast address ", ex); + actionReport.failure(logger, multiCastGroup + " is not a valid multicast address ", ex); return result; } diff --git a/nucleus/pom.xml b/nucleus/pom.xml index ab1ff694a86..65a1fa6be4e 100644 --- a/nucleus/pom.xml +++ b/nucleus/pom.xml @@ -284,10 +284,8 @@ 3.1-b41 5.0.3 1.7.0-M1 - 3.1.9 - - 3.8 - + 3.1.9 + 3.9.1 4.1.9 0.4.2 1.1.4c_7