Coverage Report - org.apache.giraph.graph.GlobalStats
 
Classes in this File Line Coverage Branch Coverage Complexity
GlobalStats
0%
0/66
0%
0/6
1.095
 
 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.graph;
 20  
 
 21  
 import java.io.DataInput;
 22  
 import java.io.DataOutput;
 23  
 import java.io.IOException;
 24  
 
 25  
 import org.apache.giraph.bsp.checkpoints.CheckpointStatus;
 26  
 import org.apache.giraph.partition.PartitionStats;
 27  
 import org.apache.hadoop.io.Writable;
 28  
 
 29  
 /**
 30  
  * Aggregated stats by the master.
 31  
  */
 32  0
 public class GlobalStats implements Writable {
 33  
   /** All vertices in the application */
 34  0
   private long vertexCount = 0;
 35  
   /** All finished vertices in the last superstep */
 36  0
   private long finishedVertexCount = 0;
 37  
   /** All edges in the last superstep */
 38  0
   private long edgeCount = 0;
 39  
   /** All messages sent in the last superstep */
 40  0
   private long messageCount = 0;
 41  
   /** All message bytes sent in the last superstep */
 42  0
   private long messageBytesCount = 0;
 43  
   /** Whether the computation should be halted */
 44  0
   private boolean haltComputation = false;
 45  
   /** Bytes of data stored to disk in the last superstep */
 46  0
   private long oocStoreBytesCount = 0;
 47  
   /** Bytes of data loaded to disk in the last superstep */
 48  0
   private long oocLoadBytesCount = 0;
 49  
   /** Lowest percentage of graph in memory throughout the execution */
 50  0
   private int lowestGraphPercentageInMemory = 100;
 51  
   /**
 52  
    * Master's decision on whether we should checkpoint and
 53  
    * what to do next.
 54  
    */
 55  0
   private CheckpointStatus checkpointStatus =
 56  
       CheckpointStatus.NONE;
 57  
 
 58  
   /**
 59  
    * Add the stats of a partition to the global stats.
 60  
    *
 61  
    * @param partitionStats Partition stats to be added.
 62  
    */
 63  
   public void addPartitionStats(PartitionStats partitionStats) {
 64  0
     this.vertexCount += partitionStats.getVertexCount();
 65  0
     this.finishedVertexCount += partitionStats.getFinishedVertexCount();
 66  0
     this.edgeCount += partitionStats.getEdgeCount();
 67  0
   }
 68  
 
 69  
   public long getVertexCount() {
 70  0
     return vertexCount;
 71  
   }
 72  
 
 73  
   public long getFinishedVertexCount() {
 74  0
     return finishedVertexCount;
 75  
   }
 76  
 
 77  
   public long getEdgeCount() {
 78  0
     return edgeCount;
 79  
   }
 80  
 
 81  
   public long getMessageCount() {
 82  0
     return messageCount;
 83  
   }
 84  
 
 85  
   public long getMessageBytesCount() {
 86  0
     return messageBytesCount;
 87  
   }
 88  
 
 89  
   public boolean getHaltComputation() {
 90  0
     return haltComputation;
 91  
   }
 92  
 
 93  
   public void setHaltComputation(boolean value) {
 94  0
     haltComputation = value;
 95  0
   }
 96  
 
 97  
   public long getOocStoreBytesCount() {
 98  0
     return oocStoreBytesCount;
 99  
   }
 100  
 
 101  
   public long getOocLoadBytesCount() {
 102  0
     return oocLoadBytesCount;
 103  
   }
 104  
 
 105  
   public CheckpointStatus getCheckpointStatus() {
 106  0
     return checkpointStatus;
 107  
   }
 108  
 
 109  
   public void setCheckpointStatus(CheckpointStatus checkpointStatus) {
 110  0
     this.checkpointStatus = checkpointStatus;
 111  0
   }
 112  
 
 113  
   public int getLowestGraphPercentageInMemory() {
 114  0
     return lowestGraphPercentageInMemory;
 115  
   }
 116  
 
 117  
   public void setLowestGraphPercentageInMemory(
 118  
       int lowestGraphPercentageInMemory) {
 119  0
     this.lowestGraphPercentageInMemory = lowestGraphPercentageInMemory;
 120  0
   }
 121  
 
 122  
   /**
 123  
    * Add bytes loaded to the global stats.
 124  
    *
 125  
    * @param oocLoadBytesCount number of bytes to be added
 126  
    */
 127  
   public void addOocLoadBytesCount(long oocLoadBytesCount) {
 128  0
     this.oocLoadBytesCount += oocLoadBytesCount;
 129  0
   }
 130  
 
 131  
   /**
 132  
    * Add bytes stored to the global stats.
 133  
    *
 134  
    * @param oocStoreBytesCount number of bytes to be added
 135  
    */
 136  
   public void addOocStoreBytesCount(long oocStoreBytesCount) {
 137  0
     this.oocStoreBytesCount += oocStoreBytesCount;
 138  0
   }
 139  
 
 140  
   /**
 141  
    * Add messages to the global stats.
 142  
    *
 143  
    * @param messageCount Number of messages to be added.
 144  
    */
 145  
   public void addMessageCount(long messageCount) {
 146  0
     this.messageCount += messageCount;
 147  0
   }
 148  
 
 149  
   /**
 150  
    * Add messages to the global stats.
 151  
    *
 152  
    * @param msgBytesCount Number of message bytes to be added.
 153  
    */
 154  
   public void addMessageBytesCount(long msgBytesCount) {
 155  0
     this.messageBytesCount += msgBytesCount;
 156  0
   }
 157  
 
 158  
   @Override
 159  
   public void readFields(DataInput input) throws IOException {
 160  0
     vertexCount = input.readLong();
 161  0
     finishedVertexCount = input.readLong();
 162  0
     edgeCount = input.readLong();
 163  0
     messageCount = input.readLong();
 164  0
     messageBytesCount = input.readLong();
 165  0
     oocLoadBytesCount = input.readLong();
 166  0
     oocStoreBytesCount = input.readLong();
 167  0
     lowestGraphPercentageInMemory = input.readInt();
 168  0
     haltComputation = input.readBoolean();
 169  0
     if (input.readBoolean()) {
 170  0
       checkpointStatus = CheckpointStatus.values()[input.readInt()];
 171  
     } else {
 172  0
       checkpointStatus = null;
 173  
     }
 174  0
   }
 175  
 
 176  
   @Override
 177  
   public void write(DataOutput output) throws IOException {
 178  0
     output.writeLong(vertexCount);
 179  0
     output.writeLong(finishedVertexCount);
 180  0
     output.writeLong(edgeCount);
 181  0
     output.writeLong(messageCount);
 182  0
     output.writeLong(messageBytesCount);
 183  0
     output.writeLong(oocLoadBytesCount);
 184  0
     output.writeLong(oocStoreBytesCount);
 185  0
     output.writeInt(lowestGraphPercentageInMemory);
 186  0
     output.writeBoolean(haltComputation);
 187  0
     output.writeBoolean(checkpointStatus != null);
 188  0
     if (checkpointStatus != null) {
 189  0
       output.writeInt(checkpointStatus.ordinal());
 190  
     }
 191  0
   }
 192  
 
 193  
   @Override
 194  
   public String toString() {
 195  0
     return "(vtx=" + vertexCount + ",finVtx=" +
 196  
         finishedVertexCount + ",edges=" + edgeCount + ",msgCount=" +
 197  
         messageCount + ",msgBytesCount=" +
 198  
           messageBytesCount + ",haltComputation=" + haltComputation +
 199  
         ", checkpointStatus=" + checkpointStatus + ')';
 200  
   }
 201  
 }