diff --git a/core/common/src/main/java/alluxio/util/OSUtils.java b/core/common/src/main/java/alluxio/util/OSUtils.java index 4b86dac1d73f..e1d525671a07 100644 --- a/core/common/src/main/java/alluxio/util/OSUtils.java +++ b/core/common/src/main/java/alluxio/util/OSUtils.java @@ -28,6 +28,10 @@ public final class OSUtils { public static final String JAVA_VENDOR_NAME = System.getProperty("java.vendor"); /** Indicates the current java vendor is IBM java or not. */ public static final boolean IBM_JAVA = JAVA_VENDOR_NAME.contains("IBM"); + /** The maximum path length supported by a domain socket on unix varies depending on the + * operating system. The conservative limit is returned here. + * */ + public static final int UNIX_SOCKET_MAX_PATH_LENGTH = 100; /** * @return true if current processor is 64 bit @@ -64,5 +68,12 @@ public static boolean isAIX() { return OSUtils.OS_NAME.equals("AIX"); } + /*** + * @return the maximum path length supported by a domain socket on unix + */ + public static int getDomainSocketMaxPathLength() { + return OSUtils.UNIX_SOCKET_MAX_PATH_LENGTH; + } + private OSUtils() {} // prevent instantiation } diff --git a/core/server/worker/src/main/java/alluxio/worker/AlluxioWorkerProcess.java b/core/server/worker/src/main/java/alluxio/worker/AlluxioWorkerProcess.java index 88d3170351b2..d73d7ecab1b0 100644 --- a/core/server/worker/src/main/java/alluxio/worker/AlluxioWorkerProcess.java +++ b/core/server/worker/src/main/java/alluxio/worker/AlluxioWorkerProcess.java @@ -20,6 +20,7 @@ import alluxio.underfs.WorkerUfsManager; import alluxio.util.CommonUtils; import alluxio.util.JvmPauseMonitor; +import alluxio.util.OSUtils; import alluxio.util.WaitForOptions; import alluxio.util.io.FileUtils; import alluxio.util.io.PathUtils; @@ -33,6 +34,7 @@ import alluxio.worker.block.BlockWorker; import alluxio.worker.grpc.GrpcDataServer; +import com.google.common.base.Preconditions; import io.netty.channel.unix.DomainSocketAddress; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -144,6 +146,9 @@ public final class AlluxioWorkerProcess implements WorkerProcess { domainSocketPath = PathUtils.concatPath(domainSocketPath, UUID.randomUUID().toString()); } + Preconditions.checkState(domainSocketPath.length() < OSUtils.getDomainSocketMaxPathLength(), + "The longest domain socket path possible on this host is %d bytes.", + OSUtils.getDomainSocketMaxPathLength()); LOG.info("Domain socket data server is enabled at {}.", domainSocketPath); mDomainSocketDataServer = new GrpcDataServer(mRpcConnectAddress.getHostName(), new DomainSocketAddress(domainSocketPath), this);