You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by sc...@apache.org on 2017/06/21 14:58:57 UTC
svn commit: r1799462 - in /tomcat/trunk: ./
java/org/apache/catalina/ha/session/ java/org/apache/catalina/ha/tcp/
java/org/apache/catalina/tribes/
test/org/apache/catalina/tribes/test/channel/ webapps/docs/
webapps/docs/config/
Author: schultz
Date: Wed Jun 21 14:58:57 2017
New Revision: 1799462
URL: http://svn.apache.org/viewvc?rev=1799462&view=rev
Log:
Allow human-readable channelSendOptions and mapSendOptions in configurations.
Patch provided by Igal Sapir.
This closes #56.
Added:
tomcat/trunk/test/org/apache/catalina/tribes/test/channel/TestChannelConfig.java (with props)
Modified:
tomcat/trunk/build.xml
tomcat/trunk/java/org/apache/catalina/ha/session/BackupManager.java
tomcat/trunk/java/org/apache/catalina/ha/session/mbeans-descriptors.xml
tomcat/trunk/java/org/apache/catalina/ha/tcp/SimpleTcpCluster.java
tomcat/trunk/java/org/apache/catalina/ha/tcp/mbeans-descriptors.xml
tomcat/trunk/java/org/apache/catalina/tribes/Channel.java
tomcat/trunk/webapps/docs/changelog.xml
tomcat/trunk/webapps/docs/cluster-howto.xml
tomcat/trunk/webapps/docs/config/cluster.xml
Modified: tomcat/trunk/build.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/build.xml?rev=1799462&r1=1799461&r2=1799462&view=diff
==============================================================================
--- tomcat/trunk/build.xml (original)
+++ tomcat/trunk/build.xml Wed Jun 21 14:58:57 2017
@@ -1423,8 +1423,8 @@
<junit printsummary="yes" fork="yes" dir="." showoutput="${test.verbose}"
errorproperty="test.result.error"
failureproperty="test.result.failure"
- haltonfailure="${test.haltonfailure}"
- threads="${test.threads}" >
+ haltonfailure="${test.haltonfailure}">
+ <!-- threads="${test.threads}" -->
<jvmarg value="${test.jvmarg.egd}"/>
<jvmarg value="-Dfile.encoding=UTF-8"/>
Modified: tomcat/trunk/java/org/apache/catalina/ha/session/BackupManager.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/ha/session/BackupManager.java?rev=1799462&r1=1799461&r2=1799462&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/ha/session/BackupManager.java (original)
+++ tomcat/trunk/java/org/apache/catalina/ha/session/BackupManager.java Wed Jun 21 14:58:57 2017
@@ -200,10 +200,26 @@ public class BackupManager extends Clust
this.mapSendOptions = mapSendOptions;
}
+ public void setMapSendOptions(String mapSendOptions) {
+
+ int value = Channel.parseSendOptions(mapSendOptions);
+ if (value > 0) {
+ this.setMapSendOptions(value);
+ }
+ }
+
public int getMapSendOptions() {
return mapSendOptions;
}
+ /**
+ * returns the SendOptions as a comma separated list of names
+ * @return a comma separated list of the option names
+ */
+ public String getMapSendOptionsName(){
+ return Channel.getSendOptionsAsString(mapSendOptions);
+ }
+
public void setRpcTimeout(long rpcTimeout) {
this.rpcTimeout = rpcTimeout;
}
Modified: tomcat/trunk/java/org/apache/catalina/ha/session/mbeans-descriptors.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/ha/session/mbeans-descriptors.xml?rev=1799462&r1=1799461&r2=1799462&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/ha/session/mbeans-descriptors.xml (original)
+++ tomcat/trunk/java/org/apache/catalina/ha/session/mbeans-descriptors.xml Wed Jun 21 14:58:57 2017
@@ -454,6 +454,11 @@
type="int"
writeable="false"/>
<attribute
+ name="mapSendOptionsName"
+ description="mapSendOptions name."
+ writeable="false"
+ type="java.lang.String"/>
+ <attribute
name="maxActive"
description="Maximum number of active sessions so far"
type="int"/>
Modified: tomcat/trunk/java/org/apache/catalina/ha/tcp/SimpleTcpCluster.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/ha/tcp/SimpleTcpCluster.java?rev=1799462&r1=1799461&r2=1799462&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/ha/tcp/SimpleTcpCluster.java (original)
+++ tomcat/trunk/java/org/apache/catalina/ha/tcp/SimpleTcpCluster.java Wed Jun 21 14:58:57 2017
@@ -339,6 +339,14 @@ public class SimpleTcpCluster extends Li
this.channelSendOptions = channelSendOptions;
}
+ public void setChannelSendOptions(String channelSendOptions) {
+
+ int value = Channel.parseSendOptions(channelSendOptions);
+ if (value > 0) {
+ this.setChannelSendOptions(value);
+ }
+ }
+
/**
* has members
*/
@@ -392,6 +400,14 @@ public class SimpleTcpCluster extends Li
}
/**
+ * returns the SendOptions as a comma separated list of names for use by JMX
+ * @return a comma separated list of the option names
+ */
+ public String getChannelSendOptionsName(){
+ return Channel.getSendOptionsAsString(channelSendOptions);
+ }
+
+ /**
* Create new Manager without add to cluster (comes with start the manager)
*
* @param name
Modified: tomcat/trunk/java/org/apache/catalina/ha/tcp/mbeans-descriptors.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/ha/tcp/mbeans-descriptors.xml?rev=1799462&r1=1799461&r2=1799462&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/ha/tcp/mbeans-descriptors.xml (original)
+++ tomcat/trunk/java/org/apache/catalina/ha/tcp/mbeans-descriptors.xml Wed Jun 21 14:58:57 2017
@@ -28,7 +28,12 @@
<attribute
name="channelSendOptions"
description="This sets channel behaviour on sent messages."
- type="int"/>
+ type="java.lang.String"/>
+ <attribute
+ name="channelSendOptionsName"
+ description="channelSendOptions name."
+ writeable="false"
+ type="java.lang.String"/>
<attribute
name="channelStartOptions"
description="This sets channel start behaviour."
Modified: tomcat/trunk/java/org/apache/catalina/tribes/Channel.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/Channel.java?rev=1799462&r1=1799461&r2=1799462&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/Channel.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/Channel.java Wed Jun 21 14:58:57 2017
@@ -16,7 +16,11 @@
*/
package org.apache.catalina.tribes;
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
+
import java.io.Serializable;
+import java.util.StringJoiner;
/**
* Channel interface<br>
@@ -369,4 +373,88 @@ public interface Channel {
*/
public void setName(String name);
+ /**
+ * Translates the name of an option to its integer value. Valid option names are "asynchronous" (alias "async"),
+ * "byte_message" (alias "byte"), "multicast", "secure", "synchronized_ack" (alias "sync"), "udp", "use_ack"
+ * @param opt The name of the option
+ * @return the int value of the passed option name
+ */
+ public static int getSendOptionValue(String opt){
+
+ switch (opt){
+
+ case "asynchronous":
+ case "async":
+ return SEND_OPTIONS_ASYNCHRONOUS;
+
+ case "byte_message":
+ case "byte":
+ return SEND_OPTIONS_BYTE_MESSAGE;
+
+ case "multicast":
+ return SEND_OPTIONS_MULTICAST;
+
+ case "secure":
+ return SEND_OPTIONS_SECURE;
+
+ case "synchronized_ack":
+ case "sync":
+ return SEND_OPTIONS_SYNCHRONIZED_ACK;
+
+ case "udp":
+ return SEND_OPTIONS_UDP;
+
+ case "use_ack":
+ return SEND_OPTIONS_USE_ACK;
+ }
+
+ throw new IllegalArgumentException(String.format("[%s] is not a valid option", opt));
+ }
+
+ /**
+ * Translates a comma separated list of option names to their bitwise-ORd value
+ * @param input A comma separated list of options, e.g. "async, multicast"
+ * @return a bitwise ORd value of the passed option names
+ */
+ public static int parseSendOptions(String input){
+
+ try {
+ return Integer.parseInt(input);
+ } catch (NumberFormatException nfe){
+ final Log log = LogFactory.getLog(Channel.class);
+ log.trace(String.format("Failed to parse [%s] as integer, channelSendOptions possibly set by name(s)", input));
+ }
+
+ String[] options = input.split("\\s*,\\s*");
+
+ int result = 0;
+ for (String opt : options) {
+ result |= getSendOptionValue(opt);
+ }
+
+ return result;
+ }
+
+ /**
+ * Translates an integer value of SendOptions to its human-friendly comma separated value list for use in JMX and such.
+ * @param input the int value of SendOptions
+ * @return the human-friendly string representation in a reverse order (i.e. the last option will be shown first)
+ */
+ public static String getSendOptionsAsString(int input){
+
+ // allOptionNames must be in order of the bits of the available options
+ final String[] allOptionNames = new String[]{ "byte", "use_ack", "sync", "async", "secure", "udp", "multicast" };
+
+ StringJoiner names = new StringJoiner(", ");
+ for (int bit=allOptionNames.length - 1; bit >= 0; bit--){
+
+ // if the bit is set then add the name to the result
+ if (((1 << bit) & input) > 0){
+ names.add(allOptionNames[bit]);
+ }
+ }
+
+ return names.toString();
+ }
+
}
Added: tomcat/trunk/test/org/apache/catalina/tribes/test/channel/TestChannelConfig.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/tribes/test/channel/TestChannelConfig.java?rev=1799462&view=auto
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/tribes/test/channel/TestChannelConfig.java (added)
+++ tomcat/trunk/test/org/apache/catalina/tribes/test/channel/TestChannelConfig.java Wed Jun 21 14:58:57 2017
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.catalina.tribes.test.channel;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.catalina.ha.session.BackupManager;
+import org.apache.catalina.tribes.Channel;
+import org.apache.catalina.ha.tcp.SimpleTcpCluster;
+import org.junit.Test;
+
+
+public class TestChannelConfig {
+
+ @Test
+ public void testIntInput() {
+
+ SimpleTcpCluster cluster = new SimpleTcpCluster();
+ cluster.setChannelSendOptions(Channel.SEND_OPTIONS_ASYNCHRONOUS | Channel.SEND_OPTIONS_MULTICAST);
+ assertEquals(Channel.SEND_OPTIONS_ASYNCHRONOUS | Channel.SEND_OPTIONS_MULTICAST, cluster.getChannelSendOptions());
+ }
+
+ @Test
+ public void testStringInputSimple() {
+
+ SimpleTcpCluster cluster = new SimpleTcpCluster();
+ cluster.setChannelSendOptions("multicast");
+ assertEquals(Channel.SEND_OPTIONS_MULTICAST, cluster.getChannelSendOptions());
+ }
+
+ @Test
+ public void testStringInputCompound() {
+
+ SimpleTcpCluster cluster = new SimpleTcpCluster();
+ cluster.setChannelSendOptions("async, multicast");
+ assertEquals(Channel.SEND_OPTIONS_ASYNCHRONOUS | Channel.SEND_OPTIONS_MULTICAST, cluster.getChannelSendOptions());
+ }
+
+ @Test
+ public void testStringRepresentationOfIntValue() {
+
+ String options = "multicast, async";
+ SimpleTcpCluster cluster = new SimpleTcpCluster();
+ cluster.setChannelSendOptions(options);
+ assertEquals(options, cluster.getChannelSendOptionsName());
+ }
+
+ @Test
+ public void testStringInputForMapSendOptions() {
+
+ BackupManager manager = new BackupManager();
+ manager.setMapSendOptions("async, multicast");
+ assertEquals(Channel.SEND_OPTIONS_ASYNCHRONOUS | Channel.SEND_OPTIONS_MULTICAST, manager.getMapSendOptions());
+ }
+
+}
\ No newline at end of file
Propchange: tomcat/trunk/test/org/apache/catalina/tribes/test/channel/TestChannelConfig.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1799462&r1=1799461&r2=1799462&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Wed Jun 21 14:58:57 2017
@@ -230,6 +230,14 @@
</fix>
</changelog>
</subsection>
+ <subsection name="Tribes">
+ <changelog>
+ <add>
+ <bug>61127</bug>Allow human-readable names for channelSendOptions and
+ mapSendOptions. Patch provided by Igal Sapir. (schultz)
+ </add>
+ </changelog>
+ </subsection>
<subsection name="Other">
<changelog>
<add>
Modified: tomcat/trunk/webapps/docs/cluster-howto.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/cluster-howto.xml?rev=1799462&r1=1799461&r2=1799462&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/cluster-howto.xml (original)
+++ tomcat/trunk/webapps/docs/cluster-howto.xml Wed Jun 21 14:58:57 2017
@@ -210,10 +210,22 @@ should be completed:</p>
sent over the wire and reinstantiated on all the other cluster nodes.
Synchronous vs. asynchronous is configured using the <code>channelSendOptions</code>
flag and is an integer value. The default value for the <code>SimpleTcpCluster/DeltaManager</code> combo is
- 8, which is asynchronous. You can read more on the <a href="tribes/introduction.html">send flag(overview)</a> or the
- <doc path="/api/org/apache/catalina/tribes/Channel.html">send flag(javadoc)</doc>.
- During async replication, the request is returned before the data has been replicated. async replication yields shorter
- request times, and synchronous replication guarantees the session to be replicated before the request returns.
+ 8, which is asynchronous.
+</p>
+<p>
+ For convenience, <code>channelSendOptions</code> can be set by name(s) rather than integer,
+ which are then translated to their integer value upon startup. The valid option names are:
+ "asynchronous" (alias "async"), "byte_message" (alias "byte"), "multicast", "secure",
+ "synchronized_ack" (alias "sync"), "udp", "use_ack". Use comma to separate multiple names,
+ e.g. pass "async, multicast" for the options
+ <code>SEND_OPTIONS_ASYNCHRONOUS | SEND_OPTIONS_MULTICAST</code>.
+</p>
+<p>
+ You can read more on the <a href="tribes/introduction.html">send flag(overview)</a> or the
+ <doc path="/api/org/apache/catalina/tribes/Channel.html">send flag(javadoc)</doc>.
+ During async replication, the request is returned before the data has been replicated. async
+ replication yields shorter request times, and synchronous replication guarantees the session
+ to be replicated before the request returns.
</p>
</section>
Modified: tomcat/trunk/webapps/docs/config/cluster.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/config/cluster.xml?rev=1799462&r1=1799461&r2=1799462&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/config/cluster.xml (original)
+++ tomcat/trunk/webapps/docs/config/cluster.xml Wed Jun 21 14:58:57 2017
@@ -142,7 +142,15 @@ Tomcat cluster. These include:</p>
<br/>
Note that if you use ASYNC messaging it is possible for update messages
for a session to be processed by the receiving nodes in a different order
- to the order in which they were sent.</p>
+ to the order in which they were sent.
+ </p>
+ <p>
+ You may also set these options as a comma separated string, e.g. "async, multicast", which
+ will be translated into <code>Channel.SEND_OPTIONS_ASYNCHRONOUS | Channel.SEND_OPTIONS_MULTICAST</code>
+ <br/>
+ The valid option names are "asynchronous" (alias "async"), "byte_message" (alias "byte")
+ , "multicast", "secure", "synchronized_ack" (alias "sync"), "udp", "use_ack"
+ </p>
</attribute>
<attribute name="channelStartOptions" required="false">
<p>Sets the start and stop flags for the <Channel> object used by the cluster.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
Re: svn commit: r1799462 - in /tomcat/trunk: ./
java/org/apache/catalina/ha/session/ java/org/apache/catalina/ha/tcp/
java/org/apache/catalina/tribes/
test/org/apache/catalina/tribes/test/channel/ webapps/docs/
webapps/docs/config/
Posted by Christopher Schultz <ch...@christopherschultz.net>.
Mark,
Sorry... I'll get this sorted today.
Thanks,
-chris
On 6/21/17 5:26 PM, Mark Thomas wrote:
> On 21/06/17 15:58, schultz@apache.org wrote:
>> Author: schultz
>> Date: Wed Jun 21 14:58:57 2017
>> New Revision: 1799462
>>
>> URL: http://svn.apache.org/viewvc?rev=1799462&view=rev
>> Log:
>> Allow human-readable channelSendOptions and mapSendOptions in configurations.
>> Patch provided by Igal Sapir.
>>
>> This closes #56.
>
> <snip/>
>
>
>> Modified: tomcat/trunk/webapps/docs/changelog.xml
>> URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1799462&r1=1799461&r2=1799462&view=diff
>> ==============================================================================
>> --- tomcat/trunk/webapps/docs/changelog.xml (original)
>> +++ tomcat/trunk/webapps/docs/changelog.xml Wed Jun 21 14:58:57 2017
>> @@ -230,6 +230,14 @@
>> </fix>
>> </changelog>
>> </subsection>
>> + <subsection name="Tribes">
>> + <changelog>
>> + <add>
>> + <bug>61127</bug>Allow human-readable names for channelSendOptions and
>> + mapSendOptions. Patch provided by Igal Sapir. (schultz)
>> + </add>
>> + </changelog>
>> + </subsection>
>> <subsection name="Other">
>> <changelog>
>> <add>
>
> Wrong version. 9.0.0.M22 had already been tagged.
>
> Mark
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
Re: svn commit: r1799462 - in /tomcat/trunk: ./
java/org/apache/catalina/ha/session/ java/org/apache/catalina/ha/tcp/
java/org/apache/catalina/tribes/
test/org/apache/catalina/tribes/test/channel/ webapps/docs/
webapps/docs/config/
Posted by Mark Thomas <ma...@apache.org>.
On 21/06/17 15:58, schultz@apache.org wrote:
> Author: schultz
> Date: Wed Jun 21 14:58:57 2017
> New Revision: 1799462
>
> URL: http://svn.apache.org/viewvc?rev=1799462&view=rev
> Log:
> Allow human-readable channelSendOptions and mapSendOptions in configurations.
> Patch provided by Igal Sapir.
>
> This closes #56.
<snip/>
> Modified: tomcat/trunk/webapps/docs/changelog.xml
> URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1799462&r1=1799461&r2=1799462&view=diff
> ==============================================================================
> --- tomcat/trunk/webapps/docs/changelog.xml (original)
> +++ tomcat/trunk/webapps/docs/changelog.xml Wed Jun 21 14:58:57 2017
> @@ -230,6 +230,14 @@
> </fix>
> </changelog>
> </subsection>
> + <subsection name="Tribes">
> + <changelog>
> + <add>
> + <bug>61127</bug>Allow human-readable names for channelSendOptions and
> + mapSendOptions. Patch provided by Igal Sapir. (schultz)
> + </add>
> + </changelog>
> + </subsection>
> <subsection name="Other">
> <changelog>
> <add>
Wrong version. 9.0.0.M22 had already been tagged.
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org