Coverage Report - org.apache.giraph.comm.requests.AskForInputSplitRequest
 
Classes in this File Line Coverage Branch Coverage Complexity
AskForInputSplitRequest
0%
0/18
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.comm.requests;
 20  
 
 21  
 import org.apache.giraph.master.MasterGlobalCommHandler;
 22  
 import org.apache.giraph.io.InputType;
 23  
 
 24  
 import java.io.DataInput;
 25  
 import java.io.DataOutput;
 26  
 import java.io.IOException;
 27  
 
 28  
 /**
 29  
  * A request which workers will send to master to ask it to give them splits
 30  
  */
 31  
 public class AskForInputSplitRequest extends WritableRequest
 32  
     implements MasterRequest {
 33  
   /** Type of split we are requesting */
 34  
   private InputType splitType;
 35  
   /** Task id of worker which requested the split */
 36  
   private int workerTaskId;
 37  
   /**
 38  
    * Whether this is the first split a thread is requesting,
 39  
    * or this request indicates that previously requested input split was done
 40  
    */
 41  
   private boolean isFirstSplit;
 42  
 
 43  
   /**
 44  
    * Constructor
 45  
    *
 46  
    * @param splitType Type of split we are requesting
 47  
    * @param workerTaskId Task id of worker which requested the split
 48  
    * @param isFirstSplit Whether this is the first split a thread is requesting,
 49  
    *   or this request indicates that previously requested input split was done
 50  
    */
 51  
   public AskForInputSplitRequest(InputType splitType, int workerTaskId,
 52  0
       boolean isFirstSplit) {
 53  0
     this.splitType = splitType;
 54  0
     this.workerTaskId = workerTaskId;
 55  0
     this.isFirstSplit = isFirstSplit;
 56  0
   }
 57  
 
 58  
   /**
 59  
    * Constructor used for reflection only
 60  
    */
 61  0
   public AskForInputSplitRequest() {
 62  0
   }
 63  
 
 64  
   @Override
 65  
   public void doRequest(MasterGlobalCommHandler commHandler) {
 66  0
     commHandler.getInputSplitsHandler().sendSplitTo(
 67  
         splitType, workerTaskId, isFirstSplit);
 68  0
   }
 69  
 
 70  
   @Override
 71  
   void readFieldsRequest(DataInput in) throws IOException {
 72  0
     splitType = InputType.values()[in.readInt()];
 73  0
     workerTaskId = in.readInt();
 74  0
     isFirstSplit = in.readBoolean();
 75  0
   }
 76  
 
 77  
   @Override
 78  
   void writeRequest(DataOutput out) throws IOException {
 79  0
     out.writeInt(splitType.ordinal());
 80  0
     out.writeInt(workerTaskId);
 81  0
     out.writeBoolean(isFirstSplit);
 82  0
   }
 83  
 
 84  
   @Override
 85  
   public RequestType getType() {
 86  0
     return RequestType.ASK_FOR_INPUT_SPLIT_REQUEST;
 87  
   }
 88  
 }