<div dir="ltr"><div><div><div><div><div>As many of you are may or may not be aware the ClusterExecutor interface and implementation were introduced into Infinispan 8.2 [1].  This class is a new API that can be used to submit commands to other nodes in a way similar to DistributedExecutor does while also not being tied to a cache.<br><br></div>The first implementation of ClusterExecutor did not include a couple features that DistributedExecutor has. For this post I will concentrate on failover and execution policies. My plan is to introduce some API to Infinispan 9 to allow for ClusterExecutor to also offer these capabilities.<br><br></div>The first change is that I wanted to add additional options to Execution Policies.  The execution policy is used to limit sending messages to nodes based on their topology (site, rack &amp; machine id).  The old execution policy allowed for SAME_MACHINE, SAME_RACK, SAME_SITE and ALL.  I plan on adding the opposite of the SAME and also supporting DIFFERENT_MACHINE, DIFFERENT_RACK and DIFFERENT_SITE in case if the user wants to ensure that data is processed elsewhere. Unless you think this is unneeded?<br><br></div>The API changes I am thinking of are as below (included in email to allow for responses inline).  Note that existing methods would be unchanged and thus submit and execute methods would be used to send commands still. One big difference is that I have not allowed for the user to control the failover node or the target node when doing a single submission with multiple available targets.  In my mind if a user wants this they should do it themselves manually, but this is open for discussion as well.<br><br><pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:&quot;dejavu sans mono&quot;;font-size:9pt"><span style="color:rgb(128,128,128);font-style:italic">/**<br></span><span style="color:rgb(128,128,128);font-style:italic"> * When a command is submitted it will only be submitted to one node of the available nodes, there is no strict<br></span><span style="color:rgb(128,128,128);font-style:italic"> * requirements as to which node is chosen and is implementation specific. Fail over can be used with configuration,<br></span><span style="color:rgb(128,128,128);font-style:italic"> * please see {</span><span style="color:rgb(128,128,128);font-weight:bold;font-style:italic">@link </span><span style="color:rgb(128,128,128);font-style:italic">ClusterExecutor#failOverRetries(int)} for more information.<br></span><span style="color:rgb(128,128,128);font-style:italic"> * </span><span style="color:rgb(128,128,128);font-weight:bold;font-style:italic">@return </span><span style="color:rgb(128,128,128);font-style:italic">this executor again with commands submitted to a single node<br></span><span style="color:rgb(128,128,128);font-style:italic"> */<br></span>ClusterExecutor singleNodeSubmission();<br><br><span style="color:rgb(128,128,128);font-style:italic">/**<br></span><span style="color:rgb(128,128,128);font-style:italic"> * When a command is submitted it will submit this command to all of the available nodes.  Fail over is not supported<br></span><span style="color:rgb(128,128,128);font-style:italic"> * with this configuration. This is the default submission method.<br></span><span style="color:rgb(128,128,128);font-style:italic"> * </span><span style="color:rgb(128,128,128);font-weight:bold;font-style:italic">@return </span><span style="color:rgb(128,128,128);font-style:italic">this executor again with commands submitted to all nodes<br></span><span style="color:rgb(128,128,128);font-style:italic"> */<br></span>ClusterExecutor allNodeSubmission();<br><br><span style="color:rgb(128,128,128);font-style:italic">/**<br></span><span style="color:rgb(128,128,128);font-style:italic"> * Enables fail over to occur when using {</span><span style="color:rgb(128,128,128);font-weight:bold;font-style:italic">@link </span><span style="color:rgb(128,128,128);font-style:italic">ClusterExecutor#singleNodeSubmission()}. If the executor<br></span><span style="color:rgb(128,128,128);font-style:italic"> * is not currently in the single node submission mode, this method will throw {</span><span style="color:rgb(128,128,128);font-weight:bold;font-style:italic">@link </span><span style="color:rgb(128,128,128);font-style:italic">IllegalStateException}.<br></span><span style="color:rgb(128,128,128);font-style:italic"> * When fail over count is applied, a submitted command will be retried up to that many times on the available<br></span><span style="color:rgb(128,128,128);font-style:italic"> * command up to desired amount of times until an exception is not met. The one exception that is not retried is a<br></span><span style="color:rgb(128,128,128);font-style:italic"> * TimeoutException since this could be related to {</span><span style="color:rgb(128,128,128);font-weight:bold;font-style:italic">@link </span><span style="color:rgb(128,128,128);font-style:italic">ClusterExecutor#timeout(long, TimeUnit)}. Each time the<br></span><span style="color:rgb(128,128,128);font-style:italic"> * fail over occurs a random node in the available nodes will be used (trying not to reuse the same node).</span><span style="color:rgb(128,128,128);font-style:italic"><br></span><span style="color:rgb(128,128,128);font-style:italic"> * </span><span style="color:rgb(128,128,128);font-weight:bold;font-style:italic">@param </span><span style="color:rgb(61,61,61);font-weight:bold;font-style:italic">failOverCount </span><span style="color:rgb(128,128,128);font-style:italic">how many times this executor will attempt a failover<br></span><span style="color:rgb(128,128,128);font-style:italic"> * </span><span style="color:rgb(128,128,128);font-weight:bold;font-style:italic">@return </span><span style="color:rgb(128,128,128);font-style:italic">this executor again with fail over retries applied<br></span><span style="color:rgb(128,128,128);font-style:italic"> * </span><span style="color:rgb(128,128,128);font-weight:bold;font-style:italic">@throws </span><span style="color:rgb(128,128,128);font-style:italic">IllegalStateException if this cluster executor is not currently configured for single node submission<br></span><span style="color:rgb(128,128,128);font-style:italic"> */<br></span>ClusterExecutor failOverRetries(<span style="color:rgb(0,0,128);font-weight:bold">int </span>failOverCount) <span style="color:rgb(0,0,128);font-weight:bold">throws </span>IllegalStateException;<br><br><span style="color:rgb(128,128,128);font-style:italic">/**<br></span><span style="color:rgb(128,128,128);font-style:italic"> * Allows for filtering of address nodes by only allowing addresses that match the given execution policy to be used.<br></span><span style="color:rgb(128,128,128);font-style:italic"> * Note this method overrides any previous filtering that was done (ie. calling<br></span><span style="color:rgb(128,128,128);font-style:italic"> * {</span><span style="color:rgb(128,128,128);font-weight:bold;font-style:italic">@link </span><span style="color:rgb(128,128,128);font-style:italic">ClusterExecutor#filterTargets(Collection)}).<br></span><span style="color:rgb(128,128,128);font-style:italic"> * </span><span style="color:rgb(128,128,128);font-weight:bold;font-style:italic">@param </span><span style="color:rgb(61,61,61);font-weight:bold;font-style:italic">policy </span><span style="color:rgb(128,128,128);font-style:italic">the policy to determine which nodes can be used<br></span><span style="color:rgb(128,128,128);font-style:italic"> * </span><span style="color:rgb(128,128,128);font-weight:bold;font-style:italic">@return </span><span style="color:rgb(128,128,128);font-style:italic">this executor again with the execution policy applied to determine which nodes are contacted<br></span><span style="color:rgb(128,128,128);font-style:italic"> */<br></span>ClusterExecutor filterTargets(ClusterExecutionPolicy policy);<br><br><span style="color:rgb(128,128,128);font-style:italic">/**<br></span><span style="color:rgb(128,128,128);font-style:italic"> * Allows for filtering of address nodes dynamically per invocation.  The predicate is applied to each member that<br></span><span style="color:rgb(128,128,128);font-style:italic"> * is part of the execution policy. Note that this method overrides any previous<br></span><span style="color:rgb(128,128,128);font-style:italic"> * filtering that was done (ie. calling {</span><span style="color:rgb(128,128,128);font-weight:bold;font-style:italic">@link </span><span style="color:rgb(128,128,128);font-style:italic">ClusterExecutor#filterTargets(Collection)}).<br></span><span style="color:rgb(128,128,128);font-style:italic"> * </span><span style="color:rgb(128,128,128);font-weight:bold;font-style:italic">@param </span><span style="color:rgb(61,61,61);font-weight:bold;font-style:italic">policy </span><span style="color:rgb(128,128,128);font-style:italic">the execution policy applied before predicate to allow only nodes in that group<br></span><span style="color:rgb(128,128,128);font-style:italic"> * </span><span style="color:rgb(128,128,128);font-weight:bold;font-style:italic">@param </span><span style="color:rgb(61,61,61);font-weight:bold;font-style:italic">predicate </span><span style="color:rgb(128,128,128);font-style:italic">the dynamic predicate applied each time an invocation is done<br></span><span style="color:rgb(128,128,128);font-style:italic"> * </span><span style="color:rgb(128,128,128);font-weight:bold;font-style:italic">@return<br></span><span style="color:rgb(128,128,128);font-weight:bold;font-style:italic"> </span><span style="color:rgb(128,128,128);font-style:italic">*/<br></span>ClusterExecutor filterTargets(ClusterExecutionPolicy policy, Predicate&lt;? <span style="color:rgb(0,0,128);font-weight:bold">super </span>Address&gt; predicate);</pre><br></div>Thanks for any input,<br><br></div> - Will<br><div><div><br>[1] <a href="https://github.com/infinispan/infinispan/blob/master/core/src/main/java/org/infinispan/manager/ClusterExecutor.java">https://github.com/infinispan/infinispan/blob/master/core/src/main/java/org/infinispan/manager/ClusterExecutor.java</a><br><br><br><div><div><br><br></div></div></div></div></div>