-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
166 additions
and
944 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
316 changes: 0 additions & 316 deletions
316
dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql
Large diffs are not rendered by default.
Oops, something went wrong.
317 changes: 0 additions & 317 deletions
317
dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql
Large diffs are not rendered by default.
Oops, something went wrong.
311 changes: 0 additions & 311 deletions
311
dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
# | ||
# 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. | ||
# | ||
|
||
BIN_DIR=$(dirname $0) | ||
DOLPHINSCHEDULER_HOME=${DOLPHINSCHEDULER_HOME:-$(cd ${BIN_DIR}/../..;pwd)} | ||
TOOLS_HOME=$(cd ${BIN_DIR}/..;pwd) | ||
|
||
if [ "$DOCKER" != "true" ]; then | ||
source "$DOLPHINSCHEDULER_HOME/bin/env/dolphinscheduler_env.sh" | ||
fi | ||
|
||
JAVA_OPTS=${JAVA_OPTS:-"-server -Duser.timezone=${SPRING_JACKSON_TIME_ZONE} -Xms4g -Xmx4g -Xmn512m -XX:+PrintGCDetails -Xloggc:gc.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=dump.hprof"} | ||
|
||
$JAVA_HOME/bin/java $JAVA_OPTS \ | ||
-cp "$TOOLS_HOME/conf":"$TOOLS_HOME/sql":"$TOOLS_HOME/libs/*" \ | ||
-Dspring.profiles.active=dropTable,${DATABASE} \ | ||
org.apache.dolphinscheduler.tools.table.DropTable |
54 changes: 54 additions & 0 deletions
54
dolphinscheduler-tools/src/main/java/org/apache/dolphinscheduler/tools/table/DropTable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* 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.tools.table; | ||
|
||
import java.sql.SQLException; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.CommandLineRunner; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.context.annotation.ComponentScan; | ||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.stereotype.Component; | ||
|
||
@SpringBootApplication | ||
@ComponentScan("org.apache.dolphinscheduler") | ||
@Slf4j | ||
public class DropTable { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(DropTable.class, args); | ||
} | ||
|
||
@Component | ||
@Profile("dropTable") | ||
static class DropTableRunner implements CommandLineRunner { | ||
|
||
@Autowired | ||
private DropTableService dropTableService; | ||
|
||
@Override | ||
public void run(String... args) throws SQLException { | ||
log.info("Starting Drop Table..."); | ||
dropTableService.dropTableOnce(); | ||
} | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
...heduler-tools/src/main/java/org/apache/dolphinscheduler/tools/table/DropTableService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* 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.tools.table; | ||
|
||
import java.sql.Connection; | ||
import java.sql.PreparedStatement; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import javax.sql.DataSource; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@Slf4j | ||
public class DropTableService { | ||
|
||
@Autowired | ||
private DataSource dataSource; | ||
|
||
public void dropTableOnce() { | ||
List<String> dropTableDDLList = getDropTableDDL(); | ||
|
||
for (String dropTableDDL : dropTableDDLList) { | ||
try { | ||
try (Connection connection = dataSource.getConnection()) { | ||
try (PreparedStatement pstmt = connection.prepareStatement(dropTableDDL)) { | ||
pstmt.executeUpdate(); | ||
} | ||
} | ||
} catch (Exception e) { | ||
log.error("Failed to execute sql: {},", dropTableDDL, e); | ||
} | ||
} | ||
} | ||
|
||
private List<String> getDropTableDDL() { | ||
List<String> dropTableDDLList = new ArrayList<>(); | ||
dropTableDDLList.add("DROP TABLE IF EXISTS t_ds_dq_comparison_type;"); | ||
dropTableDDLList.add("DROP TABLE IF EXISTS t_ds_dq_rule_execute_sql;"); | ||
dropTableDDLList.add("DROP TABLE IF EXISTS t_ds_dq_rule_input_entry;"); | ||
dropTableDDLList.add("DROP TABLE IF EXISTS t_ds_dq_task_statistics_value;"); | ||
return dropTableDDLList; | ||
} | ||
|
||
} |