From common-commits-return-16823-apmail-hadoop-common-commits-archive=hadoop.apache.org@hadoop.apache.org Sat Feb 4 03:11:26 2012 Return-Path: X-Original-To: apmail-hadoop-common-commits-archive@www.apache.org Delivered-To: apmail-hadoop-common-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E31569EC6 for ; Sat, 4 Feb 2012 03:11:26 +0000 (UTC) Received: (qmail 361 invoked by uid 500); 4 Feb 2012 03:11:26 -0000 Delivered-To: apmail-hadoop-common-commits-archive@hadoop.apache.org Received: (qmail 99731 invoked by uid 500); 4 Feb 2012 03:11:09 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-dev@hadoop.apache.org Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 99710 invoked by uid 99); 4 Feb 2012 03:11:04 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 04 Feb 2012 03:11:04 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 04 Feb 2012 03:11:02 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 2CD9F23888D2; Sat, 4 Feb 2012 03:10:40 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1240449 - in /hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop: io/retry/RetryInvocationHandler.java ipc/ProtocolTranslator.java ipc/RPC.java Date: Sat, 04 Feb 2012 03:10:39 -0000 To: common-commits@hadoop.apache.org From: atm@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120204031040.2CD9F23888D2@eris.apache.org> Author: atm Date: Sat Feb 4 03:10:39 2012 New Revision: 1240449 URL: http://svn.apache.org/viewvc?rev=1240449&view=rev Log: HDFS-2792. Make fsck work. Contributed by Aaron T. Myers. Added: hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/ProtocolTranslator.java Modified: hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryInvocationHandler.java hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/RPC.java Modified: hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryInvocationHandler.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryInvocationHandler.java?rev=1240449&r1=1240448&r2=1240449&view=diff ============================================================================== --- hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryInvocationHandler.java (original) +++ hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/retry/RetryInvocationHandler.java Sat Feb 4 03:10:39 2012 @@ -20,7 +20,6 @@ package org.apache.hadoop.io.retry; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.lang.reflect.Proxy; import java.util.Collections; import java.util.Map; @@ -29,6 +28,7 @@ import org.apache.commons.logging.LogFac import org.apache.hadoop.io.retry.RetryPolicy.RetryAction; import org.apache.hadoop.util.ThreadUtil; import org.apache.hadoop.ipc.Client.ConnectionId; +import org.apache.hadoop.ipc.RPC; import org.apache.hadoop.ipc.RpcInvocationHandler; class RetryInvocationHandler implements RpcInvocationHandler { @@ -163,9 +163,7 @@ class RetryInvocationHandler implements @Override //RpcInvocationHandler public ConnectionId getConnectionId() { - RpcInvocationHandler inv = (RpcInvocationHandler) Proxy - .getInvocationHandler(currentProxy); - return inv.getConnectionId(); + return RPC.getConnectionIdForProxy(currentProxy); } } Added: hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/ProtocolTranslator.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/ProtocolTranslator.java?rev=1240449&view=auto ============================================================================== --- hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/ProtocolTranslator.java (added) +++ hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/ProtocolTranslator.java Sat Feb 4 03:10:39 2012 @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.ipc; + +import org.apache.hadoop.classification.InterfaceAudience; + +/** + * An interface implemented by client-side protocol translators to get the + * underlying proxy object the translator is operating on. + */ +@InterfaceAudience.Private +public interface ProtocolTranslator { + + /** + * Return the proxy object underlying this protocol translator. + * @return the proxy object underlying this protocol translator. + */ + public Object getUnderlyingProxyObject(); + +} Modified: hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/RPC.java URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/RPC.java?rev=1240449&r1=1240448&r2=1240449&view=diff ============================================================================== --- hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/RPC.java (original) +++ hadoop/common/branches/HDFS-1623/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/RPC.java Sat Feb 4 03:10:39 2012 @@ -40,6 +40,7 @@ import javax.net.SocketFactory; import org.apache.commons.logging.*; import org.apache.hadoop.io.*; +import org.apache.hadoop.ipc.Client.ConnectionId; import org.apache.hadoop.ipc.RpcPayloadHeader.RpcKind; import org.apache.hadoop.ipc.protobuf.ProtocolInfoProtos.ProtocolInfoService; import org.apache.hadoop.net.NetUtils; @@ -530,9 +531,24 @@ public class RPC { * Returns the server address for a given proxy. */ public static InetSocketAddress getServerAddress(Object proxy) { + return getConnectionIdForProxy(proxy).getAddress(); + } + + /** + * Return the connection ID of the given object. If the provided object is in + * fact a protocol translator, we'll get the connection ID of the underlying + * proxy object. + * + * @param proxy the proxy object to get the connection ID of. + * @return the connection ID for the provided proxy object. + */ + public static ConnectionId getConnectionIdForProxy(Object proxy) { + if (proxy instanceof ProtocolTranslator) { + proxy = ((ProtocolTranslator)proxy).getUnderlyingProxyObject(); + } RpcInvocationHandler inv = (RpcInvocationHandler) Proxy .getInvocationHandler(proxy); - return inv.getConnectionId().getAddress(); + return inv.getConnectionId(); } /**