Ignite 简单的IAffinityFunction实现会导致崩溃

Ignite 简单的IAffinityFunction实现会导致崩溃,ignite,Ignite,我正在使用Ignite.NET2.7.6。我完成了IAffinityFunction接口的一个非常简单的实现: sealed class AffinityFunction : IAffinityFunction { public int Partitions { get { return 1; } } public int GetPartition(object key) { return 0; } public void RemoveNode(Guid nodeId) {}

我正在使用Ignite.NET2.7.6。我完成了IAffinityFunction接口的一个非常简单的实现:

sealed class AffinityFunction : IAffinityFunction
{
  public int Partitions { get { return 1; } }
  public int GetPartition(object key) { return 0; }
  public void RemoveNode(Guid nodeId) {}

  public IEnumerable<IEnumerable<IClusterNode> > AssignPartitions(AffinityFunctionContext context)
  {
    List<IClusterNode> servers = new List<IClusterNode>();
    foreach(IClusterNode node in context.CurrentTopologySnapshot)
    {
      if(!node.IsClient)
      {
        servers.Add(node);
      }
    }

    m_Partitions = new List<IEnumerable<IClusterNode> >();
    if(servers.Count != 0)
    {
      m_Partitions.Add(servers);
    }

    return m_Partitions;
  }

  private List<IEnumerable<IClusterNode> > m_Partitions;
}
据我所知,此AffinityFunction必须收集一个分区中的所有服务器,并将此分区作为要搜索的分区返回。

public int Partitions{get{return(m_Partitions!=null?m_Partitions.Count:0);}
  • 0
    不是
    分区
    属性的有效值(应为正值)
  • 分区
    属性应返回一个不基于任何条件的常量值。此属性在每个节点的每个缓存中计算一次

  • 错误消息和文档应该会更好,我将提交一张罚单。

    非常感谢。我在上面的代码中做了更改,但还是出现了相同的错误occurs@Paltr我可以用0个分区重现这个问题,但不能用1。我启动两个节点(客户端和服务器),将一个值放入缓存,没有问题。你能附上一个完整的复制机吗?我删除了服务器和客户端的工作文件夹,这个崩溃消失了!谢谢!
    java.lang.IndexOutOfBoundsException: index 0
      at java.util.concurrent.atomic.AtomicReferenceArray.checkedByteOffset(Unknown Source)
      at java.util.concurrent.atomic.AtomicReferenceArray.get(Unknown Source)
      at org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopologyImpl.localPartition0(GridDhtPartitionTopologyImpl.java:911)
      at org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopologyImpl.localPartition(GridDhtPartitionTopologyImpl.java:825)