From 45a2248a9879a839e79cc423f27be132a921af7e Mon Sep 17 00:00:00 2001 From: fyz <906328924@qq.com> Date: Fri, 19 Oct 2018 15:12:49 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=89=93=E5=BC=80=E5=B7=B2?= =?UTF-8?q?=E7=BB=8F=E9=85=8D=E7=BD=AE=E6=8F=92=E4=BB=B6=E7=9A=84=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E6=97=B6=E5=A6=82=E6=9E=9C=E6=B2=A1=E6=9C=89=E5=AF=B9?= =?UTF-8?q?=E5=BA=94=E7=9A=84hadoop=E7=8E=AF=E5=A2=83=EF=BC=8Cidea?= =?UTF-8?q?=E6=89=93=E5=BC=80=E8=B6=85=E6=9E=81=E6=85=A2=EF=BC=8C=E5=8D=A1?= =?UTF-8?q?=E6=AD=BB=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fangyuzhong/intelliJ/hadoop/core/Constants.java | 8 ++++++++ .../hadoop/fsconnection/ConnectionHandlerImpl.java | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/src/main/java/com/fangyuzhong/intelliJ/hadoop/core/Constants.java b/src/main/java/com/fangyuzhong/intelliJ/hadoop/core/Constants.java index eeb4fe9..1614c18 100755 --- a/src/main/java/com/fangyuzhong/intelliJ/hadoop/core/Constants.java +++ b/src/main/java/com/fangyuzhong/intelliJ/hadoop/core/Constants.java @@ -11,4 +11,12 @@ public class Constants public static final String FS_FILE_IMPL_VALUE = "org.apache.hadoop.fs.LocalFileSystem"; public static final String FS_DEFAULTFS_KEY = "fs.defaultFS"; public static final String YARN_RESOURCEMANAGER_SCHEDULER_ADDRESS="yarn.resourcemanager.scheduler.address"; + /** + *IPC 超时重试次数 + */ + public static final String IPC_CLIENT_CONNECT_MAX_RETRIES_ON_TIMEOUTS ="ipc.client.connect.max.retries.on.timeouts"; + /** + * IPC 超时设置 + */ + public static final String IPC_CLIENT_CONNECT_TIMEOUT="ipc.client.connect.timeout"; } \ No newline at end of file diff --git a/src/main/java/com/fangyuzhong/intelliJ/hadoop/fsconnection/ConnectionHandlerImpl.java b/src/main/java/com/fangyuzhong/intelliJ/hadoop/fsconnection/ConnectionHandlerImpl.java index 297b4ec..03381ad 100755 --- a/src/main/java/com/fangyuzhong/intelliJ/hadoop/fsconnection/ConnectionHandlerImpl.java +++ b/src/main/java/com/fangyuzhong/intelliJ/hadoop/fsconnection/ConnectionHandlerImpl.java @@ -71,6 +71,10 @@ public ConnectionHandlerImpl(ConnectionBundle connectionBundle, ConnectionSettin configurationHdfs.set(Constants.FS_FILE_IMPL_KEY,Constants.FS_FILE_IMPL_VALUE); configurationHdfs.set(Constants.FS_DEFAULTFS_KEY, hdfsPath); configurationHdfs.set(Constants.YARN_RESOURCEMANAGER_SCHEDULER_ADDRESS,yarnResourceAMPath); + /*************解决卡死的问题*******************************************************/ + configurationHdfs.set(Constants.IPC_CLIENT_CONNECT_TIMEOUT, "3000"); //默认连接3s超时 + configurationHdfs.set(Constants.IPC_CLIENT_CONNECT_MAX_RETRIES_ON_TIMEOUTS, "1");// 超时后重试1次 + /*********************************************************************************/ //通过配置初始化HDFS的FileSystem InitiFileSystem(configurationHdfs); } @@ -187,6 +191,8 @@ public boolean createTestConnection() throws IOException } else { + fileSystem.getConf().set(Constants.IPC_CLIENT_CONNECT_TIMEOUT, "3000"); //默认连接3s超时 + fileSystem.getConf().set(Constants.IPC_CLIENT_CONNECT_MAX_RETRIES_ON_TIMEOUTS, "1");// 超时后重试1次 canConnection = fileSystem.exists(new Path("/")); } return canConnection;