|
48 | 48 | import java.net.HttpURLConnection; |
49 | 49 | import java.net.InetSocketAddress; |
50 | 50 | import java.net.Socket; |
| 51 | +import java.net.URI; |
51 | 52 | import java.net.URL; |
52 | 53 | import java.net.URLConnection; |
53 | 54 | import java.nio.ByteBuffer; |
|
64 | 65 | import java.util.Set; |
65 | 66 | import java.util.UUID; |
66 | 67 | import java.util.concurrent.TimeoutException; |
| 68 | +import java.util.concurrent.atomic.AtomicBoolean; |
67 | 69 |
|
68 | 70 | import org.apache.commons.io.FileUtils; |
69 | 71 | import org.apache.commons.logging.Log; |
|
129 | 131 | import org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider; |
130 | 132 | import org.apache.hadoop.hdfs.server.protocol.DatanodeRegistration; |
131 | 133 | import org.apache.hadoop.hdfs.server.protocol.DatanodeStorage; |
| 134 | +import org.apache.hadoop.hdfs.server.protocol.NamenodeProtocol; |
132 | 135 | import org.apache.hadoop.hdfs.tools.DFSAdmin; |
133 | 136 | import org.apache.hadoop.io.IOUtils; |
134 | 137 | import org.apache.hadoop.io.nativeio.NativeIO; |
135 | 138 | import org.apache.hadoop.net.NetUtils; |
136 | 139 | import org.apache.hadoop.net.unix.DomainSocket; |
137 | 140 | import org.apache.hadoop.net.unix.TemporarySocketDirectory; |
| 141 | +import org.apache.hadoop.security.RefreshUserMappingsProtocol; |
138 | 142 | import org.apache.hadoop.security.ShellBasedUnixGroupsMapping; |
139 | 143 | import org.apache.hadoop.security.UserGroupInformation; |
140 | 144 | import org.apache.hadoop.security.token.Token; |
|
147 | 151 | import org.junit.Assume; |
148 | 152 | import org.mockito.internal.util.reflection.Whitebox; |
149 | 153 |
|
| 154 | +import com.google.common.annotations.VisibleForTesting; |
150 | 155 | import com.google.common.base.Charsets; |
151 | 156 | import com.google.common.base.Joiner; |
152 | 157 | import com.google.common.base.Preconditions; |
@@ -1755,6 +1760,41 @@ public static void setNameNodeLogLevel(Level level) { |
1755 | 1760 | GenericTestUtils.setLogLevel(NameNode.blockStateChangeLog, level); |
1756 | 1761 | } |
1757 | 1762 |
|
| 1763 | + /** |
| 1764 | + * Get the NamenodeProtocol RPC proxy for the NN associated with this |
| 1765 | + * DFSClient object |
| 1766 | + * |
| 1767 | + * @param nameNodeUri the URI of the NN to get a proxy for. |
| 1768 | + * |
| 1769 | + * @return the Namenode RPC proxy associated with this DFSClient object |
| 1770 | + */ |
| 1771 | + @VisibleForTesting |
| 1772 | + public static NamenodeProtocol getNamenodeProtocolProxy(Configuration conf, |
| 1773 | + URI nameNodeUri, UserGroupInformation ugi) |
| 1774 | + throws IOException { |
| 1775 | + return NameNodeProxies.createNonHAProxy(conf, |
| 1776 | + NameNode.getAddress(nameNodeUri), NamenodeProtocol.class, ugi, false). |
| 1777 | + getProxy(); |
| 1778 | + } |
| 1779 | + |
| 1780 | + /** |
| 1781 | + * Get the RefreshUserMappingsProtocol RPC proxy for the NN associated with |
| 1782 | + * this DFSClient object |
| 1783 | + * |
| 1784 | + * @param nameNodeUri the URI of the NN to get a proxy for. |
| 1785 | + * |
| 1786 | + * @return the RefreshUserMappingsProtocol RPC proxy associated with this |
| 1787 | + * DFSClient object |
| 1788 | + */ |
| 1789 | + @VisibleForTesting |
| 1790 | + public static RefreshUserMappingsProtocol getRefreshUserMappingsProtocolProxy( |
| 1791 | + Configuration conf, URI nameNodeUri) throws IOException { |
| 1792 | + final AtomicBoolean nnFallbackToSimpleAuth = new AtomicBoolean(false); |
| 1793 | + return NameNodeProxies.createProxy(conf, |
| 1794 | + nameNodeUri, RefreshUserMappingsProtocol.class, |
| 1795 | + nnFallbackToSimpleAuth).getProxy(); |
| 1796 | + } |
| 1797 | + |
1758 | 1798 | /** |
1759 | 1799 | * Set the datanode dead |
1760 | 1800 | */ |
|
0 commit comments