1/*2 * Licensed to the Apache Software Foundation (ASF) under one3 * or more contributor license agreements. See the NOTICE file4 * distributed with this work for additional information5 * regarding copyright ownership. The ASF licenses this file6 * to you under the Apache License, Version 2.0 (the7 * "License"); you may not use this file except in compliance8 * with the License. You may obtain a copy of the License at9 *10 * http://www.apache.org/licenses/LICENSE-2.011 *12 * Unless required by applicable law or agreed to in writing, software13 * 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 and16 * limitations under the License.17 */1819package org.apache.giraph.comm.netty.handler;
2021/**22 * Simple immutable object to use for tracking requests uniquely. This23 * object is guaranteed to be unique for a given client (based on the24 * destination task and the request).25 */26publicclassClientRequestId {
27/** Destination task id */28privatefinalint destinationTaskId;
29/** Request id */30privatefinallong requestId;
3132/**33 * Constructor.34 *35 * @param destinationTaskId Destination task id36 * @param requestId Request id37 */38publicClientRequestId(int destinationTaskId, long requestId) {
39this.destinationTaskId = destinationTaskId;
40this.requestId = requestId;
41 }
4243publicint getDestinationTaskId() {
44return destinationTaskId;
45 }
4647publiclong getRequestId() {
48return requestId;
49 }
5051 @Override
52publicint hashCode() {
53return (29 * destinationTaskId) + (int) (57 * requestId);
54 }
5556 @Override
57publicboolean equals(Object other) {
58if (other instanceof ClientRequestId) {
59ClientRequestId otherObj = (ClientRequestId) other;
60if (otherObj.getRequestId() == requestId &&
61 otherObj.getDestinationTaskId() == destinationTaskId) {
62returntrue;
63 }
64 }
6566return false;
67 }
6869 @Override
70public String toString() {
71return"(destTask=" + destinationTaskId + ",reqId=" + requestId + ")";
72 }
73 }