如何加入一致性集群

时间:2016-04-01 14:30:46

标签: oracle oracle-coherence

我无法尝试访问/加入外部一致性群集。 在我当前的项目中,我有一个运行一致性集群的服务器(不是localhost),我需要加入该集群以从该缓存中获取数据。

我正在尝试这个简单的代码,但它一直在我自己的机器上创建一致性(localhost)

public static void main(String[] args){

    XmlElement opConfig = XmlHelper.loadFileOrResource("C:\\Users\\916001\\Documents\\NetBeansProjects\\testAppProject\\src\\main\\resources\\tangosol-coherence-override.xml", "ACCESS_EXTERNAL_SERVER");
    NamedCache coherenceCache = CacheFactory.getCache("osbhmlmensage");
    System.out.println(CacheFactory.getCluster());
}

我期待的是加载“opConfig”,然后使用“CacheFactory.getCache”访问集群

在tangosol-coherence-override中我把这个:

<unicast-listener>
  <socket-provider system-property="tangosol.coherence.socketprovider"/>
  <reliable-transport system-property="tangosol.coherence.transport.reliable"/>
  <well-known-addresses>
    <socket-address id="1">
      <address system-property="tangosol.coherence.wka">xxx.xxx.xxx.xxx</address>
      <port system-property="tangosol.coherence.wka.port">yyyy</port>
    </socket-address>
  </well-known-addresses>      
</unicast-listener>

在地址中我把服务器的IP和端口放在集群的端口

我对oracle coherence缓存非常新,我目前正在使用Coherence 3.7。

谢谢!

1 个答案:

答案 0 :(得分:0)

您使用XmlHelper.loadFileOrResource阅读配置,但您无法在任何地方使用它。在创建命名高速缓存之前,您应该使用此配置作为参数调用CacheFactory.setCacheFactoryBuilderConfig

public static void main(String[] args){    
    XmlElement opConfig = XmlHelper.loadFileOrResource("C:\\Users\\916001\\Documents\\NetBeansProjects\\testAppProject\\src\\main\\resources\\tangosol-coherence-override.xml", "ACCESS_EXTERNAL_SERVER");

    // here configuration is used
    CacheFactory.setCacheFactoryBuilderConfig(opConfig);
    NamedCache coherenceCache = CacheFactory.getCache("osbhmlmensage");
    System.out.println(CacheFactory.getCluster());
}
相关问题