Kaynağa Gözat

HDFS-705. Create an adapter to access some of package-private methods of DataNode from tests. Contributed by Konstantin Boudnik

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hdfs/trunk@825589 13f79535-47bb-0310-9956-ffa450edef68
Konstantin Boudnik 16 yıl önce
ebeveyn
işleme
7da7e3f35f

+ 3 - 0
CHANGES.txt

@@ -281,6 +281,9 @@ Release 0.21.0 - Unreleased
 
     HDFS-680. Add new access method to a copy of a block's replica. (shv)
 
+    HDFS-705. Create an adapter to access some of package-private methods of
+    DataNode from tests (cos)
+
   BUG FIXES
 
     HDFS-76. Better error message to users when commands fail because of 

+ 38 - 0
src/test/hdfs/org/apache/hadoop/hdfs/server/datanode/DataNodeAdapter.java

@@ -0,0 +1,38 @@
+/**
+ * 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.hdfs.server.datanode;
+
+/**
+ * WARNING!! This is TEST ONLY class: it never has to be used
+ * for ANY development purposes.
+ * 
+ * This is a utility class to expose DataNode functionality for
+ * unit and functional tests.
+ */
+public class DataNodeAdapter {
+  /**
+   * Fetch a copy of ReplicaInfo from a datanode by block id
+   * @param dn datanode to retrieve a replicainfo object from
+   * @param blkId id of the replica's block
+   * @return copy of ReplicaInfo object @link{FSDataset#fetchReplicaInfo}
+   */
+  public static ReplicaInfo fetchReplicaInfo (final DataNode dn,
+                                              final long blkId) {
+    return ((FSDataset)dn.data).fetchReplicaInfo(blkId);
+  }
+}