Coverage Report - org.apache.giraph.bsp.CentralizedServiceMaster
 
Classes in this File Line Coverage Branch Coverage Complexity
CentralizedServiceMaster
N/A
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  
 
 19  
 package org.apache.giraph.bsp;
 20  
 
 21  
 import java.io.IOException;
 22  
 
 23  
 import org.apache.giraph.graph.MasterAggregatorUsage;
 24  
 import org.apache.hadoop.io.Writable;
 25  
 import org.apache.hadoop.io.WritableComparable;
 26  
 import org.apache.zookeeper.KeeperException;
 27  
 
 28  
 /**
 29  
  * At most, there will be one active master at a time, but many threads can
 30  
  * be trying to be the active master.
 31  
  *
 32  
  * @param <I> Vertex id
 33  
  * @param <V> Vertex value
 34  
  * @param <E> Edge value
 35  
  * @param <M> Message data
 36  
  */
 37  
 @SuppressWarnings("rawtypes")
 38  
 public interface CentralizedServiceMaster<I extends WritableComparable,
 39  
     V extends Writable, E extends Writable, M extends Writable> extends
 40  
     CentralizedService<I, V, E, M>, MasterAggregatorUsage {
 41  
   /**
 42  
    * Become the master.
 43  
    * @return true if became the master, false if the application is done.
 44  
    */
 45  
   boolean becomeMaster();
 46  
 
 47  
   /**
 48  
    * Create the {@link InputSplit} objects from the index range based on the
 49  
    * user-defined VertexInputFormat.  The {@link InputSplit} objects will
 50  
    * processed by the workers later on during the INPUT_SUPERSTEP.
 51  
    *
 52  
    * @return Number of partitions. Returns -1 on failure to create
 53  
    *         valid input splits.
 54  
    */
 55  
   int createInputSplits();
 56  
 
 57  
   /**
 58  
    * Master coordinates the superstep
 59  
    *
 60  
    * @return State of the application as a result of this superstep
 61  
    * @throws InterruptedException
 62  
    * @throws KeeperException
 63  
    */
 64  
   SuperstepState coordinateSuperstep()
 65  
     throws KeeperException, InterruptedException;
 66  
 
 67  
   /**
 68  
    * Master can decide to restart from the last good checkpoint if a
 69  
    * worker fails during a superstep.
 70  
    *
 71  
    * @param checkpoint Checkpoint to restart from
 72  
    */
 73  
   void restartFromCheckpoint(long checkpoint);
 74  
 
 75  
   /**
 76  
    * Get the last known good checkpoint
 77  
    *
 78  
    * @return Last good superstep number
 79  
    * @throws IOException
 80  
    */
 81  
   long getLastGoodCheckpoint() throws IOException;
 82  
 
 83  
   /**
 84  
    * If the master decides that this job doesn't have the resources to
 85  
    * continue, it can fail the job.  It can also designate what to do next.
 86  
    * Typically this is mainly informative.
 87  
    *
 88  
    * @param state State of the application.
 89  
    * @param applicationAttempt Attempt to start on
 90  
    * @param desiredSuperstep Superstep to restart from (if applicable)
 91  
    */
 92  
   void setJobState(ApplicationState state,
 93  
     long applicationAttempt,
 94  
     long desiredSuperstep);
 95  
 }