Coverage Report - org.apache.giraph.comm.WritableRequest
 
Classes in this File Line Coverage Branch Coverage Complexity
WritableRequest
100%
14/14
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;
 20  
 
 21  
 import java.io.DataInput;
 22  
 import java.io.DataOutput;
 23  
 import java.io.IOException;
 24  
 import org.apache.giraph.comm.RequestRegistry.Type;
 25  
 import org.apache.hadoop.conf.Configurable;
 26  
 import org.apache.hadoop.conf.Configuration;
 27  
 import org.apache.hadoop.io.Writable;
 28  
 import org.apache.hadoop.io.WritableComparable;
 29  
 
 30  
 /**
 31  
  * Interface for requests to implement
 32  
  *
 33  
  * @param <I> Vertex id
 34  
  * @param <V> Vertex data
 35  
  * @param <E> Edge data
 36  
  * @param <M> Message data
 37  
  */
 38  
 @SuppressWarnings("rawtypes")
 39  43
 public abstract class WritableRequest<I extends WritableComparable,
 40  
     V extends Writable, E extends Writable,
 41  
     M extends Writable> implements Writable, Configurable {
 42  
   /** Configuration */
 43  
   private Configuration conf;
 44  
   /** Request id */
 45  43
   private long requestId = -1;
 46  
 
 47  
   public long getRequestId() {
 48  6
     return requestId;
 49  
   }
 50  
 
 51  
   public void setRequestId(long requestId) {
 52  3
     this.requestId = requestId;
 53  3
   }
 54  
 
 55  
   /**
 56  
    * Get the type of the request
 57  
    *
 58  
    * @return Request type
 59  
    */
 60  
   public abstract Type getType();
 61  
 
 62  
   /**
 63  
    * Serialize the request
 64  
    *
 65  
    * @param input Input to read fields from
 66  
    */
 67  
   abstract void readFieldsRequest(DataInput input) throws IOException;
 68  
 
 69  
   /**
 70  
    * Deserialize the request
 71  
    *
 72  
    * @param output Output to write the request to
 73  
    */
 74  
   abstract void writeRequest(DataOutput output) throws IOException;
 75  
 
 76  
   /**
 77  
    * Execute the request
 78  
    *
 79  
    * @param serverData Accessible data that can be mutated per the request
 80  
    */
 81  
   public abstract void doRequest(ServerData<I, V, E, M> serverData);
 82  
 
 83  
   @Override
 84  
   public final Configuration getConf() {
 85  59
     return conf;
 86  
   }
 87  
 
 88  
   @Override
 89  
   public final void setConf(Configuration conf) {
 90  3
     this.conf = conf;
 91  3
   }
 92  
 
 93  
   @Override
 94  
   public final void readFields(DataInput input) throws IOException {
 95  3
     requestId = input.readLong();
 96  3
     readFieldsRequest(input);
 97  3
   }
 98  
 
 99  
   @Override
 100  
   public final void write(DataOutput output) throws IOException {
 101  3
     output.writeLong(requestId);
 102  3
     writeRequest(output);
 103  3
   }
 104  
 }