Coverage Report - org.apache.giraph.partition.PartitionStats
 
Classes in this File Line Coverage Branch Coverage Complexity
PartitionStats
0%
0/57
N/A
1
 
 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  
 package org.apache.giraph.partition;
 19  
 
 20  
 import java.io.DataInput;
 21  
 import java.io.DataOutput;
 22  
 import java.io.IOException;
 23  
 
 24  
 import org.apache.hadoop.io.Writable;
 25  
 
 26  
 /**
 27  
  * Used to keep track of statistics of every {@link Partition}. Contains no
 28  
  * actual partition data, only the statistics.
 29  
  */
 30  
 public class PartitionStats implements Writable {
 31  
   /** Id of partition to keep stats for */
 32  0
   private int partitionId = -1;
 33  
   /** Vertices in this partition */
 34  0
   private long vertexCount = 0;
 35  
   /** Finished vertices in this partition */
 36  0
   private long finishedVertexCount = 0;
 37  
   /** Edges in this partition */
 38  0
   private long edgeCount = 0;
 39  
   /** Messages sent from this partition */
 40  0
   private long messagesSentCount = 0;
 41  
   /** Message byetes sent from this partition */
 42  0
   private long messageBytesSentCount = 0;
 43  
   /**
 44  
    * How long did compute take on this partition
 45  
    * (excluding time spent in GC) (TODO and waiting on open requests)
 46  
    */
 47  
   private long computeMs;
 48  
   /** Hostname and id of worker owning this partition */
 49  
   private String workerHostnameId;
 50  
 
 51  
   /**
 52  
    * Default constructor for reflection.
 53  
    */
 54  0
   public PartitionStats() { }
 55  
 
 56  
   /**
 57  
    * Constructor with the initial stats.
 58  
    *
 59  
    * @param partitionId Partition count.
 60  
    * @param vertexCount Vertex count.
 61  
    * @param finishedVertexCount Finished vertex count.
 62  
    * @param edgeCount Edge count.
 63  
    * @param messagesSentCount Number of messages sent
 64  
    * @param messageBytesSentCount Number of message bytes sent
 65  
    * @param workerHostnameId Hostname and id of worker owning this partition
 66  
    */
 67  
   public PartitionStats(int partitionId,
 68  
       long vertexCount,
 69  
       long finishedVertexCount,
 70  
       long edgeCount,
 71  
       long messagesSentCount,
 72  
       long messageBytesSentCount,
 73  0
       String workerHostnameId) {
 74  0
     this.partitionId = partitionId;
 75  0
     this.vertexCount = vertexCount;
 76  0
     this.finishedVertexCount = finishedVertexCount;
 77  0
     this.edgeCount = edgeCount;
 78  0
     this.messagesSentCount = messagesSentCount;
 79  0
     this.messageBytesSentCount = messageBytesSentCount;
 80  0
     this.workerHostnameId = workerHostnameId;
 81  0
   }
 82  
 
 83  
   /**
 84  
    * Set the partition id.
 85  
    *
 86  
    * @param partitionId New partition id.
 87  
    */
 88  
   public void setPartitionId(int partitionId) {
 89  0
     this.partitionId = partitionId;
 90  0
   }
 91  
 
 92  
   /**
 93  
    * Get partition id.
 94  
    *
 95  
    * @return Partition id.
 96  
    */
 97  
   public int getPartitionId() {
 98  0
     return partitionId;
 99  
   }
 100  
 
 101  
   /**
 102  
    * Increment the vertex count by one.
 103  
    */
 104  
   public void incrVertexCount() {
 105  0
     ++vertexCount;
 106  0
   }
 107  
 
 108  
   /**
 109  
    * Get the vertex count.
 110  
    *
 111  
    * @return Vertex count.
 112  
    */
 113  
   public long getVertexCount() {
 114  0
     return vertexCount;
 115  
   }
 116  
 
 117  
   /**
 118  
    * Increment the finished vertex count by one.
 119  
    */
 120  
   public void incrFinishedVertexCount() {
 121  0
     ++finishedVertexCount;
 122  0
   }
 123  
 
 124  
   /**
 125  
    * Get the finished vertex count.
 126  
    *
 127  
    * @return Finished vertex count.
 128  
    */
 129  
   public long getFinishedVertexCount() {
 130  0
     return finishedVertexCount;
 131  
   }
 132  
 
 133  
   /**
 134  
    * Add edges to the edge count.
 135  
    *
 136  
    * @param edgeCount Number of edges to add.
 137  
    */
 138  
   public void addEdgeCount(long edgeCount) {
 139  0
     this.edgeCount += edgeCount;
 140  0
   }
 141  
 
 142  
   /**
 143  
    * Get the edge count.
 144  
    *
 145  
    * @return Edge count.
 146  
    */
 147  
   public long getEdgeCount() {
 148  0
     return edgeCount;
 149  
   }
 150  
 
 151  
   /**
 152  
    * Add messages to the messages sent count.
 153  
    *
 154  
    * @param messagesSentCount Number of messages to add.
 155  
    */
 156  
   public void addMessagesSentCount(long messagesSentCount) {
 157  0
     this.messagesSentCount += messagesSentCount;
 158  0
   }
 159  
 
 160  
   /**
 161  
    * Get the messages sent count.
 162  
    *
 163  
    * @return Messages sent count.
 164  
    */
 165  
   public long getMessagesSentCount() {
 166  0
     return messagesSentCount;
 167  
   }
 168  
 
 169  
   /**
 170  
    * Add message bytes to messageBytesSentCount.
 171  
    *
 172  
    * @param messageBytesSentCount Number of message bytes to add.
 173  
    */
 174  
   public void addMessageBytesSentCount(long messageBytesSentCount) {
 175  0
     this.messageBytesSentCount += messageBytesSentCount;
 176  0
   }
 177  
 
 178  
   /**
 179  
    * Get the message bytes sent count.
 180  
    *
 181  
    * @return Message bytes sent count.
 182  
    */
 183  
   public long getMessageBytesSentCount() {
 184  0
     return messageBytesSentCount;
 185  
   }
 186  
 
 187  
   public long getComputeMs() {
 188  0
     return computeMs;
 189  
   }
 190  
 
 191  
   public void setComputeMs(long computeMs) {
 192  0
     this.computeMs = computeMs;
 193  0
   }
 194  
 
 195  
   public String getWorkerHostnameId() {
 196  0
     return workerHostnameId;
 197  
   }
 198  
 
 199  
   @Override
 200  
   public void readFields(DataInput input) throws IOException {
 201  0
     partitionId = input.readInt();
 202  0
     vertexCount = input.readLong();
 203  0
     finishedVertexCount = input.readLong();
 204  0
     edgeCount = input.readLong();
 205  0
     messagesSentCount = input.readLong();
 206  0
     messageBytesSentCount = input.readLong();
 207  0
     computeMs = input.readLong();
 208  0
     workerHostnameId = input.readUTF();
 209  0
   }
 210  
 
 211  
   @Override
 212  
   public void write(DataOutput output) throws IOException {
 213  0
     output.writeInt(partitionId);
 214  0
     output.writeLong(vertexCount);
 215  0
     output.writeLong(finishedVertexCount);
 216  0
     output.writeLong(edgeCount);
 217  0
     output.writeLong(messagesSentCount);
 218  0
     output.writeLong(messageBytesSentCount);
 219  0
     output.writeLong(computeMs);
 220  0
     output.writeUTF(workerHostnameId);
 221  0
   }
 222  
 
 223  
   @Override
 224  
   public String toString() {
 225  0
     return "(id=" + partitionId + ",vtx=" + vertexCount + ",finVtx=" +
 226  
         finishedVertexCount + ",edges=" + edgeCount + ",msgsSent=" +
 227  
         messagesSentCount + ",msgBytesSent=" +
 228  
         messageBytesSentCount + ",computeMs=" + computeMs +
 229  
         ")";
 230  
   }
 231  
 }