hama程序出现Messages must never be behind the vertex in ID问题解决

在运行hama程序时,在partition完成后,经常出现java.lang.IllegalArgumentException: Messages must never be behind the vertex in ID! Current Message ID: 100003 vs. 100004。异常

看了一下hama源码,如下:

/**

   * Iterating utility that ensures following things: <br/>

   * - if vertex is active, but the given message does not match the vertexID,

   * return null. <br/>

   * - if vertex is inactive, but received a message that matches the ID, build

   * an iterator that can be iterated until the next vertex has been reached

   * (not buffer in memory) and set the vertex active <br/>

   * - if vertex is active, and the given message does match the vertexID,

   * return an iterator that can be iterated until the next vertex has been

   * reached. <br/>

   * - if vertex is inactive, and received no message, return null.

   */

  @SuppressWarnings("unchecked")

  private VertexMessageIterable<V, M> iterate(GraphJobMessage currentMessage,

      V firstMessageId, Vertex<V, E, M> vertex,

      BSPPeer<Writable, Writable, Writable, Writable, GraphJobMessage> peer) {

    int comparision = firstMessageId.compareTo(vertex.getVertexID());

    if (conf.getBoolean("hama.check.missing.vertex", true)) {

      if (comparision < 0) {

        throw new IllegalArgumentException(

          "Messages must never be behind the vertex in ID! Current Message ID: "

              + firstMessageId + " vs. " + vertex.getVertexID());

      }

    } else {

      while (comparision < 0) {

        VertexMessageIterable<V, M> messageIterable = new VertexMessageIterable<V, M>(currentMessage,

          firstMessageId, peer);

        currentMessage = messageIterable.getOverflowMessage();

        firstMessageId = (V)currentMessage.getVertexId();

        comparision = firstMessageId.compareTo(vertex.getVertexID());

      }

    }

    if (comparision == 0) {

      // vertex id matches with the vertex, return an iterator with newest

      // message

      return new VertexMessageIterable<V, M>(currentMessage,

          vertex.getVertexID(), peer);

    } else {

      // return null

      return null;

    }

  }

问题出在传递的消息没有找到对应的节点,是自己输入的文件格式有问题。Hama中如果使用Vertex类,则输入的默认格式是(点、边<起点 终点>)。与mapreduce类似,mapper类为文件的每一行调用一个map()函数,Vertex类为每一个点调用一个compute()函数。该点名作为一个peer的名字。所以在边的输入文件里的<起点 终点>也要在点的位置出现,如果没有出现就会出现上面的错误。举个例子:如果输入文件如下就会出错(边只写终点):

1   2   3   17  

2   1

3   1

图形结构如下

17在边的位置出现了,但在点的位置没有出现。消息传递不到17的点,所以抛出异常。输入文件改为

1   2   3   17  

2   1

3   1

17 1

就可以正常运行了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在JSF中新增一个具有固定列名的表格,并实现点击新增按钮自动增加一行空白可填写文本框,并提供删除行的功能,你可以按照以下步骤进行操作: 1. 创建一个后端管理bean(例如`TableBean`),用于处理表格数据和新增/删除功能。在该bean中定义一个集合属性(例如`tableData`)用于存储表格的数据。 ```java @ManagedBean @ViewScoped public class TableBean implements Serializable { private List<TableEntry> tableData; public TableBean() { tableData = new ArrayList<>(); // 初始化表格数据 tableData.add(new TableEntry("", "", "")); } public List<TableEntry> getTableData() { return tableData; } public void addRow() { tableData.add(new TableEntry("", "", "")); } public void deleteRow(TableEntry entry) { tableData.remove(entry); } // 其他操作和逻辑... } ``` 2. 创建一个自定义的表格实体类(例如`TableEntry`),用于存储每行表格的数据。 ```java public class TableEntry implements Serializable { private String scaleName; private Date date; private String result; // Getter和Setter方法... public TableEntry(String scaleName, Date date, String result) { this.scaleName = scaleName; this.date = date; this.result = result; } } ``` 3. 在JSF页面中,使用`h:dataTable`标签展示表格,并在每列中使用适当的组件来绑定数据。 ```xml <h:form> <h:dataTable value="#{tableBean.tableData}" var="entry"> <h:column> <f:facet name="header">量表名</f:facet> <h:inputText value="#{entry.scaleName}" /> </h:column> <h:column> <f:facet name="header">日期</f:facet> <h:inputText value="#{entry.date}" /> </h:column> <h:column> <f:facet name="header">结果</f:facet> <h:inputText value="#{entry.result}" /> </h:column> <h:column> <h:commandButton value="删除" action="#{tableBean.deleteRow(entry)}" /> </h:column> </h:dataTable> <h:commandButton value="新增" action="#{tableBean.addRow}" /> </h:form> ``` 在上述示例中,我们使用`h:dataTable`标签来展示`tableData`集合中的数据。每一列都使用`h:column`标签定义,并在`f:facet`标签中指定列名。对应的输入文本框使用`h:inputText`组件,并通过EL表达式绑定到`TableEntry`实体类的相应属性上。 新增按钮使用`h:commandButton`组件,并通过`action`属性绑定到后端管理bean(`TableBean`)的`addRow`方法上,用于在表格中新增一行空白数据。 删除按钮使用`h:commandButton`组件,并通过`action`属性绑定到后端管理bean(`TableBean`)的`deleteRow`方法上,用于删除选中行。 希望以上示例能够满足你的需求!如有更多问题,请随时提问。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值