samz406
5 years ago
committed by
GitHub
165 changed files with 6748 additions and 12020 deletions
@ -0,0 +1,24 @@
|
||||
version: '2' |
||||
services: |
||||
zookeeper: |
||||
image: zookeeper |
||||
restart: always |
||||
container_name: zookeeper |
||||
ports: |
||||
- "2181:2181" |
||||
environment: |
||||
ZOO_MY_ID: 1 |
||||
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: |
@ -0,0 +1,771 @@
|
||||
/* |
||||
* 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_id int DEFAULT '-1' , |
||||
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_id int DEFAULT '-1' , |
||||
message text , |
||||
PRIMARY KEY (id) |
||||
); |
||||
-- |
||||
-- Table structure for table t_ds_master_server |
||||
-- |
||||
|
||||
DROP TABLE IF EXISTS t_ds_master_server; |
||||
CREATE TABLE t_ds_master_server ( |
||||
id int NOT NULL , |
||||
host varchar(45) DEFAULT NULL , |
||||
port int DEFAULT NULL , |
||||
zk_directory varchar(64) DEFAULT NULL , |
||||
res_info varchar(256) DEFAULT NULL , |
||||
create_time timestamp DEFAULT NULL , |
||||
last_heartbeat_time timestamp DEFAULT NULL , |
||||
PRIMARY KEY (id) |
||||
) ; |
||||
|
||||
-- |
||||
-- 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 , |
||||
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_id int DEFAULT '-1' , |
||||
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 , |
||||
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_id int DEFAULT '-1' , |
||||
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_id int DEFAULT '-1' , |
||||
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_master_server_id_sequence; |
||||
CREATE SEQUENCE t_ds_master_server_id_sequence; |
||||
ALTER TABLE t_ds_master_server ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_master_server_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 ('1.2.0'); |
@ -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.api.controller; |
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status; |
||||
import org.apache.dolphinscheduler.api.utils.Result; |
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils; |
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.http.MediaType; |
||||
import org.springframework.test.web.servlet.MvcResult; |
||||
import org.springframework.util.LinkedMultiValueMap; |
||||
import org.springframework.util.MultiValueMap; |
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; |
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; |
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; |
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; |
||||
|
||||
|
||||
|
||||
public class AccessTokenControllerTest extends AbstractControllerTest{ |
||||
private static Logger logger = LoggerFactory.getLogger(AccessTokenControllerTest.class); |
||||
|
||||
|
||||
@Test |
||||
public void testCreateToken() throws Exception { |
||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); |
||||
paramsMap.add("userId","4"); |
||||
paramsMap.add("expireTime","2019-12-18 00:00:00"); |
||||
paramsMap.add("token","607f5aeaaa2093dbdff5d5522ce00510"); |
||||
MvcResult mvcResult = mockMvc.perform(post("/access-token/create") |
||||
.header("sessionId", sessionId) |
||||
.params(paramsMap)) |
||||
.andExpect(status().isCreated()) |
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) |
||||
.andReturn(); |
||||
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); |
||||
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue()); |
||||
logger.info(mvcResult.getResponse().getContentAsString()); |
||||
} |
||||
|
||||
@Test |
||||
public void testGenerateToken() throws Exception { |
||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); |
||||
paramsMap.add("userId","4"); |
||||
paramsMap.add("expireTime","2019-12-28 00:00:00"); |
||||
MvcResult mvcResult = mockMvc.perform(post("/access-token/generate") |
||||
.header("sessionId", "5925a115-1691-47e0-9c46-4c7da03f6bbd") |
||||
.params(paramsMap)) |
||||
.andExpect(status().isCreated()) |
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) |
||||
.andReturn(); |
||||
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); |
||||
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue()); |
||||
logger.info(mvcResult.getResponse().getContentAsString()); |
||||
} |
||||
|
||||
@Test |
||||
public void testQueryAccessTokenList() throws Exception { |
||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); |
||||
paramsMap.add("pageNo","1"); |
||||
paramsMap.add("pageSize","20"); |
||||
paramsMap.add("searchVal",""); |
||||
MvcResult mvcResult = mockMvc.perform(get("/access-token/list-paging") |
||||
.header("sessionId", "5925a115-1691-47e0-9c46-4c7da03f6bbd") |
||||
.params(paramsMap)) |
||||
.andExpect(status().isOk()) |
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) |
||||
.andReturn(); |
||||
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); |
||||
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue()); |
||||
logger.info(mvcResult.getResponse().getContentAsString()); |
||||
} |
||||
|
||||
@Test |
||||
public void testDelAccessTokenById() throws Exception { |
||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); |
||||
paramsMap.add("id","13"); |
||||
MvcResult mvcResult = mockMvc.perform(post("/access-token/delete") |
||||
.header("sessionId", "5925a115-1691-47e0-9c46-4c7da03f6bbd") |
||||
.params(paramsMap)) |
||||
.andExpect(status().isOk()) |
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) |
||||
.andReturn(); |
||||
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); |
||||
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue()); |
||||
logger.info(mvcResult.getResponse().getContentAsString()); |
||||
} |
||||
|
||||
@Test |
||||
public void testUpdateToken() throws Exception { |
||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); |
||||
paramsMap.add("id","12"); |
||||
paramsMap.add("userId","4"); |
||||
paramsMap.add("expireTime","2019-12-20 00:00:00"); |
||||
paramsMap.add("token","cxctoken123update"); |
||||
MvcResult mvcResult = mockMvc.perform(post("/access-token/update") |
||||
.header("sessionId", "5925a115-1691-47e0-9c46-4c7da03f6bbd") |
||||
.params(paramsMap)) |
||||
.andExpect(status().isOk()) |
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) |
||||
.andReturn(); |
||||
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); |
||||
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue()); |
||||
logger.info(mvcResult.getResponse().getContentAsString()); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,170 @@
|
||||
/* |
||||
* 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.api.controller; |
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status; |
||||
import org.apache.dolphinscheduler.api.utils.Result; |
||||
import org.apache.dolphinscheduler.common.enums.AlertType; |
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils; |
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.http.MediaType; |
||||
import org.springframework.test.web.servlet.MvcResult; |
||||
import org.springframework.util.LinkedMultiValueMap; |
||||
import org.springframework.util.MultiValueMap; |
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; |
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; |
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; |
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; |
||||
|
||||
public class AlertGroupControllerTest extends AbstractControllerTest{ |
||||
private static final Logger logger = LoggerFactory.getLogger(AlertGroupController.class); |
||||
|
||||
@Test |
||||
public void testCreateAlertgroup() throws Exception { |
||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); |
||||
paramsMap.add("groupName","cxc test group name"); |
||||
paramsMap.add("groupType", AlertType.EMAIL.toString()); |
||||
paramsMap.add("description","cxc junit 测试告警描述"); |
||||
MvcResult mvcResult = mockMvc.perform(post("/alert-group/create") |
||||
.header("sessionId", sessionId) |
||||
.params(paramsMap)) |
||||
.andExpect(status().isCreated()) |
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) |
||||
.andReturn(); |
||||
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); |
||||
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue()); |
||||
logger.info(mvcResult.getResponse().getContentAsString()); |
||||
} |
||||
|
||||
@Test |
||||
public void testList() throws Exception { |
||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); |
||||
MvcResult mvcResult = mockMvc.perform(get("/alert-group/list") |
||||
.header("sessionId", sessionId) |
||||
.params(paramsMap)) |
||||
.andExpect(status().isOk()) |
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) |
||||
.andReturn(); |
||||
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); |
||||
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue()); |
||||
logger.info(mvcResult.getResponse().getContentAsString()); |
||||
|
||||
} |
||||
|
||||
@Test |
||||
public void testListPaging() throws Exception { |
||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); |
||||
paramsMap.add("pageNo","1"); |
||||
paramsMap.add("searchVal", AlertType.EMAIL.toString()); |
||||
paramsMap.add("pageSize","1"); |
||||
MvcResult mvcResult = mockMvc.perform(get("/alert-group/list-paging") |
||||
.header("sessionId", sessionId) |
||||
.params(paramsMap)) |
||||
.andExpect(status().isOk()) |
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) |
||||
.andReturn(); |
||||
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); |
||||
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue()); |
||||
logger.info(mvcResult.getResponse().getContentAsString()); |
||||
} |
||||
|
||||
@Test |
||||
public void testUpdateAlertgroup() throws Exception { |
||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); |
||||
paramsMap.add("id","22"); |
||||
paramsMap.add("groupName", "hd test group name"); |
||||
paramsMap.add("groupType",AlertType.EMAIL.toString()); |
||||
paramsMap.add("description","update alter group"); |
||||
MvcResult mvcResult = mockMvc.perform(post("/alert-group/update") |
||||
.header("sessionId", sessionId) |
||||
.params(paramsMap)) |
||||
.andExpect(status().isOk()) |
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) |
||||
.andReturn(); |
||||
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); |
||||
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue()); |
||||
logger.info(mvcResult.getResponse().getContentAsString()); |
||||
} |
||||
|
||||
|
||||
@Test |
||||
public void testVerifyGroupName() throws Exception { |
||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); |
||||
paramsMap.add("groupName","hd test group name"); |
||||
MvcResult mvcResult = mockMvc.perform(get("/alert-group/verify-group-name") |
||||
.header("sessionId", sessionId) |
||||
.params(paramsMap)) |
||||
.andExpect(status().isOk()) |
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) |
||||
.andReturn(); |
||||
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); |
||||
Assert.assertEquals(Status.ALERT_GROUP_EXIST.getCode(),result.getCode().intValue()); |
||||
logger.info(mvcResult.getResponse().getContentAsString()); |
||||
} |
||||
|
||||
@Test |
||||
public void testVerifyGroupNameNotExit() throws Exception { |
||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); |
||||
paramsMap.add("groupName","cxc test group name"); |
||||
MvcResult mvcResult = mockMvc.perform(get("/alert-group/verify-group-name") |
||||
.header("sessionId", sessionId) |
||||
.params(paramsMap)) |
||||
.andExpect(status().isOk()) |
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) |
||||
.andReturn(); |
||||
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); |
||||
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue()); |
||||
logger.info(mvcResult.getResponse().getContentAsString()); |
||||
} |
||||
|
||||
@Test |
||||
public void testGrantUser() throws Exception { |
||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); |
||||
paramsMap.add("alertgroupId","2"); |
||||
paramsMap.add("userIds","2"); |
||||
|
||||
MvcResult mvcResult = mockMvc.perform(post("/alert-group/grant-user") |
||||
.header("sessionId", sessionId) |
||||
.params(paramsMap)) |
||||
.andExpect(status().isOk()) |
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) |
||||
.andReturn(); |
||||
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); |
||||
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue()); |
||||
logger.info(mvcResult.getResponse().getContentAsString()); |
||||
} |
||||
|
||||
@Test |
||||
public void testDelAlertgroupById() throws Exception { |
||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); |
||||
paramsMap.add("id","22"); |
||||
MvcResult mvcResult = mockMvc.perform(post("/alert-group/delete") |
||||
.header("sessionId", sessionId) |
||||
.params(paramsMap)) |
||||
.andExpect(status().isOk()) |
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) |
||||
.andReturn(); |
||||
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); |
||||
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue()); |
||||
logger.info(mvcResult.getResponse().getContentAsString()); |
||||
} |
||||
} |
@ -0,0 +1,94 @@
|
||||
/* |
||||
* 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.api.controller; |
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status; |
||||
import org.apache.dolphinscheduler.api.utils.Result; |
||||
import org.apache.dolphinscheduler.common.enums.FailureStrategy; |
||||
import org.apache.dolphinscheduler.common.enums.Priority; |
||||
import org.apache.dolphinscheduler.common.enums.WarningType; |
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils; |
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.http.MediaType; |
||||
import org.springframework.test.web.servlet.MvcResult; |
||||
import org.springframework.util.LinkedMultiValueMap; |
||||
import org.springframework.util.MultiValueMap; |
||||
|
||||
import static org.junit.Assert.*; |
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; |
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; |
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; |
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; |
||||
|
||||
public class TaskRecordControllerTest extends AbstractControllerTest { |
||||
private static final Logger logger = LoggerFactory.getLogger(TaskInstanceController.class); |
||||
|
||||
@Test |
||||
public void testQueryTaskRecordListPaging() throws Exception { |
||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); |
||||
paramsMap.add("taskName","taskName"); |
||||
paramsMap.add("state","state"); |
||||
paramsMap.add("sourceTable",""); |
||||
paramsMap.add("destTable",""); |
||||
paramsMap.add("taskDate",""); |
||||
paramsMap.add("startDate","2019-12-16 00:00:00"); |
||||
paramsMap.add("endDate","2019-12-17 00:00:00"); |
||||
paramsMap.add("pageNo","1"); |
||||
paramsMap.add("pageSize","30"); |
||||
|
||||
MvcResult mvcResult = mockMvc.perform(get("/projects/task-record/list-paging") |
||||
.header(SESSION_ID, sessionId) |
||||
.params(paramsMap)) |
||||
.andExpect(status().isOk()) |
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) |
||||
.andReturn(); |
||||
|
||||
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); |
||||
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue()); |
||||
logger.info(mvcResult.getResponse().getContentAsString()); |
||||
} |
||||
|
||||
|
||||
@Test |
||||
public void testQueryHistoryTaskRecordListPaging() throws Exception { |
||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); |
||||
paramsMap.add("taskName","taskName"); |
||||
paramsMap.add("state","state"); |
||||
paramsMap.add("sourceTable",""); |
||||
paramsMap.add("destTable",""); |
||||
paramsMap.add("taskDate",""); |
||||
paramsMap.add("startDate","2019-12-16 00:00:00"); |
||||
paramsMap.add("endDate","2019-12-17 00:00:00"); |
||||
paramsMap.add("pageNo","1"); |
||||
paramsMap.add("pageSize","30"); |
||||
|
||||
MvcResult mvcResult = mockMvc.perform(get("/projects/task-record/history-list-paging") |
||||
.header(SESSION_ID, sessionId) |
||||
.params(paramsMap)) |
||||
.andExpect(status().isOk()) |
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) |
||||
.andReturn(); |
||||
|
||||
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); |
||||
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue()); |
||||
logger.info(mvcResult.getResponse().getContentAsString()); |
||||
|
||||
} |
||||
} |
@ -0,0 +1,102 @@
|
||||
|
||||
/* |
||||
* 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.api.controller; |
||||
|
||||
import org.apache.dolphinscheduler.api.enums.Status; |
||||
import org.apache.dolphinscheduler.api.utils.Result; |
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils; |
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.http.MediaType; |
||||
import org.springframework.test.web.servlet.MvcResult; |
||||
import org.springframework.util.LinkedMultiValueMap; |
||||
import org.springframework.util.MultiValueMap; |
||||
|
||||
import static org.junit.Assert.*; |
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; |
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; |
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; |
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; |
||||
|
||||
public class WorkerGroupControllerTest extends AbstractControllerTest{ |
||||
private static Logger logger = LoggerFactory.getLogger(WorkerGroupControllerTest.class); |
||||
|
||||
@Test |
||||
public void testSaveWorkerGroup() throws Exception { |
||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); |
||||
paramsMap.add("name","cxc_work_group"); |
||||
paramsMap.add("ipList","192.16.12,192.168,10,12"); |
||||
MvcResult mvcResult = mockMvc.perform(post("/worker-group/save") |
||||
.header("sessionId", sessionId) |
||||
.params(paramsMap)) |
||||
.andExpect(status().isOk()) |
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) |
||||
.andReturn(); |
||||
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); |
||||
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue()); |
||||
logger.info(mvcResult.getResponse().getContentAsString()); |
||||
} |
||||
|
||||
@Test |
||||
public void testQueryAllWorkerGroupsPaging() throws Exception { |
||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); |
||||
paramsMap.add("pageNo","2"); |
||||
paramsMap.add("searchVal","cxc"); |
||||
paramsMap.add("pageSize","2"); |
||||
MvcResult mvcResult = mockMvc.perform(get("/worker-group/list-paging") |
||||
.header("sessionId", sessionId) |
||||
.params(paramsMap)) |
||||
.andExpect(status().isOk()) |
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) |
||||
.andReturn(); |
||||
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); |
||||
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue()); |
||||
logger.info(mvcResult.getResponse().getContentAsString()); |
||||
} |
||||
|
||||
@Test |
||||
public void testQueryAllWorkerGroups() throws Exception { |
||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); |
||||
MvcResult mvcResult = mockMvc.perform(get("/worker-group/all-groups") |
||||
.header("sessionId", sessionId) |
||||
.params(paramsMap)) |
||||
.andExpect(status().isOk()) |
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) |
||||
.andReturn(); |
||||
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); |
||||
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue()); |
||||
logger.info(mvcResult.getResponse().getContentAsString()); |
||||
} |
||||
|
||||
@Test |
||||
public void testDeleteById() throws Exception { |
||||
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); |
||||
paramsMap.add("id","12"); |
||||
MvcResult mvcResult = mockMvc.perform(get("/worker-group/delete-by-id") |
||||
.header("sessionId", sessionId) |
||||
.params(paramsMap)) |
||||
.andExpect(status().isOk()) |
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) |
||||
.andReturn(); |
||||
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class); |
||||
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue()); |
||||
logger.info(mvcResult.getResponse().getContentAsString()); |
||||
} |
||||
} |
@ -0,0 +1,32 @@
|
||||
/* |
||||
* 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.api.enums; |
||||
|
||||
import org.junit.Test; |
||||
import static org.junit.Assert.*; |
||||
|
||||
public class ExecuteTypeTest { |
||||
|
||||
@Test |
||||
public void testGetEnum() { |
||||
assertEquals(ExecuteType.REPEAT_RUNNING, ExecuteType.getEnum(1)); |
||||
assertEquals(ExecuteType.RECOVER_SUSPENDED_PROCESS, ExecuteType.getEnum(2)); |
||||
assertEquals(ExecuteType.START_FAILURE_TASK_PROCESS, ExecuteType.getEnum(3)); |
||||
assertEquals(ExecuteType.STOP, ExecuteType.getEnum(4)); |
||||
assertEquals(ExecuteType.PAUSE, ExecuteType.getEnum(5)); |
||||
} |
||||
} |
@ -0,0 +1,34 @@
|
||||
/* |
||||
* 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.api.enums; |
||||
|
||||
import org.junit.Test; |
||||
import static org.junit.Assert.*; |
||||
|
||||
public class StatusTest { |
||||
|
||||
@Test |
||||
public void testGetCode() { |
||||
assertEquals(Status.SUCCESS.getCode(), 0); |
||||
assertNotEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR.getCode(), 0); |
||||
} |
||||
|
||||
@Test |
||||
public void testGetMsg() { |
||||
assertEquals("success", Status.SUCCESS.getMsg()); |
||||
} |
||||
} |
@ -0,0 +1,288 @@
|
||||
/* |
||||
* 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.springframework.lang.Nullable; |
||||
|
||||
/** |
||||
* A collection of static utility methods to validate input. |
||||
* |
||||
* <p>This class is modelled after Google Guava's Preconditions class, and partly takes code |
||||
* from that class. We add this code to here base in order to reduce external |
||||
* dependencies. |
||||
*/ |
||||
public final class Preconditions { |
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Null checks
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/** |
||||
* Ensures that the given object reference is not null. |
||||
* Upon violation, a {@code NullPointerException} with no message is thrown. |
||||
* |
||||
* @param reference The object reference |
||||
* @return The object reference itself (generically typed). |
||||
* |
||||
* @throws NullPointerException Thrown, if the passed reference was null. |
||||
*/ |
||||
public static <T> T checkNotNull(T reference) { |
||||
if (reference == null) { |
||||
throw new NullPointerException(); |
||||
} |
||||
return reference; |
||||
} |
||||
|
||||
/** |
||||
* Ensures that the given object reference is not null. |
||||
* Upon violation, a {@code NullPointerException} with the given message is thrown. |
||||
* |
||||
* @param reference The object reference |
||||
* @param errorMessage The message for the {@code NullPointerException} that is thrown if the check fails. |
||||
* @return The object reference itself (generically typed). |
||||
* |
||||
* @throws NullPointerException Thrown, if the passed reference was null. |
||||
*/ |
||||
public static <T> T checkNotNull(T reference, @Nullable String errorMessage) { |
||||
if (reference == null) { |
||||
throw new NullPointerException(String.valueOf(errorMessage)); |
||||
} |
||||
return reference; |
||||
} |
||||
|
||||
/** |
||||
* Ensures that the given object reference is not null. |
||||
* Upon violation, a {@code NullPointerException} with the given message is thrown. |
||||
* |
||||
* <p>The error message is constructed from a template and an arguments array, after |
||||
* a similar fashion as {@link String#format(String, Object...)}, but supporting only |
||||
* {@code %s} as a placeholder. |
||||
* |
||||
* @param reference The object reference |
||||
* @param errorMessageTemplate The message template for the {@code NullPointerException} |
||||
* that is thrown if the check fails. The template substitutes its |
||||
* {@code %s} placeholders with the error message arguments. |
||||
* @param errorMessageArgs The arguments for the error message, to be inserted into the |
||||
* message template for the {@code %s} placeholders. |
||||
* |
||||
* @return The object reference itself (generically typed). |
||||
* |
||||
* @throws NullPointerException Thrown, if the passed reference was null. |
||||
*/ |
||||
public static <T> T checkNotNull(T reference, |
||||
@Nullable String errorMessageTemplate, |
||||
@Nullable Object... errorMessageArgs) { |
||||
|
||||
if (reference == null) { |
||||
throw new NullPointerException(format(errorMessageTemplate, errorMessageArgs)); |
||||
} |
||||
return reference; |
||||
} |
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Boolean Condition Checking (Argument)
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/** |
||||
* Checks the given boolean condition, and throws an {@code IllegalArgumentException} if |
||||
* the condition is not met (evaluates to {@code false}). |
||||
* |
||||
* @param condition The condition to check |
||||
* |
||||
* @throws IllegalArgumentException Thrown, if the condition is violated. |
||||
*/ |
||||
public static void checkArgument(boolean condition) { |
||||
if (!condition) { |
||||
throw new IllegalArgumentException(); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Checks the given boolean condition, and throws an {@code IllegalArgumentException} if |
||||
* the condition is not met (evaluates to {@code false}). The exception will have the |
||||
* given error message. |
||||
* |
||||
* @param condition The condition to check |
||||
* @param errorMessage The message for the {@code IllegalArgumentException} that is thrown if the check fails. |
||||
* |
||||
* @throws IllegalArgumentException Thrown, if the condition is violated. |
||||
*/ |
||||
public static void checkArgument(boolean condition, @Nullable Object errorMessage) { |
||||
if (!condition) { |
||||
throw new IllegalArgumentException(String.valueOf(errorMessage)); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Checks the given boolean condition, and throws an {@code IllegalArgumentException} if |
||||
* the condition is not met (evaluates to {@code false}). |
||||
* |
||||
* @param condition The condition to check |
||||
* @param errorMessageTemplate The message template for the {@code IllegalArgumentException} |
||||
* that is thrown if the check fails. The template substitutes its |
||||
* {@code %s} placeholders with the error message arguments. |
||||
* @param errorMessageArgs The arguments for the error message, to be inserted into the |
||||
* message template for the {@code %s} placeholders. |
||||
* |
||||
* @throws IllegalArgumentException Thrown, if the condition is violated. |
||||
*/ |
||||
public static void checkArgument(boolean condition, |
||||
@Nullable String errorMessageTemplate, |
||||
@Nullable Object... errorMessageArgs) { |
||||
|
||||
if (!condition) { |
||||
throw new IllegalArgumentException(format(errorMessageTemplate, errorMessageArgs)); |
||||
} |
||||
} |
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Boolean Condition Checking (State)
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/** |
||||
* Checks the given boolean condition, and throws an {@code IllegalStateException} if |
||||
* the condition is not met (evaluates to {@code false}). |
||||
* |
||||
* @param condition The condition to check |
||||
* |
||||
* @throws IllegalStateException Thrown, if the condition is violated. |
||||
*/ |
||||
public static void checkState(boolean condition) { |
||||
if (!condition) { |
||||
throw new IllegalStateException(); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Checks the given boolean condition, and throws an {@code IllegalStateException} if |
||||
* the condition is not met (evaluates to {@code false}). The exception will have the |
||||
* given error message. |
||||
* |
||||
* @param condition The condition to check |
||||
* @param errorMessage The message for the {@code IllegalStateException} that is thrown if the check fails. |
||||
* |
||||
* @throws IllegalStateException Thrown, if the condition is violated. |
||||
*/ |
||||
public static void checkState(boolean condition, @Nullable Object errorMessage) { |
||||
if (!condition) { |
||||
throw new IllegalStateException(String.valueOf(errorMessage)); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Checks the given boolean condition, and throws an {@code IllegalStateException} if |
||||
* the condition is not met (evaluates to {@code false}). |
||||
* |
||||
* @param condition The condition to check |
||||
* @param errorMessageTemplate The message template for the {@code IllegalStateException} |
||||
* that is thrown if the check fails. The template substitutes its |
||||
* {@code %s} placeholders with the error message arguments. |
||||
* @param errorMessageArgs The arguments for the error message, to be inserted into the |
||||
* message template for the {@code %s} placeholders. |
||||
* |
||||
* @throws IllegalStateException Thrown, if the condition is violated. |
||||
*/ |
||||
public static void checkState(boolean condition, |
||||
@Nullable String errorMessageTemplate, |
||||
@Nullable Object... errorMessageArgs) { |
||||
|
||||
if (!condition) { |
||||
throw new IllegalStateException(format(errorMessageTemplate, errorMessageArgs)); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Ensures that the given index is valid for an array, list or string of the given size. |
||||
* |
||||
* @param index index to check |
||||
* @param size size of the array, list or string |
||||
* |
||||
* @throws IllegalArgumentException Thrown, if size is negative. |
||||
* @throws IndexOutOfBoundsException Thrown, if the index negative or greater than or equal to size |
||||
*/ |
||||
public static void checkElementIndex(int index, int size) { |
||||
checkArgument(size >= 0, "Size was negative."); |
||||
if (index < 0 || index >= size) { |
||||
throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Ensures that the given index is valid for an array, list or string of the given size. |
||||
* |
||||
* @param index index to check |
||||
* @param size size of the array, list or string |
||||
* @param errorMessage The message for the {@code IndexOutOfBoundsException} that is thrown if the check fails. |
||||
* |
||||
* @throws IllegalArgumentException Thrown, if size is negative. |
||||
* @throws IndexOutOfBoundsException Thrown, if the index negative or greater than or equal to size |
||||
*/ |
||||
public static void checkElementIndex(int index, int size, @Nullable String errorMessage) { |
||||
checkArgument(size >= 0, "Size was negative."); |
||||
if (index < 0 || index >= size) { |
||||
throw new IndexOutOfBoundsException(String.valueOf(errorMessage) + " Index: " + index + ", Size: " + size); |
||||
} |
||||
} |
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Utilities
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/** |
||||
* A simplified formatting method. Similar to {@link String#format(String, Object...)}, but |
||||
* with lower overhead (only String parameters, no locale, no format validation). |
||||
* |
||||
* <p>This method is taken quasi verbatim from the Guava Preconditions class. |
||||
*/ |
||||
private static String format(@Nullable String template, @Nullable Object... args) { |
||||
final int numArgs = args == null ? 0 : args.length; |
||||
template = String.valueOf(template); // null -> "null"
|
||||
|
||||
// start substituting the arguments into the '%s' placeholders
|
||||
StringBuilder builder = new StringBuilder(template.length() + 16 * numArgs); |
||||
int templateStart = 0; |
||||
int i = 0; |
||||
while (i < numArgs) { |
||||
int placeholderStart = template.indexOf("%s", templateStart); |
||||
if (placeholderStart == -1) { |
||||
break; |
||||
} |
||||
builder.append(template.substring(templateStart, placeholderStart)); |
||||
builder.append(args[i++]); |
||||
templateStart = placeholderStart + 2; |
||||
} |
||||
builder.append(template.substring(templateStart)); |
||||
|
||||
// if we run out of placeholders, append the extra args in square braces
|
||||
if (i < numArgs) { |
||||
builder.append(" ["); |
||||
builder.append(args[i++]); |
||||
while (i < numArgs) { |
||||
builder.append(", "); |
||||
builder.append(args[i++]); |
||||
} |
||||
builder.append(']'); |
||||
} |
||||
|
||||
return builder.toString(); |
||||
} |
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/** Private constructor to prevent instantiation. */ |
||||
private Preconditions() {} |
||||
} |
@ -0,0 +1,35 @@
|
||||
/* |
||||
* 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.zk; |
||||
|
||||
import org.apache.curator.framework.CuratorFramework; |
||||
import org.apache.curator.framework.recipes.cache.TreeCacheEvent; |
||||
import org.apache.curator.framework.recipes.cache.TreeCacheListener; |
||||
|
||||
public abstract class AbstractListener implements TreeCacheListener { |
||||
|
||||
@Override |
||||
public final void childEvent(final CuratorFramework client, final TreeCacheEvent event) throws Exception { |
||||
String path = null == event.getData() ? "" : event.getData().getPath(); |
||||
if (path.isEmpty()) { |
||||
return; |
||||
} |
||||
dataChanged(client, event, path); |
||||
} |
||||
|
||||
protected abstract void dataChanged(final CuratorFramework client, final TreeCacheEvent event, final String path); |
||||
} |
@ -0,0 +1,48 @@
|
||||
/* |
||||
* 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.zk; |
||||
|
||||
import org.apache.curator.ensemble.EnsembleProvider; |
||||
|
||||
import java.io.IOException; |
||||
|
||||
/** |
||||
* default conf provider |
||||
*/ |
||||
public class DefaultEnsembleProvider implements EnsembleProvider { |
||||
|
||||
private final String serverList; |
||||
|
||||
public DefaultEnsembleProvider(String serverList){ |
||||
this.serverList = serverList; |
||||
} |
||||
|
||||
@Override |
||||
public void start() throws Exception { |
||||
//NOP
|
||||
} |
||||
|
||||
@Override |
||||
public String getConnectionString() { |
||||
return serverList; |
||||
} |
||||
|
||||
@Override |
||||
public void close() throws IOException { |
||||
//NOP
|
||||
} |
||||
} |
@ -0,0 +1,82 @@
|
||||
/* |
||||
* 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.zk; |
||||
|
||||
import org.apache.curator.framework.recipes.cache.ChildData; |
||||
import org.apache.curator.framework.recipes.cache.TreeCache; |
||||
import org.apache.curator.framework.recipes.cache.TreeCacheListener; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import java.nio.charset.StandardCharsets; |
||||
import java.util.concurrent.ConcurrentHashMap; |
||||
|
||||
import static org.apache.dolphinscheduler.common.utils.Preconditions.*; |
||||
import static org.apache.dolphinscheduler.common.utils.Preconditions.checkNotNull; |
||||
|
||||
@Component |
||||
public class ZookeeperCachedOperator extends ZookeeperOperator { |
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(ZookeeperCachedOperator.class); |
||||
|
||||
//kay is zk path, value is TreeCache
|
||||
private ConcurrentHashMap<String, TreeCache> allCaches = new ConcurrentHashMap<>(); |
||||
|
||||
/** |
||||
* @param cachePath zk path |
||||
* @param listener operator |
||||
*/ |
||||
public void registerListener(final String cachePath, final TreeCacheListener listener) { |
||||
TreeCache newCache = new TreeCache(zkClient, cachePath); |
||||
logger.info("add listener to zk path: {}", cachePath); |
||||
try { |
||||
newCache.start(); |
||||
} catch (Exception e) { |
||||
logger.error("add listener to zk path: {} failed", cachePath); |
||||
throw new RuntimeException(e); |
||||
} |
||||
|
||||
newCache.getListenable().addListener(listener); |
||||
|
||||
allCaches.put(cachePath, newCache); |
||||
} |
||||
|
||||
public String getFromCache(final String cachePath, final String key) { |
||||
ChildData resultInCache = allCaches.get(checkNotNull(cachePath)).getCurrentData(key); |
||||
if (null != resultInCache) { |
||||
return null == resultInCache.getData() ? null : new String(resultInCache.getData(), StandardCharsets.UTF_8); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public TreeCache getTreeCache(final String cachePath) { |
||||
return allCaches.get(checkNotNull(cachePath)); |
||||
} |
||||
|
||||
public void close() { |
||||
|
||||
allCaches.forEach((path, cache) -> { |
||||
cache.close(); |
||||
try { |
||||
Thread.sleep(500); |
||||
} catch (InterruptedException ignore) { |
||||
} |
||||
}); |
||||
super.close(); |
||||
} |
||||
} |
@ -0,0 +1,118 @@
|
||||
/* |
||||
* 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.zk; |
||||
|
||||
import org.springframework.beans.factory.annotation.Value; |
||||
import org.springframework.context.annotation.PropertySource; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
/** |
||||
* zookeeper conf |
||||
*/ |
||||
@Component |
||||
@PropertySource("classpath:zookeeper.properties") |
||||
public class ZookeeperConfig { |
||||
|
||||
//zk connect config
|
||||
@Value("${zookeeper.quorum}") |
||||
private String serverList; |
||||
|
||||
@Value("${zookeeper.retry.base.sleep:100}") |
||||
private int baseSleepTimeMs; |
||||
|
||||
@Value("${zookeeper.retry.max.sleep:30000}") |
||||
private int maxSleepMs; |
||||
|
||||
@Value("${zookeeper.retry.maxtime:10}") |
||||
private int maxRetries; |
||||
|
||||
@Value("${zookeeper.session.timeout:60000}") |
||||
private int sessionTimeoutMs; |
||||
|
||||
@Value("${zookeeper.connection.timeout:30000}") |
||||
private int connectionTimeoutMs; |
||||
|
||||
@Value("${zookeeper.connection.digest: }") |
||||
private String digest; |
||||
|
||||
@Value("${zookeeper.dolphinscheduler.root:/dolphinscheduler}") |
||||
private String dsRoot; |
||||
|
||||
public String getServerList() { |
||||
return serverList; |
||||
} |
||||
|
||||
public void setServerList(String serverList) { |
||||
this.serverList = serverList; |
||||
} |
||||
|
||||
public int getBaseSleepTimeMs() { |
||||
return baseSleepTimeMs; |
||||
} |
||||
|
||||
public void setBaseSleepTimeMs(int baseSleepTimeMs) { |
||||
this.baseSleepTimeMs = baseSleepTimeMs; |
||||
} |
||||
|
||||
public int getMaxSleepMs() { |
||||
return maxSleepMs; |
||||
} |
||||
|
||||
public void setMaxSleepMs(int maxSleepMs) { |
||||
this.maxSleepMs = maxSleepMs; |
||||
} |
||||
|
||||
public int getMaxRetries() { |
||||
return maxRetries; |
||||
} |
||||
|
||||
public void setMaxRetries(int maxRetries) { |
||||
this.maxRetries = maxRetries; |
||||
} |
||||
|
||||
public int getSessionTimeoutMs() { |
||||
return sessionTimeoutMs; |
||||
} |
||||
|
||||
public void setSessionTimeoutMs(int sessionTimeoutMs) { |
||||
this.sessionTimeoutMs = sessionTimeoutMs; |
||||
} |
||||
|
||||
public int getConnectionTimeoutMs() { |
||||
return connectionTimeoutMs; |
||||
} |
||||
|
||||
public void setConnectionTimeoutMs(int connectionTimeoutMs) { |
||||
this.connectionTimeoutMs = connectionTimeoutMs; |
||||
} |
||||
|
||||
public String getDigest() { |
||||
return digest; |
||||
} |
||||
|
||||
public void setDigest(String digest) { |
||||
this.digest = digest; |
||||
} |
||||
|
||||
public String getDsRoot() { |
||||
return dsRoot; |
||||
} |
||||
|
||||
public void setDsRoot(String dsRoot) { |
||||
this.dsRoot = dsRoot; |
||||
} |
||||
} |
@ -0,0 +1,232 @@
|
||||
/* |
||||
* 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.zk; |
||||
|
||||
import org.apache.commons.lang.StringUtils; |
||||
import org.apache.curator.framework.CuratorFramework; |
||||
import org.apache.curator.framework.CuratorFrameworkFactory; |
||||
import org.apache.curator.framework.api.ACLProvider; |
||||
import org.apache.curator.framework.state.ConnectionState; |
||||
import org.apache.curator.retry.ExponentialBackoffRetry; |
||||
import org.apache.curator.utils.CloseableUtils; |
||||
import org.apache.zookeeper.CreateMode; |
||||
import org.apache.zookeeper.KeeperException; |
||||
import org.apache.zookeeper.ZooDefs; |
||||
import org.apache.zookeeper.data.ACL; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.beans.factory.InitializingBean; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Component; |
||||
import org.springframework.util.CollectionUtils; |
||||
|
||||
import java.nio.charset.StandardCharsets; |
||||
import java.util.List; |
||||
|
||||
import static org.apache.dolphinscheduler.common.utils.Preconditions.*; |
||||
import static org.apache.dolphinscheduler.common.utils.Preconditions.checkNotNull; |
||||
|
||||
/** |
||||
* zk base operator |
||||
*/ |
||||
@Component |
||||
public class ZookeeperOperator implements InitializingBean { |
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(ZookeeperOperator.class); |
||||
|
||||
@Autowired |
||||
private ZookeeperConfig zookeeperConfig; |
||||
|
||||
protected CuratorFramework zkClient; |
||||
|
||||
@Override |
||||
public void afterPropertiesSet() throws Exception { |
||||
this.zkClient = buildClient(); |
||||
initStateLister(); |
||||
//init();
|
||||
} |
||||
|
||||
//for subclass
|
||||
//protected void init(){}
|
||||
|
||||
public void initStateLister() { |
||||
checkNotNull(zkClient); |
||||
|
||||
zkClient.getConnectionStateListenable().addListener((client, newState) -> { |
||||
if(newState == ConnectionState.LOST){ |
||||
logger.error("connection lost from zookeeper"); |
||||
} else if(newState == ConnectionState.RECONNECTED){ |
||||
logger.info("reconnected to zookeeper"); |
||||
} else if(newState == ConnectionState.SUSPENDED){ |
||||
logger.warn("connection SUSPENDED to zookeeper"); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private CuratorFramework buildClient() { |
||||
logger.info("zookeeper registry center init, server lists is: {}.", zookeeperConfig.getServerList()); |
||||
|
||||
CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder().ensembleProvider(new DefaultEnsembleProvider(checkNotNull(zookeeperConfig.getServerList(),"zookeeper quorum can't be null"))) |
||||
.retryPolicy(new ExponentialBackoffRetry(zookeeperConfig.getBaseSleepTimeMs(), zookeeperConfig.getMaxRetries(), zookeeperConfig.getMaxSleepMs())); |
||||
|
||||
//these has default value
|
||||
if (0 != zookeeperConfig.getSessionTimeoutMs()) { |
||||
builder.sessionTimeoutMs(zookeeperConfig.getSessionTimeoutMs()); |
||||
} |
||||
if (0 != zookeeperConfig.getConnectionTimeoutMs()) { |
||||
builder.connectionTimeoutMs(zookeeperConfig.getConnectionTimeoutMs()); |
||||
} |
||||
if (StringUtils.isNotBlank(zookeeperConfig.getDigest())) { |
||||
builder.authorization("digest", zookeeperConfig.getDigest().getBytes(StandardCharsets.UTF_8)).aclProvider(new ACLProvider() { |
||||
|
||||
@Override |
||||
public List<ACL> getDefaultAcl() { |
||||
return ZooDefs.Ids.CREATOR_ALL_ACL; |
||||
} |
||||
|
||||
@Override |
||||
public List<ACL> getAclForPath(final String path) { |
||||
return ZooDefs.Ids.CREATOR_ALL_ACL; |
||||
} |
||||
}); |
||||
} |
||||
zkClient = builder.build(); |
||||
zkClient.start(); |
||||
try { |
||||
zkClient.blockUntilConnected(); |
||||
} catch (final Exception ex) { |
||||
throw new RuntimeException(ex); |
||||
} |
||||
return zkClient; |
||||
} |
||||
|
||||
public String get(final String key) { |
||||
try { |
||||
return new String(zkClient.getData().forPath(key), StandardCharsets.UTF_8); |
||||
} catch (Exception ex) { |
||||
logger.error("get key : {}", key, ex); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
public List<String> getChildrenKeys(final String key) { |
||||
List<String> values; |
||||
try { |
||||
values = zkClient.getChildren().forPath(key); |
||||
if (CollectionUtils.isEmpty(values)) { |
||||
logger.warn("getChildrenKeys key : {} is empty", key); |
||||
} |
||||
return values; |
||||
} catch (InterruptedException ex) { |
||||
logger.error("getChildrenKeys key : {} InterruptedException", key); |
||||
throw new IllegalStateException(ex); |
||||
} catch (Exception ex) { |
||||
logger.error("getChildrenKeys key : {}", key, ex); |
||||
throw new RuntimeException(ex); |
||||
} |
||||
} |
||||
|
||||
public boolean isExisted(final String key) { |
||||
try { |
||||
return zkClient.checkExists().forPath(key) != null; |
||||
} catch (Exception ex) { |
||||
logger.error("isExisted key : {}", key, ex); |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
public void persist(final String key, final String value) { |
||||
try { |
||||
if (!isExisted(key)) { |
||||
zkClient.create().creatingParentsIfNeeded().withMode(CreateMode.PERSISTENT).forPath(key, value.getBytes(StandardCharsets.UTF_8)); |
||||
} else { |
||||
update(key, value); |
||||
} |
||||
} catch (Exception ex) { |
||||
logger.error("persist key : {} , value : {}", key, value, ex); |
||||
} |
||||
} |
||||
|
||||
public void update(final String key, final String value) { |
||||
try { |
||||
zkClient.inTransaction().check().forPath(key).and().setData().forPath(key, value.getBytes(StandardCharsets.UTF_8)).and().commit(); |
||||
} catch (Exception ex) { |
||||
logger.error("update key : {} , value : {}", key, value, ex); |
||||
} |
||||
} |
||||
|
||||
public void persistEphemeral(final String key, final String value) { |
||||
try { |
||||
if (isExisted(key)) { |
||||
try { |
||||
zkClient.delete().deletingChildrenIfNeeded().forPath(key); |
||||
} catch (KeeperException.NoNodeException ignore) { |
||||
//NOP
|
||||
} |
||||
} |
||||
zkClient.create().creatingParentsIfNeeded().withMode(CreateMode.EPHEMERAL).forPath(key, value.getBytes(StandardCharsets.UTF_8)); |
||||
} catch (final Exception ex) { |
||||
logger.error("persistEphemeral key : {} , value : {}", key, value, ex); |
||||
} |
||||
} |
||||
|
||||
public void persistEphemeral(String key, String value, boolean overwrite) { |
||||
try { |
||||
if (overwrite) { |
||||
persistEphemeral(key, value); |
||||
} else { |
||||
if (!isExisted(key)) { |
||||
zkClient.create().creatingParentsIfNeeded().withMode(CreateMode.EPHEMERAL).forPath(key, value.getBytes(StandardCharsets.UTF_8)); |
||||
} |
||||
} |
||||
} catch (final Exception ex) { |
||||
logger.error("persistEphemeral key : {} , value : {}, overwrite : {}", key, value, overwrite, ex); |
||||
} |
||||
} |
||||
|
||||
public void persistEphemeralSequential(final String key, String value) { |
||||
try { |
||||
zkClient.create().creatingParentsIfNeeded().withMode(CreateMode.EPHEMERAL_SEQUENTIAL).forPath(key, value.getBytes(StandardCharsets.UTF_8)); |
||||
} catch (final Exception ex) { |
||||
logger.error("persistEphemeralSequential key : {}", key, ex); |
||||
} |
||||
} |
||||
|
||||
public void remove(final String key) { |
||||
try { |
||||
if (isExisted(key)) { |
||||
zkClient.delete().deletingChildrenIfNeeded().forPath(key); |
||||
} |
||||
} catch (KeeperException.NoNodeException ignore) { |
||||
//NOP
|
||||
} catch (final Exception ex) { |
||||
logger.error("remove key : {}", key, ex); |
||||
} |
||||
} |
||||
|
||||
public CuratorFramework getZkClient() { |
||||
return zkClient; |
||||
} |
||||
|
||||
public ZookeeperConfig getZookeeperConfig() { |
||||
return zookeeperConfig; |
||||
} |
||||
|
||||
public void close() { |
||||
CloseableUtils.closeQuietly(zkClient); |
||||
} |
||||
} |
@ -0,0 +1,130 @@
|
||||
/* |
||||
* 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.alibaba.fastjson.JSONObject; |
||||
import org.apache.commons.lang.time.DateUtils; |
||||
import org.apache.dolphinscheduler.common.enums.CommandType; |
||||
import org.apache.dolphinscheduler.common.enums.DataType; |
||||
import org.apache.dolphinscheduler.common.enums.Direct; |
||||
import org.apache.dolphinscheduler.common.process.Property; |
||||
import org.apache.dolphinscheduler.common.utils.placeholder.PlaceholderUtils; |
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import java.util.*; |
||||
import static org.apache.dolphinscheduler.common.Constants.PARAMETER_FORMAT_TIME; |
||||
import static org.apache.dolphinscheduler.common.utils.placeholder.TimePlaceholderUtils.replacePlaceholders; |
||||
|
||||
|
||||
public class ParameterUtilsTest { |
||||
public static final Logger logger = LoggerFactory.getLogger(ParameterUtilsTest.class); |
||||
|
||||
/** |
||||
* Test convertParameterPlaceholders |
||||
*/ |
||||
@Test |
||||
public void testConvertParameterPlaceholders() throws Exception { |
||||
// parameterString,parameterMap is null
|
||||
Assert.assertNull(ParameterUtils.convertParameterPlaceholders(null, null)); |
||||
|
||||
// parameterString is null,parameterMap is not null
|
||||
Map<String, String> parameterMap = new HashMap<String,String>(); |
||||
parameterMap.put("testParameter","testParameter"); |
||||
Assert.assertNull(ParameterUtils.convertParameterPlaceholders(null, parameterMap)); |
||||
|
||||
// parameterString、parameterMap is not null
|
||||
String parameterString = "test_parameter"; |
||||
Assert.assertEquals(parameterString, ParameterUtils.convertParameterPlaceholders(parameterString, parameterMap)); |
||||
|
||||
//replace variable ${} form
|
||||
parameterMap.put("testParameter2","${testParameter}"); |
||||
Assert.assertEquals(parameterString,PlaceholderUtils.replacePlaceholders(parameterString, parameterMap, true)); |
||||
|
||||
// replace time $[...] form, eg. $[yyyyMMdd]
|
||||
Date cronTime = new Date(); |
||||
Assert.assertEquals(parameterString, replacePlaceholders(parameterString, cronTime, true)); |
||||
|
||||
// replace time $[...] form, eg. $[yyyyMMdd]
|
||||
Date cronTimeStr = DateUtils.parseDate("20191220145900", new String[]{PARAMETER_FORMAT_TIME}); |
||||
Assert.assertEquals(parameterString, replacePlaceholders(parameterString, cronTimeStr, true)); |
||||
} |
||||
|
||||
/** |
||||
* Test curingGlobalParams |
||||
*/ |
||||
@Test |
||||
public void testCuringGlobalParams() throws Exception { |
||||
//define globalMap
|
||||
Map<String, String> globalParamMap = new HashMap<>(); |
||||
globalParamMap.put("globalParams1","Params1"); |
||||
|
||||
//define globalParamList
|
||||
List<Property> globalParamList = new ArrayList<>(); |
||||
|
||||
//define scheduleTime
|
||||
Date scheduleTime = DateUtils.parseDate("20191220145900", new String[]{PARAMETER_FORMAT_TIME}); |
||||
|
||||
//test globalParamList is null
|
||||
String result = ParameterUtils.curingGlobalParams(globalParamMap, globalParamList, CommandType.START_CURRENT_TASK_PROCESS, scheduleTime); |
||||
Assert.assertNull(result); |
||||
Assert.assertNull(ParameterUtils.curingGlobalParams(null,null,CommandType.START_CURRENT_TASK_PROCESS,null)); |
||||
Assert.assertNull(ParameterUtils.curingGlobalParams(globalParamMap,null,CommandType.START_CURRENT_TASK_PROCESS,scheduleTime)); |
||||
|
||||
//test globalParamList is not null
|
||||
Property property=new Property("testGlobalParam", Direct.IN, DataType.VARCHAR,"testGlobalParam"); |
||||
globalParamList.add(property); |
||||
|
||||
String result2 = ParameterUtils.curingGlobalParams(null,globalParamList,CommandType.START_CURRENT_TASK_PROCESS,scheduleTime); |
||||
Assert.assertEquals(result2, JSONObject.toJSONString(globalParamList)); |
||||
|
||||
String result3 = ParameterUtils.curingGlobalParams(globalParamMap,globalParamList,CommandType.START_CURRENT_TASK_PROCESS,null); |
||||
Assert.assertEquals(result3, JSONObject.toJSONString(globalParamList)); |
||||
|
||||
String result4 = ParameterUtils.curingGlobalParams(globalParamMap, globalParamList, CommandType.START_CURRENT_TASK_PROCESS, scheduleTime); |
||||
Assert.assertEquals(result4, JSONObject.toJSONString(globalParamList)); |
||||
|
||||
//test var $ startsWith
|
||||
globalParamMap.put("bizDate","${system.biz.date}"); |
||||
globalParamMap.put("b1zCurdate","${system.biz.curdate}"); |
||||
|
||||
|
||||
Property property2=new Property("testParamList1", Direct.IN, DataType.VARCHAR,"testParamList"); |
||||
Property property3=new Property("testParamList2", Direct.IN, DataType.VARCHAR,"{testParamList1}"); |
||||
Property property4=new Property("testParamList3", Direct.IN, DataType.VARCHAR,"${b1zCurdate}"); |
||||
|
||||
globalParamList.add(property2); |
||||
globalParamList.add(property3); |
||||
globalParamList.add(property4); |
||||
|
||||
String result5 = ParameterUtils.curingGlobalParams(globalParamMap, globalParamList, CommandType.START_CURRENT_TASK_PROCESS, scheduleTime); |
||||
Assert.assertEquals(result5,JSONUtils.toJsonString(globalParamList)); |
||||
} |
||||
|
||||
/** |
||||
* Test handleEscapes |
||||
*/ |
||||
@Test |
||||
public void testHandleEscapes() throws Exception { |
||||
Assert.assertNull(ParameterUtils.handleEscapes(null)); |
||||
Assert.assertEquals("",ParameterUtils.handleEscapes("")); |
||||
Assert.assertEquals("test Parameter",ParameterUtils.handleEscapes("test Parameter")); |
||||
Assert.assertEquals("////%test////%Parameter",ParameterUtils.handleEscapes("%test%Parameter")); |
||||
} |
||||
|
||||
} |
@ -1,21 +1,22 @@
|
||||
The MIT License (MIT) |
||||
Copyright (c) 2010-2011 Gabe Lerner (gabelerner@gmail.com) - http://code.google.com/p/canvg/ |
||||
|
||||
Copyright (c) 2010 - present Gabe Lerner (gabelerner@gmail.com) - https://github.com/canvg/canvg |
||||
Permission is hereby granted, free of charge, to any person |
||||
obtaining a copy of this software and associated documentation |
||||
files (the "Software"), to deal in the Software without |
||||
restriction, including without limitation the rights to use, |
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
copies of the Software, and to permit persons to whom the |
||||
Software is furnished to do so, subject to the following |
||||
conditions: |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
of this software and associated documentation files (the "Software"), to deal |
||||
in the Software without restriction, including without limitation the rights |
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
copies of the Software, and to permit persons to whom the Software is |
||||
furnished to do so, subject to the following conditions: |
||||
The above copyright notice and this permission notice shall be |
||||
included in all copies or substantial portions of the Software. |
||||
|
||||
The above copyright notice and this permission notice shall be included in all |
||||
copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||||
SOFTWARE. |
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
||||
OTHER DEALINGS IN THE SOFTWARE. |
@ -1,19 +1,26 @@
|
||||
BSD-3-Clause License |
||||
Copyright (c) 2010-2016, Michael Bostock |
||||
All rights reserved. |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
of this software and associated documentation files (the "Software"), to deal |
||||
in the Software without restriction, including without limitation the rights |
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
copies of the Software, and to permit persons to whom the Software is |
||||
furnished to do so, subject to the following conditions: |
||||
Redistribution and use in source and binary forms, with or without |
||||
modification, are permitted provided that the following conditions are met: |
||||
|
||||
The above copyright notice and this permission notice shall be included in |
||||
all copies or substantial portions of the Software. |
||||
* Redistributions of source code must retain the above copyright notice, this |
||||
list of conditions and the following disclaimer. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
THE SOFTWARE. |
||||
* Redistributions in binary form must reproduce the above copyright notice, |
||||
this list of conditions and the following disclaimer in the documentation |
||||
and/or other materials provided with the distribution. |
||||
|
||||
* The name Michael Bostock may not be used to endorse or promote products |
||||
derived from this software without specific prior written permission. |
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
||||
DISCLAIMED. IN NO EVENT SHALL MICHAEL BOSTOCK BE LIABLE FOR ANY DIRECT, |
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
||||
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
||||
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
@ -1,19 +1,201 @@
|
||||
Apache-2.0 License |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
of this software and associated documentation files (the "Software"), to deal |
||||
in the Software without restriction, including without limitation the rights |
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
copies of the Software, and to permit persons to whom the Software is |
||||
furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included in |
||||
all copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
THE SOFTWARE. |
||||
Apache License |
||||
Version 2.0, January 2004 |
||||
http://www.apache.org/licenses/ |
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION |
||||
|
||||
1. Definitions. |
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction, |
||||
and distribution as defined by Sections 1 through 9 of this document. |
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by |
||||
the copyright owner that is granting the License. |
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all |
||||
other entities that control, are controlled by, or are under common |
||||
control with that entity. For the purposes of this definition, |
||||
"control" means (i) the power, direct or indirect, to cause the |
||||
direction or management of such entity, whether by contract or |
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the |
||||
outstanding shares, or (iii) beneficial ownership of such entity. |
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity |
||||
exercising permissions granted by this License. |
||||
|
||||
"Source" form shall mean the preferred form for making modifications, |
||||
including but not limited to software source code, documentation |
||||
source, and configuration files. |
||||
|
||||
"Object" form shall mean any form resulting from mechanical |
||||
transformation or translation of a Source form, including but |
||||
not limited to compiled object code, generated documentation, |
||||
and conversions to other media types. |
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or |
||||
Object form, made available under the License, as indicated by a |
||||
copyright notice that is included in or attached to the work |
||||
(an example is provided in the Appendix below). |
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object |
||||
form, that is based on (or derived from) the Work and for which the |
||||
editorial revisions, annotations, elaborations, or other modifications |
||||
represent, as a whole, an original work of authorship. For the purposes |
||||
of this License, Derivative Works shall not include works that remain |
||||
separable from, or merely link (or bind by name) to the interfaces of, |
||||
the Work and Derivative Works thereof. |
||||
|
||||
"Contribution" shall mean any work of authorship, including |
||||
the original version of the Work and any modifications or additions |
||||
to that Work or Derivative Works thereof, that is intentionally |
||||
submitted to Licensor for inclusion in the Work by the copyright owner |
||||
or by an individual or Legal Entity authorized to submit on behalf of |
||||
the copyright owner. For the purposes of this definition, "submitted" |
||||
means any form of electronic, verbal, or written communication sent |
||||
to the Licensor or its representatives, including but not limited to |
||||
communication on electronic mailing lists, source code control systems, |
||||
and issue tracking systems that are managed by, or on behalf of, the |
||||
Licensor for the purpose of discussing and improving the Work, but |
||||
excluding communication that is conspicuously marked or otherwise |
||||
designated in writing by the copyright owner as "Not a Contribution." |
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity |
||||
on behalf of whom a Contribution has been received by Licensor and |
||||
subsequently incorporated within the Work. |
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of |
||||
this License, each Contributor hereby grants to You a perpetual, |
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable |
||||
copyright license to reproduce, prepare Derivative Works of, |
||||
publicly display, publicly perform, sublicense, and distribute the |
||||
Work and such Derivative Works in Source or Object form. |
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of |
||||
this License, each Contributor hereby grants to You a perpetual, |
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable |
||||
(except as stated in this section) patent license to make, have made, |
||||
use, offer to sell, sell, import, and otherwise transfer the Work, |
||||
where such license applies only to those patent claims licensable |
||||
by such Contributor that are necessarily infringed by their |
||||
Contribution(s) alone or by combination of their Contribution(s) |
||||
with the Work to which such Contribution(s) was submitted. If You |
||||
institute patent litigation against any entity (including a |
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work |
||||
or a Contribution incorporated within the Work constitutes direct |
||||
or contributory patent infringement, then any patent licenses |
||||
granted to You under this License for that Work shall terminate |
||||
as of the date such litigation is filed. |
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the |
||||
Work or Derivative Works thereof in any medium, with or without |
||||
modifications, and in Source or Object form, provided that You |
||||
meet the following conditions: |
||||
|
||||
(a) You must give any other recipients of the Work or |
||||
Derivative Works a copy of this License; and |
||||
|
||||
(b) You must cause any modified files to carry prominent notices |
||||
stating that You changed the files; and |
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works |
||||
that You distribute, all copyright, patent, trademark, and |
||||
attribution notices from the Source form of the Work, |
||||
excluding those notices that do not pertain to any part of |
||||
the Derivative Works; and |
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its |
||||
distribution, then any Derivative Works that You distribute must |
||||
include a readable copy of the attribution notices contained |
||||
within such NOTICE file, excluding those notices that do not |
||||
pertain to any part of the Derivative Works, in at least one |
||||
of the following places: within a NOTICE text file distributed |
||||
as part of the Derivative Works; within the Source form or |
||||
documentation, if provided along with the Derivative Works; or, |
||||
within a display generated by the Derivative Works, if and |
||||
wherever such third-party notices normally appear. The contents |
||||
of the NOTICE file are for informational purposes only and |
||||
do not modify the License. You may add Your own attribution |
||||
notices within Derivative Works that You distribute, alongside |
||||
or as an addendum to the NOTICE text from the Work, provided |
||||
that such additional attribution notices cannot be construed |
||||
as modifying the License. |
||||
|
||||
You may add Your own copyright statement to Your modifications and |
||||
may provide additional or different license terms and conditions |
||||
for use, reproduction, or distribution of Your modifications, or |
||||
for any such Derivative Works as a whole, provided Your use, |
||||
reproduction, and distribution of the Work otherwise complies with |
||||
the conditions stated in this License. |
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise, |
||||
any Contribution intentionally submitted for inclusion in the Work |
||||
by You to the Licensor shall be under the terms and conditions of |
||||
this License, without any additional terms or conditions. |
||||
Notwithstanding the above, nothing herein shall supersede or modify |
||||
the terms of any separate license agreement you may have executed |
||||
with Licensor regarding such Contributions. |
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade |
||||
names, trademarks, service marks, or product names of the Licensor, |
||||
except as required for reasonable and customary use in describing the |
||||
origin of the Work and reproducing the content of the NOTICE file. |
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or |
||||
agreed to in writing, Licensor provides the Work (and each |
||||
Contributor provides its Contributions) on an "AS IS" BASIS, |
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
||||
implied, including, without limitation, any warranties or conditions |
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A |
||||
PARTICULAR PURPOSE. You are solely responsible for determining the |
||||
appropriateness of using or redistributing the Work and assume any |
||||
risks associated with Your exercise of permissions under this License. |
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory, |
||||
whether in tort (including negligence), contract, or otherwise, |
||||
unless required by applicable law (such as deliberate and grossly |
||||
negligent acts) or agreed to in writing, shall any Contributor be |
||||
liable to You for damages, including any direct, indirect, special, |
||||
incidental, or consequential damages of any character arising as a |
||||
result of this License or out of the use or inability to use the |
||||
Work (including but not limited to damages for loss of goodwill, |
||||
work stoppage, computer failure or malfunction, or any and all |
||||
other commercial damages or losses), even if such Contributor |
||||
has been advised of the possibility of such damages. |
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing |
||||
the Work or Derivative Works thereof, You may choose to offer, |
||||
and charge a fee for, acceptance of support, warranty, indemnity, |
||||
or other liability obligations and/or rights consistent with this |
||||
License. However, in accepting such obligations, You may act only |
||||
on Your own behalf and on Your sole responsibility, not on behalf |
||||
of any other Contributor, and only if You agree to indemnify, |
||||
defend, and hold each Contributor harmless for any liability |
||||
incurred by, or claims asserted against, such Contributor by reason |
||||
of your accepting any such warranty or additional liability. |
||||
|
||||
END OF TERMS AND CONDITIONS |
||||
|
||||
APPENDIX: How to apply the Apache License to your work. |
||||
|
||||
To apply the Apache License to your work, attach the following |
||||
boilerplate notice, with the fields enclosed by brackets "[]" |
||||
replaced with your own identifying information. (Don't include |
||||
the brackets!) The text should be enclosed in the appropriate |
||||
comment syntax for the file format. We also recommend that a |
||||
file or class name and description of purpose be included on the |
||||
same "printed page" as the copyright notice for easier |
||||
identification within third-party archives. |
||||
|
||||
Copyright [yyyy] [name of copyright owner] |
||||
|
||||
Licensed 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. |
@ -1,21 +1,36 @@
|
||||
MIT License |
||||
|
||||
Copyright (c) 2016-present |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
of this software and associated documentation files (the "Software"), to deal |
||||
in the Software without restriction, including without limitation the rights |
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
copies of the Software, and to permit persons to whom the Software is |
||||
furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included in |
||||
all copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
THE SOFTWARE. |
||||
Copyright JS Foundation and other contributors, https://js.foundation/ |
||||
|
||||
This software consists of voluntary contributions made by many |
||||
individuals. For exact contribution history, see the revision history |
||||
available at https://github.com/jquery/jquery |
||||
|
||||
The following license applies to all parts of this software except as |
||||
documented below: |
||||
|
||||
==== |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining |
||||
a copy of this software and associated documentation files (the |
||||
"Software"), to deal in the Software without restriction, including |
||||
without limitation the rights to use, copy, modify, merge, publish, |
||||
distribute, sublicense, and/or sell copies of the Software, and to |
||||
permit persons to whom the Software is furnished to do so, subject to |
||||
the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be |
||||
included in all copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
|
||||
==== |
||||
|
||||
All files located in the node_modules and external directories are |
||||
externally maintained libraries used by this software which have their |
||||
own licenses; we recommend you read them, as their terms may differ from |
||||
the terms above. |
@ -0,0 +1,43 @@
|
||||
Copyright jQuery Foundation and other contributors, https://jquery.org/ |
||||
|
||||
This software consists of voluntary contributions made by many |
||||
individuals. For exact contribution history, see the revision history |
||||
available at https://github.com/jquery/jquery-ui |
||||
|
||||
The following license applies to all parts of this software except as |
||||
documented below: |
||||
|
||||
==== |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining |
||||
a copy of this software and associated documentation files (the |
||||
"Software"), to deal in the Software without restriction, including |
||||
without limitation the rights to use, copy, modify, merge, publish, |
||||
distribute, sublicense, and/or sell copies of the Software, and to |
||||
permit persons to whom the Software is furnished to do so, subject to |
||||
the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be |
||||
included in all copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||||
|
||||
==== |
||||
|
||||
Copyright and related rights for sample code are waived via CC0. Sample |
||||
code is defined as all source code contained within the demos directory. |
||||
|
||||
CC0: http://creativecommons.org/publicdomain/zero/1.0/ |
||||
|
||||
==== |
||||
|
||||
All files located in the node_modules and external directories are |
||||
externally maintained libraries used by this software which have their |
||||
own licenses; we recommend you read them, as their terms may differ from |
||||
the terms above. |
@ -0,0 +1,21 @@
|
||||
MIT License |
||||
|
||||
Copyright (c) 2018 Copyright 2018 Klaus Hartl, Fagner Brack, GitHub Contributors |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
of this software and associated documentation files (the "Software"), to deal |
||||
in the Software without restriction, including without limitation the rights |
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
copies of the Software, and to permit persons to whom the Software is |
||||
furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included in all |
||||
copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||||
SOFTWARE. |
@ -0,0 +1,236 @@
|
||||
<!-- |
||||
~ 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. |
||||
--> |
||||
|
||||
<assembly |
||||
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"> |
||||
<id>dolphinscheduler-nginx</id> |
||||
<formats> |
||||
<format>tar.gz</format> |
||||
</formats> |
||||
<includeBaseDirectory>true</includeBaseDirectory> |
||||
<baseDirectory>${project.build.finalName}-dolphinscheduler-bin</baseDirectory> |
||||
|
||||
<fileSets> |
||||
<!--alert start--> |
||||
<fileSet> |
||||
<directory>${basedir}/../dolphinscheduler-alert/src/main/resources</directory> |
||||
<includes> |
||||
<include>**/*.properties</include> |
||||
<include>**/*.xml</include> |
||||
<include>**/*.json</include> |
||||
<include>**/*.ftl</include> |
||||
</includes> |
||||
<outputDirectory>./conf</outputDirectory> |
||||
</fileSet> |
||||
<!--alert end--> |
||||
|
||||
<!--api start--> |
||||
<fileSet> |
||||
<directory>src/main/resources</directory> |
||||
<includes> |
||||
<include>**/*.properties</include> |
||||
<include>**/*.xml</include> |
||||
<include>**/*.json</include> |
||||
</includes> |
||||
<outputDirectory>conf</outputDirectory> |
||||
</fileSet> |
||||
<fileSet> |
||||
<directory>${basedir}/../dolphinscheduler-common/src/main/resources</directory> |
||||
<includes> |
||||
<include>**/*.properties</include> |
||||
<include>**/*.xml</include> |
||||
<include>**/*.json</include> |
||||
</includes> |
||||
<outputDirectory>conf</outputDirectory> |
||||
</fileSet> |
||||
<fileSet> |
||||
<directory>${basedir}/../dolphinscheduler-common/src/main/resources/bin</directory> |
||||
<includes> |
||||
<include>*.*</include> |
||||
</includes> |
||||
<directoryMode>755</directoryMode> |
||||
<outputDirectory>bin</outputDirectory> |
||||
</fileSet> |
||||
<fileSet> |
||||
<directory>${basedir}/../dolphinscheduler-dao/src/main/resources</directory> |
||||
<includes> |
||||
<include>**/*.properties</include> |
||||
<include>**/*.xml</include> |
||||
<include>**/*.json</include> |
||||
</includes> |
||||
<outputDirectory>conf</outputDirectory> |
||||
</fileSet> |
||||
<fileSet> |
||||
<directory>${basedir}/../dolphinscheduler-api/src/main/resources</directory> |
||||
<includes> |
||||
<include>**/*.properties</include> |
||||
<include>**/*.xml</include> |
||||
<include>**/*.json</include> |
||||
</includes> |
||||
<outputDirectory>conf</outputDirectory> |
||||
</fileSet> |
||||
<!--api end--> |
||||
|
||||
<!--server start--> |
||||
<fileSet> |
||||
<directory>${basedir}/../dolphinscheduler-server/src/main/resources</directory> |
||||
<includes> |
||||
<include>**/*.properties</include> |
||||
<include>**/*.xml</include> |
||||
<include>**/*.json</include> |
||||
</includes> |
||||
<outputDirectory>conf</outputDirectory> |
||||
</fileSet> |
||||
<fileSet> |
||||
<directory>${basedir}/../dolphinscheduler-common/src/main/resources</directory> |
||||
<includes> |
||||
<include>**/*.properties</include> |
||||
<include>**/*.xml</include> |
||||
<include>**/*.json</include> |
||||
</includes> |
||||
<outputDirectory>conf</outputDirectory> |
||||
</fileSet> |
||||
<fileSet> |
||||
<directory>${basedir}/../dolphinscheduler-common/src/main/resources/bin</directory> |
||||
<includes> |
||||
<include>*.*</include> |
||||
</includes> |
||||
<directoryMode>755</directoryMode> |
||||
<outputDirectory>bin</outputDirectory> |
||||
</fileSet> |
||||
<fileSet> |
||||
<directory>${basedir}/../dolphinscheduler-dao/src/main/resources</directory> |
||||
<includes> |
||||
<include>**/*.properties</include> |
||||
<include>**/*.xml</include> |
||||
<include>**/*.json</include> |
||||
<include>**/*.yml</include> |
||||
</includes> |
||||
<outputDirectory>conf</outputDirectory> |
||||
</fileSet> |
||||
<!--server end--> |
||||
|
||||
<fileSet> |
||||
<directory>${basedir}/../dolphinscheduler-server/target/dolphinscheduler-server-${project.version}</directory> |
||||
<includes> |
||||
<include>**/*.*</include> |
||||
</includes> |
||||
<outputDirectory>.</outputDirectory> |
||||
</fileSet> |
||||
|
||||
<fileSet> |
||||
<directory>${basedir}/../dolphinscheduler-api/target/dolphinscheduler-api-${project.version}</directory> |
||||
<includes> |
||||
<include>**/*.*</include> |
||||
</includes> |
||||
<outputDirectory>.</outputDirectory> |
||||
</fileSet> |
||||
|
||||
<fileSet> |
||||
<directory>${basedir}/../dolphinscheduler-alert/target/dolphinscheduler-alert-${project.version}</directory> |
||||
<includes> |
||||
<include>**/*.*</include> |
||||
</includes> |
||||
<outputDirectory>.</outputDirectory> |
||||
</fileSet> |
||||
|
||||
<fileSet> |
||||
<directory>${basedir}/../dolphinscheduler-ui/dist</directory> |
||||
<includes> |
||||
<include>**/*.*</include> |
||||
</includes> |
||||
<outputDirectory>./ui/dist</outputDirectory> |
||||
</fileSet> |
||||
|
||||
<fileSet> |
||||
<directory>${basedir}/../dolphinscheduler-ui</directory> |
||||
<includes> |
||||
<include>install-dolphinscheduler-ui.sh</include> |
||||
</includes> |
||||
<outputDirectory>./ui</outputDirectory> |
||||
</fileSet> |
||||
|
||||
<fileSet> |
||||
<directory>${basedir}/../sql</directory> |
||||
<includes> |
||||
<include>**/*</include> |
||||
</includes> |
||||
<outputDirectory>./sql</outputDirectory> |
||||
</fileSet> |
||||
|
||||
<fileSet> |
||||
<directory>${basedir}/../script</directory> |
||||
<includes> |
||||
<include>*.*</include> |
||||
</includes> |
||||
<outputDirectory>./script</outputDirectory> |
||||
</fileSet> |
||||
|
||||
<fileSet> |
||||
<directory>${basedir}/../script</directory> |
||||
<includes> |
||||
<include>config/*.*</include> |
||||
<include>env/*.*</include> |
||||
</includes> |
||||
<outputDirectory>./conf</outputDirectory> |
||||
</fileSet> |
||||
|
||||
<fileSet> |
||||
<directory>${basedir}/../script</directory> |
||||
<includes> |
||||
<include>start-all.sh</include> |
||||
<include>stop-all.sh</include> |
||||
<include>dolphinscheduler-daemon.sh</include> |
||||
</includes> |
||||
<outputDirectory>./bin</outputDirectory> |
||||
</fileSet> |
||||
|
||||
<fileSet> |
||||
<directory>${basedir}/.././</directory> |
||||
<includes> |
||||
<include>*.sh</include> |
||||
<include>*.py</include> |
||||
<include>DISCLAIMER</include> |
||||
</includes> |
||||
<outputDirectory>.</outputDirectory> |
||||
</fileSet> |
||||
|
||||
<fileSet> |
||||
<directory>${basedir}/release-docs</directory> |
||||
<useDefaultExcludes>true</useDefaultExcludes> |
||||
<includes> |
||||
<include>**/*</include> |
||||
</includes> |
||||
<outputDirectory>.</outputDirectory> |
||||
</fileSet> |
||||
|
||||
</fileSets> |
||||
|
||||
<dependencySets> |
||||
<dependencySet> |
||||
<outputDirectory>lib</outputDirectory> |
||||
<useProjectArtifact>true</useProjectArtifact> |
||||
<excludes> |
||||
<exclude>javax.servlet:servlet-api</exclude> |
||||
<exclude>org.eclipse.jetty.aggregate:jetty-all</exclude> |
||||
<exclude>org.slf4j:slf4j-log4j12</exclude> |
||||
</excludes> |
||||
</dependencySet> |
||||
</dependencySets> |
||||
</assembly> |
@ -0,0 +1,126 @@
|
||||
/* |
||||
* 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.server.monitor; |
||||
|
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.apache.dolphinscheduler.common.utils.CollectionUtils; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import java.util.HashSet; |
||||
import java.util.Map; |
||||
import java.util.Set; |
||||
|
||||
/** |
||||
* abstract server monitor and auto restart server |
||||
*/ |
||||
@Component |
||||
public abstract class AbstractMonitor implements Monitor { |
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(AbstractMonitor.class); |
||||
|
||||
|
||||
@Autowired |
||||
private RunConfig runConfig; |
||||
|
||||
/** |
||||
* monitor server and restart |
||||
*/ |
||||
@Override |
||||
public void monitor(String masterPath,String workerPath,Integer port,String installPath) { |
||||
try { |
||||
restartServer(masterPath,port,installPath); |
||||
restartServer(workerPath,port,installPath); |
||||
}catch (Exception e){ |
||||
logger.error("server start up error",e); |
||||
} |
||||
} |
||||
|
||||
private void restartServer(String path,Integer port,String installPath) throws Exception{ |
||||
|
||||
String type = path.split("/")[2]; |
||||
String serverName = null; |
||||
String nodes = null; |
||||
if ("masters".equals(type)){ |
||||
serverName = "master-server"; |
||||
nodes = runConfig.getMasters(); |
||||
}else if ("workers".equals(type)){ |
||||
serverName = "worker-server"; |
||||
nodes = runConfig.getWorkers(); |
||||
} |
||||
|
||||
Map<String, String> activeNodeMap = getActiveNodesByPath(path); |
||||
|
||||
Set<String> needRestartServer = getNeedRestartServer(getRunConfigServer(nodes), |
||||
activeNodeMap.keySet()); |
||||
|
||||
for (String node : needRestartServer){ |
||||
// os.system('ssh -p ' + ssh_port + ' ' + self.get_ip_by_hostname(master) + ' sh ' + install_path + '/bin/dolphinscheduler-daemon.sh start master-server')
|
||||
String runCmd = "ssh -p " + port + " " + node + " sh " + installPath + "/bin/dolphinscheduler-daemon.sh start " + serverName; |
||||
Runtime.getRuntime().exec(runCmd); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* get need restart server |
||||
* @param deployedNodes deployedNodes |
||||
* @param activeNodes activeNodes |
||||
* @return need restart server |
||||
*/ |
||||
private Set<String> getNeedRestartServer(Set<String> deployedNodes,Set<String> activeNodes){ |
||||
if (CollectionUtils.isEmpty(activeNodes)){ |
||||
return deployedNodes; |
||||
} |
||||
|
||||
Set<String> result = new HashSet<>(); |
||||
|
||||
result.addAll(deployedNodes); |
||||
result.removeAll(activeNodes); |
||||
|
||||
return result; |
||||
} |
||||
|
||||
/** |
||||
* run config masters/workers |
||||
* @return master set/worker set |
||||
*/ |
||||
private Set<String> getRunConfigServer(String nodes){ |
||||
Set<String> nodeSet = new HashSet(); |
||||
|
||||
|
||||
if (StringUtils.isEmpty(nodes)){ |
||||
return null; |
||||
} |
||||
|
||||
String[] nodeArr = nodes.split(","); |
||||
|
||||
for (String node : nodeArr){ |
||||
nodeSet.add(node); |
||||
} |
||||
|
||||
return nodeSet; |
||||
} |
||||
|
||||
/** |
||||
* get active nodes by path |
||||
* @param path path |
||||
* @return active nodes |
||||
*/ |
||||
protected abstract Map<String,String> getActiveNodesByPath(String path); |
||||
} |
@ -0,0 +1,63 @@
|
||||
/* |
||||
* 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.server.monitor; |
||||
|
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.boot.CommandLineRunner; |
||||
import org.springframework.boot.WebApplicationType; |
||||
import org.springframework.boot.builder.SpringApplicationBuilder; |
||||
import org.springframework.context.annotation.ComponentScan; |
||||
|
||||
/** |
||||
* monitor server |
||||
*/ |
||||
@ComponentScan("org.apache.dolphinscheduler") |
||||
public class MonitorServer implements CommandLineRunner { |
||||
|
||||
private static Integer ARGS_LENGTH = 4; |
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(MonitorServer.class); |
||||
|
||||
/** |
||||
* monitor |
||||
*/ |
||||
@Autowired |
||||
private Monitor monitor; |
||||
|
||||
|
||||
|
||||
public static void main(String[] args) throws Exception{ |
||||
|
||||
new SpringApplicationBuilder(MonitorServer.class).web(WebApplicationType.NONE).run(args); |
||||
} |
||||
|
||||
@Override |
||||
public void run(String... args) throws Exception { |
||||
if (args.length != ARGS_LENGTH){ |
||||
logger.error("Usage: <masterPath> <workerPath> <port> <installPath>"); |
||||
return; |
||||
} |
||||
|
||||
String masterPath = args[0]; |
||||
String workerPath = args[1]; |
||||
Integer port = Integer.parseInt(args[2]); |
||||
String installPath = args[3]; |
||||
monitor.monitor(masterPath,workerPath,port,installPath); |
||||
} |
||||
} |
@ -0,0 +1,85 @@
|
||||
/* |
||||
* 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.server.monitor; |
||||
|
||||
import org.springframework.beans.factory.annotation.Value; |
||||
import org.springframework.context.annotation.PropertySource; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
/** |
||||
* zookeeper conf |
||||
*/ |
||||
@Component |
||||
@PropertySource("classpath:config/run_config.conf") |
||||
public class RunConfig { |
||||
|
||||
//zk connect config
|
||||
@Value("${masters}") |
||||
private String masters; |
||||
|
||||
@Value("${workers}") |
||||
private String workers; |
||||
|
||||
@Value("${alertServer}") |
||||
private String alertServer; |
||||
|
||||
@Value("${apiServers}") |
||||
private String apiServers; |
||||
|
||||
@Value("${sshPort}") |
||||
private String sshPort; |
||||
|
||||
public String getMasters() { |
||||
return masters; |
||||
} |
||||
|
||||
public void setMasters(String masters) { |
||||
this.masters = masters; |
||||
} |
||||
|
||||
public String getWorkers() { |
||||
return workers; |
||||
} |
||||
|
||||
public void setWorkers(String workers) { |
||||
this.workers = workers; |
||||
} |
||||
|
||||
public String getAlertServer() { |
||||
return alertServer; |
||||
} |
||||
|
||||
public void setAlertServer(String alertServer) { |
||||
this.alertServer = alertServer; |
||||
} |
||||
|
||||
public String getApiServers() { |
||||
return apiServers; |
||||
} |
||||
|
||||
public void setApiServers(String apiServers) { |
||||
this.apiServers = apiServers; |
||||
} |
||||
|
||||
public String getSshPort() { |
||||
return sshPort; |
||||
} |
||||
|
||||
public void setSshPort(String sshPort) { |
||||
this.sshPort = sshPort; |
||||
} |
||||
} |
@ -0,0 +1,62 @@
|
||||
/* |
||||
* 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.server.monitor; |
||||
|
||||
import org.apache.dolphinscheduler.common.zk.ZookeeperOperator; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* zk monitor server impl |
||||
*/ |
||||
@Component |
||||
public class ZKMonitorImpl extends AbstractMonitor { |
||||
|
||||
/** |
||||
* zookeeper operator |
||||
*/ |
||||
@Autowired |
||||
private ZookeeperOperator zookeeperOperator; |
||||
|
||||
|
||||
/** |
||||
* get active nodes map by path |
||||
* @param path path |
||||
* @return active nodes map |
||||
*/ |
||||
@Override |
||||
protected Map<String,String> getActiveNodesByPath(String path) { |
||||
|
||||
Map<String,String> maps = new HashMap<>(); |
||||
|
||||
List<String> childrenList = zookeeperOperator.getChildrenKeys(path); |
||||
|
||||
if (childrenList == null){ |
||||
return maps; |
||||
} |
||||
|
||||
for (String child : childrenList){ |
||||
maps.put(child.split("_")[0],child); |
||||
} |
||||
|
||||
return maps; |
||||
} |
||||
} |
@ -0,0 +1,59 @@
|
||||
/* |
||||
* 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.server.utils; |
||||
|
||||
import org.apache.dolphinscheduler.common.zk.ZookeeperOperator; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.boot.CommandLineRunner; |
||||
import org.springframework.boot.WebApplicationType; |
||||
import org.springframework.boot.builder.SpringApplicationBuilder; |
||||
import org.springframework.context.annotation.ComponentScan; |
||||
|
||||
@ComponentScan("org.apache.dolphinscheduler") |
||||
public class RemoveZKNode implements CommandLineRunner { |
||||
|
||||
private static Integer ARGS_LENGTH = 1; |
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(RemoveZKNode.class); |
||||
|
||||
|
||||
/** |
||||
* zookeeper operator |
||||
*/ |
||||
@Autowired |
||||
private ZookeeperOperator zookeeperOperator; |
||||
|
||||
public static void main(String[] args) { |
||||
|
||||
new SpringApplicationBuilder(RemoveZKNode.class).web(WebApplicationType.NONE).run(args); |
||||
} |
||||
|
||||
@Override |
||||
public void run(String... args) throws Exception { |
||||
|
||||
if (args.length != ARGS_LENGTH){ |
||||
logger.error("Usage: <node>"); |
||||
return; |
||||
} |
||||
|
||||
zookeeperOperator.remove(args[0]); |
||||
zookeeperOperator.close(); |
||||
|
||||
} |
||||
} |
@ -0,0 +1,39 @@
|
||||
/* |
||||
* 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.server.utils; |
||||
|
||||
import org.apache.commons.lang.StringUtils; |
||||
import org.apache.dolphinscheduler.common.Constants; |
||||
|
||||
/** |
||||
* sensitive log Util |
||||
*/ |
||||
public class SensitiveLogUtil { |
||||
|
||||
/** |
||||
* @param dataSourcePwd data source password |
||||
* @return String |
||||
*/ |
||||
public static String maskDataSourcePwd(String dataSourcePwd){ |
||||
|
||||
if (StringUtils.isNotEmpty(dataSourcePwd)) { |
||||
dataSourcePwd = Constants.PASSWORD_DEFAULT; |
||||
} |
||||
return dataSourcePwd; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,92 @@
|
||||
/* |
||||
* 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.server.worker.log; |
||||
|
||||
|
||||
import ch.qos.logback.classic.pattern.MessageConverter; |
||||
import ch.qos.logback.classic.spi.ILoggingEvent; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.apache.dolphinscheduler.common.Constants; |
||||
import org.apache.dolphinscheduler.server.utils.SensitiveLogUtil; |
||||
|
||||
import java.util.regex.Matcher; |
||||
import java.util.regex.Pattern; |
||||
|
||||
/** |
||||
* sensitive data log converter |
||||
*/ |
||||
@Slf4j |
||||
public class SensitiveDataConverter extends MessageConverter { |
||||
|
||||
/** |
||||
* password pattern |
||||
*/ |
||||
private final Pattern pwdPattern = Pattern.compile(Constants.DATASOURCE_PASSWORD_REGEX); |
||||
|
||||
|
||||
@Override |
||||
public String convert(ILoggingEvent event) { |
||||
|
||||
// get original log
|
||||
String requestLogMsg = event.getFormattedMessage(); |
||||
|
||||
// desensitization log
|
||||
return convertMsg(requestLogMsg); |
||||
} |
||||
|
||||
/** |
||||
* deal with sensitive log |
||||
* |
||||
* @param oriLogMsg original log |
||||
*/ |
||||
private String convertMsg(final String oriLogMsg) { |
||||
|
||||
String tempLogMsg = oriLogMsg; |
||||
|
||||
if (StringUtils.isNotEmpty(tempLogMsg)) { |
||||
tempLogMsg = passwordHandler(pwdPattern, tempLogMsg); |
||||
} |
||||
return tempLogMsg; |
||||
} |
||||
|
||||
/** |
||||
* password regex |
||||
* |
||||
* @param logMsg original log |
||||
*/ |
||||
private String passwordHandler(Pattern pwdPattern, String logMsg) { |
||||
|
||||
Matcher matcher = pwdPattern.matcher(logMsg); |
||||
|
||||
StringBuffer sb = new StringBuffer(logMsg.length()); |
||||
|
||||
while (matcher.find()) { |
||||
|
||||
String password = matcher.group(); |
||||
|
||||
String maskPassword = SensitiveLogUtil.maskDataSourcePwd(password); |
||||
|
||||
matcher.appendReplacement(sb, maskPassword); |
||||
} |
||||
matcher.appendTail(sb); |
||||
|
||||
return sb.toString(); |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,131 @@
|
||||
/* |
||||
* 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.server.utils; |
||||
|
||||
import org.apache.dolphinscheduler.common.enums.ProgramType; |
||||
import org.apache.dolphinscheduler.common.process.ResourceInfo; |
||||
import org.apache.dolphinscheduler.common.task.flink.FlinkParameters; |
||||
import org.junit.Before; |
||||
import org.junit.Test; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
|
||||
import java.util.List; |
||||
|
||||
import static org.junit.Assert.assertEquals; |
||||
import static org.junit.Assert.assertSame; |
||||
|
||||
/** |
||||
* Test FlinkArgsUtils |
||||
*/ |
||||
public class FlinkArgsUtilsTest { |
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(FlinkArgsUtilsTest.class); |
||||
|
||||
public String mode = "cluster"; |
||||
public int slot = 2; |
||||
public String appName = "testFlink"; |
||||
public int taskManager = 4; |
||||
public String taskManagerMemory = "2G"; |
||||
public String jobManagerMemory = "4G"; |
||||
public ProgramType programType = ProgramType.JAVA; |
||||
public String mainClass = "com.test"; |
||||
public ResourceInfo mainJar = null; |
||||
public String mainArgs = "testArgs"; |
||||
public String queue = "queue1"; |
||||
public String others = "--input file:///home"; |
||||
|
||||
|
||||
@Before |
||||
public void setUp() throws Exception { |
||||
|
||||
ResourceInfo main = new ResourceInfo(); |
||||
main.setRes("testflink-1.0.0-SNAPSHOT.jar"); |
||||
mainJar = main; |
||||
} |
||||
|
||||
/** |
||||
* Test buildArgs |
||||
*/ |
||||
@Test |
||||
public void testBuildArgs() { |
||||
|
||||
//Define params
|
||||
FlinkParameters param = new FlinkParameters(); |
||||
param.setDeployMode(mode); |
||||
param.setMainClass(mainClass); |
||||
param.setAppName(appName); |
||||
param.setSlot(slot); |
||||
param.setTaskManager(taskManager); |
||||
param.setJobManagerMemory(jobManagerMemory); |
||||
param.setTaskManagerMemory(taskManagerMemory); |
||||
param.setMainJar(mainJar); |
||||
param.setProgramType(programType); |
||||
param.setMainArgs(mainArgs); |
||||
param.setQueue(queue); |
||||
param.setOthers(others); |
||||
|
||||
//Invoke buildArgs
|
||||
List<String> result = FlinkArgsUtils.buildArgs(param); |
||||
for (String s : result) { |
||||
logger.info(s); |
||||
} |
||||
|
||||
//Expected values and order
|
||||
assertEquals(result.size(),20); |
||||
|
||||
assertEquals(result.get(0),"-m"); |
||||
assertEquals(result.get(1),"yarn-cluster"); |
||||
|
||||
assertEquals(result.get(2),"-ys"); |
||||
assertSame(Integer.valueOf(result.get(3)),slot); |
||||
|
||||
assertEquals(result.get(4),"-ynm"); |
||||
assertEquals(result.get(5),appName); |
||||
|
||||
assertEquals(result.get(6),"-yn"); |
||||
assertSame(Integer.valueOf(result.get(7)),taskManager); |
||||
|
||||
assertEquals(result.get(8),"-yjm"); |
||||
assertEquals(result.get(9),jobManagerMemory); |
||||
|
||||
assertEquals(result.get(10),"-ytm"); |
||||
assertEquals(result.get(11),taskManagerMemory); |
||||
|
||||
assertEquals(result.get(12),"-d"); |
||||
|
||||
assertEquals(result.get(13),"-c"); |
||||
assertEquals(result.get(14),mainClass); |
||||
|
||||
assertEquals(result.get(15),mainJar.getRes()); |
||||
assertEquals(result.get(16),mainArgs); |
||||
|
||||
assertEquals(result.get(17),"--qu"); |
||||
assertEquals(result.get(18),queue); |
||||
|
||||
assertEquals(result.get(19),others); |
||||
|
||||
//Others param without --qu
|
||||
FlinkParameters param1 = new FlinkParameters(); |
||||
param1.setQueue(queue); |
||||
param1.setDeployMode(mode); |
||||
result = FlinkArgsUtils.buildArgs(param1); |
||||
assertEquals(result.size(),5); |
||||
|
||||
} |
||||
} |
@ -0,0 +1,37 @@
|
||||
/* |
||||
* 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.server.utils; |
||||
|
||||
|
||||
import org.apache.dolphinscheduler.common.Constants; |
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
|
||||
|
||||
public class SensitiveLogUtilTest { |
||||
|
||||
@Test |
||||
public void testMaskDataSourcePwd() { |
||||
|
||||
String password = "123456"; |
||||
String emptyPassword = ""; |
||||
|
||||
Assert.assertEquals(Constants.PASSWORD_DEFAULT, SensitiveLogUtil.maskDataSourcePwd(password)); |
||||
Assert.assertEquals("", SensitiveLogUtil.maskDataSourcePwd(emptyPassword)); |
||||
|
||||
} |
||||
} |
@ -0,0 +1,128 @@
|
||||
/* |
||||
* 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.server.utils; |
||||
|
||||
import org.apache.dolphinscheduler.common.enums.ProgramType; |
||||
import org.apache.dolphinscheduler.common.process.ResourceInfo; |
||||
import org.apache.dolphinscheduler.common.task.spark.SparkParameters; |
||||
import org.junit.Before; |
||||
import org.junit.Test; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
|
||||
import java.util.List; |
||||
|
||||
import static org.junit.Assert.assertEquals; |
||||
import static org.junit.Assert.assertSame; |
||||
|
||||
/** |
||||
* Test SparkArgsUtils |
||||
*/ |
||||
public class SparkArgsUtilsTest { |
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(SparkArgsUtilsTest.class); |
||||
|
||||
public String mode = "cluster"; |
||||
public String mainClass = "com.test"; |
||||
public ResourceInfo mainJar = null; |
||||
public String mainArgs = "partitions=2"; |
||||
public String driverMemory = "2G"; |
||||
public String executorMemory = "4G"; |
||||
public ProgramType programType = ProgramType.JAVA; |
||||
public int driverCores = 2; |
||||
public int executorCores = 6; |
||||
public String sparkVersion = "SPARK1"; |
||||
public int numExecutors = 4; |
||||
public String queue = "queue1"; |
||||
|
||||
|
||||
@Before |
||||
public void setUp() throws Exception { |
||||
|
||||
ResourceInfo main = new ResourceInfo(); |
||||
main.setRes("testspark-1.0.0-SNAPSHOT.jar"); |
||||
mainJar = main; |
||||
} |
||||
|
||||
/** |
||||
* Test buildArgs |
||||
*/ |
||||
@Test |
||||
public void testBuildArgs() { |
||||
|
||||
//Define params
|
||||
SparkParameters param = new SparkParameters(); |
||||
param.setDeployMode(mode); |
||||
param.setMainClass(mainClass); |
||||
param.setDriverCores(driverCores); |
||||
param.setDriverMemory(driverMemory); |
||||
param.setExecutorCores(executorCores); |
||||
param.setExecutorMemory(executorMemory); |
||||
param.setMainJar(mainJar); |
||||
param.setNumExecutors(numExecutors); |
||||
param.setProgramType(programType); |
||||
param.setSparkVersion(sparkVersion); |
||||
param.setMainArgs(mainArgs); |
||||
param.setQueue(queue); |
||||
|
||||
//Invoke buildArgs
|
||||
List<String> result = SparkArgsUtils.buildArgs(param); |
||||
for (String s : result) { |
||||
logger.info(s); |
||||
} |
||||
|
||||
//Expected values and order
|
||||
assertEquals(result.size(),20); |
||||
|
||||
assertEquals(result.get(0),"--master"); |
||||
assertEquals(result.get(1),"yarn"); |
||||
|
||||
assertEquals(result.get(2),"--deploy-mode"); |
||||
assertEquals(result.get(3),mode); |
||||
|
||||
assertEquals(result.get(4),"--class"); |
||||
assertEquals(result.get(5),mainClass); |
||||
|
||||
assertEquals(result.get(6),"--driver-cores"); |
||||
assertSame(Integer.valueOf(result.get(7)),driverCores); |
||||
|
||||
assertEquals(result.get(8),"--driver-memory"); |
||||
assertEquals(result.get(9),driverMemory); |
||||
|
||||
assertEquals(result.get(10),"--num-executors"); |
||||
assertSame(Integer.valueOf(result.get(11)),numExecutors); |
||||
|
||||
assertEquals(result.get(12),"--executor-cores"); |
||||
assertSame(Integer.valueOf(result.get(13)),executorCores); |
||||
|
||||
assertEquals(result.get(14),"--executor-memory"); |
||||
assertEquals(result.get(15),executorMemory); |
||||
|
||||
assertEquals(result.get(16),"--queue"); |
||||
assertEquals(result.get(17),queue); |
||||
assertEquals(result.get(18),mainJar.getRes()); |
||||
assertEquals(result.get(19),mainArgs); |
||||
|
||||
//Others param without --queue
|
||||
SparkParameters param1 = new SparkParameters(); |
||||
param1.setOthers("--files xxx/hive-site.xml"); |
||||
param1.setQueue(queue); |
||||
result = SparkArgsUtils.buildArgs(param1); |
||||
assertEquals(result.size(),7); |
||||
} |
||||
} |
@ -0,0 +1,92 @@
|
||||
/* |
||||
* 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.server.worker.log; |
||||
|
||||
|
||||
import org.apache.dolphinscheduler.common.Constants; |
||||
import org.apache.dolphinscheduler.server.utils.SensitiveLogUtil; |
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
|
||||
import java.util.regex.Matcher; |
||||
import java.util.regex.Pattern; |
||||
|
||||
public class SensitiveDataConverterTest { |
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(SensitiveDataConverterTest.class); |
||||
|
||||
/** |
||||
* password pattern |
||||
*/ |
||||
private final Pattern pwdPattern = Pattern.compile(Constants.DATASOURCE_PASSWORD_REGEX); |
||||
|
||||
|
||||
/** |
||||
* mask sensitive logMsg - sql task datasource password |
||||
*/ |
||||
@Test |
||||
public void testPwdLogMsgConverter() { |
||||
|
||||
String logMsg = "{\"address\":\"jdbc:mysql://192.168.xx.xx:3306\"," + |
||||
"\"database\":\"carbond\"," + |
||||
"\"jdbcUrl\":\"jdbc:mysql://192.168.xx.xx:3306/ods\"," + |
||||
"\"user\":\"view\"," + |
||||
"\"password\":\"view1\"}"; |
||||
|
||||
String maskLogMsg = "{\"address\":\"jdbc:mysql://192.168.xx.xx:3306\"," + |
||||
"\"database\":\"carbond\"," + |
||||
"\"jdbcUrl\":\"jdbc:mysql://192.168.xx.xx:3306/ods\"," + |
||||
"\"user\":\"view\"," + |
||||
"\"password\":\"******\"}"; |
||||
|
||||
|
||||
logger.info("parameter : {}", logMsg); |
||||
logger.info("parameter : {}", passwordHandler(pwdPattern, logMsg)); |
||||
|
||||
Assert.assertNotEquals(logMsg, passwordHandler(pwdPattern, logMsg)); |
||||
Assert.assertEquals(maskLogMsg, passwordHandler(pwdPattern, logMsg)); |
||||
|
||||
} |
||||
|
||||
/** |
||||
* password regex test |
||||
* |
||||
* @param logMsg original log |
||||
*/ |
||||
private static String passwordHandler(Pattern pattern, String logMsg) { |
||||
|
||||
Matcher matcher = pattern.matcher(logMsg); |
||||
|
||||
StringBuffer sb = new StringBuffer(logMsg.length()); |
||||
|
||||
while (matcher.find()) { |
||||
|
||||
String password = matcher.group(); |
||||
|
||||
String maskPassword = SensitiveLogUtil.maskDataSourcePwd(password); |
||||
|
||||
matcher.appendReplacement(sb, maskPassword); |
||||
} |
||||
matcher.appendTail(sb); |
||||
|
||||
return sb.toString(); |
||||
} |
||||
|
||||
|
||||
} |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue