Coverage Report - org.apache.giraph.comm.netty.handler.ClientRequestId
 
Classes in this File Line Coverage Branch Coverage Complexity
ClientRequestId
0%
0/14
0%
0/6
1.667
 
 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.netty.handler;
 20  
 
 21  
 /**
 22  
  * Simple immutable object to use for tracking requests uniquely.  This
 23  
  * object is guaranteed to be unique for a given client (based on the
 24  
  * destination task and the request).
 25  
  */
 26  
 public class ClientRequestId {
 27  
   /** Destination task id */
 28  
   private final int destinationTaskId;
 29  
   /** Request id */
 30  
   private final long requestId;
 31  
 
 32  
   /**
 33  
    * Constructor.
 34  
    *
 35  
    * @param destinationTaskId Destination task id
 36  
    * @param requestId Request id
 37  
    */
 38  0
   public ClientRequestId(int destinationTaskId, long requestId) {
 39  0
     this.destinationTaskId = destinationTaskId;
 40  0
     this.requestId = requestId;
 41  0
   }
 42  
 
 43  
   public int getDestinationTaskId() {
 44  0
     return destinationTaskId;
 45  
   }
 46  
 
 47  
   public long getRequestId() {
 48  0
     return requestId;
 49  
   }
 50  
 
 51  
   @Override
 52  
   public int hashCode() {
 53  0
     return (29 * destinationTaskId) + (int) (57 * requestId);
 54  
   }
 55  
 
 56  
   @Override
 57  
   public boolean equals(Object other) {
 58  0
     if (other instanceof ClientRequestId) {
 59  0
       ClientRequestId otherObj = (ClientRequestId) other;
 60  0
       if (otherObj.getRequestId() == requestId &&
 61  0
           otherObj.getDestinationTaskId() == destinationTaskId) {
 62  0
         return true;
 63  
       }
 64  
     }
 65  
 
 66  0
     return false;
 67  
   }
 68  
 
 69  
   @Override
 70  
   public String toString() {
 71  0
     return "(destTask=" + destinationTaskId + ",reqId=" + requestId + ")";
 72  
   }
 73  
 }