Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
DolphinScheduler
提交
98ab5219
DolphinScheduler
项目概览
apache
/
DolphinScheduler
上一次同步 1 年多
通知
705
Star
9572
Fork
3514
代码
文件
提交
分支
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,体验更适合开发者的 AI 搜索 >>
未验证
提交
98ab5219
编写于
12月 06, 2021
作者:
K
kezhenxu94
提交者:
GitHub
12月 06, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix SQL create / upgrade scripts cannot run (#7212)
上级
58f5f398
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
17 addition
and
148 deletion
+17
-148
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/SchemaUtils.java
...org/apache/dolphinscheduler/common/utils/SchemaUtils.java
+0
-145
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/DolphinSchedulerManager.java
...dolphinscheduler/dao/upgrade/DolphinSchedulerManager.java
+0
-1
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/UpgradeDao.java
...a/org/apache/dolphinscheduler/dao/upgrade/UpgradeDao.java
+4
-0
dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.0_schema/postgresql/dolphinscheduler_ddl.sql
.../upgrade/2.0.0_schema/postgresql/dolphinscheduler_ddl.sql
+2
-1
dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.1_schema/mysql/dolphinscheduler_ddl.sql
...s/sql/upgrade/2.0.1_schema/mysql/dolphinscheduler_ddl.sql
+0
-0
dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.1_schema/postgre/dolphinscheduler_ddl.sql
...sql/upgrade/2.0.1_schema/postgre/dolphinscheduler_ddl.sql
+1
-1
script/create-dolphinscheduler.sh
script/create-dolphinscheduler.sh
+5
-0
script/upgrade-dolphinscheduler.sh
script/upgrade-dolphinscheduler.sh
+5
-0
未找到文件。
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/SchemaUtils.java
已删除
100644 → 0
浏览文件 @
58f5f398
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.dolphinscheduler.common.utils
;
import
org.apache.commons.lang.StringUtils
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileNotFoundException
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* Metadata related common classes
*/
public
class
SchemaUtils
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
SchemaUtils
.
class
);
private
static
final
Pattern
p
=
Pattern
.
compile
(
"\\s*|\t|\r|\n"
);
private
SchemaUtils
()
{
throw
new
UnsupportedOperationException
(
"Construct SchemaUtils"
);
}
/**
* Gets upgradable schemas for all upgrade directories
*
* @return all schema list
*/
public
static
List
<
String
>
getAllSchemaList
()
{
List
<
String
>
schemaDirList
=
new
ArrayList
<>();
File
[]
schemaDirArr
=
FileUtils
.
getAllDir
(
"sql/upgrade"
);
if
(
schemaDirArr
==
null
||
schemaDirArr
.
length
==
0
)
{
return
null
;
}
for
(
File
file
:
schemaDirArr
)
{
schemaDirList
.
add
(
file
.
getName
());
}
schemaDirList
.
sort
((
o1
,
o2
)
->
{
try
{
String
dir1
=
String
.
valueOf
(
o1
);
String
dir2
=
String
.
valueOf
(
o2
);
String
version1
=
dir1
.
split
(
"_"
)[
0
];
String
version2
=
dir2
.
split
(
"_"
)[
0
];
if
(
version1
.
equals
(
version2
))
{
return
0
;
}
if
(
SchemaUtils
.
isAGreatVersion
(
version1
,
version2
))
{
return
1
;
}
return
-
1
;
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
throw
new
RuntimeException
(
e
);
}
});
return
schemaDirList
;
}
/**
* Determine whether schemaVersion is higher than version
*
* @param schemaVersion schema version
* @param version version
* @return Determine whether schemaVersion is higher than version
*/
public
static
boolean
isAGreatVersion
(
String
schemaVersion
,
String
version
)
{
if
(
StringUtils
.
isEmpty
(
schemaVersion
)
||
StringUtils
.
isEmpty
(
version
))
{
throw
new
RuntimeException
(
"schemaVersion or version is empty"
);
}
String
[]
schemaVersionArr
=
schemaVersion
.
split
(
"\\."
);
String
[]
versionArr
=
version
.
split
(
"\\."
);
int
arrLength
=
Math
.
min
(
schemaVersionArr
.
length
,
versionArr
.
length
);
for
(
int
i
=
0
;
i
<
arrLength
;
i
++)
{
if
(
Integer
.
parseInt
(
schemaVersionArr
[
i
])
>
Integer
.
parseInt
(
versionArr
[
i
]))
{
return
true
;
}
else
if
(
Integer
.
parseInt
(
schemaVersionArr
[
i
])
<
Integer
.
parseInt
(
versionArr
[
i
]))
{
return
false
;
}
}
// If the version and schema version is the same from 0 up to the arrlength-1 element,whoever has a larger arrLength has a larger version number
return
schemaVersionArr
.
length
>
versionArr
.
length
;
}
/**
* Gets the current software version number of the system
*
* @return current software version
*/
public
static
String
getSoftVersion
()
{
String
softVersion
;
try
{
softVersion
=
FileUtils
.
readFile2Str
(
new
FileInputStream
(
"sql/soft_version"
));
softVersion
=
replaceBlank
(
softVersion
);
}
catch
(
FileNotFoundException
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
throw
new
RuntimeException
(
"Failed to get the product version description file. The file could not be found"
,
e
);
}
return
softVersion
;
}
/**
* Strips the string of space carriage returns and tabs
*
* @param str string
* @return string removed blank
*/
public
static
String
replaceBlank
(
String
str
)
{
String
dest
=
""
;
if
(
str
!=
null
)
{
Matcher
m
=
p
.
matcher
(
str
);
dest
=
m
.
replaceAll
(
""
);
}
return
dest
;
}
}
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/DolphinSchedulerManager.java
浏览文件 @
98ab5219
...
...
@@ -17,7 +17,6 @@
package
org.apache.dolphinscheduler.dao.upgrade
;
import
org.apache.dolphinscheduler.common.utils.SchemaUtils
;
import
org.apache.dolphinscheduler.spi.enums.DbType
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/upgrade/UpgradeDao.java
浏览文件 @
98ab5219
...
...
@@ -288,6 +288,10 @@ public abstract class UpgradeDao {
private
void
upgradeDolphinSchedulerDML
(
String
schemaDir
)
{
String
schemaVersion
=
schemaDir
.
split
(
"_"
)[
0
];
Resource
sqlFilePath
=
new
ClassPathResource
(
String
.
format
(
"sql/upgrade/%s/%s/dolphinscheduler_dml.sql"
,
schemaDir
,
getDbType
().
name
().
toLowerCase
()));
if
(!
sqlFilePath
.
exists
())
{
logger
.
info
(
"No dml file {}, returning"
,
sqlFilePath
);
return
;
}
logger
.
info
(
"sqlSQLFilePath"
+
sqlFilePath
);
Connection
conn
=
null
;
PreparedStatement
pstmt
=
null
;
...
...
dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.0_schema/postgresql/dolphinscheduler_ddl.sql
浏览文件 @
98ab5219
...
...
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
delimiter
d
//
CREATE
OR
REPLACE
FUNCTION
public
.
dolphin_update_metadata
(
)
RETURNS
character
varying
...
...
@@ -304,3 +304,4 @@ BEGIN
END
;
$
BODY
$
;
d
//
dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.1
-
schema/mysql/dolphinscheduler_ddl.sql
→
dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.1
_
schema/mysql/dolphinscheduler_ddl.sql
浏览文件 @
98ab5219
文件已移动
dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.1
-
schema/postgre/dolphinscheduler_ddl.sql
→
dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.1
_
schema/postgre/dolphinscheduler_ddl.sql
浏览文件 @
98ab5219
script/create-dolphinscheduler.sh
浏览文件 @
98ab5219
...
...
@@ -20,6 +20,11 @@ BIN_DIR=`dirname $0`
BIN_DIR
=
`
cd
"
$BIN_DIR
"
;
pwd
`
DOLPHINSCHEDULER_HOME
=
$BIN_DIR
/..
set
-a
source
"
${
DOLPHINSCHEDULER_HOME
}
/conf/env/dolphinscheduler_env.sh"
source
"
${
DOLPHINSCHEDULER_HOME
}
/conf/config/install_config.conf"
set
+a
export
JAVA_HOME
=
$JAVA_HOME
export
DATABASE_TYPE
=
${
DATABASE_TYPE
:-
"h2"
}
...
...
script/upgrade-dolphinscheduler.sh
浏览文件 @
98ab5219
...
...
@@ -20,6 +20,11 @@ BIN_DIR=`dirname $0`
BIN_DIR
=
`
cd
"
$BIN_DIR
"
;
pwd
`
DOLPHINSCHEDULER_HOME
=
$BIN_DIR
/..
set
-a
source
"
${
DOLPHINSCHEDULER_HOME
}
/conf/env/dolphinscheduler_env.sh"
source
"
${
DOLPHINSCHEDULER_HOME
}
/conf/config/install_config.conf"
set
+a
export
JAVA_HOME
=
$JAVA_HOME
export
DATABASE_TYPE
=
${
DATABASE_TYPE
:-
"h2"
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录