Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
doujutun3207
flink
提交
f5d3c722
F
flink
项目概览
doujutun3207
/
flink
与 Fork 源项目一致
从无法访问的项目Fork
通知
24
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
flink
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f5d3c722
编写于
8月 22, 2017
作者:
A
Aljoscha Krettek
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[FLINK-2268] Only print Hadoop env info if Hadoop is in the classpath
上级
5bdcf9b2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
41 addition
and
16 deletion
+41
-16
flink-runtime/src/main/java/org/apache/flink/runtime/util/EnvironmentInformation.java
...org/apache/flink/runtime/util/EnvironmentInformation.java
+39
-15
flink-runtime/src/test/java/org/apache/flink/runtime/util/EnvironmentInformationTest.java
...apache/flink/runtime/util/EnvironmentInformationTest.java
+2
-1
未找到文件。
flink-runtime/src/main/java/org/apache/flink/runtime/util/EnvironmentInformation.java
浏览文件 @
f5d3c722
...
...
@@ -26,13 +26,10 @@ import java.util.List;
import
java.util.Properties
;
import
org.apache.flink.util.OperatingSystem
;
import
org.apache.hadoop.util.VersionInfo
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.apache.hadoop.security.UserGroupInformation
;
/**
* Utility class that gives access to the execution environment of the JVM, like
* the executing user, startup options, or the JVM version.
...
...
@@ -87,9 +84,20 @@ public class EnvironmentInformation {
*
* @return The name of the user that is running the JVM.
*/
public
static
String
get
UserRunning
()
{
public
static
String
get
HadoopUser
()
{
try
{
return
UserGroupInformation
.
getCurrentUser
().
getShortUserName
();
Class
<?>
ugiClass
=
Class
.
forName
(
"org.apache.hadoop.security.UserGroupInformation"
,
false
,
EnvironmentInformation
.
class
.
getClassLoader
());
Method
currentUserMethod
=
ugiClass
.
getMethod
(
"getCurrentUser"
);
Method
shortUserNameMethod
=
ugiClass
.
getMethod
(
"getShortUserName"
);
Object
ugi
=
currentUserMethod
.
invoke
(
null
);
return
(
String
)
shortUserNameMethod
.
invoke
(
ugi
);
}
catch
(
ClassNotFoundException
e
)
{
return
"<no hadoop dependency found>"
;
}
catch
(
LinkageError
e
)
{
// hadoop classes are not in the classpath
...
...
@@ -101,12 +109,7 @@ public class EnvironmentInformation {
LOG
.
warn
(
"Error while accessing user/group information via Hadoop utils."
,
t
);
}
String
user
=
System
.
getProperty
(
"user.name"
);
if
(
user
==
null
)
{
user
=
UNKNOWN
;
LOG
.
debug
(
"Cannot determine user/group information for the current user."
);
}
return
user
;
return
UNKNOWN
;
}
/**
...
...
@@ -268,8 +271,6 @@ public class EnvironmentInformation {
RevisionInformation
rev
=
getRevisionInformation
();
String
version
=
getVersion
();
String
user
=
getUserRunning
();
String
jvmVersion
=
getJvmVersion
();
String
[]
options
=
getJvmStartupOptionsArray
();
...
...
@@ -280,11 +281,18 @@ public class EnvironmentInformation {
log
.
info
(
"--------------------------------------------------------------------------------"
);
log
.
info
(
" Starting "
+
componentName
+
" (Version: "
+
version
+
", "
+
"Rev:"
+
rev
.
commitId
+
", "
+
"Date:"
+
rev
.
commitDate
+
")"
);
log
.
info
(
" Current user: "
+
user
);
log
.
info
(
" OS current user: "
+
System
.
getProperty
(
"user.name"
));
log
.
info
(
" Current Hadoop/Kerberos user: "
+
getHadoopUser
());
log
.
info
(
" JVM: "
+
jvmVersion
);
log
.
info
(
" Maximum heap size: "
+
maxHeapMegabytes
+
" MiBytes"
);
log
.
info
(
" JAVA_HOME: "
+
(
javaHome
==
null
?
"(not set)"
:
javaHome
));
log
.
info
(
" Hadoop version: "
+
VersionInfo
.
getVersion
());
String
hadoopVersionString
=
getHadoopVersionString
();
if
(
hadoopVersionString
!=
null
)
{
log
.
info
(
" Hadoop version: "
+
hadoopVersionString
);
}
else
{
log
.
info
(
" No Hadoop Dependency available"
);
}
if
(
options
.
length
==
0
)
{
log
.
info
(
" JVM Options: (none)"
);
...
...
@@ -312,6 +320,22 @@ public class EnvironmentInformation {
}
}
public
static
String
getHadoopVersionString
()
{
try
{
Class
<?>
versionInfoClass
=
Class
.
forName
(
"org.apache.hadoop.util.VersionInfo"
,
false
,
EnvironmentInformation
.
class
.
getClassLoader
());
Method
method
=
versionInfoClass
.
getMethod
(
"getVersion"
);
return
(
String
)
method
.
invoke
(
null
);
}
catch
(
ClassNotFoundException
|
NoSuchMethodException
e
)
{
return
null
;
}
catch
(
Throwable
e
)
{
LOG
.
error
(
"Cannot invoke VersionInfo.getVersion reflectively."
,
e
);
return
null
;
}
}
// --------------------------------------------------------------------------------------------
/** Don't instantiate this class */
...
...
flink-runtime/src/test/java/org/apache/flink/runtime/util/EnvironmentInformationTest.java
浏览文件 @
f5d3c722
...
...
@@ -63,7 +63,8 @@ public class EnvironmentInformationTest {
assertNotNull
(
EnvironmentInformation
.
getJvmVersion
());
assertNotNull
(
EnvironmentInformation
.
getRevisionInformation
());
assertNotNull
(
EnvironmentInformation
.
getVersion
());
assertNotNull
(
EnvironmentInformation
.
getUserRunning
());
EnvironmentInformation
.
getHadoopVersionString
();
assertNotNull
(
EnvironmentInformation
.
getHadoopUser
());
assertTrue
(
EnvironmentInformation
.
getOpenFileHandlesLimit
()
>=
-
1
);
}
catch
(
Exception
e
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录