Coverage Report - org.apache.giraph.examples.utils.BrachaTouegDeadlockMessage
 
Classes in this File Line Coverage Branch Coverage Complexity
BrachaTouegDeadlockMessage
0%
0/29
0%
0/10
1.714
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one
 3  
  * or more contributor license agreements.  See the NOTICE file
 4  
  * distributed with this work for additional information
 5  
  * regarding copyright ownership.  The ASF licenses this file
 6  
  * to you under the Apache License, Version 2.0 (the
 7  
  * "License"); you may not use this file except in compliance
 8  
  * with the License.  You may obtain a copy of the License at
 9  
  *
 10  
  *     http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing, software
 13  
  * distributed under the License is distributed on an "AS IS" BASIS,
 14  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15  
  * See the License for the specific language governing permissions and
 16  
  * limitations under the License.
 17  
  */
 18  
 
 19  
 package org.apache.giraph.examples.utils;
 20  
 
 21  
 import java.io.DataInput;
 22  
 import java.io.DataOutput;
 23  
 import java.io.IOException;
 24  
 
 25  
 import org.apache.hadoop.io.Writable;
 26  
 
 27  
 /**
 28  
  * Data sent via a message that includes the source vertex id.
 29  
  */
 30  
 public class BrachaTouegDeadlockMessage implements Writable {
 31  
   /**
 32  
    * Bracha-Toueg NOTICE message. This message is sent by a vertex on all its
 33  
    * outgoing edges.
 34  
    */
 35  
   public static final long NOTIFY = 1;
 36  
   /**
 37  
    * Bracha-Toueg GRANT message. This message is sent by a vertex on all its
 38  
    * incoming edges.
 39  
    */
 40  
   public static final long GRANT = 1 << 1;
 41  
   /**
 42  
    * Bracha-Toueg ACK message. This message is sent by a vertex on its
 43  
    * outgoing edges.
 44  
    */
 45  
   public static final long ACK = 1 << 2;
 46  
   /**
 47  
    * Bracha-Toueg DONE message. This message is sent by a vertex on its
 48  
    * incoming edges.
 49  
    */
 50  
   public static final long DONE = 1 << 3;
 51  
   /** Bracha-Toueg control incoming-edge message */
 52  
   public static final long CTRL_IN_EDGE = 1 << 4;
 53  
 
 54  
   /** Vertex ID of the sender. */
 55  
   private long  senderId;
 56  
   /** Message type. */
 57  
   private long  type;
 58  
 
 59  
   /** Default empty constructor. */
 60  0
   public BrachaTouegDeadlockMessage() { /* no action */ }
 61  
 
 62  
   /**
 63  
    * @param id        id of the vertex
 64  
    * @param type      actual message content
 65  
    */
 66  0
   public BrachaTouegDeadlockMessage(long id, long type) {
 67  0
     this.senderId = id;
 68  0
     this.type = type;
 69  0
   }
 70  
 
 71  
   @Override
 72  
   public void readFields(DataInput input) throws IOException {
 73  0
     senderId = input.readLong();
 74  0
     this.type = input.readLong();
 75  0
   }
 76  
 
 77  
   @Override
 78  
   public void write(DataOutput output) throws IOException {
 79  0
     output.writeLong(senderId);
 80  0
     output.writeLong(this.type);
 81  0
   }
 82  
 
 83  
   /**
 84  
    * @return long the id
 85  
    */
 86  
   public long getSenderId() {
 87  0
     return senderId;
 88  
   }
 89  
 
 90  
   /**
 91  
    * @return long the type
 92  
    */
 93  
   public long getType() {
 94  0
     return type;
 95  
   }
 96  
 
 97  
   @Override
 98  
   public String toString() {
 99  0
     StringBuffer buffer = new StringBuffer();
 100  
 
 101  0
     buffer.append("Message ");
 102  0
     buffer.append("{ sender: " +  this.senderId + "; type: ");
 103  0
     if (this.type == BrachaTouegDeadlockMessage.NOTIFY) {
 104  0
       buffer.append("notify");
 105  0
     } else if (this.type == BrachaTouegDeadlockMessage.GRANT) {
 106  0
       buffer.append("grant");
 107  0
     } else if (this.type == BrachaTouegDeadlockMessage.ACK) {
 108  0
       buffer.append("ack");
 109  0
     } else if (this.type == BrachaTouegDeadlockMessage.DONE) {
 110  0
       buffer.append("done");
 111  0
     } else if (this.type == BrachaTouegDeadlockMessage.CTRL_IN_EDGE) {
 112  0
       buffer.append("<ctrl>");
 113  
     } else {
 114  0
       buffer.append("unknown");
 115  
     }
 116  0
     buffer.append(" }");
 117  
 
 118  0
     return buffer.toString();
 119  
   }
 120  
 }