Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Algorithm 为WSO2 ESB编写负载平衡算法_Algorithm_Wso2_Load Balancing_Wso2esb - Fatal编程技术网

Algorithm 为WSO2 ESB编写负载平衡算法

Algorithm 为WSO2 ESB编写负载平衡算法,algorithm,wso2,load-balancing,wso2esb,Algorithm,Wso2,Load Balancing,Wso2esb,我将面对定制负载平衡端点的负载平衡算法实现 在此文档页面上: 我读到: 算法-组的默认“循环”或自定义加载算法。请参阅本文中有关此算法的更多信息 其中“文章”是指向此页面的链接点: 但是引用的文章并不完整,也没有讲述任何关于算法开发的内容。有谁能给我一个有效的例子吗?正如文档中指定的那样,该算法应该是org.apache.synapse.endpoints.algorithms.LoadbalanceAlgorithm 您需要编写一个实现接口的类。您可以参考包中现有的实现RoundRobin

我将面对定制负载平衡端点的负载平衡算法实现

在此文档页面上:

我读到:

算法-组的默认“循环”或自定义加载算法。请参阅本文中有关此算法的更多信息

其中“文章”是指向此页面的链接点:


但是引用的文章并不完整,也没有讲述任何关于算法开发的内容。有谁能给我一个有效的例子吗?

正如文档中指定的那样,该算法应该是
org.apache.synapse.endpoints.algorithms.LoadbalanceAlgorithm

您需要编写一个实现接口的类。您可以参考包中现有的实现
RoundRobin
weighteddrlcalgorithm
WeightedRoundRobin

然后用类创建一个jar文件,并将其添加到
/repository/components/lib
文件夹中,然后重新启动服务器


现在,在添加负载平衡端点时,为
算法选择
其他…
,并提供自定义算法的完整类名。例如:
org.apache.synapse.endpoints.algorithms.WeightedRoundRobin

您可以使用下面的示例发送多个请求,以使用RoundRobin算法在不同的端点之间共享

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="TestLoadBalance"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <endpoint>
         <loadbalance algorithm="org.apache.synapse.endpoints.algorithms.RoundRobin">
            <endpoint>
               <address uri="http://localhost:9000/services/SimpleStockQuoteService/"/>
            </endpoint>
            <endpoint>
               <address uri="http://localhost:9001/services/SimpleStockQuoteService/"/>
            </endpoint>
            <endpoint>
               <address uri="http://localhost:9002/services/SimpleStockQuoteService/"/>
            </endpoint>
         </loadbalance>
      </endpoint>
   </target>
   <description/>
</proxy>

查看 LoadBalanceAlgortim不可能简单地给它一个端点的动态列表。 关于LoadBalanceMambershipHandler及其实现(Axis2和服务)…它使用如下对象:

org.apache.axis2.clustering.management.GroupManagementAgent
and
org.apache.axis2.clustering.ClusteringAgent
因此,您必须使用ESB的/repository/conf/axis2文件夹中的axi2.xml配置集群中的节点。
使用ESB注册表将loadbalance enpoint保存在中,然后通过代码对其进行访问,以便为其添加一个新的地址端点列表。

谢谢,我已经尝试过了,它可以正常工作。但是,我希望能够编写自己的负载平衡算法,并使用动态负载平衡端点,拥有自己的loadbalancehandlermembership。我知道这是一个接口,有两种实现:Axis和Service one。但是有没有教程一步一步地解释它们是如何实现的呢?请看加权算法的实现,这样您就可以遵循相同的步骤了。)