Coverage Report - org.apache.giraph.comm.CommunicationsInterface
 
Classes in this File Line Coverage Branch Coverage Complexity
CommunicationsInterface
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.comm;
 20  
 
 21  
 import org.apache.giraph.graph.Vertex;
 22  
 
 23  
 
 24  
 import org.apache.giraph.hadoop.BspTokenSelector;
 25  
 import org.apache.hadoop.security.token.TokenInfo;
 26  
 
 27  
 import org.apache.hadoop.io.Writable;
 28  
 import org.apache.hadoop.io.WritableComparable;
 29  
 import org.apache.hadoop.ipc.VersionedProtocol;
 30  
 
 31  
 import java.io.IOException;
 32  
 
 33  
 
 34  
 /**
 35  
  * Basic interface for communication between workers.
 36  
  *
 37  
  * @param <I> Vertex id
 38  
  * @param <V> Vertex data
 39  
  * @param <E> Edge data
 40  
  * @param <M> Message data
 41  
  */
 42  
 @SuppressWarnings("rawtypes")
 43  
 
 44  
 
 45  
 @TokenInfo(BspTokenSelector.class)
 46  
 
 47  
 public interface CommunicationsInterface<I extends WritableComparable,
 48  
     V extends Writable, E extends Writable, M extends Writable>
 49  
     extends VersionedProtocol {
 50  
   /**
 51  
    * Interface Version History
 52  
    *
 53  
    * 0 - First Version
 54  
    */
 55  
   long VERSION_ID = 0L;
 56  
 
 57  
   /**
 58  
    * Adds incoming message.
 59  
    *
 60  
    * @param vertexIndex Destination vertex index.
 61  
    * @param message Message to store.
 62  
    * @throws IOException
 63  
    */
 64  
   void putMsg(I vertexIndex, M message) throws IOException;
 65  
 
 66  
   /**
 67  
    * Adds incoming message list.
 68  
    *
 69  
    * @param vertexIndex Vertex index where the message are added
 70  
    * @param msgList messages added
 71  
    * @throws IOException
 72  
    */
 73  
   void putMsgList(I vertexIndex, MsgList<M> msgList) throws IOException;
 74  
 
 75  
   /**
 76  
    * Adds a list of vertex ids and their respective message lists.
 77  
    *
 78  
    * @param vertexIdMessagesList messages to be added
 79  
    * @throws IOException
 80  
    */
 81  
   void putVertexIdMessagesList(
 82  
       VertexIdMessagesList<I, M> vertexIdMessagesList) throws IOException;
 83  
 
 84  
   /**
 85  
    * Adds vertex list (index, value, edges, etc.) to the appropriate worker.
 86  
    *
 87  
    * @param partitionId Partition id of the vertices to be added.
 88  
    * @param vertexList List of vertices to add
 89  
    */
 90  
   void putVertexList(int partitionId,
 91  
       VertexList<I, V, E, M> vertexList) throws IOException;
 92  
 
 93  
   /**
 94  
    * Add an edge to a remote vertex
 95  
    *
 96  
    * @param sourceVertexId Source vertex id
 97  
    * @param targetVertexId Target vertex id
 98  
    * @param edgeValue Edge value
 99  
    * @throws IOException
 100  
    */
 101  
   void addEdge(I sourceVertexId, I targetVertexId,
 102  
                E edgeValue) throws IOException;
 103  
 
 104  
   /**
 105  
    * Remove an edge on a remote vertex
 106  
    *
 107  
    * @param vertexIndex Vertex index where the edge is added
 108  
    * @param destinationVertexIndex Edge vertex index to be removed
 109  
    * @throws IOException
 110  
    */
 111  
   void removeEdge(I vertexIndex, I destinationVertexIndex) throws IOException;
 112  
 
 113  
   /**
 114  
    * Add a remote vertex
 115  
    *
 116  
    * @param vertex Vertex that will be added
 117  
    * @throws IOException
 118  
    */
 119  
   void addVertex(Vertex<I, V, E, M> vertex) throws IOException;
 120  
 
 121  
   /**
 122  
    * Removed a remote vertex
 123  
    *
 124  
    * @param vertexIndex Vertex index representing vertex to be removed
 125  
    * @throws IOException
 126  
    */
 127  
   void removeVertex(I vertexIndex) throws IOException;
 128  
 
 129  
   /**
 130  
    * @return The name of this worker in the format "hostname:port".
 131  
    */
 132  
   String getName();
 133  
 }