primaryValues表现不如预期

问题描述:

在我们的poc中,我们在PARTIONED MODE中有一个缓存,有2个备份,并且我们启动了3个节点。 100个条目被加载到缓存中,我们在下面的步骤中进行检索。primaryValues表现不如预期

public void perform() throws GridException { 
     final GridCache<Long, Entity> cache= g.cache("cache"); 
     GridProjection proj= g.forCache("cache"); 

     Collection< Collection<Entity>> list= proj .compute().broadcast(
       new GridCallable< Collection<Entity>>() { 
      @Override public Collection<Entity> call() throws Exception { 

       Collection<Entity> values= cache.primaryValues(); 

       System.out.println("List size on each Node: "+ values.size()); 
        // console from each node shows 28,38,34 respectively, which is correct 

       return values; 
      } 
     }).get(); 

     for (Collection<Entity> e: list){ 
      System.out.println("list size when arrives on main Node :"+ e.size()); 
//console shows 28 for three times, which is not correct 
     } 
} 

我假定primaryValues()是将primaryEntrySet()返回的每个元素的值取出并放入一个Collection中。我也尝试使用primaryEntrySet,它没有这个问题。

GridGain将缓存集合序列化的方式仅供参考,可能并不直观。我已经提交给美国阿帕奇的Ignite项目JIRA问题(这是GridGain开源版本的下一个版本):https://issues.apache.org/jira/browse/IGNITE-38

在此同时,请尝试以下方法从GridCallable,这应该工作:

return new ArrayList(cache.primaryValues()); 
+0

这工作,谢谢!我忘了提及,该方法适用于REPLICATED模式。 – 2014-12-08 21:32:39