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.graph; 19 20 import org.apache.giraph.bsp.checkpoints.CheckpointStatus; 21 22 /** 23 * Immutable graph stats after the completion of a superstep 24 */ 25 public class FinishedSuperstepStats extends VertexEdgeCount { 26 /** Number of local vertices */ 27 private final long localVertexCount; 28 /** Are all the graph vertices halted? */ 29 private final boolean allVerticesHalted; 30 /** Needs to load a checkpoint */ 31 private final boolean mustLoadCheckpoint; 32 /** 33 * Master decides when we need to checkpoint and what should 34 * we do next. 35 */ 36 private final CheckpointStatus checkpointStatus; 37 38 /** 39 * Constructor. 40 * 41 * @param numLocalVertices Number of local vertices 42 * @param allVerticesHalted Are all the vertices halted 43 * @param numVertices Number of vertices 44 * @param numEdges Number of edges 45 * @param mustLoadCheckpoint Has to load a checkpoint? 46 * @param checkpointStatus Should we checkpoint after this superstep? 47 */ 48 public FinishedSuperstepStats(long numLocalVertices, 49 boolean allVerticesHalted, 50 long numVertices, 51 long numEdges, 52 boolean mustLoadCheckpoint, 53 CheckpointStatus checkpointStatus) { 54 super(numVertices, numEdges, 0); 55 this.localVertexCount = numLocalVertices; 56 this.allVerticesHalted = allVerticesHalted; 57 this.mustLoadCheckpoint = mustLoadCheckpoint; 58 this.checkpointStatus = checkpointStatus; 59 } 60 61 public long getLocalVertexCount() { 62 return localVertexCount; 63 } 64 65 /** 66 * Are all the vertices halted? 67 * 68 * @return True if all halted, false otherwise 69 */ 70 public boolean allVerticesHalted() { 71 return allVerticesHalted; 72 } 73 74 /** 75 * Must load the checkpoint? 76 * 77 * @return True if the checkpoint must be loaded, false otherwise 78 */ 79 public boolean mustLoadCheckpoint() { 80 return mustLoadCheckpoint; 81 } 82 83 /** 84 * What master thinks about checkpointing after this superstep. 85 * @return CheckpointStatus that reflects master decision. 86 */ 87 public CheckpointStatus getCheckpointStatus() { 88 return checkpointStatus; 89 } 90 }