|
85 | 85 | import org.apache.hadoop.hdfs.server.federation.resolver.MountTableResolver; |
86 | 86 | import org.apache.hadoop.hdfs.server.federation.resolver.RemoteLocation; |
87 | 87 | import org.apache.hadoop.hdfs.server.federation.resolver.RouterResolveException; |
| 88 | +import org.apache.hadoop.hdfs.server.federation.router.async.AsyncErasureCoding; |
| 89 | +import org.apache.hadoop.hdfs.server.federation.router.async.RouterAsyncCacheAdmin; |
| 90 | +import org.apache.hadoop.hdfs.server.federation.router.async.RouterAsyncSnapshot; |
| 91 | +import org.apache.hadoop.hdfs.server.federation.router.async.RouterAsyncStoragePolicy; |
88 | 92 | import org.apache.hadoop.hdfs.server.federation.router.security.RouterSecurityManager; |
89 | 93 | import org.apache.hadoop.hdfs.server.federation.store.records.MountTable; |
90 | 94 | import org.apache.hadoop.hdfs.server.namenode.NameNode; |
@@ -194,10 +198,17 @@ protected RouterClientProtocol(Configuration conf, RouterRpcServer rpcServer) { |
194 | 198 | this.superGroup = conf.get( |
195 | 199 | DFSConfigKeys.DFS_PERMISSIONS_SUPERUSERGROUP_KEY, |
196 | 200 | DFSConfigKeys.DFS_PERMISSIONS_SUPERUSERGROUP_DEFAULT); |
197 | | - this.erasureCoding = new ErasureCoding(rpcServer); |
198 | | - this.storagePolicy = new RouterStoragePolicy(rpcServer); |
199 | | - this.snapshotProto = new RouterSnapshot(rpcServer); |
200 | | - this.routerCacheAdmin = new RouterCacheAdmin(rpcServer); |
| 201 | + if (rpcServer.isAsync()) { |
| 202 | + this.erasureCoding = new AsyncErasureCoding(rpcServer); |
| 203 | + this.storagePolicy = new RouterAsyncStoragePolicy(rpcServer); |
| 204 | + this.snapshotProto = new RouterAsyncSnapshot(rpcServer); |
| 205 | + this.routerCacheAdmin = new RouterAsyncCacheAdmin(rpcServer); |
| 206 | + } else { |
| 207 | + this.erasureCoding = new ErasureCoding(rpcServer); |
| 208 | + this.storagePolicy = new RouterStoragePolicy(rpcServer); |
| 209 | + this.snapshotProto = new RouterSnapshot(rpcServer); |
| 210 | + this.routerCacheAdmin = new RouterCacheAdmin(rpcServer); |
| 211 | + } |
201 | 212 | this.securityManager = rpcServer.getRouterSecurityManager(); |
202 | 213 | this.rbfRename = new RouterFederationRename(rpcServer, conf); |
203 | 214 | this.defaultNameServiceEnabled = conf.getBoolean( |
@@ -831,6 +842,10 @@ public int compare(byte[] o1, byte[] o2) { |
831 | 842 | private static GetListingComparator comparator = |
832 | 843 | new GetListingComparator(); |
833 | 844 |
|
| 845 | + public static GetListingComparator getComparator() { |
| 846 | + return comparator; |
| 847 | + } |
| 848 | + |
834 | 849 | @Override |
835 | 850 | public DirectoryListing getListing(String src, byte[] startAfter, |
836 | 851 | boolean needLocation) throws IOException { |
@@ -1338,9 +1353,9 @@ Map<String, List<RemoteLocation>> getAllLocations(String path) throws IOExceptio |
1338 | 1353 | * Get all the locations of the path for {@link RouterClientProtocol#getContentSummary(String)}. |
1339 | 1354 | * For example, there are some mount points: |
1340 | 1355 | * <p> |
1341 | | - * /a -> ns0 -> /a |
1342 | | - * /a/b -> ns0 -> /a/b |
1343 | | - * /a/b/c -> ns1 -> /a/b/c |
| 1356 | + * /a - > ns0 - > /a |
| 1357 | + * /a/b - > ns0 - > /a/b |
| 1358 | + * /a/b/c - > ns1 - > /a/b/c |
1344 | 1359 | * </p> |
1345 | 1360 | * When the path is '/a', the result of locations should be |
1346 | 1361 | * [RemoteLocation('/a', ns0, '/a'), RemoteLocation('/a/b/c', ns1, '/a/b/c')] |
@@ -2042,7 +2057,7 @@ public HAServiceProtocol.HAServiceState getHAServiceState() { |
2042 | 2057 | * replacement value. |
2043 | 2058 | * @throws IOException If the dst paths could not be determined. |
2044 | 2059 | */ |
2045 | | - private RemoteParam getRenameDestinations( |
| 2060 | + protected RemoteParam getRenameDestinations( |
2046 | 2061 | final List<RemoteLocation> srcLocations, |
2047 | 2062 | final List<RemoteLocation> dstLocations) throws IOException { |
2048 | 2063 |
|
@@ -2210,7 +2225,7 @@ protected static FsPermission getParentPermission(final FsPermission mask) { |
2210 | 2225 | * @return New HDFS file status representing a mount point. |
2211 | 2226 | */ |
2212 | 2227 | @VisibleForTesting |
2213 | | - HdfsFileStatus getMountPointStatus( |
| 2228 | + protected HdfsFileStatus getMountPointStatus( |
2214 | 2229 | String name, int childrenNum, long date) { |
2215 | 2230 | return getMountPointStatus(name, childrenNum, date, true); |
2216 | 2231 | } |
@@ -2433,7 +2448,7 @@ protected static boolean shouldAddMountPoint( |
2433 | 2448 | * @throws IOException if unable to get the file status. |
2434 | 2449 | */ |
2435 | 2450 | @VisibleForTesting |
2436 | | - boolean isMultiDestDirectory(String src) throws IOException { |
| 2451 | + protected boolean isMultiDestDirectory(String src) throws IOException { |
2437 | 2452 | try { |
2438 | 2453 | if (rpcServer.isPathAll(src)) { |
2439 | 2454 | List<RemoteLocation> locations; |
@@ -2502,11 +2517,11 @@ public RouterStoragePolicy getStoragePolicy() { |
2502 | 2517 | return storagePolicy; |
2503 | 2518 | } |
2504 | 2519 |
|
2505 | | - public void setServerDefaults(FsServerDefaults serverDefaults) { |
2506 | | - this.serverDefaults = serverDefaults; |
2507 | | - } |
2508 | | - |
2509 | 2520 | public void setServerDefaultsLastUpdate(long serverDefaultsLastUpdate) { |
2510 | 2521 | this.serverDefaultsLastUpdate = serverDefaultsLastUpdate; |
2511 | 2522 | } |
| 2523 | + |
| 2524 | + public RouterFederationRename getRbfRename() { |
| 2525 | + return rbfRename; |
| 2526 | + } |
2512 | 2527 | } |
0 commit comments