diff --git a/shell/src/main/java/alluxio/cli/fs/command/LoadCommand.java b/shell/src/main/java/alluxio/cli/fs/command/LoadCommand.java index 36115b5adf1a..1f8f4be6d3e3 100644 --- a/shell/src/main/java/alluxio/cli/fs/command/LoadCommand.java +++ b/shell/src/main/java/alluxio/cli/fs/command/LoadCommand.java @@ -168,15 +168,21 @@ private void cacheBlock(long blockId, WorkerNetAddress dataSource, boolean local URIStatus status, Protocol.OpenUfsBlockOptions options) { BlockInfo info = status.getBlockInfo(blockId); long blockLength = info.getLength(); + String host = dataSource.getHost(); + // issues#11172: If the worker is in a container, use the container hostname + // to establish the connection. + if (!dataSource.getContainerHost().equals("")) { + host = dataSource.getContainerHost(); + } CacheRequest request = CacheRequest.newBuilder().setBlockId(blockId).setLength(blockLength) - .setOpenUfsBlockOptions(options).setSourceHost(dataSource.getHost()) + .setOpenUfsBlockOptions(options).setSourceHost(host) .setSourcePort(dataSource.getDataPort()).build(); try (CloseableResource blockWorker = mFsContext.acquireBlockWorkerClient(dataSource)) { blockWorker.get().cache(request); } catch (Exception e) { System.out.printf("Failed to complete cache request for block %d of file %s: %s", blockId, - status.getPath(), e.toString()); + status.getPath(), e); } } }