Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wk1234123
DolphinScheduler
提交
7473d5e9
DolphinScheduler
项目概览
wk1234123
/
DolphinScheduler
与 Fork 源项目一致
Fork自
apache / DolphinScheduler
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
DolphinScheduler
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
7473d5e9
编写于
3月 12, 2020
作者:
G
gabry.wu
提交者:
GitHub
3月 12, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adapting partial code(file name start with H) to the sonar cloud rule (#2145)
上级
9fda4da7
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
33 addition
and
40 deletion
+33
-40
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java
...org/apache/dolphinscheduler/common/utils/HadoopUtils.java
+11
-15
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HttpUtils.java
...a/org/apache/dolphinscheduler/common/utils/HttpUtils.java
+5
-7
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/PropertyUtils.java
...g/apache/dolphinscheduler/common/utils/PropertyUtils.java
+1
-1
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/HttpUtilsTest.java
...g/apache/dolphinscheduler/common/utils/HttpUtilsTest.java
+1
-1
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/datasource/HiveDataSource.java
...pache/dolphinscheduler/dao/datasource/HiveDataSource.java
+1
-1
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/http/HttpTask.java
...he/dolphinscheduler/server/worker/task/http/HttpTask.java
+14
-15
未找到文件。
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java
浏览文件 @
7473d5e9
...
...
@@ -32,7 +32,9 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
java.io.*
;
import
java.nio.file.Files
;
import
java.security.PrivilegedExceptionAction
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
...
...
@@ -46,16 +48,14 @@ public class HadoopUtils implements Closeable {
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
HadoopUtils
.
class
);
private
static
String
hdfsUser
=
PropertyUtils
.
getString
(
Constants
.
HDFS_ROOT_USER
);
private
static
volatile
HadoopUtils
instance
=
new
HadoopUtils
();
private
static
volatile
Configuration
configuration
;
private
static
HadoopUtils
instance
=
new
HadoopUtils
();
private
static
Configuration
configuration
;
private
static
FileSystem
fs
;
private
String
hdfsUser
;
private
HadoopUtils
(){
if
(
StringUtils
.
isEmpty
(
hdfsUser
)){
hdfsUser
=
PropertyUtils
.
getString
(
Constants
.
HDFS_ROOT_USER
);
}
hdfsUser
=
PropertyUtils
.
getString
(
Constants
.
HDFS_ROOT_USER
);
init
();
initHdfsPath
();
}
...
...
@@ -129,7 +129,6 @@ public class HadoopUtils implements Closeable {
if
(
fs
==
null
)
{
if
(
StringUtils
.
isNotEmpty
(
hdfsUser
)){
//UserGroupInformation ugi = UserGroupInformation.createProxyUser(hdfsUser,UserGroupInformation.getLoginUser());
UserGroupInformation
ugi
=
UserGroupInformation
.
createRemoteUser
(
hdfsUser
);
ugi
.
doAs
(
new
PrivilegedExceptionAction
<
Boolean
>()
{
@Override
...
...
@@ -196,7 +195,7 @@ public class HadoopUtils implements Closeable {
if
(
StringUtils
.
isBlank
(
hdfsFilePath
)){
logger
.
error
(
"hdfs file path:{} is blank"
,
hdfsFilePath
);
return
n
ull
;
return
n
ew
byte
[
0
]
;
}
FSDataInputStream
fsDataInputStream
=
fs
.
open
(
new
Path
(
hdfsFilePath
));
...
...
@@ -218,7 +217,7 @@ public class HadoopUtils implements Closeable {
if
(
StringUtils
.
isBlank
(
hdfsFilePath
)){
logger
.
error
(
"hdfs file path:{} is blank"
,
hdfsFilePath
);
return
null
;
return
Collections
.
emptyList
()
;
}
try
(
FSDataInputStream
in
=
fs
.
open
(
new
Path
(
hdfsFilePath
))){
...
...
@@ -293,7 +292,7 @@ public class HadoopUtils implements Closeable {
if
(
dstPath
.
exists
())
{
if
(
dstPath
.
isFile
())
{
if
(
overwrite
)
{
dstPath
.
delete
(
);
Files
.
delete
(
dstPath
.
toPath
()
);
}
}
else
{
logger
.
error
(
"destination file must be a file"
);
...
...
@@ -378,7 +377,7 @@ public class HadoopUtils implements Closeable {
String
responseContent
=
HttpUtils
.
get
(
applicationUrl
);
JSONObject
jsonObject
=
JSON
Object
.
parseObject
(
responseContent
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
responseContent
);
String
result
=
jsonObject
.
getJSONObject
(
"app"
).
getString
(
"finalStatus"
);
switch
(
result
)
{
...
...
@@ -525,8 +524,6 @@ public class HadoopUtils implements Closeable {
*/
private
static
final
class
YarnHAAdminUtils
extends
RMAdminCLI
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
YarnHAAdminUtils
.
class
);
/**
* get active resourcemanager
*
...
...
@@ -585,8 +582,7 @@ public class HadoopUtils implements Closeable {
JSONObject
jsonObject
=
JSON
.
parseObject
(
retStr
);
//get ResourceManager state
String
state
=
jsonObject
.
getJSONObject
(
"clusterInfo"
).
getString
(
"haState"
);
return
state
;
return
jsonObject
.
getJSONObject
(
"clusterInfo"
).
getString
(
"haState"
);
}
}
...
...
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HttpUtils.java
浏览文件 @
7473d5e9
...
...
@@ -81,17 +81,15 @@ public class HttpUtils {
logger
.
error
(
e
.
getMessage
(),
e
);
}
if
(
httpget
!=
null
&&
!
httpget
.
isAborted
())
{
if
(!
httpget
.
isAborted
())
{
httpget
.
releaseConnection
();
httpget
.
abort
();
}
if
(
httpclient
!=
null
)
{
try
{
httpclient
.
close
();
}
catch
(
IOException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
try
{
httpclient
.
close
();
}
catch
(
IOException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
}
return
responseContent
;
...
...
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/PropertyUtils.java
浏览文件 @
7473d5e9
...
...
@@ -125,7 +125,7 @@ public class PropertyUtils {
* @param key property name
* @return property value
*/
public
static
B
oolean
getBoolean
(
String
key
)
{
public
static
b
oolean
getBoolean
(
String
key
)
{
String
value
=
properties
.
getProperty
(
key
.
trim
());
if
(
null
!=
value
){
return
Boolean
.
parseBoolean
(
value
);
...
...
dolphinscheduler-common/src/test/java/org/apache/dolphinscheduler/common/utils/HttpUtilsTest.java
浏览文件 @
7473d5e9
...
...
@@ -38,7 +38,7 @@ public class HttpUtilsTest {
String
result
=
HttpUtils
.
get
(
"https://github.com/manifest.json"
);
Assert
.
assertNotNull
(
result
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
result
);
Assert
.
assertEquals
(
jsonObject
.
getString
(
"name"
),
"GitHub"
);
Assert
.
assertEquals
(
"GitHub"
,
jsonObject
.
getString
(
"name"
)
);
result
=
HttpUtils
.
get
(
"https://123.333.111.33/ccc"
);
Assert
.
assertNull
(
result
);
...
...
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/datasource/HiveDataSource.java
浏览文件 @
7473d5e9
...
...
@@ -39,7 +39,7 @@ public class HiveDataSource extends BaseDataSource {
@Override
public
String
getJdbcUrl
()
{
String
jdbcUrl
=
getAddress
();
if
(
jdbcUrl
.
lastIndexOf
(
"/"
)
!=
(
jdbcUrl
.
length
()
-
1
))
{
if
(
jdbcUrl
.
lastIndexOf
(
'/'
)
!=
(
jdbcUrl
.
length
()
-
1
))
{
jdbcUrl
+=
"/"
;
}
...
...
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/http/HttpTask.java
浏览文件 @
7473d5e9
...
...
@@ -17,6 +17,7 @@
package
org.apache.dolphinscheduler.server.worker.task.http
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
org.apache.commons.io.Charsets
;
import
org.apache.dolphinscheduler.common.Constants
;
...
...
@@ -26,6 +27,7 @@ import org.apache.dolphinscheduler.common.process.HttpProperty;
import
org.apache.dolphinscheduler.common.process.Property
;
import
org.apache.dolphinscheduler.common.task.AbstractParameters
;
import
org.apache.dolphinscheduler.common.task.http.HttpParameters
;
import
org.apache.dolphinscheduler.common.utils.CollectionUtils
;
import
org.apache.dolphinscheduler.common.utils.DateUtils
;
import
org.apache.dolphinscheduler.common.utils.ParameterUtils
;
import
org.apache.dolphinscheduler.common.utils.StringUtils
;
...
...
@@ -51,6 +53,7 @@ import org.slf4j.Logger;
import
java.io.IOException
;
import
java.nio.charset.StandardCharsets
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -98,7 +101,7 @@ public class HttpTask extends AbstractTask {
@Override
public
void
init
()
{
logger
.
info
(
"http task params {}"
,
taskProps
.
getTaskParams
());
this
.
httpParameters
=
JSON
Object
.
parseObject
(
taskProps
.
getTaskParams
(),
HttpParameters
.
class
);
this
.
httpParameters
=
JSON
.
parseObject
(
taskProps
.
getTaskParams
(),
HttpParameters
.
class
);
if
(!
httpParameters
.
checkParameters
())
{
throw
new
RuntimeException
(
"http task params is not valid"
);
...
...
@@ -146,12 +149,12 @@ public class HttpTask extends AbstractTask {
processInstance
.
getCmdTypeIfComplement
(),
processInstance
.
getScheduleTime
());
List
<
HttpProperty
>
httpPropertyList
=
new
ArrayList
<>();
if
(
httpParameters
.
getHttpParams
()
!=
null
&&
httpParameters
.
getHttpParams
().
size
()
>
0
){
if
(
CollectionUtils
.
isNotEmpty
(
httpParameters
.
getHttpParams
()
)
){
for
(
HttpProperty
httpProperty:
httpParameters
.
getHttpParams
())
{
String
jsonObject
=
JSON
Object
.
toJSONString
(
httpProperty
);
String
jsonObject
=
JSON
.
toJSONString
(
httpProperty
);
String
params
=
ParameterUtils
.
convertParameterPlaceholders
(
jsonObject
,
ParamUtils
.
convert
(
paramsMap
));
logger
.
info
(
"http request params:{}"
,
params
);
httpPropertyList
.
add
(
JSON
Object
.
parseObject
(
params
,
HttpProperty
.
class
));
httpPropertyList
.
add
(
JSON
.
parseObject
(
params
,
HttpProperty
.
class
));
}
}
addRequestParams
(
builder
,
httpPropertyList
);
...
...
@@ -176,8 +179,7 @@ public class HttpTask extends AbstractTask {
if
(
entity
==
null
)
{
return
null
;
}
String
webPage
=
EntityUtils
.
toString
(
entity
,
StandardCharsets
.
UTF_8
.
name
());
return
webPage
;
return
EntityUtils
.
toString
(
entity
,
StandardCharsets
.
UTF_8
.
name
());
}
/**
...
...
@@ -186,8 +188,7 @@ public class HttpTask extends AbstractTask {
* @return status code
*/
protected
int
getStatusCode
(
CloseableHttpResponse
httpResponse
)
{
int
status
=
httpResponse
.
getStatusLine
().
getStatusCode
();
return
status
;
return
httpResponse
.
getStatusLine
().
getStatusCode
();
}
/**
...
...
@@ -252,7 +253,7 @@ public class HttpTask extends AbstractTask {
* @param httpPropertyList http property list
*/
protected
void
addRequestParams
(
RequestBuilder
builder
,
List
<
HttpProperty
>
httpPropertyList
)
{
if
(
httpPropertyList
!=
null
&&
httpPropertyList
.
size
()
>
0
){
if
(
CollectionUtils
.
isNotEmpty
(
httpPropertyList
)
){
JSONObject
jsonParam
=
new
JSONObject
();
for
(
HttpProperty
property:
httpPropertyList
){
if
(
property
.
getHttpParametersType
()
!=
null
){
...
...
@@ -276,12 +277,10 @@ public class HttpTask extends AbstractTask {
* @param httpPropertyList http property list
*/
protected
void
setHeaders
(
HttpUriRequest
request
,
List
<
HttpProperty
>
httpPropertyList
)
{
if
(
httpPropertyList
!=
null
&&
httpPropertyList
.
size
()
>
0
){
for
(
HttpProperty
property:
httpPropertyList
){
if
(
property
.
getHttpParametersType
()
!=
null
)
{
if
(
property
.
getHttpParametersType
().
equals
(
HttpParametersType
.
HEADERS
))
{
request
.
addHeader
(
property
.
getProp
(),
property
.
getValue
());
}
if
(
CollectionUtils
.
isNotEmpty
(
httpPropertyList
)){
for
(
HttpProperty
property:
httpPropertyList
)
{
if
(
HttpParametersType
.
HEADERS
.
equals
(
property
.
getHttpParametersType
()))
{
request
.
addHeader
(
property
.
getProp
(),
property
.
getValue
());
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录