Hama0.7.1的同步问题

来源:互联网 发布:广东联合数据科技服务 编辑:程序博客网 时间:2024/06/06 10:36

读Hama代码发现的同步问题,

实际使用IncomingVertexMessageManager类作为消息管理类,


开始我看到AbstractMessageManager中init函数

    this.localQueueForNextIteration = getSynchronizedReceiverQueue();

还以为加了同步,后来发现真没有。。。。



这样会存在IncomingVertexMessageManager中的

  public void add(GraphJobMessage item) {
    if (item.isVertexMessage()) {                   //没有执行singeLockQueue的同步代码,存在同步问题!
      if (!storage.containsKey(item.getVertexId())) {   
        storage.putIfAbsent(item.getVertexId(), item);
      } else {
        storage.get(item.getVertexId()).addValuesBytes(item.getValuesBytes(),
            item.size());
      }
    } else {
      mapMessages.add(item);
    }
  }


不知道为何这样写呢?


真是坑爹啊!

0 0