Coverage Report - org.apache.giraph.block_app.framework.internal.PairedPieceAndStage
 
Classes in this File Line Coverage Branch Coverage Complexity
PairedPieceAndStage
0%
0/27
0%
0/14
1.818
 
 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.block_app.framework.internal;
 19  
 
 20  
 import java.util.List;
 21  
 
 22  
 import org.apache.giraph.block_app.framework.api.BlockMasterApi;
 23  
 import org.apache.giraph.block_app.framework.api.BlockWorkerContextReceiveApi;
 24  
 import org.apache.giraph.block_app.framework.api.BlockWorkerContextSendApi;
 25  
 import org.apache.giraph.block_app.framework.api.BlockWorkerReceiveApi;
 26  
 import org.apache.giraph.block_app.framework.api.BlockWorkerSendApi;
 27  
 import org.apache.giraph.block_app.framework.piece.AbstractPiece;
 28  
 import org.apache.giraph.block_app.framework.piece.AbstractPiece.InnerVertexSender;
 29  
 import org.apache.giraph.block_app.framework.piece.interfaces.VertexReceiver;
 30  
 import org.apache.hadoop.io.Writable;
 31  
 
 32  
 /**
 33  
  * Object holding piece with it's corresponding execution stage.
 34  
  *
 35  
  * @param <S> Execution stage type
 36  
  */
 37  
 @SuppressWarnings({ "rawtypes", "unchecked" })
 38  
 public class PairedPieceAndStage<S> {
 39  
   private final AbstractPiece piece;
 40  
   private final S executionStage;
 41  
 
 42  0
   public PairedPieceAndStage(AbstractPiece piece, S executionStage) {
 43  0
     this.piece = piece;
 44  0
     this.executionStage = executionStage;
 45  0
   }
 46  
 
 47  
   public S nextExecutionStage() {
 48  
     // if piece is null, then it cannot change the execution stage
 49  0
     return piece != null ?
 50  0
       (S) piece.nextExecutionStage(executionStage) : executionStage;
 51  
   }
 52  
 
 53  
   public S getExecutionStage() {
 54  0
     return executionStage;
 55  
   }
 56  
 
 57  
   public void registerReducers(BlockMasterApi masterApi) {
 58  0
     if (piece != null) {
 59  0
       piece.wrappedRegisterReducers(masterApi, executionStage);
 60  
     }
 61  0
   }
 62  
 
 63  
   public InnerVertexSender getVertexSender(BlockWorkerSendApi sendApi) {
 64  0
     if (piece != null) {
 65  0
       return piece.getWrappedVertexSender(sendApi, executionStage);
 66  
     }
 67  0
     return null;
 68  
   }
 69  
 
 70  
   public void masterCompute(BlockMasterApi masterApi) {
 71  0
     if (piece != null) {
 72  0
       piece.masterCompute(masterApi, executionStage);
 73  
     }
 74  0
   }
 75  
 
 76  
   public VertexReceiver getVertexReceiver(
 77  
       BlockWorkerReceiveApi receiveApi) {
 78  0
     if (piece != null) {
 79  0
       return piece.getVertexReceiver(receiveApi, executionStage);
 80  
     }
 81  0
     return null;
 82  
   }
 83  
 
 84  
   public void workerContextSend(
 85  
       BlockWorkerContextSendApi workerContextApi, Object workerValue) {
 86  0
     if (piece != null) {
 87  0
       piece.workerContextSend(workerContextApi, executionStage, workerValue);
 88  
     }
 89  0
   }
 90  
 
 91  
   public void workerContextReceive(
 92  
       BlockWorkerContextReceiveApi workerContextApi,
 93  
       Object workerValue, List<Writable> workerMessages) {
 94  0
     if (piece != null) {
 95  0
       piece.workerContextReceive(
 96  
           workerContextApi, executionStage, workerValue, workerMessages);
 97  
     }
 98  0
   }
 99  
 
 100  
   /**
 101  
    * @return the piece
 102  
    */
 103  
   public AbstractPiece getPiece() {
 104  0
     return piece;
 105  
   }
 106  
 
 107  
   @Override
 108  
   public String toString() {
 109  0
     return "Piece " + piece + " in stage " + executionStage;
 110  
   }
 111  
 }