dailidong
4 years ago
82 changed files with 1199 additions and 1078 deletions
@ -1,40 +0,0 @@ |
|||||||
# 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. |
|
||||||
version: '2' |
|
||||||
services: |
|
||||||
zookeeper: |
|
||||||
image: zookeeper |
|
||||||
restart: always |
|
||||||
container_name: zookeeper |
|
||||||
ports: |
|
||||||
- "2181:2181" |
|
||||||
environment: |
|
||||||
ZOO_MY_ID: 1 |
|
||||||
ZOO_4LW_COMMANDS_WHITELIST: srvr,ruok,wchs,cons |
|
||||||
db: |
|
||||||
image: postgres |
|
||||||
container_name: postgres |
|
||||||
environment: |
|
||||||
- POSTGRES_USER=test |
|
||||||
- POSTGRES_PASSWORD=test |
|
||||||
- POSTGRES_DB=dolphinscheduler |
|
||||||
ports: |
|
||||||
- "5432:5432" |
|
||||||
volumes: |
|
||||||
- pgdata:/var/lib/postgresql/data |
|
||||||
- ./postgres/docker-entrypoint-initdb:/docker-entrypoint-initdb.d |
|
||||||
volumes: |
|
||||||
pgdata: |
|
@ -1,762 +0,0 @@ |
|||||||
/* |
|
||||||
* 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. |
|
||||||
*/ |
|
||||||
|
|
||||||
DROP TABLE IF EXISTS QRTZ_FIRED_TRIGGERS; |
|
||||||
DROP TABLE IF EXISTS QRTZ_PAUSED_TRIGGER_GRPS; |
|
||||||
DROP TABLE IF EXISTS QRTZ_SCHEDULER_STATE; |
|
||||||
DROP TABLE IF EXISTS QRTZ_LOCKS; |
|
||||||
DROP TABLE IF EXISTS QRTZ_SIMPLE_TRIGGERS; |
|
||||||
DROP TABLE IF EXISTS QRTZ_SIMPROP_TRIGGERS; |
|
||||||
DROP TABLE IF EXISTS QRTZ_CRON_TRIGGERS; |
|
||||||
DROP TABLE IF EXISTS QRTZ_BLOB_TRIGGERS; |
|
||||||
DROP TABLE IF EXISTS QRTZ_TRIGGERS; |
|
||||||
DROP TABLE IF EXISTS QRTZ_JOB_DETAILS; |
|
||||||
DROP TABLE IF EXISTS QRTZ_CALENDARS; |
|
||||||
|
|
||||||
CREATE TABLE QRTZ_JOB_DETAILS( |
|
||||||
SCHED_NAME character varying(120) NOT NULL, |
|
||||||
JOB_NAME character varying(200) NOT NULL, |
|
||||||
JOB_GROUP character varying(200) NOT NULL, |
|
||||||
DESCRIPTION character varying(250) NULL, |
|
||||||
JOB_CLASS_NAME character varying(250) NOT NULL, |
|
||||||
IS_DURABLE boolean NOT NULL, |
|
||||||
IS_NONCONCURRENT boolean NOT NULL, |
|
||||||
IS_UPDATE_DATA boolean NOT NULL, |
|
||||||
REQUESTS_RECOVERY boolean NOT NULL, |
|
||||||
JOB_DATA bytea NULL); |
|
||||||
alter table QRTZ_JOB_DETAILS add primary key(SCHED_NAME,JOB_NAME,JOB_GROUP); |
|
||||||
|
|
||||||
CREATE TABLE QRTZ_TRIGGERS ( |
|
||||||
SCHED_NAME character varying(120) NOT NULL, |
|
||||||
TRIGGER_NAME character varying(200) NOT NULL, |
|
||||||
TRIGGER_GROUP character varying(200) NOT NULL, |
|
||||||
JOB_NAME character varying(200) NOT NULL, |
|
||||||
JOB_GROUP character varying(200) NOT NULL, |
|
||||||
DESCRIPTION character varying(250) NULL, |
|
||||||
NEXT_FIRE_TIME BIGINT NULL, |
|
||||||
PREV_FIRE_TIME BIGINT NULL, |
|
||||||
PRIORITY INTEGER NULL, |
|
||||||
TRIGGER_STATE character varying(16) NOT NULL, |
|
||||||
TRIGGER_TYPE character varying(8) NOT NULL, |
|
||||||
START_TIME BIGINT NOT NULL, |
|
||||||
END_TIME BIGINT NULL, |
|
||||||
CALENDAR_NAME character varying(200) NULL, |
|
||||||
MISFIRE_INSTR SMALLINT NULL, |
|
||||||
JOB_DATA bytea NULL) ; |
|
||||||
alter table QRTZ_TRIGGERS add primary key(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP); |
|
||||||
|
|
||||||
CREATE TABLE QRTZ_SIMPLE_TRIGGERS ( |
|
||||||
SCHED_NAME character varying(120) NOT NULL, |
|
||||||
TRIGGER_NAME character varying(200) NOT NULL, |
|
||||||
TRIGGER_GROUP character varying(200) NOT NULL, |
|
||||||
REPEAT_COUNT BIGINT NOT NULL, |
|
||||||
REPEAT_INTERVAL BIGINT NOT NULL, |
|
||||||
TIMES_TRIGGERED BIGINT NOT NULL) ; |
|
||||||
alter table QRTZ_SIMPLE_TRIGGERS add primary key(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP); |
|
||||||
|
|
||||||
CREATE TABLE QRTZ_CRON_TRIGGERS ( |
|
||||||
SCHED_NAME character varying(120) NOT NULL, |
|
||||||
TRIGGER_NAME character varying(200) NOT NULL, |
|
||||||
TRIGGER_GROUP character varying(200) NOT NULL, |
|
||||||
CRON_EXPRESSION character varying(120) NOT NULL, |
|
||||||
TIME_ZONE_ID character varying(80)) ; |
|
||||||
alter table QRTZ_CRON_TRIGGERS add primary key(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP); |
|
||||||
|
|
||||||
CREATE TABLE QRTZ_SIMPROP_TRIGGERS |
|
||||||
( |
|
||||||
SCHED_NAME character varying(120) NOT NULL, |
|
||||||
TRIGGER_NAME character varying(200) NOT NULL, |
|
||||||
TRIGGER_GROUP character varying(200) NOT NULL, |
|
||||||
STR_PROP_1 character varying(512) NULL, |
|
||||||
STR_PROP_2 character varying(512) NULL, |
|
||||||
STR_PROP_3 character varying(512) NULL, |
|
||||||
INT_PROP_1 INT NULL, |
|
||||||
INT_PROP_2 INT NULL, |
|
||||||
LONG_PROP_1 BIGINT NULL, |
|
||||||
LONG_PROP_2 BIGINT NULL, |
|
||||||
DEC_PROP_1 NUMERIC(13,4) NULL, |
|
||||||
DEC_PROP_2 NUMERIC(13,4) NULL, |
|
||||||
BOOL_PROP_1 boolean NULL, |
|
||||||
BOOL_PROP_2 boolean NULL) ; |
|
||||||
alter table QRTZ_SIMPROP_TRIGGERS add primary key(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP); |
|
||||||
|
|
||||||
CREATE TABLE QRTZ_BLOB_TRIGGERS ( |
|
||||||
SCHED_NAME character varying(120) NOT NULL, |
|
||||||
TRIGGER_NAME character varying(200) NOT NULL, |
|
||||||
TRIGGER_GROUP character varying(200) NOT NULL, |
|
||||||
BLOB_DATA bytea NULL) ; |
|
||||||
alter table QRTZ_BLOB_TRIGGERS add primary key(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP); |
|
||||||
|
|
||||||
CREATE TABLE QRTZ_CALENDARS ( |
|
||||||
SCHED_NAME character varying(120) NOT NULL, |
|
||||||
CALENDAR_NAME character varying(200) NOT NULL, |
|
||||||
CALENDAR bytea NOT NULL) ; |
|
||||||
alter table QRTZ_CALENDARS add primary key(SCHED_NAME,CALENDAR_NAME); |
|
||||||
|
|
||||||
CREATE TABLE QRTZ_PAUSED_TRIGGER_GRPS ( |
|
||||||
SCHED_NAME character varying(120) NOT NULL, |
|
||||||
TRIGGER_GROUP character varying(200) NOT NULL) ; |
|
||||||
alter table QRTZ_PAUSED_TRIGGER_GRPS add primary key(SCHED_NAME,TRIGGER_GROUP); |
|
||||||
|
|
||||||
CREATE TABLE QRTZ_FIRED_TRIGGERS ( |
|
||||||
SCHED_NAME character varying(120) NOT NULL, |
|
||||||
ENTRY_ID character varying(95) NOT NULL, |
|
||||||
TRIGGER_NAME character varying(200) NOT NULL, |
|
||||||
TRIGGER_GROUP character varying(200) NOT NULL, |
|
||||||
INSTANCE_NAME character varying(200) NOT NULL, |
|
||||||
FIRED_TIME BIGINT NOT NULL, |
|
||||||
SCHED_TIME BIGINT NOT NULL, |
|
||||||
PRIORITY INTEGER NOT NULL, |
|
||||||
STATE character varying(16) NOT NULL, |
|
||||||
JOB_NAME character varying(200) NULL, |
|
||||||
JOB_GROUP character varying(200) NULL, |
|
||||||
IS_NONCONCURRENT boolean NULL, |
|
||||||
REQUESTS_RECOVERY boolean NULL) ; |
|
||||||
alter table QRTZ_FIRED_TRIGGERS add primary key(SCHED_NAME,ENTRY_ID); |
|
||||||
|
|
||||||
CREATE TABLE QRTZ_SCHEDULER_STATE ( |
|
||||||
SCHED_NAME character varying(120) NOT NULL, |
|
||||||
INSTANCE_NAME character varying(200) NOT NULL, |
|
||||||
LAST_CHECKIN_TIME BIGINT NOT NULL, |
|
||||||
CHECKIN_INTERVAL BIGINT NOT NULL) ; |
|
||||||
alter table QRTZ_SCHEDULER_STATE add primary key(SCHED_NAME,INSTANCE_NAME); |
|
||||||
|
|
||||||
CREATE TABLE QRTZ_LOCKS ( |
|
||||||
SCHED_NAME character varying(120) NOT NULL, |
|
||||||
LOCK_NAME character varying(40) NOT NULL) ; |
|
||||||
alter table QRTZ_LOCKS add primary key(SCHED_NAME,LOCK_NAME); |
|
||||||
|
|
||||||
CREATE INDEX IDX_QRTZ_J_REQ_RECOVERY ON QRTZ_JOB_DETAILS(SCHED_NAME,REQUESTS_RECOVERY); |
|
||||||
CREATE INDEX IDX_QRTZ_J_GRP ON QRTZ_JOB_DETAILS(SCHED_NAME,JOB_GROUP); |
|
||||||
|
|
||||||
CREATE INDEX IDX_QRTZ_T_J ON QRTZ_TRIGGERS(SCHED_NAME,JOB_NAME,JOB_GROUP); |
|
||||||
CREATE INDEX IDX_QRTZ_T_JG ON QRTZ_TRIGGERS(SCHED_NAME,JOB_GROUP); |
|
||||||
CREATE INDEX IDX_QRTZ_T_C ON QRTZ_TRIGGERS(SCHED_NAME,CALENDAR_NAME); |
|
||||||
CREATE INDEX IDX_QRTZ_T_G ON QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_GROUP); |
|
||||||
CREATE INDEX IDX_QRTZ_T_STATE ON QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_STATE); |
|
||||||
CREATE INDEX IDX_QRTZ_T_N_STATE ON QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP,TRIGGER_STATE); |
|
||||||
CREATE INDEX IDX_QRTZ_T_N_G_STATE ON QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_GROUP,TRIGGER_STATE); |
|
||||||
CREATE INDEX IDX_QRTZ_T_NEXT_FIRE_TIME ON QRTZ_TRIGGERS(SCHED_NAME,NEXT_FIRE_TIME); |
|
||||||
CREATE INDEX IDX_QRTZ_T_NFT_ST ON QRTZ_TRIGGERS(SCHED_NAME,TRIGGER_STATE,NEXT_FIRE_TIME); |
|
||||||
CREATE INDEX IDX_QRTZ_T_NFT_MISFIRE ON QRTZ_TRIGGERS(SCHED_NAME,MISFIRE_INSTR,NEXT_FIRE_TIME); |
|
||||||
CREATE INDEX IDX_QRTZ_T_NFT_ST_MISFIRE ON QRTZ_TRIGGERS(SCHED_NAME,MISFIRE_INSTR,NEXT_FIRE_TIME,TRIGGER_STATE); |
|
||||||
CREATE INDEX IDX_QRTZ_T_NFT_ST_MISFIRE_GRP ON QRTZ_TRIGGERS(SCHED_NAME,MISFIRE_INSTR,NEXT_FIRE_TIME,TRIGGER_GROUP,TRIGGER_STATE); |
|
||||||
|
|
||||||
CREATE INDEX IDX_QRTZ_FT_TRIG_INST_NAME ON QRTZ_FIRED_TRIGGERS(SCHED_NAME,INSTANCE_NAME); |
|
||||||
CREATE INDEX IDX_QRTZ_FT_INST_JOB_REQ_RCVRY ON QRTZ_FIRED_TRIGGERS(SCHED_NAME,INSTANCE_NAME,REQUESTS_RECOVERY); |
|
||||||
CREATE INDEX IDX_QRTZ_FT_J_G ON QRTZ_FIRED_TRIGGERS(SCHED_NAME,JOB_NAME,JOB_GROUP); |
|
||||||
CREATE INDEX IDX_QRTZ_FT_JG ON QRTZ_FIRED_TRIGGERS(SCHED_NAME,JOB_GROUP); |
|
||||||
CREATE INDEX IDX_QRTZ_FT_T_G ON QRTZ_FIRED_TRIGGERS(SCHED_NAME,TRIGGER_NAME,TRIGGER_GROUP); |
|
||||||
CREATE INDEX IDX_QRTZ_FT_TG ON QRTZ_FIRED_TRIGGERS(SCHED_NAME,TRIGGER_GROUP); |
|
||||||
|
|
||||||
|
|
||||||
-- |
|
||||||
-- Table structure for table t_ds_access_token |
|
||||||
-- |
|
||||||
|
|
||||||
DROP TABLE IF EXISTS t_ds_access_token; |
|
||||||
CREATE TABLE t_ds_access_token ( |
|
||||||
id int NOT NULL , |
|
||||||
user_id int DEFAULT NULL , |
|
||||||
token varchar(64) DEFAULT NULL , |
|
||||||
expire_time timestamp DEFAULT NULL , |
|
||||||
create_time timestamp DEFAULT NULL , |
|
||||||
update_time timestamp DEFAULT NULL , |
|
||||||
PRIMARY KEY (id) |
|
||||||
) ; |
|
||||||
|
|
||||||
-- |
|
||||||
-- Table structure for table t_ds_alert |
|
||||||
-- |
|
||||||
|
|
||||||
DROP TABLE IF EXISTS t_ds_alert; |
|
||||||
CREATE TABLE t_ds_alert ( |
|
||||||
id int NOT NULL , |
|
||||||
title varchar(64) DEFAULT NULL , |
|
||||||
show_type int DEFAULT NULL , |
|
||||||
content text , |
|
||||||
alert_type int DEFAULT NULL , |
|
||||||
alert_status int DEFAULT '0' , |
|
||||||
·log· text , |
|
||||||
alertgroup_id int DEFAULT NULL , |
|
||||||
receivers text , |
|
||||||
receivers_cc text , |
|
||||||
create_time timestamp DEFAULT NULL , |
|
||||||
update_time timestamp DEFAULT NULL , |
|
||||||
PRIMARY KEY (id) |
|
||||||
) ; |
|
||||||
-- |
|
||||||
-- Table structure for table t_ds_alertgroup |
|
||||||
-- |
|
||||||
|
|
||||||
DROP TABLE IF EXISTS t_ds_alertgroup; |
|
||||||
CREATE TABLE t_ds_alertgroup ( |
|
||||||
id int NOT NULL , |
|
||||||
group_name varchar(255) DEFAULT NULL , |
|
||||||
group_type int DEFAULT NULL , |
|
||||||
description varchar(255) DEFAULT NULL , |
|
||||||
create_time timestamp DEFAULT NULL , |
|
||||||
update_time timestamp DEFAULT NULL , |
|
||||||
PRIMARY KEY (id) |
|
||||||
) ; |
|
||||||
|
|
||||||
-- |
|
||||||
-- Table structure for table t_ds_command |
|
||||||
-- |
|
||||||
|
|
||||||
DROP TABLE IF EXISTS t_ds_command; |
|
||||||
CREATE TABLE t_ds_command ( |
|
||||||
id int NOT NULL , |
|
||||||
command_type int DEFAULT NULL , |
|
||||||
process_definition_id int DEFAULT NULL , |
|
||||||
command_param text , |
|
||||||
task_depend_type int DEFAULT NULL , |
|
||||||
failure_strategy int DEFAULT '0' , |
|
||||||
warning_type int DEFAULT '0' , |
|
||||||
warning_group_id int DEFAULT NULL , |
|
||||||
schedule_time timestamp DEFAULT NULL , |
|
||||||
start_time timestamp DEFAULT NULL , |
|
||||||
executor_id int DEFAULT NULL , |
|
||||||
dependence varchar(255) DEFAULT NULL , |
|
||||||
update_time timestamp DEFAULT NULL , |
|
||||||
process_instance_priority int DEFAULT NULL , |
|
||||||
worker_group varchar(64), |
|
||||||
PRIMARY KEY (id) |
|
||||||
) ; |
|
||||||
|
|
||||||
-- |
|
||||||
-- Table structure for table t_ds_datasource |
|
||||||
-- |
|
||||||
|
|
||||||
DROP TABLE IF EXISTS t_ds_datasource; |
|
||||||
CREATE TABLE t_ds_datasource ( |
|
||||||
id int NOT NULL , |
|
||||||
name varchar(64) NOT NULL , |
|
||||||
note varchar(256) DEFAULT NULL , |
|
||||||
type int NOT NULL , |
|
||||||
user_id int NOT NULL , |
|
||||||
connection_params text NOT NULL , |
|
||||||
create_time timestamp NOT NULL , |
|
||||||
update_time timestamp DEFAULT NULL , |
|
||||||
PRIMARY KEY (id) |
|
||||||
) ; |
|
||||||
|
|
||||||
-- |
|
||||||
-- Table structure for table t_ds_error_command |
|
||||||
-- |
|
||||||
|
|
||||||
DROP TABLE IF EXISTS t_ds_error_command; |
|
||||||
CREATE TABLE t_ds_error_command ( |
|
||||||
id int NOT NULL , |
|
||||||
command_type int DEFAULT NULL , |
|
||||||
executor_id int DEFAULT NULL , |
|
||||||
process_definition_id int DEFAULT NULL , |
|
||||||
command_param text , |
|
||||||
task_depend_type int DEFAULT NULL , |
|
||||||
failure_strategy int DEFAULT '0' , |
|
||||||
warning_type int DEFAULT '0' , |
|
||||||
warning_group_id int DEFAULT NULL , |
|
||||||
schedule_time timestamp DEFAULT NULL , |
|
||||||
start_time timestamp DEFAULT NULL , |
|
||||||
update_time timestamp DEFAULT NULL , |
|
||||||
dependence text , |
|
||||||
process_instance_priority int DEFAULT NULL , |
|
||||||
worker_group varchar(64), |
|
||||||
message text , |
|
||||||
PRIMARY KEY (id) |
|
||||||
); |
|
||||||
-- |
|
||||||
-- Table structure for table t_ds_master_server |
|
||||||
-- |
|
||||||
|
|
||||||
-- |
|
||||||
-- Table structure for table t_ds_process_definition |
|
||||||
-- |
|
||||||
|
|
||||||
DROP TABLE IF EXISTS t_ds_process_definition; |
|
||||||
CREATE TABLE t_ds_process_definition ( |
|
||||||
id int NOT NULL , |
|
||||||
name varchar(255) DEFAULT NULL , |
|
||||||
version int DEFAULT NULL , |
|
||||||
release_state int DEFAULT NULL , |
|
||||||
project_id int DEFAULT NULL , |
|
||||||
user_id int DEFAULT NULL , |
|
||||||
process_definition_json text , |
|
||||||
description text , |
|
||||||
global_params text , |
|
||||||
flag int DEFAULT NULL , |
|
||||||
locations text , |
|
||||||
connects text , |
|
||||||
receivers text , |
|
||||||
receivers_cc text , |
|
||||||
create_time timestamp DEFAULT NULL , |
|
||||||
timeout int DEFAULT '0' , |
|
||||||
tenant_id int NOT NULL DEFAULT '-1' , |
|
||||||
update_time timestamp DEFAULT NULL , |
|
||||||
modify_by varchar(36) DEFAULT '' , |
|
||||||
resource_ids varchar(64), |
|
||||||
PRIMARY KEY (id) |
|
||||||
) ; |
|
||||||
|
|
||||||
create index process_definition_index on t_ds_process_definition (project_id,id); |
|
||||||
|
|
||||||
-- |
|
||||||
-- Table structure for table t_ds_process_instance |
|
||||||
-- |
|
||||||
|
|
||||||
DROP TABLE IF EXISTS t_ds_process_instance; |
|
||||||
CREATE TABLE t_ds_process_instance ( |
|
||||||
id int NOT NULL , |
|
||||||
name varchar(255) DEFAULT NULL , |
|
||||||
process_definition_id int DEFAULT NULL , |
|
||||||
state int DEFAULT NULL , |
|
||||||
recovery int DEFAULT NULL , |
|
||||||
start_time timestamp DEFAULT NULL , |
|
||||||
end_time timestamp DEFAULT NULL , |
|
||||||
run_times int DEFAULT NULL , |
|
||||||
host varchar(45) DEFAULT NULL , |
|
||||||
command_type int DEFAULT NULL , |
|
||||||
command_param text , |
|
||||||
task_depend_type int DEFAULT NULL , |
|
||||||
max_try_times int DEFAULT '0' , |
|
||||||
failure_strategy int DEFAULT '0' , |
|
||||||
warning_type int DEFAULT '0' , |
|
||||||
warning_group_id int DEFAULT NULL , |
|
||||||
schedule_time timestamp DEFAULT NULL , |
|
||||||
command_start_time timestamp DEFAULT NULL , |
|
||||||
global_params text , |
|
||||||
process_instance_json text , |
|
||||||
flag int DEFAULT '1' , |
|
||||||
update_time timestamp NULL , |
|
||||||
is_sub_process int DEFAULT '0' , |
|
||||||
executor_id int NOT NULL , |
|
||||||
locations text , |
|
||||||
connects text , |
|
||||||
history_cmd text , |
|
||||||
dependence_schedule_times text , |
|
||||||
process_instance_priority int DEFAULT NULL , |
|
||||||
worker_group varchar(64) , |
|
||||||
timeout int DEFAULT '0' , |
|
||||||
tenant_id int NOT NULL DEFAULT '-1' , |
|
||||||
PRIMARY KEY (id) |
|
||||||
) ; |
|
||||||
create index process_instance_index on t_ds_process_instance (process_definition_id,id); |
|
||||||
create index start_time_index on t_ds_process_instance (start_time); |
|
||||||
|
|
||||||
-- |
|
||||||
-- Table structure for table t_ds_project |
|
||||||
-- |
|
||||||
|
|
||||||
DROP TABLE IF EXISTS t_ds_project; |
|
||||||
CREATE TABLE t_ds_project ( |
|
||||||
id int NOT NULL , |
|
||||||
name varchar(100) DEFAULT NULL , |
|
||||||
description varchar(200) DEFAULT NULL , |
|
||||||
user_id int DEFAULT NULL , |
|
||||||
flag int DEFAULT '1' , |
|
||||||
create_time timestamp DEFAULT CURRENT_TIMESTAMP , |
|
||||||
update_time timestamp DEFAULT CURRENT_TIMESTAMP , |
|
||||||
PRIMARY KEY (id) |
|
||||||
) ; |
|
||||||
create index user_id_index on t_ds_project (user_id); |
|
||||||
|
|
||||||
-- |
|
||||||
-- Table structure for table t_ds_queue |
|
||||||
-- |
|
||||||
|
|
||||||
DROP TABLE IF EXISTS t_ds_queue; |
|
||||||
CREATE TABLE t_ds_queue ( |
|
||||||
id int NOT NULL , |
|
||||||
queue_name varchar(64) DEFAULT NULL , |
|
||||||
queue varchar(64) DEFAULT NULL , |
|
||||||
create_time timestamp DEFAULT NULL , |
|
||||||
update_time timestamp DEFAULT NULL , |
|
||||||
PRIMARY KEY (id) |
|
||||||
); |
|
||||||
|
|
||||||
|
|
||||||
-- |
|
||||||
-- Table structure for table t_ds_relation_datasource_user |
|
||||||
-- |
|
||||||
|
|
||||||
DROP TABLE IF EXISTS t_ds_relation_datasource_user; |
|
||||||
CREATE TABLE t_ds_relation_datasource_user ( |
|
||||||
id int NOT NULL , |
|
||||||
user_id int NOT NULL , |
|
||||||
datasource_id int DEFAULT NULL , |
|
||||||
perm int DEFAULT '1' , |
|
||||||
create_time timestamp DEFAULT NULL , |
|
||||||
update_time timestamp DEFAULT NULL , |
|
||||||
PRIMARY KEY (id) |
|
||||||
) ; |
|
||||||
; |
|
||||||
|
|
||||||
-- |
|
||||||
-- Table structure for table t_ds_relation_process_instance |
|
||||||
-- |
|
||||||
|
|
||||||
DROP TABLE IF EXISTS t_ds_relation_process_instance; |
|
||||||
CREATE TABLE t_ds_relation_process_instance ( |
|
||||||
id int NOT NULL , |
|
||||||
parent_process_instance_id int DEFAULT NULL , |
|
||||||
parent_task_instance_id int DEFAULT NULL , |
|
||||||
process_instance_id int DEFAULT NULL , |
|
||||||
PRIMARY KEY (id) |
|
||||||
) ; |
|
||||||
|
|
||||||
|
|
||||||
-- |
|
||||||
-- Table structure for table t_ds_relation_project_user |
|
||||||
-- |
|
||||||
|
|
||||||
DROP TABLE IF EXISTS t_ds_relation_project_user; |
|
||||||
CREATE TABLE t_ds_relation_project_user ( |
|
||||||
id int NOT NULL , |
|
||||||
user_id int NOT NULL , |
|
||||||
project_id int DEFAULT NULL , |
|
||||||
perm int DEFAULT '1' , |
|
||||||
create_time timestamp DEFAULT NULL , |
|
||||||
update_time timestamp DEFAULT NULL , |
|
||||||
PRIMARY KEY (id) |
|
||||||
) ; |
|
||||||
create index relation_project_user_id_index on t_ds_relation_project_user (user_id); |
|
||||||
|
|
||||||
-- |
|
||||||
-- Table structure for table t_ds_relation_resources_user |
|
||||||
-- |
|
||||||
|
|
||||||
DROP TABLE IF EXISTS t_ds_relation_resources_user; |
|
||||||
CREATE TABLE t_ds_relation_resources_user ( |
|
||||||
id int NOT NULL , |
|
||||||
user_id int NOT NULL , |
|
||||||
resources_id int DEFAULT NULL , |
|
||||||
perm int DEFAULT '1' , |
|
||||||
create_time timestamp DEFAULT NULL , |
|
||||||
update_time timestamp DEFAULT NULL , |
|
||||||
PRIMARY KEY (id) |
|
||||||
) ; |
|
||||||
|
|
||||||
-- |
|
||||||
-- Table structure for table t_ds_relation_udfs_user |
|
||||||
-- |
|
||||||
|
|
||||||
DROP TABLE IF EXISTS t_ds_relation_udfs_user; |
|
||||||
CREATE TABLE t_ds_relation_udfs_user ( |
|
||||||
id int NOT NULL , |
|
||||||
user_id int NOT NULL , |
|
||||||
udf_id int DEFAULT NULL , |
|
||||||
perm int DEFAULT '1' , |
|
||||||
create_time timestamp DEFAULT NULL , |
|
||||||
update_time timestamp DEFAULT NULL , |
|
||||||
PRIMARY KEY (id) |
|
||||||
) ; |
|
||||||
; |
|
||||||
|
|
||||||
-- |
|
||||||
-- Table structure for table t_ds_relation_user_alertgroup |
|
||||||
-- |
|
||||||
|
|
||||||
DROP TABLE IF EXISTS t_ds_relation_user_alertgroup; |
|
||||||
CREATE TABLE t_ds_relation_user_alertgroup ( |
|
||||||
id int NOT NULL, |
|
||||||
alertgroup_id int DEFAULT NULL, |
|
||||||
user_id int DEFAULT NULL, |
|
||||||
create_time timestamp DEFAULT NULL, |
|
||||||
update_time timestamp DEFAULT NULL, |
|
||||||
PRIMARY KEY (id) |
|
||||||
); |
|
||||||
|
|
||||||
-- |
|
||||||
-- Table structure for table t_ds_resources |
|
||||||
-- |
|
||||||
|
|
||||||
DROP TABLE IF EXISTS t_ds_resources; |
|
||||||
CREATE TABLE t_ds_resources ( |
|
||||||
id int NOT NULL , |
|
||||||
alias varchar(64) DEFAULT NULL , |
|
||||||
file_name varchar(64) DEFAULT NULL , |
|
||||||
description varchar(256) DEFAULT NULL , |
|
||||||
user_id int DEFAULT NULL , |
|
||||||
type int DEFAULT NULL , |
|
||||||
size bigint DEFAULT NULL , |
|
||||||
create_time timestamp DEFAULT NULL , |
|
||||||
update_time timestamp DEFAULT NULL , |
|
||||||
pid int, |
|
||||||
full_name varchar(64), |
|
||||||
is_directory int, |
|
||||||
PRIMARY KEY (id) |
|
||||||
) ; |
|
||||||
|
|
||||||
|
|
||||||
-- |
|
||||||
-- Table structure for table t_ds_schedules |
|
||||||
-- |
|
||||||
|
|
||||||
DROP TABLE IF EXISTS t_ds_schedules; |
|
||||||
CREATE TABLE t_ds_schedules ( |
|
||||||
id int NOT NULL , |
|
||||||
process_definition_id int NOT NULL , |
|
||||||
start_time timestamp NOT NULL , |
|
||||||
end_time timestamp NOT NULL , |
|
||||||
crontab varchar(256) NOT NULL , |
|
||||||
failure_strategy int NOT NULL , |
|
||||||
user_id int NOT NULL , |
|
||||||
release_state int NOT NULL , |
|
||||||
warning_type int NOT NULL , |
|
||||||
warning_group_id int DEFAULT NULL , |
|
||||||
process_instance_priority int DEFAULT NULL , |
|
||||||
worker_group varchar(64), |
|
||||||
create_time timestamp NOT NULL , |
|
||||||
update_time timestamp NOT NULL , |
|
||||||
PRIMARY KEY (id) |
|
||||||
); |
|
||||||
|
|
||||||
-- |
|
||||||
-- Table structure for table t_ds_session |
|
||||||
-- |
|
||||||
|
|
||||||
DROP TABLE IF EXISTS t_ds_session; |
|
||||||
CREATE TABLE t_ds_session ( |
|
||||||
id varchar(64) NOT NULL , |
|
||||||
user_id int DEFAULT NULL , |
|
||||||
ip varchar(45) DEFAULT NULL , |
|
||||||
last_login_time timestamp DEFAULT NULL , |
|
||||||
PRIMARY KEY (id) |
|
||||||
); |
|
||||||
|
|
||||||
-- |
|
||||||
-- Table structure for table t_ds_task_instance |
|
||||||
-- |
|
||||||
|
|
||||||
DROP TABLE IF EXISTS t_ds_task_instance; |
|
||||||
CREATE TABLE t_ds_task_instance ( |
|
||||||
id int NOT NULL , |
|
||||||
name varchar(255) DEFAULT NULL , |
|
||||||
task_type varchar(64) DEFAULT NULL , |
|
||||||
process_definition_id int DEFAULT NULL , |
|
||||||
process_instance_id int DEFAULT NULL , |
|
||||||
task_json text , |
|
||||||
state int DEFAULT NULL , |
|
||||||
submit_time timestamp DEFAULT NULL , |
|
||||||
start_time timestamp DEFAULT NULL , |
|
||||||
end_time timestamp DEFAULT NULL , |
|
||||||
host varchar(45) DEFAULT NULL , |
|
||||||
execute_path varchar(200) DEFAULT NULL , |
|
||||||
log_path varchar(200) DEFAULT NULL , |
|
||||||
alert_flag int DEFAULT NULL , |
|
||||||
retry_times int DEFAULT '0' , |
|
||||||
pid int DEFAULT NULL , |
|
||||||
app_link varchar(255) DEFAULT NULL , |
|
||||||
flag int DEFAULT '1' , |
|
||||||
retry_interval int DEFAULT NULL , |
|
||||||
max_retry_times int DEFAULT NULL , |
|
||||||
task_instance_priority int DEFAULT NULL , |
|
||||||
worker_group varchar(64), |
|
||||||
executor_id int DEFAULT NULL , |
|
||||||
PRIMARY KEY (id) |
|
||||||
) ; |
|
||||||
|
|
||||||
-- |
|
||||||
-- Table structure for table t_ds_tenant |
|
||||||
-- |
|
||||||
|
|
||||||
DROP TABLE IF EXISTS t_ds_tenant; |
|
||||||
CREATE TABLE t_ds_tenant ( |
|
||||||
id int NOT NULL , |
|
||||||
tenant_code varchar(64) DEFAULT NULL , |
|
||||||
tenant_name varchar(64) DEFAULT NULL , |
|
||||||
description varchar(256) DEFAULT NULL , |
|
||||||
queue_id int DEFAULT NULL , |
|
||||||
create_time timestamp DEFAULT NULL , |
|
||||||
update_time timestamp DEFAULT NULL , |
|
||||||
PRIMARY KEY (id) |
|
||||||
) ; |
|
||||||
|
|
||||||
-- |
|
||||||
-- Table structure for table t_ds_udfs |
|
||||||
-- |
|
||||||
|
|
||||||
DROP TABLE IF EXISTS t_ds_udfs; |
|
||||||
CREATE TABLE t_ds_udfs ( |
|
||||||
id int NOT NULL , |
|
||||||
user_id int NOT NULL , |
|
||||||
func_name varchar(100) NOT NULL , |
|
||||||
class_name varchar(255) NOT NULL , |
|
||||||
type int NOT NULL , |
|
||||||
arg_types varchar(255) DEFAULT NULL , |
|
||||||
database varchar(255) DEFAULT NULL , |
|
||||||
description varchar(255) DEFAULT NULL , |
|
||||||
resource_id int NOT NULL , |
|
||||||
resource_name varchar(255) NOT NULL , |
|
||||||
create_time timestamp NOT NULL , |
|
||||||
update_time timestamp NOT NULL , |
|
||||||
PRIMARY KEY (id) |
|
||||||
) ; |
|
||||||
|
|
||||||
-- |
|
||||||
-- Table structure for table t_ds_user |
|
||||||
-- |
|
||||||
|
|
||||||
DROP TABLE IF EXISTS t_ds_user; |
|
||||||
CREATE TABLE t_ds_user ( |
|
||||||
id int NOT NULL , |
|
||||||
user_name varchar(64) DEFAULT NULL , |
|
||||||
user_password varchar(64) DEFAULT NULL , |
|
||||||
user_type int DEFAULT NULL , |
|
||||||
email varchar(64) DEFAULT NULL , |
|
||||||
phone varchar(11) DEFAULT NULL , |
|
||||||
tenant_id int DEFAULT NULL , |
|
||||||
create_time timestamp DEFAULT NULL , |
|
||||||
update_time timestamp DEFAULT NULL , |
|
||||||
queue varchar(64) DEFAULT NULL , |
|
||||||
PRIMARY KEY (id) |
|
||||||
); |
|
||||||
|
|
||||||
-- |
|
||||||
-- Table structure for table t_ds_version |
|
||||||
-- |
|
||||||
|
|
||||||
DROP TABLE IF EXISTS t_ds_version; |
|
||||||
CREATE TABLE t_ds_version ( |
|
||||||
id int NOT NULL , |
|
||||||
version varchar(200) NOT NULL, |
|
||||||
PRIMARY KEY (id) |
|
||||||
) ; |
|
||||||
create index version_index on t_ds_version(version); |
|
||||||
|
|
||||||
-- |
|
||||||
-- Table structure for table t_ds_worker_group |
|
||||||
-- |
|
||||||
|
|
||||||
DROP TABLE IF EXISTS t_ds_worker_group; |
|
||||||
CREATE TABLE t_ds_worker_group ( |
|
||||||
id bigint NOT NULL , |
|
||||||
name varchar(256) DEFAULT NULL , |
|
||||||
ip_list varchar(256) DEFAULT NULL , |
|
||||||
create_time timestamp DEFAULT NULL , |
|
||||||
update_time timestamp DEFAULT NULL , |
|
||||||
PRIMARY KEY (id) |
|
||||||
) ; |
|
||||||
|
|
||||||
-- |
|
||||||
-- Table structure for table t_ds_worker_server |
|
||||||
-- |
|
||||||
|
|
||||||
DROP TABLE IF EXISTS t_ds_worker_server; |
|
||||||
CREATE TABLE t_ds_worker_server ( |
|
||||||
id int NOT NULL , |
|
||||||
host varchar(45) DEFAULT NULL , |
|
||||||
port int DEFAULT NULL , |
|
||||||
zk_directory varchar(64) DEFAULT NULL , |
|
||||||
res_info varchar(255) DEFAULT NULL , |
|
||||||
create_time timestamp DEFAULT NULL , |
|
||||||
last_heartbeat_time timestamp DEFAULT NULL , |
|
||||||
PRIMARY KEY (id) |
|
||||||
) ; |
|
||||||
|
|
||||||
|
|
||||||
DROP SEQUENCE IF EXISTS t_ds_access_token_id_sequence; |
|
||||||
CREATE SEQUENCE t_ds_access_token_id_sequence; |
|
||||||
ALTER TABLE t_ds_access_token ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_access_token_id_sequence'); |
|
||||||
DROP SEQUENCE IF EXISTS t_ds_alert_id_sequence; |
|
||||||
CREATE SEQUENCE t_ds_alert_id_sequence; |
|
||||||
ALTER TABLE t_ds_alert ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_alert_id_sequence'); |
|
||||||
DROP SEQUENCE IF EXISTS t_ds_alertgroup_id_sequence; |
|
||||||
CREATE SEQUENCE t_ds_alertgroup_id_sequence; |
|
||||||
ALTER TABLE t_ds_alertgroup ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_alertgroup_id_sequence'); |
|
||||||
|
|
||||||
DROP SEQUENCE IF EXISTS t_ds_command_id_sequence; |
|
||||||
CREATE SEQUENCE t_ds_command_id_sequence; |
|
||||||
ALTER TABLE t_ds_command ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_command_id_sequence'); |
|
||||||
DROP SEQUENCE IF EXISTS t_ds_datasource_id_sequence; |
|
||||||
CREATE SEQUENCE t_ds_datasource_id_sequence; |
|
||||||
ALTER TABLE t_ds_datasource ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_datasource_id_sequence'); |
|
||||||
DROP SEQUENCE IF EXISTS t_ds_process_definition_id_sequence; |
|
||||||
CREATE SEQUENCE t_ds_process_definition_id_sequence; |
|
||||||
ALTER TABLE t_ds_process_definition ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_process_definition_id_sequence'); |
|
||||||
DROP SEQUENCE IF EXISTS t_ds_process_instance_id_sequence; |
|
||||||
CREATE SEQUENCE t_ds_process_instance_id_sequence; |
|
||||||
ALTER TABLE t_ds_process_instance ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_process_instance_id_sequence'); |
|
||||||
DROP SEQUENCE IF EXISTS t_ds_project_id_sequence; |
|
||||||
CREATE SEQUENCE t_ds_project_id_sequence; |
|
||||||
ALTER TABLE t_ds_project ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_project_id_sequence'); |
|
||||||
DROP SEQUENCE IF EXISTS t_ds_queue_id_sequence; |
|
||||||
CREATE SEQUENCE t_ds_queue_id_sequence; |
|
||||||
ALTER TABLE t_ds_queue ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_queue_id_sequence'); |
|
||||||
|
|
||||||
DROP SEQUENCE IF EXISTS t_ds_relation_datasource_user_id_sequence; |
|
||||||
CREATE SEQUENCE t_ds_relation_datasource_user_id_sequence; |
|
||||||
ALTER TABLE t_ds_relation_datasource_user ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_relation_datasource_user_id_sequence'); |
|
||||||
DROP SEQUENCE IF EXISTS t_ds_relation_process_instance_id_sequence; |
|
||||||
CREATE SEQUENCE t_ds_relation_process_instance_id_sequence; |
|
||||||
ALTER TABLE t_ds_relation_process_instance ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_relation_process_instance_id_sequence'); |
|
||||||
DROP SEQUENCE IF EXISTS t_ds_relation_project_user_id_sequence; |
|
||||||
CREATE SEQUENCE t_ds_relation_project_user_id_sequence; |
|
||||||
ALTER TABLE t_ds_relation_project_user ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_relation_project_user_id_sequence'); |
|
||||||
DROP SEQUENCE IF EXISTS t_ds_relation_resources_user_id_sequence; |
|
||||||
CREATE SEQUENCE t_ds_relation_resources_user_id_sequence; |
|
||||||
ALTER TABLE t_ds_relation_resources_user ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_relation_resources_user_id_sequence'); |
|
||||||
DROP SEQUENCE IF EXISTS t_ds_relation_udfs_user_id_sequence; |
|
||||||
CREATE SEQUENCE t_ds_relation_udfs_user_id_sequence; |
|
||||||
ALTER TABLE t_ds_relation_udfs_user ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_relation_udfs_user_id_sequence'); |
|
||||||
DROP SEQUENCE IF EXISTS t_ds_relation_user_alertgroup_id_sequence; |
|
||||||
CREATE SEQUENCE t_ds_relation_user_alertgroup_id_sequence; |
|
||||||
ALTER TABLE t_ds_relation_user_alertgroup ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_relation_user_alertgroup_id_sequence'); |
|
||||||
|
|
||||||
DROP SEQUENCE IF EXISTS t_ds_resources_id_sequence; |
|
||||||
CREATE SEQUENCE t_ds_resources_id_sequence; |
|
||||||
ALTER TABLE t_ds_resources ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_resources_id_sequence'); |
|
||||||
DROP SEQUENCE IF EXISTS t_ds_schedules_id_sequence; |
|
||||||
CREATE SEQUENCE t_ds_schedules_id_sequence; |
|
||||||
ALTER TABLE t_ds_schedules ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_schedules_id_sequence'); |
|
||||||
DROP SEQUENCE IF EXISTS t_ds_task_instance_id_sequence; |
|
||||||
CREATE SEQUENCE t_ds_task_instance_id_sequence; |
|
||||||
ALTER TABLE t_ds_task_instance ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_task_instance_id_sequence'); |
|
||||||
DROP SEQUENCE IF EXISTS t_ds_tenant_id_sequence; |
|
||||||
CREATE SEQUENCE t_ds_tenant_id_sequence; |
|
||||||
ALTER TABLE t_ds_tenant ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_tenant_id_sequence'); |
|
||||||
DROP SEQUENCE IF EXISTS t_ds_udfs_id_sequence; |
|
||||||
CREATE SEQUENCE t_ds_udfs_id_sequence; |
|
||||||
ALTER TABLE t_ds_udfs ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_udfs_id_sequence'); |
|
||||||
DROP SEQUENCE IF EXISTS t_ds_user_id_sequence; |
|
||||||
CREATE SEQUENCE t_ds_user_id_sequence; |
|
||||||
ALTER TABLE t_ds_user ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_user_id_sequence'); |
|
||||||
|
|
||||||
DROP SEQUENCE IF EXISTS t_ds_version_id_sequence; |
|
||||||
CREATE SEQUENCE t_ds_version_id_sequence; |
|
||||||
ALTER TABLE t_ds_version ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_version_id_sequence'); |
|
||||||
|
|
||||||
DROP SEQUENCE IF EXISTS t_ds_worker_group_id_sequence; |
|
||||||
CREATE SEQUENCE t_ds_worker_group_id_sequence; |
|
||||||
ALTER TABLE t_ds_worker_group ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_worker_group_id_sequence'); |
|
||||||
DROP SEQUENCE IF EXISTS t_ds_worker_server_id_sequence; |
|
||||||
CREATE SEQUENCE t_ds_worker_server_id_sequence; |
|
||||||
ALTER TABLE t_ds_worker_server ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_worker_server_id_sequence'); |
|
||||||
|
|
||||||
|
|
||||||
-- Records of t_ds_user?user : admin , password : dolphinscheduler123 |
|
||||||
INSERT INTO t_ds_user(user_name,user_password,user_type,email,phone,tenant_id,create_time,update_time) VALUES ('admin', '7ad2410b2f4c074479a8937a28a22b8f', '0', 'xxx@qq.com', 'xx', '0', '2018-03-27 15:48:50', '2018-10-24 17:40:22'); |
|
||||||
|
|
||||||
-- Records of t_ds_alertgroup,dolphinscheduler warning group |
|
||||||
INSERT INTO t_ds_alertgroup(group_name,group_type,description,create_time,update_time) VALUES ('dolphinscheduler warning group', '0', 'dolphinscheduler warning group','2018-11-29 10:20:39', '2018-11-29 10:20:39'); |
|
||||||
INSERT INTO t_ds_relation_user_alertgroup(alertgroup_id,user_id,create_time,update_time) VALUES ( '1', '1', '2018-11-29 10:22:33', '2018-11-29 10:22:33'); |
|
||||||
|
|
||||||
-- Records of t_ds_queue,default queue name : default |
|
||||||
INSERT INTO t_ds_queue(queue_name,queue,create_time,update_time) VALUES ('default', 'default','2018-11-29 10:22:33', '2018-11-29 10:22:33'); |
|
||||||
|
|
||||||
-- Records of t_ds_queue,default queue name : default |
|
||||||
INSERT INTO t_ds_version(version) VALUES ('2.0.0'); |
|
@ -0,0 +1,53 @@ |
|||||||
|
/* |
||||||
|
* 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.alert.manager; |
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.alert.utils.Constants; |
||||||
|
import org.apache.dolphinscheduler.alert.utils.DingTalkUtils; |
||||||
|
import org.apache.dolphinscheduler.plugin.model.AlertInfo; |
||||||
|
import org.slf4j.Logger; |
||||||
|
import org.slf4j.LoggerFactory; |
||||||
|
|
||||||
|
import java.io.IOException; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* Ding Talk Manager |
||||||
|
*/ |
||||||
|
public class DingTalkManager { |
||||||
|
private static final Logger logger = LoggerFactory.getLogger(EnterpriseWeChatManager.class); |
||||||
|
|
||||||
|
public Map<String,Object> send(AlertInfo alert) { |
||||||
|
Map<String,Object> retMap = new HashMap<>(); |
||||||
|
retMap.put(Constants.STATUS, false); |
||||||
|
logger.info("send message {}", alert.getAlertData().getTitle()); |
||||||
|
try { |
||||||
|
String msg = buildMessage(alert); |
||||||
|
DingTalkUtils.sendDingTalkMsg(msg, Constants.UTF_8); |
||||||
|
} catch (IOException e) { |
||||||
|
logger.error(e.getMessage(),e); |
||||||
|
} |
||||||
|
retMap.put(Constants.STATUS, true); |
||||||
|
return retMap; |
||||||
|
} |
||||||
|
|
||||||
|
private String buildMessage(AlertInfo alert) { |
||||||
|
String msg = alert.getAlertData().getContent(); |
||||||
|
return msg; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,136 @@ |
|||||||
|
/* |
||||||
|
* 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.alert.utils; |
||||||
|
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON; |
||||||
|
import org.apache.commons.codec.binary.StringUtils; |
||||||
|
import org.apache.http.HttpEntity; |
||||||
|
import org.apache.http.HttpHost; |
||||||
|
import org.apache.http.auth.AuthScope; |
||||||
|
import org.apache.http.auth.UsernamePasswordCredentials; |
||||||
|
import org.apache.http.client.CredentialsProvider; |
||||||
|
import org.apache.http.client.config.RequestConfig; |
||||||
|
import org.apache.http.client.methods.CloseableHttpResponse; |
||||||
|
import org.apache.http.client.methods.HttpPost; |
||||||
|
import org.apache.http.entity.StringEntity; |
||||||
|
import org.apache.http.impl.client.BasicCredentialsProvider; |
||||||
|
import org.apache.http.impl.client.CloseableHttpClient; |
||||||
|
import org.apache.http.impl.client.HttpClients; |
||||||
|
import org.apache.http.util.EntityUtils; |
||||||
|
import org.slf4j.Logger; |
||||||
|
import org.slf4j.LoggerFactory; |
||||||
|
|
||||||
|
import java.io.IOException; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* DingTalkUtils utils |
||||||
|
* support send msg to ding talk by robot message push function. |
||||||
|
* support proxy setting |
||||||
|
*/ |
||||||
|
public class DingTalkUtils { |
||||||
|
public static final Logger logger = LoggerFactory.getLogger(DingTalkUtils.class); |
||||||
|
|
||||||
|
public static final boolean isEnableDingTalk = PropertyUtils.getBoolean(Constants.DINGTALK_ENABLE); |
||||||
|
private static final String dingTaskUrl = PropertyUtils.getString(Constants.DINGTALK_WEBHOOK); |
||||||
|
private static final String keyword = PropertyUtils.getString(Constants.DINGTALK_KEYWORD); |
||||||
|
private static final Boolean isEnableProxy = PropertyUtils.getBoolean(Constants.DINGTALK_PROXY_ENABLE); |
||||||
|
private static final String proxy = PropertyUtils.getString(Constants.DINGTALK_PROXY); |
||||||
|
private static final String user = PropertyUtils.getString(Constants.DINGTALK_USER); |
||||||
|
private static final String passwd = PropertyUtils.getString(Constants.DINGTALK_PASSWORD); |
||||||
|
private static final Integer port = PropertyUtils.getInt(Constants.DINGTALK_PORT); |
||||||
|
|
||||||
|
/** |
||||||
|
* send message interface
|
||||||
|
* only support text message format now. |
||||||
|
* @param msg message context to send |
||||||
|
* @param charset charset type |
||||||
|
* @return result of sending msg |
||||||
|
* @throws IOException the IOException |
||||||
|
*/ |
||||||
|
public static String sendDingTalkMsg(String msg, String charset) throws IOException { |
||||||
|
String msgToJson = textToJsonString(msg + "#" + keyword); |
||||||
|
HttpPost httpPost = constructHttpPost(msgToJson, charset); |
||||||
|
|
||||||
|
CloseableHttpClient httpClient; |
||||||
|
if (isEnableProxy) { |
||||||
|
httpClient = getProxyClient(); |
||||||
|
RequestConfig rcf = getProxyConfig(); |
||||||
|
httpPost.setConfig(rcf); |
||||||
|
} else { |
||||||
|
httpClient = getDefaultClient(); |
||||||
|
} |
||||||
|
|
||||||
|
try { |
||||||
|
CloseableHttpResponse response = httpClient.execute(httpPost); |
||||||
|
String resp; |
||||||
|
try { |
||||||
|
HttpEntity entity = response.getEntity(); |
||||||
|
resp = EntityUtils.toString(entity, charset); |
||||||
|
EntityUtils.consume(entity); |
||||||
|
} finally { |
||||||
|
response.close(); |
||||||
|
} |
||||||
|
logger.info("Ding Talk send [{}], resp:{%s}", msg, resp); |
||||||
|
return resp; |
||||||
|
} finally { |
||||||
|
httpClient.close(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public static HttpPost constructHttpPost(String msg, String charset) { |
||||||
|
HttpPost post = new HttpPost(dingTaskUrl); |
||||||
|
StringEntity entity = new StringEntity(msg, charset); |
||||||
|
post.setEntity(entity); |
||||||
|
post.addHeader("Content-Type", "application/json; charset=utf-8"); |
||||||
|
return post; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public static CloseableHttpClient getProxyClient() { |
||||||
|
HttpHost httpProxy = new HttpHost(proxy, port); |
||||||
|
CredentialsProvider provider = new BasicCredentialsProvider(); |
||||||
|
provider.setCredentials(new AuthScope(httpProxy), new UsernamePasswordCredentials(user, passwd)); |
||||||
|
CloseableHttpClient httpClient = HttpClients.custom().setDefaultCredentialsProvider(provider).build(); |
||||||
|
return httpClient; |
||||||
|
} |
||||||
|
|
||||||
|
public static CloseableHttpClient getDefaultClient() { |
||||||
|
return HttpClients.createDefault(); |
||||||
|
} |
||||||
|
|
||||||
|
public static RequestConfig getProxyConfig() { |
||||||
|
HttpHost httpProxy = new HttpHost(proxy, port); |
||||||
|
return RequestConfig.custom().setProxy(httpProxy).build(); |
||||||
|
} |
||||||
|
|
||||||
|
public static String textToJsonString(String text) { |
||||||
|
Map<String, Object> items = new HashMap<String, Object>(); |
||||||
|
items.put("msgtype", "text"); |
||||||
|
Map<String, String> textContent = new HashMap<String, String>(); |
||||||
|
byte[] byt = StringUtils.getBytesUtf8(text); |
||||||
|
String txt = StringUtils.newStringUtf8(byt); |
||||||
|
textContent.put("content", txt); |
||||||
|
items.put("text", textContent); |
||||||
|
|
||||||
|
return JSON.toJSONString(items); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,125 @@ |
|||||||
|
/* |
||||||
|
* 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.alert.utils; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON; |
||||||
|
import org.apache.http.client.config.RequestConfig; |
||||||
|
import org.apache.http.client.methods.HttpPost; |
||||||
|
import org.apache.http.impl.client.CloseableHttpClient; |
||||||
|
import org.junit.Assert; |
||||||
|
import org.junit.Before; |
||||||
|
import org.junit.Ignore; |
||||||
|
import org.junit.Test; |
||||||
|
import org.junit.runner.RunWith; |
||||||
|
import org.mockito.Mockito; |
||||||
|
import org.powermock.api.mockito.PowerMockito; |
||||||
|
import org.powermock.core.classloader.annotations.PowerMockIgnore; |
||||||
|
import org.powermock.core.classloader.annotations.PrepareForTest; |
||||||
|
import org.powermock.modules.junit4.PowerMockRunner; |
||||||
|
import org.slf4j.Logger; |
||||||
|
import org.slf4j.LoggerFactory; |
||||||
|
|
||||||
|
import java.io.IOException; |
||||||
|
|
||||||
|
import static org.junit.Assert.*; |
||||||
|
|
||||||
|
@PrepareForTest(PropertyUtils.class) |
||||||
|
@RunWith(PowerMockRunner.class) |
||||||
|
@PowerMockIgnore("javax.net.ssl.*") |
||||||
|
public class DingTalkUtilsTest { |
||||||
|
Logger logger = LoggerFactory.getLogger(DingTalkUtilsTest.class); |
||||||
|
|
||||||
|
private static final String mockUrl = "https://oapi.dingtalk.com/robot/send?access_token=test"; |
||||||
|
private static final String mockKeyWords = "onway"; |
||||||
|
private static final String msg = "ding talk test"; |
||||||
|
|
||||||
|
@Before |
||||||
|
public void init(){ |
||||||
|
PowerMockito.mockStatic(PropertyUtils.class); |
||||||
|
Mockito.when(PropertyUtils.getString(Constants.DINGTALK_WEBHOOK)).thenReturn(mockUrl); |
||||||
|
Mockito.when(PropertyUtils.getString(Constants.DINGTALK_KEYWORD)).thenReturn(mockKeyWords); |
||||||
|
Mockito.when(PropertyUtils.getBoolean(Constants.DINGTALK_PROXY_ENABLE)).thenReturn(true); |
||||||
|
Mockito.when(PropertyUtils.getString(Constants.DINGTALK_PROXY)).thenReturn("proxy.com.cn"); |
||||||
|
Mockito.when(PropertyUtils.getString(Constants.DINGTALK_USER)).thenReturn("user"); |
||||||
|
Mockito.when(PropertyUtils.getString(Constants.DINGTALK_PASSWORD)).thenReturn("pswd"); |
||||||
|
Mockito.when(PropertyUtils.getInt(Constants.DINGTALK_PORT)).thenReturn(80); |
||||||
|
} |
||||||
|
|
||||||
|
// @Test
|
||||||
|
// @Ignore
|
||||||
|
// public void testSendMsg() {
|
||||||
|
// try {
|
||||||
|
// String msgTosend = "msg to send";
|
||||||
|
// logger.info(PropertyUtils.getString(Constants.DINGTALK_WEBHOOK));
|
||||||
|
// String rsp = DingTalkUtils.sendDingTalkMsg(msgTosend, Constants.UTF_8);
|
||||||
|
// logger.info("send msg result:{}",rsp);
|
||||||
|
// String errmsg = JSON.parseObject(rsp).getString("errmsg");
|
||||||
|
// Assert.assertEquals("ok", errmsg);
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
@Test |
||||||
|
public void testCreateDefaultClient() { |
||||||
|
CloseableHttpClient client = DingTalkUtils.getDefaultClient();; |
||||||
|
try { |
||||||
|
Assert.assertNotNull(client); |
||||||
|
client.close(); |
||||||
|
} catch (IOException ex) { |
||||||
|
logger.info("close exception",ex.getMessage()); |
||||||
|
new Throwable(); |
||||||
|
} |
||||||
|
} |
||||||
|
@Test |
||||||
|
public void testCreateProxyClient() { |
||||||
|
CloseableHttpClient client = DingTalkUtils.getProxyClient(); |
||||||
|
try { |
||||||
|
Assert.assertNotNull(client); |
||||||
|
client.close(); |
||||||
|
} catch (IOException ex) { |
||||||
|
logger.info("close exception",ex.getMessage()); |
||||||
|
new Throwable(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
@Test |
||||||
|
public void testProxyConfig() { |
||||||
|
RequestConfig rc = DingTalkUtils.getProxyConfig(); |
||||||
|
Assert.assertEquals(rc.getProxy().getPort(), 80); |
||||||
|
Assert.assertEquals(rc.getProxy().getHostName(), "proxy.com.cn"); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testDingTalkMsgToJson() { |
||||||
|
String jsonString = DingTalkUtils.textToJsonString("this is test"); |
||||||
|
|
||||||
|
logger.info(jsonString); |
||||||
|
String expect = "{\"text\":{\"content\":\"this is test\"},\"msgtype\":\"text\"}"; |
||||||
|
Assert.assertEquals(expect, jsonString); |
||||||
|
} |
||||||
|
@Test |
||||||
|
public void testDingTalkMsgUtf8() { |
||||||
|
String msg = DingTalkUtils.textToJsonString("this is test:中文"); |
||||||
|
|
||||||
|
logger.info("test support utf8, actual:" + msg); |
||||||
|
logger.info("test support utf8, actual:" + DingTalkUtils.isEnableDingTalk); |
||||||
|
String expect = "{\"text\":{\"content\":\"this is test:中文\"},\"msgtype\":\"text\"}"; |
||||||
|
Assert.assertEquals(expect, msg); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,108 @@ |
|||||||
|
/* |
||||||
|
* 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 com.github.rholder.retry.*; |
||||||
|
import org.apache.dolphinscheduler.common.Constants; |
||||||
|
|
||||||
|
import java.util.concurrent.Callable; |
||||||
|
import java.util.concurrent.ExecutionException; |
||||||
|
import java.util.concurrent.TimeUnit; |
||||||
|
|
||||||
|
/** |
||||||
|
* The Retryer util. |
||||||
|
*/ |
||||||
|
public class RetryerUtils { |
||||||
|
private static Retryer<Boolean> defaultRetryerResultCheck; |
||||||
|
private static Retryer<Boolean> defaultRetryerResultNoCheck; |
||||||
|
|
||||||
|
private RetryerUtils() { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
private static Retryer<Boolean> getDefaultRetryerResultNoCheck() { |
||||||
|
if (defaultRetryerResultNoCheck == null) { |
||||||
|
defaultRetryerResultNoCheck = RetryerBuilder |
||||||
|
.<Boolean>newBuilder() |
||||||
|
.retryIfException() |
||||||
|
.withWaitStrategy(WaitStrategies.fixedWait(Constants.SLEEP_TIME_MILLIS, TimeUnit.MILLISECONDS)) |
||||||
|
.withStopStrategy(StopStrategies.stopAfterAttempt(3)) |
||||||
|
.build(); |
||||||
|
} |
||||||
|
return defaultRetryerResultNoCheck; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Gets default retryer. |
||||||
|
* the retryer will retry 3 times if exceptions throw |
||||||
|
* and wait 1 second between each retry |
||||||
|
* |
||||||
|
* @param checkResult true means the callable must return true before retrying |
||||||
|
* false means that retry callable only throw exceptions |
||||||
|
* @return the default retryer |
||||||
|
*/ |
||||||
|
public static Retryer<Boolean> getDefaultRetryer(boolean checkResult) { |
||||||
|
return checkResult ? getDefaultRetryer() : getDefaultRetryerResultNoCheck(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Gets default retryer. |
||||||
|
* the retryer will retry 3 times if exceptions throw |
||||||
|
* and wait 1 second between each retry |
||||||
|
* |
||||||
|
* @return the default retryer |
||||||
|
*/ |
||||||
|
public static Retryer<Boolean> getDefaultRetryer() { |
||||||
|
if (defaultRetryerResultCheck == null) { |
||||||
|
defaultRetryerResultCheck = RetryerBuilder |
||||||
|
.<Boolean>newBuilder() |
||||||
|
.retryIfResult(Boolean.FALSE::equals) |
||||||
|
.retryIfException() |
||||||
|
.withWaitStrategy(WaitStrategies.fixedWait(Constants.SLEEP_TIME_MILLIS, TimeUnit.MILLISECONDS)) |
||||||
|
.withStopStrategy(StopStrategies.stopAfterAttempt(3)) |
||||||
|
.build(); |
||||||
|
} |
||||||
|
return defaultRetryerResultCheck; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Use RETRYER to invoke the Callable |
||||||
|
* |
||||||
|
* @param callable the callable |
||||||
|
* @param checkResult true means that retry callable before returning true |
||||||
|
* false means that retry callable only throw exceptions |
||||||
|
* @return the final result of callable |
||||||
|
* @throws ExecutionException the execution exception |
||||||
|
* @throws RetryException the retry exception |
||||||
|
*/ |
||||||
|
public static Boolean retryCall(final Callable<Boolean> callable, boolean checkResult) throws ExecutionException, RetryException { |
||||||
|
return getDefaultRetryer(checkResult).call(callable); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Use RETRYER to invoke the Callable before returning true |
||||||
|
* |
||||||
|
* @param callable the callable |
||||||
|
* @return the boolean |
||||||
|
* @throws ExecutionException the execution exception |
||||||
|
* @throws RetryException the retry exception |
||||||
|
*/ |
||||||
|
public static Boolean retryCall(final Callable<Boolean> callable) throws ExecutionException, RetryException { |
||||||
|
return retryCall(callable, true); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,216 @@ |
|||||||
|
/* |
||||||
|
* 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 com.github.rholder.retry.RetryException; |
||||||
|
import com.github.rholder.retry.Retryer; |
||||||
|
import org.junit.Assert; |
||||||
|
import org.junit.Test; |
||||||
|
|
||||||
|
import java.util.concurrent.ExecutionException; |
||||||
|
|
||||||
|
public class RetryerUtilsTest { |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testDefaultRetryer() { |
||||||
|
Retryer<Boolean> retryer = RetryerUtils.getDefaultRetryer(); |
||||||
|
Assert.assertNotNull(retryer); |
||||||
|
try { |
||||||
|
boolean result = retryer.call(() -> true); |
||||||
|
Assert.assertTrue(result); |
||||||
|
} catch (ExecutionException | RetryException e) { |
||||||
|
Assert.fail("Retry call failed " + e.getMessage()); |
||||||
|
} |
||||||
|
Retryer<Boolean> retryer1 = RetryerUtils.getDefaultRetryer(true); |
||||||
|
Assert.assertEquals(retryer, retryer1); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testDefaultRetryerResultCheck() { |
||||||
|
Retryer<Boolean> retryer = RetryerUtils.getDefaultRetryer(); |
||||||
|
Assert.assertNotNull(retryer); |
||||||
|
try { |
||||||
|
for (int execTarget = 1; execTarget <= 3; execTarget++) { |
||||||
|
int finalExecTarget = execTarget; |
||||||
|
int[] execTime = {0}; |
||||||
|
boolean result = retryer.call(() -> { |
||||||
|
execTime[0]++; |
||||||
|
return execTime[0] == finalExecTarget; |
||||||
|
}); |
||||||
|
Assert.assertEquals(finalExecTarget, execTime[0]); |
||||||
|
Assert.assertTrue(result); |
||||||
|
} |
||||||
|
} catch (ExecutionException | RetryException e) { |
||||||
|
Assert.fail("Retry call failed " + e.getMessage()); |
||||||
|
} |
||||||
|
int[] execTime = {0}; |
||||||
|
try { |
||||||
|
retryer.call(() -> { |
||||||
|
execTime[0]++; |
||||||
|
return execTime[0] == 4; |
||||||
|
}); |
||||||
|
Assert.fail("Retry times not reached"); |
||||||
|
} catch (RetryException e) { |
||||||
|
Assert.assertEquals(3, e.getNumberOfFailedAttempts()); |
||||||
|
Assert.assertEquals(3, execTime[0]); |
||||||
|
} catch (ExecutionException e) { |
||||||
|
Assert.fail("Retry call failed " + e.getMessage()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testDefaultRetryerResultNoCheck() { |
||||||
|
Retryer<Boolean> retryer = RetryerUtils.getDefaultRetryer(false); |
||||||
|
Assert.assertNotNull(retryer); |
||||||
|
try { |
||||||
|
for (int execTarget = 1; execTarget <= 5; execTarget++) { |
||||||
|
int[] execTime = {0}; |
||||||
|
boolean result = retryer.call(() -> { |
||||||
|
execTime[0]++; |
||||||
|
return execTime[0] > 1; |
||||||
|
}); |
||||||
|
Assert.assertEquals(1, execTime[0]); |
||||||
|
Assert.assertFalse(result); |
||||||
|
} |
||||||
|
} catch (ExecutionException | RetryException e) { |
||||||
|
Assert.fail("Retry call failed " + e.getMessage()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testRecallResultCheck() { |
||||||
|
try { |
||||||
|
for (int execTarget = 1; execTarget <= 3; execTarget++) { |
||||||
|
int finalExecTarget = execTarget; |
||||||
|
int[] execTime = {0}; |
||||||
|
boolean result = RetryerUtils.retryCall(() -> { |
||||||
|
execTime[0]++; |
||||||
|
return execTime[0] == finalExecTarget; |
||||||
|
}); |
||||||
|
Assert.assertEquals(finalExecTarget, execTime[0]); |
||||||
|
Assert.assertTrue(result); |
||||||
|
} |
||||||
|
} catch (ExecutionException | RetryException e) { |
||||||
|
Assert.fail("Retry call failed " + e.getMessage()); |
||||||
|
} |
||||||
|
int[] execTime = {0}; |
||||||
|
try { |
||||||
|
RetryerUtils.retryCall(() -> { |
||||||
|
execTime[0]++; |
||||||
|
return execTime[0] == 4; |
||||||
|
}); |
||||||
|
Assert.fail("Recall times not reached"); |
||||||
|
} catch (RetryException e) { |
||||||
|
Assert.assertEquals(3, e.getNumberOfFailedAttempts()); |
||||||
|
Assert.assertEquals(3, execTime[0]); |
||||||
|
} catch (ExecutionException e) { |
||||||
|
Assert.fail("Retry call failed " + e.getMessage()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testRecallResultCheckWithPara() { |
||||||
|
try { |
||||||
|
for (int execTarget = 1; execTarget <= 3; execTarget++) { |
||||||
|
int finalExecTarget = execTarget; |
||||||
|
int[] execTime = {0}; |
||||||
|
boolean result = RetryerUtils.retryCall(() -> { |
||||||
|
execTime[0]++; |
||||||
|
return execTime[0] == finalExecTarget; |
||||||
|
}, true); |
||||||
|
Assert.assertEquals(finalExecTarget, execTime[0]); |
||||||
|
Assert.assertTrue(result); |
||||||
|
} |
||||||
|
} catch (ExecutionException | RetryException e) { |
||||||
|
Assert.fail("Retry call failed " + e.getMessage()); |
||||||
|
} |
||||||
|
int[] execTime = {0}; |
||||||
|
try { |
||||||
|
RetryerUtils.retryCall(() -> { |
||||||
|
execTime[0]++; |
||||||
|
return execTime[0] == 4; |
||||||
|
}, true); |
||||||
|
Assert.fail("Recall times not reached"); |
||||||
|
} catch (RetryException e) { |
||||||
|
Assert.assertEquals(3, e.getNumberOfFailedAttempts()); |
||||||
|
Assert.assertEquals(3, execTime[0]); |
||||||
|
} catch (ExecutionException e) { |
||||||
|
Assert.fail("Retry call failed " + e.getMessage()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testRecallResultNoCheck() { |
||||||
|
try { |
||||||
|
for (int execTarget = 1; execTarget <= 5; execTarget++) { |
||||||
|
int[] execTime = {0}; |
||||||
|
boolean result = RetryerUtils.retryCall(() -> { |
||||||
|
execTime[0]++; |
||||||
|
return execTime[0] > 1; |
||||||
|
}, false); |
||||||
|
Assert.assertEquals(1, execTime[0]); |
||||||
|
Assert.assertFalse(result); |
||||||
|
} |
||||||
|
} catch (ExecutionException | RetryException e) { |
||||||
|
Assert.fail("Retry call failed " + e.getMessage()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private void testRetryExceptionWithPara(boolean checkResult) { |
||||||
|
try { |
||||||
|
for (int execTarget = 1; execTarget <= 3; execTarget++) { |
||||||
|
int finalExecTarget = execTarget; |
||||||
|
int[] execTime = {0}; |
||||||
|
boolean result = RetryerUtils.retryCall(() -> { |
||||||
|
execTime[0]++; |
||||||
|
if (execTime[0] != finalExecTarget) { |
||||||
|
throw new IllegalArgumentException(String.valueOf(execTime[0])); |
||||||
|
} |
||||||
|
return true; |
||||||
|
}, checkResult); |
||||||
|
Assert.assertEquals(finalExecTarget, execTime[0]); |
||||||
|
Assert.assertTrue(result); |
||||||
|
} |
||||||
|
} catch (ExecutionException | RetryException e) { |
||||||
|
Assert.fail("Retry call failed " + e.getMessage()); |
||||||
|
} |
||||||
|
int[] execTime = {0}; |
||||||
|
try { |
||||||
|
RetryerUtils.retryCall(() -> { |
||||||
|
execTime[0]++; |
||||||
|
if (execTime[0] != 4) { |
||||||
|
throw new IllegalArgumentException(String.valueOf(execTime[0])); |
||||||
|
} |
||||||
|
return true; |
||||||
|
}, checkResult); |
||||||
|
Assert.fail("Recall times not reached"); |
||||||
|
} catch (RetryException e) { |
||||||
|
Assert.assertEquals(3, e.getNumberOfFailedAttempts()); |
||||||
|
Assert.assertEquals(3, execTime[0]); |
||||||
|
Assert.assertNotNull(e.getCause()); |
||||||
|
Assert.assertEquals(3, Integer.parseInt(e.getCause().getMessage())); |
||||||
|
} catch (ExecutionException e) { |
||||||
|
Assert.fail("Retry call failed " + e.getMessage()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
public void testRetryException() { |
||||||
|
testRetryExceptionWithPara(true); |
||||||
|
testRetryExceptionWithPara(false); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue