简体   繁体   English

以编程方式为集群中的Infinispan开发Jgroup渠道

[英]Develop programmatically a Jgroup Channel for Infinispan in a Cluster

I'm working with infinispan 8.1.0 Final and Wildfly 10 in a cluster set up. 我正在集群设置中使用infinispan 8.1.0 Final和Wildfly 10。

Each server is started running 每个服务器开始运行

C:\wildfly-10\bin\standalone.bat --server-config=standalone-ha.xml -b 10.09.139.215 -u 230.0.0.4  -Djboss.node.name=MyNode

I want to use Infinispan in distributed mode in order to have a distributed cache. 我想在分布式模式下使用Infinispan以获得分布式缓存。 But for mandatory requirements I need to build a JGroups channel for dynamically reading some properties from a file. 但是对于强制性要求,我需要构建一个JGroups通道以动态读取文件中的某些属性。

This channel is necessary for me to build a cluster-group based on TYPE and NAME (for example Type1-MyCluster). 该通道对于我基于TYPE和NAME(例如Type1-MyCluster)构建集群组是必需的。 Each server who wants to join a cluster has to use the related channel. 每个要加入群集的服务器都必须使用相关的通道。

Sailing the net I have found some code like the one below: 在网上航行时,我发现了一些类似于以下代码的代码:

public class JGroupsChannelServiceActivator implements ServiceActivator  { 
    @Override 
public void activate(ServiceActivatorContext context) { 
    stackName = "udp"; 
    try { 
        channelServiceName = ChannelService.getServiceName(CHANNEL_NAME); 
        createChannel(context.getServiceTarget()); 
    } catch (IllegalStateException e) { 
        log.log(Level.INFO, "channel seems to already exist, skipping creation and binding."); 
    } 
}
void createChannel(ServiceTarget target) { 

    InjectedValue<ChannelFactory> channelFactory = new InjectedValue<>(); 
    ServiceName serviceName = ChannelFactoryService.getServiceName(stackName); 
    ChannelService channelService = new ChannelService(CHANNEL_NAME, channelFactory); 

    target.addService(channelServiceName, channelService) 
    .addDependency(serviceName, ChannelFactory.class, channelFactory).install(); 
} 

I have created the META-INF/services/....JGroupsChannelServiceActivator file. 我已经创建了META-INF / services / .... JGroupsChannelServiceActivator文件。

When I deploy my war into the server, the operation fails with this error: 当我将战争部署到服务器时,操作失败,并显示以下错误:

"{\"WFLYCTL0180: Services with missing/unavailable dependencies\" => [\"jboss.jgroups.channel.clusterWatchdog is missing [jboss.jgroups.stack.udp]\"]}"

What am I doing wrong? 我究竟做错了什么? How can I build a channel the way I need? 如何以自己的方式建立渠道? In what way I can tell to infinispan to use that channel for distributed caching? 我可以通过什么方式告诉infinispan使用该通道进行分布式缓存?

The proposal you found is implementation dependent and might cause a lot of problems during the upgrade. 您发现的建议取决于实现,并且在升级过程中可能会引起很多问题。 I wouldn't recommend it. 我不推荐它。

Let me check if I understand your problem correctly - you need to be able to create a JGroups channel manually because you use some custom properties for it. 让我检查一下我是否正确理解了您的问题-您需要能够手动创建JGroups频道,因为您为此使用了一些自定义属性。

If that is the case - you could obtain a JGroups channel as suggested here . 如果是这种情况,您可以按照此处的建议获取JGroups通道。 But then you obtain a JChannel instance which is already connected (so this might be too late for your case). 但是然后您获得一个已经连接的JChannel实例(因此对于您的情况来说可能为时已晚)。

Unfortunately since Wildfly manages the JChannel (it is required for clustering sessions, EJB etc) the only way to get full control of JChannel creating process is using Infinispan embedded (library) mode. 不幸的是,由于Wildfly管理JChannel (集群会​​话,EJB等需要它),因此要完全控制JChannel创建过程, JChannel方法是使用Infinispan嵌入式(库)模式。 This would require adding infinispan-embedded into your WAR dependencies. 这将需要在您的WAR依赖项中添加infinispan-embedded After that you can initialize it similarly to this test . 之后,您可以类似于此测试来初始化它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM