0
在我們的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,它沒有這個問題。
這工作,謝謝!我忘了提及,該方法適用於REPLICATED模式。 – 2014-12-08 21:32:39