Remove dao module in worker (#13242)
This commit is contained in:
parent
3ecb4dbe24
commit
14ec4a2398
|
|
@ -39,6 +39,7 @@ config.gypi
|
||||||
test/coverage
|
test/coverage
|
||||||
/docs/zh_CN/介绍
|
/docs/zh_CN/介绍
|
||||||
/docs/zh_CN/贡献代码.md
|
/docs/zh_CN/贡献代码.md
|
||||||
|
derby.log
|
||||||
dolphinscheduler-common/src/main/resources/zookeeper.properties
|
dolphinscheduler-common/src/main/resources/zookeeper.properties
|
||||||
dolphinscheduler-dao/src/main/resources/dao/data_source.properties
|
dolphinscheduler-dao/src/main/resources/dao/data_source.properties
|
||||||
dolphinscheduler-alert/logs/
|
dolphinscheduler-alert/logs/
|
||||||
|
|
|
||||||
|
|
@ -199,8 +199,8 @@ In the early schedule design, if there is no priority design and use the fair sc
|
||||||
```xml
|
```xml
|
||||||
<conversionRule conversionWord="message" converterClass="org.apache.dolphinscheduler.common.log.SensitiveDataConverter"/>
|
<conversionRule conversionWord="message" converterClass="org.apache.dolphinscheduler.common.log.SensitiveDataConverter"/>
|
||||||
<appender name="TASKLOGFILE" class="ch.qos.logback.classic.sift.SiftingAppender">
|
<appender name="TASKLOGFILE" class="ch.qos.logback.classic.sift.SiftingAppender">
|
||||||
<filter class="org.apache.dolphinscheduler.service.log.TaskLogFilter"/>
|
<filter class="org.apache.dolphinscheduler.plugin.task.api.log.TaskLogFilter"/>
|
||||||
<Discriminator class="org.apache.dolphinscheduler.service.log.TaskLogDiscriminator">
|
<Discriminator class="org.apache.dolphinscheduler.plugin.task.api.log.TaskLogDiscriminator">
|
||||||
<key>taskAppId</key>
|
<key>taskAppId</key>
|
||||||
<logBase>${log.base}</logBase>
|
<logBase>${log.base}</logBase>
|
||||||
</Discriminator>
|
</Discriminator>
|
||||||
|
|
|
||||||
|
|
@ -197,8 +197,8 @@
|
||||||
```xml
|
```xml
|
||||||
<conversionRule conversionWord="message" converterClass="org.apache.dolphinscheduler.common.log.SensitiveDataConverter"/>
|
<conversionRule conversionWord="message" converterClass="org.apache.dolphinscheduler.common.log.SensitiveDataConverter"/>
|
||||||
<appender name="TASKLOGFILE" class="ch.qos.logback.classic.sift.SiftingAppender">
|
<appender name="TASKLOGFILE" class="ch.qos.logback.classic.sift.SiftingAppender">
|
||||||
<filter class="org.apache.dolphinscheduler.service.log.TaskLogFilter"/>
|
<filter class="org.apache.dolphinscheduler.plugin.task.api.log.TaskLogFilter"/>
|
||||||
<Discriminator class="org.apache.dolphinscheduler.service.log.TaskLogDiscriminator">
|
<Discriminator class="org.apache.dolphinscheduler.plugin.task.api.log.TaskLogDiscriminator">
|
||||||
<key>taskAppId</key>
|
<key>taskAppId</key>
|
||||||
<logBase>${log.base}</logBase>
|
<logBase>${log.base}</logBase>
|
||||||
</Discriminator>
|
</Discriminator>
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,10 @@
|
||||||
<groupId>org.apache.dolphinscheduler</groupId>
|
<groupId>org.apache.dolphinscheduler</groupId>
|
||||||
<artifactId>dolphinscheduler-scheduler-all</artifactId>
|
<artifactId>dolphinscheduler-scheduler-all</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.dolphinscheduler</groupId>
|
||||||
|
<artifactId>dolphinscheduler-storage-all</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.codehaus.janino</groupId>
|
<groupId>org.codehaus.janino</groupId>
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ import org.apache.dolphinscheduler.common.enums.PluginType;
|
||||||
import org.apache.dolphinscheduler.dao.PluginDao;
|
import org.apache.dolphinscheduler.dao.PluginDao;
|
||||||
import org.apache.dolphinscheduler.dao.entity.PluginDefine;
|
import org.apache.dolphinscheduler.dao.entity.PluginDefine;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.TaskChannelFactory;
|
import org.apache.dolphinscheduler.plugin.task.api.TaskChannelFactory;
|
||||||
import org.apache.dolphinscheduler.service.task.TaskPluginManager;
|
import org.apache.dolphinscheduler.plugin.task.api.TaskPluginManager;
|
||||||
import org.apache.dolphinscheduler.spi.params.PluginParamsTransfer;
|
import org.apache.dolphinscheduler.spi.params.PluginParamsTransfer;
|
||||||
import org.apache.dolphinscheduler.spi.params.base.PluginParams;
|
import org.apache.dolphinscheduler.spi.params.base.PluginParams;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,9 +38,9 @@ import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.common.constants.Constants;
|
import org.apache.dolphinscheduler.common.constants.Constants;
|
||||||
import org.apache.dolphinscheduler.dao.entity.User;
|
import org.apache.dolphinscheduler.dao.entity.User;
|
||||||
import org.apache.dolphinscheduler.plugin.datasource.api.datasource.BaseDataSourceParamDTO;
|
import org.apache.dolphinscheduler.plugin.datasource.api.datasource.BaseDataSourceParamDTO;
|
||||||
|
import org.apache.dolphinscheduler.plugin.datasource.api.utils.CommonUtils;
|
||||||
import org.apache.dolphinscheduler.plugin.datasource.api.utils.DataSourceUtils;
|
import org.apache.dolphinscheduler.plugin.datasource.api.utils.DataSourceUtils;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils;
|
import org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils;
|
||||||
import org.apache.dolphinscheduler.service.utils.CommonUtils;
|
|
||||||
import org.apache.dolphinscheduler.spi.datasource.ConnectionParam;
|
import org.apache.dolphinscheduler.spi.datasource.ConnectionParam;
|
||||||
import org.apache.dolphinscheduler.spi.enums.DbType;
|
import org.apache.dolphinscheduler.spi.enums.DbType;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ package org.apache.dolphinscheduler.api.dto.resources.visitor;
|
||||||
import org.apache.dolphinscheduler.api.dto.resources.Directory;
|
import org.apache.dolphinscheduler.api.dto.resources.Directory;
|
||||||
import org.apache.dolphinscheduler.api.dto.resources.FileLeaf;
|
import org.apache.dolphinscheduler.api.dto.resources.FileLeaf;
|
||||||
import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent;
|
import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent;
|
||||||
import org.apache.dolphinscheduler.service.storage.StorageEntity;
|
import org.apache.dolphinscheduler.plugin.storage.api.StorageEntity;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ import org.apache.dolphinscheduler.dao.mapper.ProjectMapper;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.ProjectUserMapper;
|
import org.apache.dolphinscheduler.dao.mapper.ProjectUserMapper;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.ScheduleMapper;
|
import org.apache.dolphinscheduler.dao.mapper.ScheduleMapper;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper;
|
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper;
|
||||||
import org.apache.dolphinscheduler.service.storage.StorageEntity;
|
import org.apache.dolphinscheduler.plugin.storage.api.StorageEntity;
|
||||||
import org.apache.dolphinscheduler.spi.enums.ResourceType;
|
import org.apache.dolphinscheduler.spi.enums.ResourceType;
|
||||||
|
|
||||||
import py4j.GatewayServer;
|
import py4j.GatewayServer;
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ import org.apache.dolphinscheduler.api.dto.resources.DeleteDataTransferResponse;
|
||||||
import org.apache.dolphinscheduler.api.utils.Result;
|
import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.common.enums.ProgramType;
|
import org.apache.dolphinscheduler.common.enums.ProgramType;
|
||||||
import org.apache.dolphinscheduler.dao.entity.User;
|
import org.apache.dolphinscheduler.dao.entity.User;
|
||||||
import org.apache.dolphinscheduler.service.storage.StorageEntity;
|
import org.apache.dolphinscheduler.plugin.storage.api.StorageEntity;
|
||||||
import org.apache.dolphinscheduler.spi.enums.ResourceType;
|
import org.apache.dolphinscheduler.spi.enums.ResourceType;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ import org.apache.dolphinscheduler.common.model.WorkerServerModel;
|
||||||
import org.apache.dolphinscheduler.dao.MonitorDBDao;
|
import org.apache.dolphinscheduler.dao.MonitorDBDao;
|
||||||
import org.apache.dolphinscheduler.dao.entity.MonitorRecord;
|
import org.apache.dolphinscheduler.dao.entity.MonitorRecord;
|
||||||
import org.apache.dolphinscheduler.dao.entity.User;
|
import org.apache.dolphinscheduler.dao.entity.User;
|
||||||
import org.apache.dolphinscheduler.service.registry.RegistryClient;
|
import org.apache.dolphinscheduler.registry.api.RegistryClient;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
|
||||||
|
|
@ -111,6 +111,7 @@ import org.apache.dolphinscheduler.dao.mapper.UserMapper;
|
||||||
import org.apache.dolphinscheduler.dao.model.PageListingResult;
|
import org.apache.dolphinscheduler.dao.model.PageListingResult;
|
||||||
import org.apache.dolphinscheduler.dao.repository.ProcessDefinitionDao;
|
import org.apache.dolphinscheduler.dao.repository.ProcessDefinitionDao;
|
||||||
import org.apache.dolphinscheduler.dao.repository.TaskDefinitionLogDao;
|
import org.apache.dolphinscheduler.dao.repository.TaskDefinitionLogDao;
|
||||||
|
import org.apache.dolphinscheduler.plugin.task.api.TaskPluginManager;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.enums.SqlType;
|
import org.apache.dolphinscheduler.plugin.task.api.enums.SqlType;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskTimeoutStrategy;
|
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskTimeoutStrategy;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.model.Property;
|
import org.apache.dolphinscheduler.plugin.task.api.model.Property;
|
||||||
|
|
@ -118,7 +119,6 @@ import org.apache.dolphinscheduler.plugin.task.api.parameters.ParametersNode;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.parameters.SqlParameters;
|
import org.apache.dolphinscheduler.plugin.task.api.parameters.SqlParameters;
|
||||||
import org.apache.dolphinscheduler.service.model.TaskNode;
|
import org.apache.dolphinscheduler.service.model.TaskNode;
|
||||||
import org.apache.dolphinscheduler.service.process.ProcessService;
|
import org.apache.dolphinscheduler.service.process.ProcessService;
|
||||||
import org.apache.dolphinscheduler.service.task.TaskPluginManager;
|
|
||||||
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,7 @@ import org.apache.dolphinscheduler.dao.mapper.TenantMapper;
|
||||||
import org.apache.dolphinscheduler.dao.repository.ProcessInstanceDao;
|
import org.apache.dolphinscheduler.dao.repository.ProcessInstanceDao;
|
||||||
import org.apache.dolphinscheduler.dao.repository.TaskInstanceDao;
|
import org.apache.dolphinscheduler.dao.repository.TaskInstanceDao;
|
||||||
import org.apache.dolphinscheduler.dao.utils.WorkflowUtils;
|
import org.apache.dolphinscheduler.dao.utils.WorkflowUtils;
|
||||||
|
import org.apache.dolphinscheduler.plugin.task.api.TaskPluginManager;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.enums.DependResult;
|
import org.apache.dolphinscheduler.plugin.task.api.enums.DependResult;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.model.Property;
|
import org.apache.dolphinscheduler.plugin.task.api.model.Property;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.parameters.ParametersNode;
|
import org.apache.dolphinscheduler.plugin.task.api.parameters.ParametersNode;
|
||||||
|
|
@ -79,7 +80,6 @@ import org.apache.dolphinscheduler.plugin.task.api.utils.ParameterUtils;
|
||||||
import org.apache.dolphinscheduler.service.expand.CuringParamsService;
|
import org.apache.dolphinscheduler.service.expand.CuringParamsService;
|
||||||
import org.apache.dolphinscheduler.service.model.TaskNode;
|
import org.apache.dolphinscheduler.service.model.TaskNode;
|
||||||
import org.apache.dolphinscheduler.service.process.ProcessService;
|
import org.apache.dolphinscheduler.service.process.ProcessService;
|
||||||
import org.apache.dolphinscheduler.service.task.TaskPluginManager;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -61,10 +61,10 @@ import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.TenantMapper;
|
import org.apache.dolphinscheduler.dao.mapper.TenantMapper;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.UdfFuncMapper;
|
import org.apache.dolphinscheduler.dao.mapper.UdfFuncMapper;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.UserMapper;
|
import org.apache.dolphinscheduler.dao.mapper.UserMapper;
|
||||||
|
import org.apache.dolphinscheduler.plugin.storage.api.StorageEntity;
|
||||||
|
import org.apache.dolphinscheduler.plugin.storage.api.StorageOperate;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
|
import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
|
||||||
import org.apache.dolphinscheduler.service.process.ProcessService;
|
import org.apache.dolphinscheduler.service.process.ProcessService;
|
||||||
import org.apache.dolphinscheduler.service.storage.StorageEntity;
|
|
||||||
import org.apache.dolphinscheduler.service.storage.StorageOperate;
|
|
||||||
import org.apache.dolphinscheduler.spi.enums.ResourceType;
|
import org.apache.dolphinscheduler.spi.enums.ResourceType;
|
||||||
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
|
|
||||||
|
|
@ -63,9 +63,9 @@ import org.apache.dolphinscheduler.dao.mapper.ProcessTaskRelationMapper;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper;
|
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionLogMapper;
|
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionLogMapper;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper;
|
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper;
|
||||||
|
import org.apache.dolphinscheduler.plugin.task.api.TaskPluginManager;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.parameters.ParametersNode;
|
import org.apache.dolphinscheduler.plugin.task.api.parameters.ParametersNode;
|
||||||
import org.apache.dolphinscheduler.service.process.ProcessService;
|
import org.apache.dolphinscheduler.service.process.ProcessService;
|
||||||
import org.apache.dolphinscheduler.service.task.TaskPluginManager;
|
|
||||||
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.collections4.MapUtils;
|
import org.apache.commons.collections4.MapUtils;
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.ProcessInstanceMapper;
|
import org.apache.dolphinscheduler.dao.mapper.ProcessInstanceMapper;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.TenantMapper;
|
import org.apache.dolphinscheduler.dao.mapper.TenantMapper;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.UserMapper;
|
import org.apache.dolphinscheduler.dao.mapper.UserMapper;
|
||||||
import org.apache.dolphinscheduler.service.storage.StorageOperate;
|
import org.apache.dolphinscheduler.plugin.storage.api.StorageOperate;
|
||||||
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ import org.apache.dolphinscheduler.dao.entity.User;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.ResourceMapper;
|
import org.apache.dolphinscheduler.dao.mapper.ResourceMapper;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.UDFUserMapper;
|
import org.apache.dolphinscheduler.dao.mapper.UDFUserMapper;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.UdfFuncMapper;
|
import org.apache.dolphinscheduler.dao.mapper.UdfFuncMapper;
|
||||||
import org.apache.dolphinscheduler.service.storage.StorageOperate;
|
import org.apache.dolphinscheduler.plugin.storage.api.StorageOperate;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ import org.apache.dolphinscheduler.dao.mapper.TenantMapper;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.UDFUserMapper;
|
import org.apache.dolphinscheduler.dao.mapper.UDFUserMapper;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.UserMapper;
|
import org.apache.dolphinscheduler.dao.mapper.UserMapper;
|
||||||
import org.apache.dolphinscheduler.dao.utils.ResourceProcessDefinitionUtils;
|
import org.apache.dolphinscheduler.dao.utils.ResourceProcessDefinitionUtils;
|
||||||
import org.apache.dolphinscheduler.service.storage.StorageOperate;
|
import org.apache.dolphinscheduler.plugin.storage.api.StorageOperate;
|
||||||
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,8 @@ import org.apache.dolphinscheduler.dao.mapper.EnvironmentWorkerGroupRelationMapp
|
||||||
import org.apache.dolphinscheduler.dao.mapper.ProcessInstanceMapper;
|
import org.apache.dolphinscheduler.dao.mapper.ProcessInstanceMapper;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.ScheduleMapper;
|
import org.apache.dolphinscheduler.dao.mapper.ScheduleMapper;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.WorkerGroupMapper;
|
import org.apache.dolphinscheduler.dao.mapper.WorkerGroupMapper;
|
||||||
|
import org.apache.dolphinscheduler.registry.api.RegistryClient;
|
||||||
import org.apache.dolphinscheduler.service.process.ProcessService;
|
import org.apache.dolphinscheduler.service.process.ProcessService;
|
||||||
import org.apache.dolphinscheduler.service.registry.RegistryClient;
|
|
||||||
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||||
import org.apache.dolphinscheduler.dao.entity.WorkerGroup;
|
import org.apache.dolphinscheduler.dao.entity.WorkerGroup;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.ProcessInstanceMapper;
|
import org.apache.dolphinscheduler.dao.mapper.ProcessInstanceMapper;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.WorkerGroupMapper;
|
import org.apache.dolphinscheduler.dao.mapper.WorkerGroupMapper;
|
||||||
import org.apache.dolphinscheduler.service.registry.RegistryClient;
|
import org.apache.dolphinscheduler.registry.api.RegistryClient;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
package org.apache.dolphinscheduler.api.dto.resources.visitor;
|
package org.apache.dolphinscheduler.api.dto.resources.visitor;
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent;
|
import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent;
|
||||||
import org.apache.dolphinscheduler.service.storage.StorageEntity;
|
import org.apache.dolphinscheduler.plugin.storage.api.StorageEntity;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ import org.apache.dolphinscheduler.dao.entity.User;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper;
|
import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper;
|
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper;
|
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper;
|
||||||
import org.apache.dolphinscheduler.service.storage.StorageEntity;
|
import org.apache.dolphinscheduler.plugin.storage.api.StorageEntity;
|
||||||
import org.apache.dolphinscheduler.spi.enums.ResourceType;
|
import org.apache.dolphinscheduler.spi.enums.ResourceType;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ import org.apache.dolphinscheduler.api.utils.Result;
|
||||||
import org.apache.dolphinscheduler.common.constants.Constants;
|
import org.apache.dolphinscheduler.common.constants.Constants;
|
||||||
import org.apache.dolphinscheduler.common.enums.UserType;
|
import org.apache.dolphinscheduler.common.enums.UserType;
|
||||||
import org.apache.dolphinscheduler.dao.entity.User;
|
import org.apache.dolphinscheduler.dao.entity.User;
|
||||||
import org.apache.dolphinscheduler.service.storage.impl.HadoopUtils;
|
import org.apache.dolphinscheduler.plugin.storage.hdfs.HdfsStorageOperator;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
@ -48,7 +48,7 @@ public class BaseServiceTest {
|
||||||
private BaseServiceImpl baseService;
|
private BaseServiceImpl baseService;
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private HadoopUtils hadoopUtils;
|
private HdfsStorageOperator hdfsStorageOperator;
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ import org.apache.dolphinscheduler.common.model.Server;
|
||||||
import org.apache.dolphinscheduler.dao.MonitorDBDao;
|
import org.apache.dolphinscheduler.dao.MonitorDBDao;
|
||||||
import org.apache.dolphinscheduler.dao.entity.MonitorRecord;
|
import org.apache.dolphinscheduler.dao.entity.MonitorRecord;
|
||||||
import org.apache.dolphinscheduler.dao.entity.User;
|
import org.apache.dolphinscheduler.dao.entity.User;
|
||||||
import org.apache.dolphinscheduler.service.registry.RegistryClient;
|
import org.apache.dolphinscheduler.registry.api.RegistryClient;
|
||||||
import org.apache.dolphinscheduler.spi.enums.DbType;
|
import org.apache.dolphinscheduler.spi.enums.DbType;
|
||||||
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
|
|
||||||
|
|
@ -58,12 +58,12 @@ import org.apache.dolphinscheduler.dao.mapper.TaskInstanceMapper;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.TenantMapper;
|
import org.apache.dolphinscheduler.dao.mapper.TenantMapper;
|
||||||
import org.apache.dolphinscheduler.dao.repository.ProcessInstanceDao;
|
import org.apache.dolphinscheduler.dao.repository.ProcessInstanceDao;
|
||||||
import org.apache.dolphinscheduler.dao.repository.TaskInstanceDao;
|
import org.apache.dolphinscheduler.dao.repository.TaskInstanceDao;
|
||||||
|
import org.apache.dolphinscheduler.plugin.task.api.TaskPluginManager;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.enums.DependResult;
|
import org.apache.dolphinscheduler.plugin.task.api.enums.DependResult;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
|
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
|
||||||
import org.apache.dolphinscheduler.service.expand.CuringParamsService;
|
import org.apache.dolphinscheduler.service.expand.CuringParamsService;
|
||||||
import org.apache.dolphinscheduler.service.model.TaskNode;
|
import org.apache.dolphinscheduler.service.model.TaskNode;
|
||||||
import org.apache.dolphinscheduler.service.process.ProcessService;
|
import org.apache.dolphinscheduler.service.process.ProcessService;
|
||||||
import org.apache.dolphinscheduler.service.task.TaskPluginManager;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
|
|
|
||||||
|
|
@ -40,8 +40,8 @@ import org.apache.dolphinscheduler.dao.mapper.ResourceUserMapper;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.TenantMapper;
|
import org.apache.dolphinscheduler.dao.mapper.TenantMapper;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.UdfFuncMapper;
|
import org.apache.dolphinscheduler.dao.mapper.UdfFuncMapper;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.UserMapper;
|
import org.apache.dolphinscheduler.dao.mapper.UserMapper;
|
||||||
import org.apache.dolphinscheduler.service.storage.StorageEntity;
|
import org.apache.dolphinscheduler.plugin.storage.api.StorageEntity;
|
||||||
import org.apache.dolphinscheduler.service.storage.StorageOperate;
|
import org.apache.dolphinscheduler.plugin.storage.api.StorageOperate;
|
||||||
import org.apache.dolphinscheduler.spi.enums.ResourceType;
|
import org.apache.dolphinscheduler.spi.enums.ResourceType;
|
||||||
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
|
|
||||||
|
|
@ -56,9 +56,9 @@ import org.apache.dolphinscheduler.dao.mapper.ProcessTaskRelationMapper;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper;
|
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionLogMapper;
|
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionLogMapper;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper;
|
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper;
|
||||||
|
import org.apache.dolphinscheduler.plugin.task.api.TaskPluginManager;
|
||||||
import org.apache.dolphinscheduler.service.process.ProcessService;
|
import org.apache.dolphinscheduler.service.process.ProcessService;
|
||||||
import org.apache.dolphinscheduler.service.process.ProcessServiceImpl;
|
import org.apache.dolphinscheduler.service.process.ProcessServiceImpl;
|
||||||
import org.apache.dolphinscheduler.service.task.TaskPluginManager;
|
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.ProcessInstanceMapper;
|
import org.apache.dolphinscheduler.dao.mapper.ProcessInstanceMapper;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.TenantMapper;
|
import org.apache.dolphinscheduler.dao.mapper.TenantMapper;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.UserMapper;
|
import org.apache.dolphinscheduler.dao.mapper.UserMapper;
|
||||||
import org.apache.dolphinscheduler.service.storage.StorageOperate;
|
import org.apache.dolphinscheduler.plugin.storage.api.StorageOperate;
|
||||||
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ import org.apache.dolphinscheduler.dao.entity.User;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.ResourceMapper;
|
import org.apache.dolphinscheduler.dao.mapper.ResourceMapper;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.UDFUserMapper;
|
import org.apache.dolphinscheduler.dao.mapper.UDFUserMapper;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.UdfFuncMapper;
|
import org.apache.dolphinscheduler.dao.mapper.UdfFuncMapper;
|
||||||
import org.apache.dolphinscheduler.service.storage.StorageOperate;
|
import org.apache.dolphinscheduler.plugin.storage.api.StorageOperate;
|
||||||
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ import org.apache.dolphinscheduler.dao.mapper.ResourceUserMapper;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.TenantMapper;
|
import org.apache.dolphinscheduler.dao.mapper.TenantMapper;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.UDFUserMapper;
|
import org.apache.dolphinscheduler.dao.mapper.UDFUserMapper;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.UserMapper;
|
import org.apache.dolphinscheduler.dao.mapper.UserMapper;
|
||||||
import org.apache.dolphinscheduler.service.storage.StorageOperate;
|
import org.apache.dolphinscheduler.plugin.storage.api.StorageOperate;
|
||||||
import org.apache.dolphinscheduler.spi.enums.ResourceType;
|
import org.apache.dolphinscheduler.spi.enums.ResourceType;
|
||||||
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,8 @@ import org.apache.dolphinscheduler.dao.entity.WorkerGroup;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.EnvironmentWorkerGroupRelationMapper;
|
import org.apache.dolphinscheduler.dao.mapper.EnvironmentWorkerGroupRelationMapper;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.ProcessInstanceMapper;
|
import org.apache.dolphinscheduler.dao.mapper.ProcessInstanceMapper;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.WorkerGroupMapper;
|
import org.apache.dolphinscheduler.dao.mapper.WorkerGroupMapper;
|
||||||
|
import org.apache.dolphinscheduler.registry.api.RegistryClient;
|
||||||
import org.apache.dolphinscheduler.service.process.ProcessService;
|
import org.apache.dolphinscheduler.service.process.ProcessService;
|
||||||
import org.apache.dolphinscheduler.service.registry.RegistryClient;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
|
||||||
|
|
@ -51,12 +51,6 @@ public final class Constants {
|
||||||
|
|
||||||
public static final String RESOURCE_TYPE_UDF = "udfs";
|
public static final String RESOURCE_TYPE_UDF = "udfs";
|
||||||
|
|
||||||
public static final String STORAGE_S3 = "S3";
|
|
||||||
|
|
||||||
public static final String STORAGE_OSS = "OSS";
|
|
||||||
|
|
||||||
public static final String STORAGE_HDFS = "HDFS";
|
|
||||||
|
|
||||||
public static final String EMPTY_STRING = "";
|
public static final String EMPTY_STRING = "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.LOGIN_US
|
||||||
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.LOGIN_USER_KEY_TAB_USERNAME;
|
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.LOGIN_USER_KEY_TAB_USERNAME;
|
||||||
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.RESOURCE_UPLOAD_PATH;
|
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.RESOURCE_UPLOAD_PATH;
|
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.common.constants.Constants;
|
||||||
import org.apache.dolphinscheduler.common.enums.ResUploadType;
|
import org.apache.dolphinscheduler.common.enums.ResUploadType;
|
||||||
import org.apache.dolphinscheduler.common.utils.PropertyUtils;
|
import org.apache.dolphinscheduler.common.utils.PropertyUtils;
|
||||||
|
|
||||||
|
|
@ -46,6 +47,15 @@ public class CommonUtils {
|
||||||
throw new UnsupportedOperationException("Construct CommonUtils");
|
throw new UnsupportedOperationException("Construct CommonUtils");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final boolean IS_DEVELOP_MODE = PropertyUtils.getBoolean(Constants.DEVELOPMENT_STATE, true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return is develop mode
|
||||||
|
*/
|
||||||
|
public static boolean isDevelopMode() {
|
||||||
|
return IS_DEVELOP_MODE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* if upload resource is HDFS and kerberos startup is true , else false
|
* if upload resource is HDFS and kerberos startup is true , else false
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,11 @@
|
||||||
<artifactId>dolphinscheduler-task-all</artifactId>
|
<artifactId>dolphinscheduler-task-all</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.dolphinscheduler</groupId>
|
||||||
|
<artifactId>dolphinscheduler-storage-all</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-cache</artifactId>
|
<artifactId>spring-boot-starter-cache</artifactId>
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ import org.apache.dolphinscheduler.common.IStoppable;
|
||||||
import org.apache.dolphinscheduler.common.constants.Constants;
|
import org.apache.dolphinscheduler.common.constants.Constants;
|
||||||
import org.apache.dolphinscheduler.common.lifecycle.ServerLifeCycleManager;
|
import org.apache.dolphinscheduler.common.lifecycle.ServerLifeCycleManager;
|
||||||
import org.apache.dolphinscheduler.common.thread.ThreadUtils;
|
import org.apache.dolphinscheduler.common.thread.ThreadUtils;
|
||||||
|
import org.apache.dolphinscheduler.plugin.task.api.TaskPluginManager;
|
||||||
import org.apache.dolphinscheduler.scheduler.api.SchedulerApi;
|
import org.apache.dolphinscheduler.scheduler.api.SchedulerApi;
|
||||||
import org.apache.dolphinscheduler.server.master.registry.MasterRegistryClient;
|
import org.apache.dolphinscheduler.server.master.registry.MasterRegistryClient;
|
||||||
import org.apache.dolphinscheduler.server.master.rpc.MasterRPCServer;
|
import org.apache.dolphinscheduler.server.master.rpc.MasterRPCServer;
|
||||||
|
|
@ -28,7 +29,6 @@ import org.apache.dolphinscheduler.server.master.runner.EventExecuteService;
|
||||||
import org.apache.dolphinscheduler.server.master.runner.FailoverExecuteThread;
|
import org.apache.dolphinscheduler.server.master.runner.FailoverExecuteThread;
|
||||||
import org.apache.dolphinscheduler.server.master.runner.MasterSchedulerBootstrap;
|
import org.apache.dolphinscheduler.server.master.runner.MasterSchedulerBootstrap;
|
||||||
import org.apache.dolphinscheduler.service.bean.SpringApplicationContext;
|
import org.apache.dolphinscheduler.service.bean.SpringApplicationContext;
|
||||||
import org.apache.dolphinscheduler.service.task.TaskPluginManager;
|
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,8 @@ package org.apache.dolphinscheduler.server.master.registry;
|
||||||
import org.apache.dolphinscheduler.common.lifecycle.ServerLifeCycleManager;
|
import org.apache.dolphinscheduler.common.lifecycle.ServerLifeCycleManager;
|
||||||
import org.apache.dolphinscheduler.registry.api.ConnectionListener;
|
import org.apache.dolphinscheduler.registry.api.ConnectionListener;
|
||||||
import org.apache.dolphinscheduler.registry.api.ConnectionState;
|
import org.apache.dolphinscheduler.registry.api.ConnectionState;
|
||||||
|
import org.apache.dolphinscheduler.registry.api.RegistryClient;
|
||||||
import org.apache.dolphinscheduler.server.master.config.MasterConfig;
|
import org.apache.dolphinscheduler.server.master.config.MasterConfig;
|
||||||
import org.apache.dolphinscheduler.service.registry.RegistryClient;
|
|
||||||
|
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,11 +25,11 @@ import org.apache.dolphinscheduler.common.enums.NodeType;
|
||||||
import org.apache.dolphinscheduler.common.thread.ThreadUtils;
|
import org.apache.dolphinscheduler.common.thread.ThreadUtils;
|
||||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||||
import org.apache.dolphinscheduler.common.utils.NetUtils;
|
import org.apache.dolphinscheduler.common.utils.NetUtils;
|
||||||
|
import org.apache.dolphinscheduler.registry.api.RegistryClient;
|
||||||
import org.apache.dolphinscheduler.registry.api.RegistryException;
|
import org.apache.dolphinscheduler.registry.api.RegistryException;
|
||||||
import org.apache.dolphinscheduler.server.master.config.MasterConfig;
|
import org.apache.dolphinscheduler.server.master.config.MasterConfig;
|
||||||
import org.apache.dolphinscheduler.server.master.service.FailoverService;
|
import org.apache.dolphinscheduler.server.master.service.FailoverService;
|
||||||
import org.apache.dolphinscheduler.server.master.task.MasterHeartBeatTask;
|
import org.apache.dolphinscheduler.server.master.task.MasterHeartBeatTask;
|
||||||
import org.apache.dolphinscheduler.service.registry.RegistryClient;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,9 @@
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.server.master.registry;
|
package org.apache.dolphinscheduler.server.master.registry;
|
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.registry.api.RegistryClient;
|
||||||
import org.apache.dolphinscheduler.registry.api.StrategyType;
|
import org.apache.dolphinscheduler.registry.api.StrategyType;
|
||||||
import org.apache.dolphinscheduler.server.master.config.MasterConfig;
|
import org.apache.dolphinscheduler.server.master.config.MasterConfig;
|
||||||
import org.apache.dolphinscheduler.service.registry.RegistryClient;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ import org.apache.dolphinscheduler.common.lifecycle.ServerLifeCycleException;
|
||||||
import org.apache.dolphinscheduler.common.lifecycle.ServerLifeCycleManager;
|
import org.apache.dolphinscheduler.common.lifecycle.ServerLifeCycleManager;
|
||||||
import org.apache.dolphinscheduler.common.lifecycle.ServerStatus;
|
import org.apache.dolphinscheduler.common.lifecycle.ServerStatus;
|
||||||
import org.apache.dolphinscheduler.registry.api.Registry;
|
import org.apache.dolphinscheduler.registry.api.Registry;
|
||||||
|
import org.apache.dolphinscheduler.registry.api.RegistryClient;
|
||||||
import org.apache.dolphinscheduler.registry.api.RegistryException;
|
import org.apache.dolphinscheduler.registry.api.RegistryException;
|
||||||
import org.apache.dolphinscheduler.registry.api.StrategyType;
|
import org.apache.dolphinscheduler.registry.api.StrategyType;
|
||||||
import org.apache.dolphinscheduler.server.master.cache.ProcessInstanceExecCacheManager;
|
import org.apache.dolphinscheduler.server.master.cache.ProcessInstanceExecCacheManager;
|
||||||
|
|
@ -28,7 +29,6 @@ import org.apache.dolphinscheduler.server.master.config.MasterConfig;
|
||||||
import org.apache.dolphinscheduler.server.master.event.WorkflowEventQueue;
|
import org.apache.dolphinscheduler.server.master.event.WorkflowEventQueue;
|
||||||
import org.apache.dolphinscheduler.server.master.rpc.MasterRPCServer;
|
import org.apache.dolphinscheduler.server.master.rpc.MasterRPCServer;
|
||||||
import org.apache.dolphinscheduler.server.master.runner.StateWheelExecuteThread;
|
import org.apache.dolphinscheduler.server.master.runner.StateWheelExecuteThread;
|
||||||
import org.apache.dolphinscheduler.service.registry.RegistryClient;
|
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,11 +30,11 @@ import org.apache.dolphinscheduler.dao.entity.WorkerGroup;
|
||||||
import org.apache.dolphinscheduler.dao.mapper.WorkerGroupMapper;
|
import org.apache.dolphinscheduler.dao.mapper.WorkerGroupMapper;
|
||||||
import org.apache.dolphinscheduler.registry.api.Event;
|
import org.apache.dolphinscheduler.registry.api.Event;
|
||||||
import org.apache.dolphinscheduler.registry.api.Event.Type;
|
import org.apache.dolphinscheduler.registry.api.Event.Type;
|
||||||
|
import org.apache.dolphinscheduler.registry.api.RegistryClient;
|
||||||
import org.apache.dolphinscheduler.registry.api.SubscribeListener;
|
import org.apache.dolphinscheduler.registry.api.SubscribeListener;
|
||||||
import org.apache.dolphinscheduler.remote.utils.NamedThreadFactory;
|
import org.apache.dolphinscheduler.remote.utils.NamedThreadFactory;
|
||||||
import org.apache.dolphinscheduler.server.master.config.MasterConfig;
|
import org.apache.dolphinscheduler.server.master.config.MasterConfig;
|
||||||
import org.apache.dolphinscheduler.service.queue.MasterPriorityQueue;
|
import org.apache.dolphinscheduler.service.queue.MasterPriorityQueue;
|
||||||
import org.apache.dolphinscheduler.service.registry.RegistryClient;
|
|
||||||
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ package org.apache.dolphinscheduler.server.master.rpc;
|
||||||
import org.apache.dolphinscheduler.remote.NettyRemotingServer;
|
import org.apache.dolphinscheduler.remote.NettyRemotingServer;
|
||||||
import org.apache.dolphinscheduler.remote.command.CommandType;
|
import org.apache.dolphinscheduler.remote.command.CommandType;
|
||||||
import org.apache.dolphinscheduler.remote.config.NettyServerConfig;
|
import org.apache.dolphinscheduler.remote.config.NettyServerConfig;
|
||||||
|
import org.apache.dolphinscheduler.remote.processor.LoggerRequestProcessor;
|
||||||
import org.apache.dolphinscheduler.server.master.config.MasterConfig;
|
import org.apache.dolphinscheduler.server.master.config.MasterConfig;
|
||||||
import org.apache.dolphinscheduler.server.master.processor.CacheProcessor;
|
import org.apache.dolphinscheduler.server.master.processor.CacheProcessor;
|
||||||
import org.apache.dolphinscheduler.server.master.processor.StateEventProcessor;
|
import org.apache.dolphinscheduler.server.master.processor.StateEventProcessor;
|
||||||
|
|
@ -30,7 +31,6 @@ import org.apache.dolphinscheduler.server.master.processor.TaskExecuteStartProce
|
||||||
import org.apache.dolphinscheduler.server.master.processor.TaskKillResponseProcessor;
|
import org.apache.dolphinscheduler.server.master.processor.TaskKillResponseProcessor;
|
||||||
import org.apache.dolphinscheduler.server.master.processor.TaskRecallProcessor;
|
import org.apache.dolphinscheduler.server.master.processor.TaskRecallProcessor;
|
||||||
import org.apache.dolphinscheduler.server.master.processor.WorkflowExecutingDataRequestProcessor;
|
import org.apache.dolphinscheduler.server.master.processor.WorkflowExecutingDataRequestProcessor;
|
||||||
import org.apache.dolphinscheduler.service.log.LoggerRequestProcessor;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ import org.apache.dolphinscheduler.dao.mapper.ProcessTaskRelationMapper;
|
||||||
import org.apache.dolphinscheduler.dao.repository.TaskInstanceDao;
|
import org.apache.dolphinscheduler.dao.repository.TaskInstanceDao;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.TaskChannel;
|
import org.apache.dolphinscheduler.plugin.task.api.TaskChannel;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
|
import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
|
||||||
|
import org.apache.dolphinscheduler.plugin.task.api.TaskPluginManager;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
|
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.model.Property;
|
import org.apache.dolphinscheduler.plugin.task.api.model.Property;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
|
import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
|
||||||
|
|
@ -57,7 +58,6 @@ import org.apache.dolphinscheduler.server.master.metrics.TaskMetrics;
|
||||||
import org.apache.dolphinscheduler.server.master.processor.queue.TaskEvent;
|
import org.apache.dolphinscheduler.server.master.processor.queue.TaskEvent;
|
||||||
import org.apache.dolphinscheduler.service.bean.SpringApplicationContext;
|
import org.apache.dolphinscheduler.service.bean.SpringApplicationContext;
|
||||||
import org.apache.dolphinscheduler.service.process.ProcessService;
|
import org.apache.dolphinscheduler.service.process.ProcessService;
|
||||||
import org.apache.dolphinscheduler.service.task.TaskPluginManager;
|
|
||||||
import org.apache.dolphinscheduler.service.utils.LoggerUtils;
|
import org.apache.dolphinscheduler.service.utils.LoggerUtils;
|
||||||
import org.apache.dolphinscheduler.spi.enums.ResourceType;
|
import org.apache.dolphinscheduler.spi.enums.ResourceType;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,11 +49,13 @@ import org.apache.dolphinscheduler.dao.entity.Tenant;
|
||||||
import org.apache.dolphinscheduler.dao.entity.UdfFunc;
|
import org.apache.dolphinscheduler.dao.entity.UdfFunc;
|
||||||
import org.apache.dolphinscheduler.dao.repository.ProcessInstanceDao;
|
import org.apache.dolphinscheduler.dao.repository.ProcessInstanceDao;
|
||||||
import org.apache.dolphinscheduler.dao.repository.TaskInstanceDao;
|
import org.apache.dolphinscheduler.dao.repository.TaskInstanceDao;
|
||||||
|
import org.apache.dolphinscheduler.plugin.storage.api.StorageOperate;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.DataQualityTaskExecutionContext;
|
import org.apache.dolphinscheduler.plugin.task.api.DataQualityTaskExecutionContext;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.K8sTaskExecutionContext;
|
import org.apache.dolphinscheduler.plugin.task.api.K8sTaskExecutionContext;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.TaskChannel;
|
import org.apache.dolphinscheduler.plugin.task.api.TaskChannel;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
|
import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
|
import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
|
||||||
|
import org.apache.dolphinscheduler.plugin.task.api.TaskPluginManager;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
|
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.enums.dp.ConnectorType;
|
import org.apache.dolphinscheduler.plugin.task.api.enums.dp.ConnectorType;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.enums.dp.ExecuteSqlType;
|
import org.apache.dolphinscheduler.plugin.task.api.enums.dp.ExecuteSqlType;
|
||||||
|
|
@ -75,8 +77,6 @@ import org.apache.dolphinscheduler.server.master.config.MasterConfig;
|
||||||
import org.apache.dolphinscheduler.service.bean.SpringApplicationContext;
|
import org.apache.dolphinscheduler.service.bean.SpringApplicationContext;
|
||||||
import org.apache.dolphinscheduler.service.expand.CuringParamsService;
|
import org.apache.dolphinscheduler.service.expand.CuringParamsService;
|
||||||
import org.apache.dolphinscheduler.service.process.ProcessService;
|
import org.apache.dolphinscheduler.service.process.ProcessService;
|
||||||
import org.apache.dolphinscheduler.service.storage.impl.HadoopUtils;
|
|
||||||
import org.apache.dolphinscheduler.service.task.TaskPluginManager;
|
|
||||||
import org.apache.dolphinscheduler.service.utils.LoggerUtils;
|
import org.apache.dolphinscheduler.service.utils.LoggerUtils;
|
||||||
import org.apache.dolphinscheduler.spi.enums.DbType;
|
import org.apache.dolphinscheduler.spi.enums.DbType;
|
||||||
import org.apache.dolphinscheduler.spi.enums.ResourceType;
|
import org.apache.dolphinscheduler.spi.enums.ResourceType;
|
||||||
|
|
@ -124,6 +124,8 @@ public abstract class BaseTaskProcessor implements ITaskProcessor {
|
||||||
|
|
||||||
protected ProcessInstanceDao processInstanceDao;
|
protected ProcessInstanceDao processInstanceDao;
|
||||||
|
|
||||||
|
protected StorageOperate storageOperate;
|
||||||
|
|
||||||
protected MasterConfig masterConfig;
|
protected MasterConfig masterConfig;
|
||||||
|
|
||||||
protected TaskPluginManager taskPluginManager;
|
protected TaskPluginManager taskPluginManager;
|
||||||
|
|
@ -140,6 +142,7 @@ public abstract class BaseTaskProcessor implements ITaskProcessor {
|
||||||
taskPluginManager = SpringApplicationContext.getBean(TaskPluginManager.class);
|
taskPluginManager = SpringApplicationContext.getBean(TaskPluginManager.class);
|
||||||
curingParamsService = SpringApplicationContext.getBean(CuringParamsService.class);
|
curingParamsService = SpringApplicationContext.getBean(CuringParamsService.class);
|
||||||
taskInstanceDao = SpringApplicationContext.getBean(TaskInstanceDao.class);
|
taskInstanceDao = SpringApplicationContext.getBean(TaskInstanceDao.class);
|
||||||
|
storageOperate = SpringApplicationContext.getBean(StorageOperate.class, null);
|
||||||
this.taskInstance = taskInstance;
|
this.taskInstance = taskInstance;
|
||||||
this.processInstance = processInstance;
|
this.processInstance = processInstance;
|
||||||
this.maxRetryTimes = masterConfig.getTaskCommitRetryTimes();
|
this.maxRetryTimes = masterConfig.getTaskCommitRetryTimes();
|
||||||
|
|
@ -395,7 +398,7 @@ public abstract class BaseTaskProcessor implements ITaskProcessor {
|
||||||
udfFuncList.forEach(udfFunc -> {
|
udfFuncList.forEach(udfFunc -> {
|
||||||
UdfFuncParameters udfFuncParameters =
|
UdfFuncParameters udfFuncParameters =
|
||||||
JSONUtils.parseObject(JSONUtils.toJsonString(udfFunc), UdfFuncParameters.class);
|
JSONUtils.parseObject(JSONUtils.toJsonString(udfFunc), UdfFuncParameters.class);
|
||||||
udfFuncParameters.setDefaultFS(HadoopUtils.getInstance().getDefaultFS());
|
udfFuncParameters.setDefaultFS(PropertyUtils.getString(Constants.FS_DEFAULT_FS));
|
||||||
String tenantCode = processService.queryTenantCodeByResName(udfFunc.getResourceName(), ResourceType.UDF);
|
String tenantCode = processService.queryTenantCodeByResName(udfFunc.getResourceName(), ResourceType.UDF);
|
||||||
udfFuncParameters.setTenantCode(tenantCode);
|
udfFuncParameters.setTenantCode(tenantCode);
|
||||||
map.put(udfFunc.getId(), udfFuncParameters);
|
map.put(udfFunc.getId(), udfFuncParameters);
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ import org.apache.dolphinscheduler.dao.repository.ProcessDefinitionDao;
|
||||||
import org.apache.dolphinscheduler.dao.repository.TaskInstanceDao;
|
import org.apache.dolphinscheduler.dao.repository.TaskInstanceDao;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
|
import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
|
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
|
||||||
|
import org.apache.dolphinscheduler.registry.api.RegistryClient;
|
||||||
import org.apache.dolphinscheduler.remote.command.TaskKillRequestCommand;
|
import org.apache.dolphinscheduler.remote.command.TaskKillRequestCommand;
|
||||||
import org.apache.dolphinscheduler.remote.utils.Host;
|
import org.apache.dolphinscheduler.remote.utils.Host;
|
||||||
import org.apache.dolphinscheduler.server.master.builder.TaskExecutionContextBuilder;
|
import org.apache.dolphinscheduler.server.master.builder.TaskExecutionContextBuilder;
|
||||||
|
|
@ -39,7 +40,6 @@ import org.apache.dolphinscheduler.server.master.metrics.TaskMetrics;
|
||||||
import org.apache.dolphinscheduler.server.master.runner.task.TaskProcessorFactory;
|
import org.apache.dolphinscheduler.server.master.runner.task.TaskProcessorFactory;
|
||||||
import org.apache.dolphinscheduler.service.log.LogClient;
|
import org.apache.dolphinscheduler.service.log.LogClient;
|
||||||
import org.apache.dolphinscheduler.service.process.ProcessService;
|
import org.apache.dolphinscheduler.service.process.ProcessService;
|
||||||
import org.apache.dolphinscheduler.service.registry.RegistryClient;
|
|
||||||
import org.apache.dolphinscheduler.service.utils.LoggerUtils;
|
import org.apache.dolphinscheduler.service.utils.LoggerUtils;
|
||||||
import org.apache.dolphinscheduler.service.utils.ProcessUtils;
|
import org.apache.dolphinscheduler.service.utils.ProcessUtils;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ import org.apache.dolphinscheduler.dao.entity.TaskInstance;
|
||||||
import org.apache.dolphinscheduler.dao.repository.TaskInstanceDao;
|
import org.apache.dolphinscheduler.dao.repository.TaskInstanceDao;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
|
import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
|
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
|
||||||
|
import org.apache.dolphinscheduler.registry.api.RegistryClient;
|
||||||
import org.apache.dolphinscheduler.server.master.builder.TaskExecutionContextBuilder;
|
import org.apache.dolphinscheduler.server.master.builder.TaskExecutionContextBuilder;
|
||||||
import org.apache.dolphinscheduler.server.master.cache.ProcessInstanceExecCacheManager;
|
import org.apache.dolphinscheduler.server.master.cache.ProcessInstanceExecCacheManager;
|
||||||
import org.apache.dolphinscheduler.server.master.config.MasterConfig;
|
import org.apache.dolphinscheduler.server.master.config.MasterConfig;
|
||||||
|
|
@ -37,7 +38,6 @@ import org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteThreadPoo
|
||||||
import org.apache.dolphinscheduler.server.master.runner.task.TaskProcessorFactory;
|
import org.apache.dolphinscheduler.server.master.runner.task.TaskProcessorFactory;
|
||||||
import org.apache.dolphinscheduler.service.log.LogClient;
|
import org.apache.dolphinscheduler.service.log.LogClient;
|
||||||
import org.apache.dolphinscheduler.service.process.ProcessService;
|
import org.apache.dolphinscheduler.service.process.ProcessService;
|
||||||
import org.apache.dolphinscheduler.service.registry.RegistryClient;
|
|
||||||
import org.apache.dolphinscheduler.service.utils.LoggerUtils;
|
import org.apache.dolphinscheduler.service.utils.LoggerUtils;
|
||||||
import org.apache.dolphinscheduler.service.utils.ProcessUtils;
|
import org.apache.dolphinscheduler.service.utils.ProcessUtils;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@ import org.apache.dolphinscheduler.common.model.BaseHeartBeatTask;
|
||||||
import org.apache.dolphinscheduler.common.model.MasterHeartBeat;
|
import org.apache.dolphinscheduler.common.model.MasterHeartBeat;
|
||||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||||
import org.apache.dolphinscheduler.common.utils.OSUtils;
|
import org.apache.dolphinscheduler.common.utils.OSUtils;
|
||||||
|
import org.apache.dolphinscheduler.registry.api.RegistryClient;
|
||||||
import org.apache.dolphinscheduler.server.master.config.MasterConfig;
|
import org.apache.dolphinscheduler.server.master.config.MasterConfig;
|
||||||
import org.apache.dolphinscheduler.service.registry.RegistryClient;
|
|
||||||
|
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,8 @@
|
||||||
<conversionRule conversionWord="message"
|
<conversionRule conversionWord="message"
|
||||||
converterClass="org.apache.dolphinscheduler.common.log.SensitiveDataConverter"/>
|
converterClass="org.apache.dolphinscheduler.common.log.SensitiveDataConverter"/>
|
||||||
<appender name="TASKLOGFILE" class="ch.qos.logback.classic.sift.SiftingAppender">
|
<appender name="TASKLOGFILE" class="ch.qos.logback.classic.sift.SiftingAppender">
|
||||||
<filter class="org.apache.dolphinscheduler.service.log.TaskLogFilter"/>
|
<filter class="org.apache.dolphinscheduler.plugin.task.api.log.TaskLogFilter"/>
|
||||||
<Discriminator class="org.apache.dolphinscheduler.service.log.TaskLogDiscriminator">
|
<Discriminator class="org.apache.dolphinscheduler.plugin.task.api.log.TaskLogDiscriminator">
|
||||||
<key>taskAppId</key>
|
<key>taskAppId</key>
|
||||||
<logBase>${log.base}</logBase>
|
<logBase>${log.base}</logBase>
|
||||||
</Discriminator>
|
</Discriminator>
|
||||||
|
|
|
||||||
|
|
@ -24,10 +24,10 @@ import org.apache.dolphinscheduler.common.enums.NodeType;
|
||||||
import org.apache.dolphinscheduler.common.model.Server;
|
import org.apache.dolphinscheduler.common.model.Server;
|
||||||
import org.apache.dolphinscheduler.dao.entity.ProcessInstance;
|
import org.apache.dolphinscheduler.dao.entity.ProcessInstance;
|
||||||
import org.apache.dolphinscheduler.dao.entity.TaskInstance;
|
import org.apache.dolphinscheduler.dao.entity.TaskInstance;
|
||||||
|
import org.apache.dolphinscheduler.registry.api.RegistryClient;
|
||||||
import org.apache.dolphinscheduler.server.master.config.MasterConfig;
|
import org.apache.dolphinscheduler.server.master.config.MasterConfig;
|
||||||
import org.apache.dolphinscheduler.server.master.task.MasterHeartBeatTask;
|
import org.apache.dolphinscheduler.server.master.task.MasterHeartBeatTask;
|
||||||
import org.apache.dolphinscheduler.service.process.ProcessService;
|
import org.apache.dolphinscheduler.service.process.ProcessService;
|
||||||
import org.apache.dolphinscheduler.service.registry.RegistryClient;
|
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ import org.apache.dolphinscheduler.dao.entity.TaskInstance;
|
||||||
import org.apache.dolphinscheduler.dao.repository.ProcessDefinitionDao;
|
import org.apache.dolphinscheduler.dao.repository.ProcessDefinitionDao;
|
||||||
import org.apache.dolphinscheduler.dao.repository.TaskInstanceDao;
|
import org.apache.dolphinscheduler.dao.repository.TaskInstanceDao;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
|
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
|
||||||
|
import org.apache.dolphinscheduler.registry.api.RegistryClient;
|
||||||
import org.apache.dolphinscheduler.server.master.cache.ProcessInstanceExecCacheManager;
|
import org.apache.dolphinscheduler.server.master.cache.ProcessInstanceExecCacheManager;
|
||||||
import org.apache.dolphinscheduler.server.master.config.MasterConfig;
|
import org.apache.dolphinscheduler.server.master.config.MasterConfig;
|
||||||
import org.apache.dolphinscheduler.server.master.dispatch.executor.NettyExecutorManager;
|
import org.apache.dolphinscheduler.server.master.dispatch.executor.NettyExecutorManager;
|
||||||
|
|
@ -41,7 +42,6 @@ import org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteThreadPoo
|
||||||
import org.apache.dolphinscheduler.service.bean.SpringApplicationContext;
|
import org.apache.dolphinscheduler.service.bean.SpringApplicationContext;
|
||||||
import org.apache.dolphinscheduler.service.log.LogClient;
|
import org.apache.dolphinscheduler.service.log.LogClient;
|
||||||
import org.apache.dolphinscheduler.service.process.ProcessService;
|
import org.apache.dolphinscheduler.service.process.ProcessService;
|
||||||
import org.apache.dolphinscheduler.service.registry.RegistryClient;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
|
||||||
|
|
@ -27,4 +27,11 @@
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>dolphinscheduler-registry-api</artifactId>
|
<artifactId>dolphinscheduler-registry-api</artifactId>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.dolphinscheduler</groupId>
|
||||||
|
<artifactId>dolphinscheduler-common</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
||||||
|
|
@ -15,13 +15,9 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.service.registry;
|
package org.apache.dolphinscheduler.registry.api;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static org.apache.dolphinscheduler.common.constants.Constants.COLON;
|
|
||||||
import static org.apache.dolphinscheduler.common.constants.Constants.REGISTRY_DOLPHINSCHEDULER_MASTERS;
|
|
||||||
import static org.apache.dolphinscheduler.common.constants.Constants.REGISTRY_DOLPHINSCHEDULER_WORKERS;
|
|
||||||
import static org.apache.dolphinscheduler.common.constants.Constants.SINGLE_SLASH;
|
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.common.IStoppable;
|
import org.apache.dolphinscheduler.common.IStoppable;
|
||||||
import org.apache.dolphinscheduler.common.constants.Constants;
|
import org.apache.dolphinscheduler.common.constants.Constants;
|
||||||
|
|
@ -30,10 +26,6 @@ import org.apache.dolphinscheduler.common.model.MasterHeartBeat;
|
||||||
import org.apache.dolphinscheduler.common.model.Server;
|
import org.apache.dolphinscheduler.common.model.Server;
|
||||||
import org.apache.dolphinscheduler.common.model.WorkerHeartBeat;
|
import org.apache.dolphinscheduler.common.model.WorkerHeartBeat;
|
||||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||||
import org.apache.dolphinscheduler.registry.api.ConnectionListener;
|
|
||||||
import org.apache.dolphinscheduler.registry.api.Registry;
|
|
||||||
import org.apache.dolphinscheduler.registry.api.RegistryException;
|
|
||||||
import org.apache.dolphinscheduler.registry.api.SubscribeListener;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
|
@ -126,7 +118,7 @@ public class RegistryClient {
|
||||||
// todo: add host, port in heartBeat Info, so that we don't need to parse this again
|
// todo: add host, port in heartBeat Info, so that we don't need to parse this again
|
||||||
server.setZkDirectory(parentPath + "/" + serverPath);
|
server.setZkDirectory(parentPath + "/" + serverPath);
|
||||||
// set host and port
|
// set host and port
|
||||||
String[] hostAndPort = serverPath.split(COLON);
|
String[] hostAndPort = serverPath.split(Constants.COLON);
|
||||||
// fetch the last one
|
// fetch the last one
|
||||||
server.setHost(hostAndPort[0]);
|
server.setHost(hostAndPort[0]);
|
||||||
server.setPort(Integer.parseInt(hostAndPort[1]));
|
server.setPort(Integer.parseInt(hostAndPort[1]));
|
||||||
|
|
@ -144,7 +136,7 @@ public class RegistryClient {
|
||||||
String path = rootNodePath(nodeType);
|
String path = rootNodePath(nodeType);
|
||||||
Collection<String> serverList = getServerNodes(nodeType);
|
Collection<String> serverList = getServerNodes(nodeType);
|
||||||
for (String server : serverList) {
|
for (String server : serverList) {
|
||||||
serverMap.putIfAbsent(server, get(path + SINGLE_SLASH + server));
|
serverMap.putIfAbsent(server, get(path + Constants.SINGLE_SLASH + server));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("get server list failed", e);
|
logger.error("get server list failed", e);
|
||||||
|
|
@ -160,7 +152,7 @@ public class RegistryClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<String> getMasterNodesDirectly() {
|
public Collection<String> getMasterNodesDirectly() {
|
||||||
return getChildrenKeys(REGISTRY_DOLPHINSCHEDULER_MASTERS);
|
return getChildrenKeys(Constants.REGISTRY_DOLPHINSCHEDULER_MASTERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -172,7 +164,7 @@ public class RegistryClient {
|
||||||
public String getHostByEventDataPath(String path) {
|
public String getHostByEventDataPath(String path) {
|
||||||
checkArgument(!Strings.isNullOrEmpty(path), "path cannot be null or empty");
|
checkArgument(!Strings.isNullOrEmpty(path), "path cannot be null or empty");
|
||||||
|
|
||||||
final String[] pathArray = path.split(SINGLE_SLASH);
|
final String[] pathArray = path.split(Constants.SINGLE_SLASH);
|
||||||
|
|
||||||
checkArgument(pathArray.length >= 1, "cannot parse path: %s", path);
|
checkArgument(pathArray.length >= 1, "cannot parse path: %s", path);
|
||||||
|
|
||||||
|
|
@ -224,11 +216,11 @@ public class RegistryClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isMasterPath(String path) {
|
public boolean isMasterPath(String path) {
|
||||||
return path != null && path.startsWith(REGISTRY_DOLPHINSCHEDULER_MASTERS);
|
return path != null && path.startsWith(Constants.REGISTRY_DOLPHINSCHEDULER_MASTERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isWorkerPath(String path) {
|
public boolean isWorkerPath(String path) {
|
||||||
return path != null && path.startsWith(REGISTRY_DOLPHINSCHEDULER_WORKERS);
|
return path != null && path.startsWith(Constants.REGISTRY_DOLPHINSCHEDULER_WORKERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<String> getChildrenKeys(final String key) {
|
public Collection<String> getChildrenKeys(final String key) {
|
||||||
|
|
@ -244,8 +236,8 @@ public class RegistryClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initNodes() {
|
private void initNodes() {
|
||||||
registry.put(REGISTRY_DOLPHINSCHEDULER_MASTERS, EMPTY, false);
|
registry.put(Constants.REGISTRY_DOLPHINSCHEDULER_MASTERS, EMPTY, false);
|
||||||
registry.put(REGISTRY_DOLPHINSCHEDULER_WORKERS, EMPTY, false);
|
registry.put(Constants.REGISTRY_DOLPHINSCHEDULER_WORKERS, EMPTY, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String rootNodePath(NodeType type) {
|
private String rootNodePath(NodeType type) {
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.service.log;
|
package org.apache.dolphinscheduler.remote.processor;
|
||||||
|
|
||||||
import static org.apache.dolphinscheduler.common.constants.Constants.APPID_COLLECT;
|
import static org.apache.dolphinscheduler.common.constants.Constants.APPID_COLLECT;
|
||||||
import static org.apache.dolphinscheduler.common.constants.Constants.DEFAULT_COLLECT_WAY;
|
import static org.apache.dolphinscheduler.common.constants.Constants.DEFAULT_COLLECT_WAY;
|
||||||
|
|
@ -35,10 +35,6 @@ import org.apache.dolphinscheduler.remote.command.log.RollViewLogRequestCommand;
|
||||||
import org.apache.dolphinscheduler.remote.command.log.RollViewLogResponseCommand;
|
import org.apache.dolphinscheduler.remote.command.log.RollViewLogResponseCommand;
|
||||||
import org.apache.dolphinscheduler.remote.command.log.ViewLogRequestCommand;
|
import org.apache.dolphinscheduler.remote.command.log.ViewLogRequestCommand;
|
||||||
import org.apache.dolphinscheduler.remote.command.log.ViewLogResponseCommand;
|
import org.apache.dolphinscheduler.remote.command.log.ViewLogResponseCommand;
|
||||||
import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
|
|
||||||
import org.apache.dolphinscheduler.remote.utils.Constants;
|
|
||||||
import org.apache.dolphinscheduler.remote.utils.NamedThreadFactory;
|
|
||||||
import org.apache.dolphinscheduler.service.utils.LoggerUtils;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
|
@ -52,8 +48,6 @@ import java.nio.file.Files;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
|
@ -71,13 +65,6 @@ public class LoggerRequestProcessor implements NettyRequestProcessor {
|
||||||
|
|
||||||
private final Logger logger = LoggerFactory.getLogger(LoggerRequestProcessor.class);
|
private final Logger logger = LoggerFactory.getLogger(LoggerRequestProcessor.class);
|
||||||
|
|
||||||
private final ExecutorService executor;
|
|
||||||
|
|
||||||
public LoggerRequestProcessor() {
|
|
||||||
this.executor = Executors.newFixedThreadPool(Constants.CPUS * 2 + 1,
|
|
||||||
new NamedThreadFactory("Log-Request-Process-Thread"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process(Channel channel, Command command) {
|
public void process(Channel channel, Command command) {
|
||||||
logger.info("received command : {}", command);
|
logger.info("received command : {}", command);
|
||||||
|
|
@ -103,7 +90,7 @@ public class LoggerRequestProcessor implements NettyRequestProcessor {
|
||||||
if (!checkPathSecurity(viewLogPath)) {
|
if (!checkPathSecurity(viewLogPath)) {
|
||||||
throw new IllegalArgumentException("Illegal path: " + viewLogPath);
|
throw new IllegalArgumentException("Illegal path: " + viewLogPath);
|
||||||
}
|
}
|
||||||
String msg = LoggerUtils.readWholeFileContent(viewLogPath);
|
String msg = LogUtils.readWholeFileContent(viewLogPath);
|
||||||
ViewLogResponseCommand viewLogResponse = new ViewLogResponseCommand(msg);
|
ViewLogResponseCommand viewLogResponse = new ViewLogResponseCommand(msg);
|
||||||
channel.writeAndFlush(viewLogResponse.convert2Command(command.getOpaque()));
|
channel.writeAndFlush(viewLogResponse.convert2Command(command.getOpaque()));
|
||||||
break;
|
break;
|
||||||
|
|
@ -199,10 +186,6 @@ public class LoggerRequestProcessor implements NettyRequestProcessor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExecutorService getExecutor() {
|
|
||||||
return this.executor;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get files content bytes for download file
|
* get files content bytes for download file
|
||||||
*
|
*
|
||||||
|
|
@ -74,207 +74,9 @@
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.hadoop</groupId>
|
|
||||||
<artifactId>hadoop-common</artifactId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.slf4j</groupId>
|
|
||||||
<artifactId>slf4j-log4j12</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>jdk.tools</groupId>
|
|
||||||
<artifactId>jdk.tools</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>javax.servlet</groupId>
|
|
||||||
<artifactId>servlet-api</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>javax.servlet</groupId>
|
|
||||||
<artifactId>servlet-api</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>log4j</groupId>
|
|
||||||
<artifactId>log4j</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.apache.curator</groupId>
|
|
||||||
<artifactId>curator-client</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
|
|
||||||
<exclusion>
|
|
||||||
<groupId>commons-configuration</groupId>
|
|
||||||
<artifactId>commons-configuration</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>io.grpc</groupId>
|
|
||||||
<artifactId>grpc-protobuf</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>io.netty</groupId>
|
|
||||||
<artifactId>netty</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.codehaus.jackson</groupId>
|
|
||||||
<artifactId>jackson-core-asl</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.codehaus.jackson</groupId>
|
|
||||||
<artifactId>jackson-mapper-asl</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>com.google.protobuf</groupId>
|
|
||||||
<artifactId>jackson-mapper-asl</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>com.google.code.gson</groupId>
|
|
||||||
<artifactId>gson</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>xmlenc</groupId>
|
|
||||||
<artifactId>xmlenc</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>commons-net</groupId>
|
|
||||||
<artifactId>commons-net</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.apache.avro</groupId>
|
|
||||||
<artifactId>avro</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.apache.zookeeper</groupId>
|
|
||||||
<artifactId>zookeeper</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>javax.servlet.jsp</groupId>
|
|
||||||
<artifactId>jsp-api</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>com.sun.jersey</groupId>
|
|
||||||
<artifactId>jersey-json</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>com.sun.jersey</groupId>
|
|
||||||
<artifactId>jersey-server</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>com.sun.jersey</groupId>
|
|
||||||
<artifactId>jersey-core</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.mortbay.jetty</groupId>
|
|
||||||
<artifactId>jetty</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.hbase.thirdparty</groupId>
|
<groupId>org.apache.hbase.thirdparty</groupId>
|
||||||
<artifactId>hbase-noop-htrace</artifactId>
|
<artifactId>hbase-noop-htrace</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.hadoop</groupId>
|
|
||||||
<artifactId>hadoop-client</artifactId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.slf4j</groupId>
|
|
||||||
<artifactId>slf4j-log4j12</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>javax.servlet</groupId>
|
|
||||||
<artifactId>servlet-api</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.codehaus.jackson</groupId>
|
|
||||||
<artifactId>jackson-jaxrs</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.codehaus.jackson</groupId>
|
|
||||||
<artifactId>jackson-xc</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.fusesource.leveldbjni</groupId>
|
|
||||||
<artifactId>leveldbjni-all</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.apache.zookeeper</groupId>
|
|
||||||
<artifactId>zookeeper</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.apache.hadoop</groupId>
|
|
||||||
<artifactId>hadoop-mapreduce-client-shuffle</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>com.sun.jersey</groupId>
|
|
||||||
<artifactId>jersey-client</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>com.sun.jersey</groupId>
|
|
||||||
<artifactId>jersey-core</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>javax.xml.bind</groupId>
|
|
||||||
<artifactId>jaxb-api</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>log4j</groupId>
|
|
||||||
<artifactId>log4j</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.hadoop</groupId>
|
|
||||||
<artifactId>hadoop-hdfs</artifactId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>javax.servlet</groupId>
|
|
||||||
<artifactId>servlet-api</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>io.netty</groupId>
|
|
||||||
<artifactId>netty</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>com.google.protobuf</groupId>
|
|
||||||
<artifactId>protobuf-java</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>xmlenc</groupId>
|
|
||||||
<artifactId>xmlenc</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>io.netty</groupId>
|
|
||||||
<artifactId>netty-all</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>org.fusesource.leveldbjni</groupId>
|
|
||||||
<artifactId>leveldbjni-all</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>com.sun.jersey</groupId>
|
|
||||||
<artifactId>jersey-core</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>com.sun.jersey</groupId>
|
|
||||||
<artifactId>jersey-server</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>log4j</groupId>
|
|
||||||
<artifactId>log4j</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.amazonaws</groupId>
|
|
||||||
<artifactId>aws-java-sdk-s3</artifactId>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
package org.apache.dolphinscheduler.service.bean;
|
package org.apache.dolphinscheduler.service.bean;
|
||||||
|
|
||||||
import org.springframework.beans.BeansException;
|
import org.springframework.beans.BeansException;
|
||||||
|
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.ApplicationContextAware;
|
import org.springframework.context.ApplicationContextAware;
|
||||||
import org.springframework.context.support.AbstractApplicationContext;
|
import org.springframework.context.support.AbstractApplicationContext;
|
||||||
|
|
@ -44,4 +45,12 @@ public class SpringApplicationContext implements ApplicationContextAware, AutoCl
|
||||||
public static <T> T getBean(Class<T> requiredType) {
|
public static <T> T getBean(Class<T> requiredType) {
|
||||||
return applicationContext.getBean(requiredType);
|
return applicationContext.getBean(requiredType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T> T getBean(Class<T> requiredType, T defaultValue) {
|
||||||
|
try {
|
||||||
|
return applicationContext.getBean(requiredType);
|
||||||
|
} catch (NoSuchBeanDefinitionException e) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,13 +19,13 @@ package org.apache.dolphinscheduler.service.cache.impl;
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.common.enums.NodeType;
|
import org.apache.dolphinscheduler.common.enums.NodeType;
|
||||||
import org.apache.dolphinscheduler.common.model.Server;
|
import org.apache.dolphinscheduler.common.model.Server;
|
||||||
|
import org.apache.dolphinscheduler.registry.api.RegistryClient;
|
||||||
import org.apache.dolphinscheduler.remote.NettyRemotingClient;
|
import org.apache.dolphinscheduler.remote.NettyRemotingClient;
|
||||||
import org.apache.dolphinscheduler.remote.command.Command;
|
import org.apache.dolphinscheduler.remote.command.Command;
|
||||||
import org.apache.dolphinscheduler.remote.config.NettyClientConfig;
|
import org.apache.dolphinscheduler.remote.config.NettyClientConfig;
|
||||||
import org.apache.dolphinscheduler.remote.processor.NettyRemoteChannel;
|
import org.apache.dolphinscheduler.remote.processor.NettyRemoteChannel;
|
||||||
import org.apache.dolphinscheduler.remote.utils.Host;
|
import org.apache.dolphinscheduler.remote.utils.Host;
|
||||||
import org.apache.dolphinscheduler.service.cache.CacheNotifyService;
|
import org.apache.dolphinscheduler.service.cache.CacheNotifyService;
|
||||||
import org.apache.dolphinscheduler.service.registry.RegistryClient;
|
|
||||||
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -116,6 +116,7 @@ import org.apache.dolphinscheduler.dao.repository.TaskDefinitionDao;
|
||||||
import org.apache.dolphinscheduler.dao.repository.TaskDefinitionLogDao;
|
import org.apache.dolphinscheduler.dao.repository.TaskDefinitionLogDao;
|
||||||
import org.apache.dolphinscheduler.dao.repository.TaskInstanceDao;
|
import org.apache.dolphinscheduler.dao.repository.TaskInstanceDao;
|
||||||
import org.apache.dolphinscheduler.dao.utils.DqRuleUtils;
|
import org.apache.dolphinscheduler.dao.utils.DqRuleUtils;
|
||||||
|
import org.apache.dolphinscheduler.plugin.task.api.TaskPluginManager;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.enums.Direct;
|
import org.apache.dolphinscheduler.plugin.task.api.enums.Direct;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
|
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.enums.dp.DqTaskState;
|
import org.apache.dolphinscheduler.plugin.task.api.enums.dp.DqTaskState;
|
||||||
|
|
@ -137,7 +138,6 @@ import org.apache.dolphinscheduler.service.exceptions.ServiceException;
|
||||||
import org.apache.dolphinscheduler.service.expand.CuringParamsService;
|
import org.apache.dolphinscheduler.service.expand.CuringParamsService;
|
||||||
import org.apache.dolphinscheduler.service.log.LogClient;
|
import org.apache.dolphinscheduler.service.log.LogClient;
|
||||||
import org.apache.dolphinscheduler.service.model.TaskNode;
|
import org.apache.dolphinscheduler.service.model.TaskNode;
|
||||||
import org.apache.dolphinscheduler.service.task.TaskPluginManager;
|
|
||||||
import org.apache.dolphinscheduler.service.utils.ClusterConfUtils;
|
import org.apache.dolphinscheduler.service.utils.ClusterConfUtils;
|
||||||
import org.apache.dolphinscheduler.service.utils.DagHelper;
|
import org.apache.dolphinscheduler.service.utils.DagHelper;
|
||||||
import org.apache.dolphinscheduler.spi.enums.ResourceType;
|
import org.apache.dolphinscheduler.spi.enums.ResourceType;
|
||||||
|
|
|
||||||
|
|
@ -1,60 +0,0 @@
|
||||||
/*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership.
|
|
||||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
||||||
* (the "License"); you may not use this file except in compliance with
|
|
||||||
* the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.service.storage;
|
|
||||||
|
|
||||||
import static org.apache.dolphinscheduler.common.constants.Constants.RESOURCE_STORAGE_TYPE;
|
|
||||||
import static org.apache.dolphinscheduler.common.constants.Constants.STORAGE_HDFS;
|
|
||||||
import static org.apache.dolphinscheduler.common.constants.Constants.STORAGE_OSS;
|
|
||||||
import static org.apache.dolphinscheduler.common.constants.Constants.STORAGE_S3;
|
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.common.utils.PropertyUtils;
|
|
||||||
import org.apache.dolphinscheduler.service.storage.impl.HadoopUtils;
|
|
||||||
import org.apache.dolphinscheduler.service.storage.impl.OssOperator;
|
|
||||||
import org.apache.dolphinscheduler.service.storage.impl.S3Utils;
|
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* choose the impl of storage by RESOURCE_STORAGE_TYPE
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Component
|
|
||||||
@Configuration
|
|
||||||
public class StoreConfiguration {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public StorageOperate storageOperate() {
|
|
||||||
switch (PropertyUtils.getUpperCaseString(RESOURCE_STORAGE_TYPE)) {
|
|
||||||
case STORAGE_OSS:
|
|
||||||
OssOperator ossOperator = new OssOperator();
|
|
||||||
// TODO: change to use ossOperator.init(ossConnection) after DS supports Configuration / Connection
|
|
||||||
// Center
|
|
||||||
ossOperator.init();
|
|
||||||
return ossOperator;
|
|
||||||
case STORAGE_S3:
|
|
||||||
return S3Utils.getInstance();
|
|
||||||
case STORAGE_HDFS:
|
|
||||||
return HadoopUtils.getInstance();
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -19,15 +19,11 @@ package org.apache.dolphinscheduler.service.utils;
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.common.constants.Constants;
|
import org.apache.dolphinscheduler.common.constants.Constants;
|
||||||
import org.apache.dolphinscheduler.common.constants.DataSourceConstants;
|
import org.apache.dolphinscheduler.common.constants.DataSourceConstants;
|
||||||
import org.apache.dolphinscheduler.common.enums.ResUploadType;
|
|
||||||
import org.apache.dolphinscheduler.common.utils.PropertyUtils;
|
import org.apache.dolphinscheduler.common.utils.PropertyUtils;
|
||||||
|
|
||||||
import org.apache.commons.codec.binary.Base64;
|
import org.apache.commons.codec.binary.Base64;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.hadoop.conf.Configuration;
|
|
||||||
import org.apache.hadoop.security.UserGroupInformation;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
|
@ -66,79 +62,6 @@ public class CommonUtils {
|
||||||
return envPath;
|
return envPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return is develop mode
|
|
||||||
*/
|
|
||||||
public static boolean isDevelopMode() {
|
|
||||||
return PropertyUtils.getBoolean(Constants.DEVELOPMENT_STATE, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* if upload resource is HDFS and kerberos startup is true , else false
|
|
||||||
*
|
|
||||||
* @return true if upload resource is HDFS and kerberos startup
|
|
||||||
*/
|
|
||||||
public static boolean getKerberosStartupState() {
|
|
||||||
String resUploadStartupType = PropertyUtils.getUpperCaseString(Constants.RESOURCE_STORAGE_TYPE);
|
|
||||||
ResUploadType resUploadType = ResUploadType.valueOf(resUploadStartupType);
|
|
||||||
Boolean kerberosStartupState =
|
|
||||||
PropertyUtils.getBoolean(Constants.HADOOP_SECURITY_AUTHENTICATION_STARTUP_STATE, false);
|
|
||||||
return resUploadType == ResUploadType.HDFS && kerberosStartupState;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* load kerberos configuration
|
|
||||||
*
|
|
||||||
* @param configuration
|
|
||||||
* @return load kerberos config return true
|
|
||||||
* @throws IOException errors
|
|
||||||
*/
|
|
||||||
public static boolean loadKerberosConf(Configuration configuration) throws IOException {
|
|
||||||
return loadKerberosConf(PropertyUtils.getString(Constants.JAVA_SECURITY_KRB5_CONF_PATH),
|
|
||||||
PropertyUtils.getString(Constants.LOGIN_USER_KEY_TAB_USERNAME),
|
|
||||||
PropertyUtils.getString(Constants.LOGIN_USER_KEY_TAB_PATH), configuration);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* load kerberos configuration
|
|
||||||
*
|
|
||||||
* @param javaSecurityKrb5Conf javaSecurityKrb5Conf
|
|
||||||
* @param loginUserKeytabUsername loginUserKeytabUsername
|
|
||||||
* @param loginUserKeytabPath loginUserKeytabPath
|
|
||||||
* @throws IOException errors
|
|
||||||
*/
|
|
||||||
public static void loadKerberosConf(String javaSecurityKrb5Conf, String loginUserKeytabUsername,
|
|
||||||
String loginUserKeytabPath) throws IOException {
|
|
||||||
loadKerberosConf(javaSecurityKrb5Conf, loginUserKeytabUsername, loginUserKeytabPath, new Configuration());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* load kerberos configuration
|
|
||||||
*
|
|
||||||
* @param javaSecurityKrb5Conf javaSecurityKrb5Conf
|
|
||||||
* @param loginUserKeytabUsername loginUserKeytabUsername
|
|
||||||
* @param loginUserKeytabPath loginUserKeytabPath
|
|
||||||
* @param configuration configuration
|
|
||||||
* @return load kerberos config return true
|
|
||||||
* @throws IOException errors
|
|
||||||
*/
|
|
||||||
public static boolean loadKerberosConf(String javaSecurityKrb5Conf, String loginUserKeytabUsername,
|
|
||||||
String loginUserKeytabPath, Configuration configuration) throws IOException {
|
|
||||||
if (CommonUtils.getKerberosStartupState()) {
|
|
||||||
System.setProperty(Constants.JAVA_SECURITY_KRB5_CONF, StringUtils.defaultIfBlank(javaSecurityKrb5Conf,
|
|
||||||
PropertyUtils.getString(Constants.JAVA_SECURITY_KRB5_CONF_PATH)));
|
|
||||||
configuration.set(Constants.HADOOP_SECURITY_AUTHENTICATION, Constants.KERBEROS);
|
|
||||||
UserGroupInformation.setConfiguration(configuration);
|
|
||||||
UserGroupInformation.loginUserFromKeytab(
|
|
||||||
StringUtils.defaultIfBlank(loginUserKeytabUsername,
|
|
||||||
PropertyUtils.getString(Constants.LOGIN_USER_KEY_TAB_USERNAME)),
|
|
||||||
StringUtils.defaultIfBlank(loginUserKeytabPath,
|
|
||||||
PropertyUtils.getString(Constants.LOGIN_USER_KEY_TAB_PATH)));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* encode password
|
* encode password
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ import org.apache.dolphinscheduler.common.constants.Constants;
|
||||||
import org.apache.dolphinscheduler.common.constants.DateConstants;
|
import org.apache.dolphinscheduler.common.constants.DateConstants;
|
||||||
import org.apache.dolphinscheduler.common.utils.DateUtils;
|
import org.apache.dolphinscheduler.common.utils.DateUtils;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
|
import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
|
||||||
import org.apache.dolphinscheduler.service.log.TaskLogDiscriminator;
|
import org.apache.dolphinscheduler.plugin.task.api.log.TaskLogDiscriminator;
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
|
|
||||||
|
|
@ -35,18 +35,14 @@ import org.slf4j.LoggerFactory;
|
||||||
import org.slf4j.MDC;
|
import org.slf4j.MDC;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* logger utils
|
* Please use {@link org.apache.dolphinscheduler.plugin.task.api.utils.LogUtils}.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class LoggerUtils {
|
public class LoggerUtils {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(LoggerUtils.class);
|
private static final Logger logger = LoggerFactory.getLogger(LoggerUtils.class);
|
||||||
|
|
||||||
/**
|
|
||||||
* build job id
|
|
||||||
*
|
|
||||||
* @return task id format
|
|
||||||
*/
|
|
||||||
public static String buildTaskId(Date firstSubmitTime,
|
public static String buildTaskId(Date firstSubmitTime,
|
||||||
Long processDefineCode,
|
Long processDefineCode,
|
||||||
int processDefineVersion,
|
int processDefineVersion,
|
||||||
|
|
@ -79,28 +75,46 @@ public class LoggerUtils {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Please use {@link org.apache.dolphinscheduler.plugin.task.api.utils.LogUtils}
|
||||||
|
*/
|
||||||
public static void setWorkflowAndTaskInstanceIDMDC(Integer workflowInstanceId, Integer taskInstanceId) {
|
public static void setWorkflowAndTaskInstanceIDMDC(Integer workflowInstanceId, Integer taskInstanceId) {
|
||||||
setWorkflowInstanceIdMDC(workflowInstanceId);
|
setWorkflowInstanceIdMDC(workflowInstanceId);
|
||||||
setTaskInstanceIdMDC(taskInstanceId);
|
setTaskInstanceIdMDC(taskInstanceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Please use {@link org.apache.dolphinscheduler.plugin.task.api.utils.LogUtils}
|
||||||
|
*/
|
||||||
public static void setWorkflowInstanceIdMDC(Integer workflowInstanceId) {
|
public static void setWorkflowInstanceIdMDC(Integer workflowInstanceId) {
|
||||||
MDC.put(Constants.WORKFLOW_INSTANCE_ID_MDC_KEY, String.valueOf(workflowInstanceId));
|
MDC.put(Constants.WORKFLOW_INSTANCE_ID_MDC_KEY, String.valueOf(workflowInstanceId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Please use {@link org.apache.dolphinscheduler.plugin.task.api.utils.LogUtils}
|
||||||
|
*/
|
||||||
public static void setTaskInstanceIdMDC(Integer taskInstanceId) {
|
public static void setTaskInstanceIdMDC(Integer taskInstanceId) {
|
||||||
MDC.put(Constants.TASK_INSTANCE_ID_MDC_KEY, String.valueOf(taskInstanceId));
|
MDC.put(Constants.TASK_INSTANCE_ID_MDC_KEY, String.valueOf(taskInstanceId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Please use {@link org.apache.dolphinscheduler.plugin.task.api.utils.LogUtils}
|
||||||
|
*/
|
||||||
public static void removeWorkflowAndTaskInstanceIdMDC() {
|
public static void removeWorkflowAndTaskInstanceIdMDC() {
|
||||||
removeWorkflowInstanceIdMDC();
|
removeWorkflowInstanceIdMDC();
|
||||||
removeTaskInstanceIdMDC();
|
removeTaskInstanceIdMDC();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Please use {@link org.apache.dolphinscheduler.plugin.task.api.utils.LogUtils}
|
||||||
|
*/
|
||||||
public static void removeWorkflowInstanceIdMDC() {
|
public static void removeWorkflowInstanceIdMDC() {
|
||||||
MDC.remove(Constants.WORKFLOW_INSTANCE_ID_MDC_KEY);
|
MDC.remove(Constants.WORKFLOW_INSTANCE_ID_MDC_KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Please use {@link org.apache.dolphinscheduler.plugin.task.api.utils.LogUtils}
|
||||||
|
*/
|
||||||
public static void removeTaskInstanceIdMDC() {
|
public static void removeTaskInstanceIdMDC() {
|
||||||
MDC.remove(Constants.TASK_INSTANCE_ID_MDC_KEY);
|
MDC.remove(Constants.TASK_INSTANCE_ID_MDC_KEY);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,8 @@ import org.apache.dolphinscheduler.common.utils.FileUtils;
|
||||||
import org.apache.dolphinscheduler.common.utils.OSUtils;
|
import org.apache.dolphinscheduler.common.utils.OSUtils;
|
||||||
import org.apache.dolphinscheduler.common.utils.PropertyUtils;
|
import org.apache.dolphinscheduler.common.utils.PropertyUtils;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
|
import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
|
|
||||||
import org.apache.dolphinscheduler.remote.utils.Host;
|
import org.apache.dolphinscheduler.remote.utils.Host;
|
||||||
import org.apache.dolphinscheduler.service.log.LogClient;
|
import org.apache.dolphinscheduler.service.log.LogClient;
|
||||||
import org.apache.dolphinscheduler.service.storage.impl.HadoopUtils;
|
|
||||||
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
@ -64,34 +62,6 @@ public class ProcessUtils {
|
||||||
*/
|
*/
|
||||||
private static final Pattern WINDOWSATTERN = Pattern.compile("\\w+\\((\\d+)\\)");
|
private static final Pattern WINDOWSATTERN = Pattern.compile("\\w+\\((\\d+)\\)");
|
||||||
|
|
||||||
/**
|
|
||||||
* kill yarn application.
|
|
||||||
*
|
|
||||||
* @param appIds app id list
|
|
||||||
* @param logger logger
|
|
||||||
* @param tenantCode tenant code
|
|
||||||
* @param executePath execute path
|
|
||||||
*/
|
|
||||||
public static void cancelApplication(List<String> appIds, Logger logger, String tenantCode, String executePath) {
|
|
||||||
if (appIds == null || appIds.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (String appId : appIds) {
|
|
||||||
try {
|
|
||||||
TaskExecutionStatus applicationStatus = HadoopUtils.getInstance().getApplicationStatus(appId);
|
|
||||||
|
|
||||||
if (!applicationStatus.isFinished()) {
|
|
||||||
String commandFile = String.format("%s/%s.kill", executePath, appId);
|
|
||||||
String cmd = getKerberosInitCommand() + "yarn application -kill " + appId;
|
|
||||||
execYarnKillCommand(logger, tenantCode, appId, commandFile, cmd);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("Get yarn application app id [{}}] status failed", appId, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get kerberos init command
|
* get kerberos init command
|
||||||
*/
|
*/
|
||||||
|
|
@ -214,7 +184,8 @@ public class ProcessUtils {
|
||||||
taskExecutionContext.getTaskInstanceId()));
|
taskExecutionContext.getTaskInstanceId()));
|
||||||
}
|
}
|
||||||
FileUtils.createWorkDirIfAbsent(taskExecutionContext.getExecutePath());
|
FileUtils.createWorkDirIfAbsent(taskExecutionContext.getExecutePath());
|
||||||
cancelApplication(appIds, logger, taskExecutionContext.getTenantCode(),
|
org.apache.dolphinscheduler.plugin.task.api.utils.ProcessUtils.cancelApplication(appIds, logger,
|
||||||
|
taskExecutionContext.getTenantCode(),
|
||||||
taskExecutionContext.getExecutePath());
|
taskExecutionContext.getExecutePath());
|
||||||
return appIds;
|
return appIds;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,13 @@ import org.apache.dolphinscheduler.common.enums.CacheType;
|
||||||
import org.apache.dolphinscheduler.common.enums.NodeType;
|
import org.apache.dolphinscheduler.common.enums.NodeType;
|
||||||
import org.apache.dolphinscheduler.common.model.Server;
|
import org.apache.dolphinscheduler.common.model.Server;
|
||||||
import org.apache.dolphinscheduler.dao.entity.User;
|
import org.apache.dolphinscheduler.dao.entity.User;
|
||||||
|
import org.apache.dolphinscheduler.registry.api.RegistryClient;
|
||||||
import org.apache.dolphinscheduler.remote.NettyRemotingServer;
|
import org.apache.dolphinscheduler.remote.NettyRemotingServer;
|
||||||
import org.apache.dolphinscheduler.remote.command.CacheExpireCommand;
|
import org.apache.dolphinscheduler.remote.command.CacheExpireCommand;
|
||||||
import org.apache.dolphinscheduler.remote.command.Command;
|
import org.apache.dolphinscheduler.remote.command.Command;
|
||||||
import org.apache.dolphinscheduler.remote.command.CommandType;
|
import org.apache.dolphinscheduler.remote.command.CommandType;
|
||||||
import org.apache.dolphinscheduler.remote.config.NettyServerConfig;
|
import org.apache.dolphinscheduler.remote.config.NettyServerConfig;
|
||||||
import org.apache.dolphinscheduler.service.cache.impl.CacheNotifyServiceImpl;
|
import org.apache.dolphinscheduler.service.cache.impl.CacheNotifyServiceImpl;
|
||||||
import org.apache.dolphinscheduler.service.registry.RegistryClient;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||||
import org.apache.dolphinscheduler.remote.command.Command;
|
import org.apache.dolphinscheduler.remote.command.Command;
|
||||||
import org.apache.dolphinscheduler.remote.command.CommandType;
|
import org.apache.dolphinscheduler.remote.command.CommandType;
|
||||||
import org.apache.dolphinscheduler.remote.command.log.ViewLogRequestCommand;
|
import org.apache.dolphinscheduler.remote.command.log.ViewLogRequestCommand;
|
||||||
|
import org.apache.dolphinscheduler.remote.processor.LoggerRequestProcessor;
|
||||||
import org.apache.dolphinscheduler.service.utils.LoggerUtils;
|
import org.apache.dolphinscheduler.service.utils.LoggerUtils;
|
||||||
|
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
|
|
|
||||||
|
|
@ -1,56 +0,0 @@
|
||||||
/*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership.
|
|
||||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
||||||
* (the "License"); you may not use this file except in compliance with
|
|
||||||
* the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.apache.dolphinscheduler.service.log;
|
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.common.constants.Constants;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.Assertions;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import ch.qos.logback.classic.Level;
|
|
||||||
import ch.qos.logback.classic.spi.LoggingEvent;
|
|
||||||
import ch.qos.logback.core.spi.FilterReply;
|
|
||||||
|
|
||||||
public class MasterLogFilterTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void decide() {
|
|
||||||
MasterLogFilter masterLogFilter = new MasterLogFilter();
|
|
||||||
|
|
||||||
FilterReply filterReply = masterLogFilter.decide(new LoggingEvent() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getThreadName() {
|
|
||||||
return Constants.THREAD_NAME_MASTER_SERVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Level getLevel() {
|
|
||||||
return Level.INFO;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getMessage() {
|
|
||||||
return "master insert into queue success, task : shell2";
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
Assertions.assertEquals(FilterReply.ACCEPT, filterReply);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
package org.apache.dolphinscheduler.service.log;
|
package org.apache.dolphinscheduler.service.log;
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
|
import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
|
||||||
|
import org.apache.dolphinscheduler.plugin.task.api.log.TaskLogDiscriminator;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
package org.apache.dolphinscheduler.service.log;
|
package org.apache.dolphinscheduler.service.log;
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
|
import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
|
||||||
|
import org.apache.dolphinscheduler.plugin.task.api.log.TaskLogFilter;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
|
||||||
|
|
@ -1,66 +0,0 @@
|
||||||
/*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership.
|
|
||||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
||||||
* (the "License"); you may not use this file except in compliance with
|
|
||||||
* the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.apache.dolphinscheduler.service.log;
|
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.common.constants.Constants;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.Assertions;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import ch.qos.logback.classic.Level;
|
|
||||||
import ch.qos.logback.classic.spi.LoggingEvent;
|
|
||||||
import ch.qos.logback.core.spi.FilterReply;
|
|
||||||
|
|
||||||
public class WorkerLogFilterTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void decide() {
|
|
||||||
WorkerLogFilter workerLogFilter = new WorkerLogFilter();
|
|
||||||
|
|
||||||
FilterReply filterReply = workerLogFilter.decide(new LoggingEvent() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getThreadName() {
|
|
||||||
return Constants.THREAD_NAME_WORKER_SERVER;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Level getLevel() {
|
|
||||||
return Level.INFO;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getMessage() {
|
|
||||||
return "consume tasks: [2_177_2_704_-1],there still have 0 tasks need to be executed";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object[] getArgumentArray() {
|
|
||||||
return new Object[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getFormattedMessage() {
|
|
||||||
return "consume tasks: [2_177_2_704_-1],there still have 0 tasks need to be executed";
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
Assertions.assertEquals(FilterReply.ACCEPT, filterReply);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -70,6 +70,7 @@ import org.apache.dolphinscheduler.dao.repository.ProcessInstanceDao;
|
||||||
import org.apache.dolphinscheduler.dao.repository.TaskDefinitionDao;
|
import org.apache.dolphinscheduler.dao.repository.TaskDefinitionDao;
|
||||||
import org.apache.dolphinscheduler.dao.repository.TaskDefinitionLogDao;
|
import org.apache.dolphinscheduler.dao.repository.TaskDefinitionLogDao;
|
||||||
import org.apache.dolphinscheduler.dao.repository.TaskInstanceDao;
|
import org.apache.dolphinscheduler.dao.repository.TaskInstanceDao;
|
||||||
|
import org.apache.dolphinscheduler.plugin.task.api.TaskPluginManager;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.enums.dp.DqTaskState;
|
import org.apache.dolphinscheduler.plugin.task.api.enums.dp.DqTaskState;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.enums.dp.ExecuteSqlType;
|
import org.apache.dolphinscheduler.plugin.task.api.enums.dp.ExecuteSqlType;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.enums.dp.InputType;
|
import org.apache.dolphinscheduler.plugin.task.api.enums.dp.InputType;
|
||||||
|
|
@ -82,7 +83,6 @@ import org.apache.dolphinscheduler.service.exceptions.CronParseException;
|
||||||
import org.apache.dolphinscheduler.service.exceptions.ServiceException;
|
import org.apache.dolphinscheduler.service.exceptions.ServiceException;
|
||||||
import org.apache.dolphinscheduler.service.expand.CuringParamsService;
|
import org.apache.dolphinscheduler.service.expand.CuringParamsService;
|
||||||
import org.apache.dolphinscheduler.service.model.TaskNode;
|
import org.apache.dolphinscheduler.service.model.TaskNode;
|
||||||
import org.apache.dolphinscheduler.service.task.TaskPluginManager;
|
|
||||||
import org.apache.dolphinscheduler.spi.params.base.FormType;
|
import org.apache.dolphinscheduler.spi.params.base.FormType;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
package org.apache.dolphinscheduler.service.utils;
|
package org.apache.dolphinscheduler.service.utils;
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.common.utils.FileUtils;
|
import org.apache.dolphinscheduler.common.utils.FileUtils;
|
||||||
import org.apache.dolphinscheduler.service.storage.impl.HadoopUtils;
|
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
|
@ -45,18 +44,6 @@ public class CommonUtilsTest {
|
||||||
Assertions.assertEquals("/etc/profile", envPath);
|
Assertions.assertEquals("/etc/profile", envPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void isDevelopMode() {
|
|
||||||
logger.info("develop mode: {}", CommonUtils.isDevelopMode());
|
|
||||||
Assertions.assertTrue(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getHdfsDataBasePath() {
|
|
||||||
logger.info(HadoopUtils.getHdfsDataBasePath());
|
|
||||||
Assertions.assertTrue(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getDownloadFilename() {
|
public void getDownloadFilename() {
|
||||||
logger.info(FileUtils.getDownloadFilename("a.txt"));
|
logger.info(FileUtils.getDownloadFilename("a.txt"));
|
||||||
|
|
@ -69,12 +56,6 @@ public class CommonUtilsTest {
|
||||||
Assertions.assertTrue(true);
|
Assertions.assertTrue(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getHdfsDir() {
|
|
||||||
logger.info(HadoopUtils.getHdfsResDir("1234"));
|
|
||||||
Assertions.assertTrue(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void test() {
|
||||||
InetAddress ip;
|
InetAddress ip;
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ package org.apache.dolphinscheduler.service.utils;
|
||||||
import org.apache.dolphinscheduler.common.constants.DateConstants;
|
import org.apache.dolphinscheduler.common.constants.DateConstants;
|
||||||
import org.apache.dolphinscheduler.common.utils.DateUtils;
|
import org.apache.dolphinscheduler.common.utils.DateUtils;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
|
import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
|
||||||
import org.apache.dolphinscheduler.service.log.TaskLogDiscriminator;
|
import org.apache.dolphinscheduler.plugin.task.api.log.TaskLogDiscriminator;
|
||||||
|
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
|
|
||||||
|
|
@ -22,11 +22,6 @@ import static org.mockito.ArgumentMatchers.anyString;
|
||||||
import org.apache.dolphinscheduler.common.constants.Constants;
|
import org.apache.dolphinscheduler.common.constants.Constants;
|
||||||
import org.apache.dolphinscheduler.common.utils.OSUtils;
|
import org.apache.dolphinscheduler.common.utils.OSUtils;
|
||||||
import org.apache.dolphinscheduler.common.utils.PropertyUtils;
|
import org.apache.dolphinscheduler.common.utils.PropertyUtils;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
|
|
||||||
import org.apache.dolphinscheduler.service.storage.impl.HadoopUtils;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
|
@ -80,27 +75,4 @@ public class ProcessUtilsTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testCancelApplication() {
|
|
||||||
List<String> appIds = new ArrayList<>();
|
|
||||||
appIds.add("application_1585532379175_228491");
|
|
||||||
appIds.add("application_1598885606600_3677");
|
|
||||||
String tenantCode = "dev";
|
|
||||||
String executePath = "/ds-exec/1/1/1";
|
|
||||||
TaskExecutionStatus running = TaskExecutionStatus.RUNNING_EXECUTION;
|
|
||||||
|
|
||||||
try (MockedStatic<HadoopUtils> mockedStaticHadoopUtils = Mockito.mockStatic(HadoopUtils.class)) {
|
|
||||||
HadoopUtils hadoop = HadoopUtils.getInstance();
|
|
||||||
|
|
||||||
try {
|
|
||||||
Mockito.when(hadoop.getApplicationStatus("application_1585532379175_228491")).thenReturn(running);
|
|
||||||
Mockito.when(hadoop.getApplicationStatus("application_1598885606600_3677")).thenReturn(running);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
ProcessUtils.cancelApplication(appIds, logger, tenantCode, executePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
Assertions.assertNotNull(appIds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,8 +50,8 @@
|
||||||
<conversionRule conversionWord="message"
|
<conversionRule conversionWord="message"
|
||||||
converterClass="org.apache.dolphinscheduler.common.log.SensitiveDataConverter"/>
|
converterClass="org.apache.dolphinscheduler.common.log.SensitiveDataConverter"/>
|
||||||
<appender name="TASKLOGFILE" class="ch.qos.logback.classic.sift.SiftingAppender">
|
<appender name="TASKLOGFILE" class="ch.qos.logback.classic.sift.SiftingAppender">
|
||||||
<filter class="org.apache.dolphinscheduler.service.log.TaskLogFilter"/>
|
<filter class="org.apache.dolphinscheduler.plugin.task.api.log.TaskLogFilter"/>
|
||||||
<Discriminator class="org.apache.dolphinscheduler.service.log.TaskLogDiscriminator">
|
<Discriminator class="org.apache.dolphinscheduler.plugin.task.api.log.TaskLogDiscriminator">
|
||||||
<key>taskAppId</key>
|
<key>taskAppId</key>
|
||||||
<logBase>${log.base}</logBase>
|
<logBase>${log.base}</logBase>
|
||||||
</Discriminator>
|
</Discriminator>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
~ 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.
|
||||||
|
-->
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.apache.dolphinscheduler</groupId>
|
||||||
|
<artifactId>dolphinscheduler-storage-plugin</artifactId>
|
||||||
|
<version>dev-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>dolphinscheduler-storage-all</artifactId>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.dolphinscheduler</groupId>
|
||||||
|
<artifactId>dolphinscheduler-storage-api</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.dolphinscheduler</groupId>
|
||||||
|
<artifactId>dolphinscheduler-storage-s3</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.dolphinscheduler</groupId>
|
||||||
|
<artifactId>dolphinscheduler-storage-hdfs</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.dolphinscheduler</groupId>
|
||||||
|
<artifactId>dolphinscheduler-storage-oss</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
~ 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.
|
||||||
|
-->
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.apache.dolphinscheduler</groupId>
|
||||||
|
<artifactId>dolphinscheduler-storage-plugin</artifactId>
|
||||||
|
<version>dev-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>dolphinscheduler-storage-api</artifactId>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.dolphinscheduler</groupId>
|
||||||
|
<artifactId>dolphinscheduler-spi</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
/*
|
||||||
|
* 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.plugin.storage.api;
|
||||||
|
|
||||||
|
import static org.apache.dolphinscheduler.common.constants.Constants.RESOURCE_STORAGE_TYPE;
|
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.common.utils.PropertyUtils;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.ServiceLoader;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
// todo: If we move the config to yaml
|
||||||
|
@Configuration
|
||||||
|
public class StorageConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public StorageOperate storageOperate() {
|
||||||
|
Optional<StorageType> storageTypeOptional =
|
||||||
|
StorageType.getStorageType(PropertyUtils.getUpperCaseString(RESOURCE_STORAGE_TYPE));
|
||||||
|
Optional<StorageOperate> storageOperate = storageTypeOptional.map(storageType -> {
|
||||||
|
ServiceLoader<StorageOperateFactory> storageOperateFactories =
|
||||||
|
ServiceLoader.load(StorageOperateFactory.class);
|
||||||
|
for (StorageOperateFactory storageOperateFactory : storageOperateFactories) {
|
||||||
|
if (storageOperateFactory.getStorageOperate() == storageType) {
|
||||||
|
return storageOperateFactory.createStorageOperate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
return storageOperate.orElse(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.service.storage;
|
package org.apache.dolphinscheduler.plugin.storage.api;
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.spi.enums.ResourceType;
|
import org.apache.dolphinscheduler.spi.enums.ResourceType;
|
||||||
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.service.storage;
|
package org.apache.dolphinscheduler.plugin.storage.api;
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.common.constants.Constants;
|
import org.apache.dolphinscheduler.common.constants.Constants;
|
||||||
import org.apache.dolphinscheduler.common.enums.ResUploadType;
|
import org.apache.dolphinscheduler.common.enums.ResUploadType;
|
||||||
|
|
@ -177,18 +177,18 @@ public interface StorageOperate {
|
||||||
/**
|
/**
|
||||||
* return files and folders in the current directory and subdirectories
|
* return files and folders in the current directory and subdirectories
|
||||||
* */
|
* */
|
||||||
public List<StorageEntity> listFilesStatusRecursively(String path, String defaultPath, String tenantCode,
|
List<StorageEntity> listFilesStatusRecursively(String path, String defaultPath, String tenantCode,
|
||||||
ResourceType type);
|
ResourceType type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return files and folders in the current directory
|
* return files and folders in the current directory
|
||||||
* */
|
* */
|
||||||
public List<StorageEntity> listFilesStatus(String path, String defaultPath, String tenantCode,
|
List<StorageEntity> listFilesStatus(String path, String defaultPath, String tenantCode,
|
||||||
ResourceType type) throws Exception;
|
ResourceType type) throws Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return a file status
|
* return a file status
|
||||||
* */
|
* */
|
||||||
public StorageEntity getFileStatus(String path, String defaultPath, String tenantCode,
|
StorageEntity getFileStatus(String path, String defaultPath, String tenantCode,
|
||||||
ResourceType type) throws Exception;
|
ResourceType type) throws Exception;
|
||||||
}
|
}
|
||||||
|
|
@ -15,23 +15,11 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.server.worker.processor;
|
package org.apache.dolphinscheduler.plugin.storage.api;
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.service.process.ProcessService;
|
public interface StorageOperateFactory {
|
||||||
|
|
||||||
import org.mockito.Mockito;
|
StorageOperate createStorageOperate();
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* dependency config
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class TaskCallbackServiceTestConfig {
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public ProcessService processService() {
|
|
||||||
return Mockito.mock(ProcessService.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
StorageType getStorageOperate();
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,53 @@
|
||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership.
|
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
* (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.apache.dolphinscheduler.plugin.storage.api;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public enum StorageType {
|
||||||
|
|
||||||
|
HDFS(0, "HDFS"),
|
||||||
|
OSS(1, "OSS"),
|
||||||
|
S3(2, "S3"),
|
||||||
|
;
|
||||||
|
|
||||||
|
private final int code;
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
StorageType(int code, String name) {
|
||||||
|
this.code = code;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Optional<StorageType> getStorageType(String name) {
|
||||||
|
for (StorageType storageType : StorageType.values()) {
|
||||||
|
if (storageType.getName().equals(name)) {
|
||||||
|
return Optional.of(storageType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,232 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
~ 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.
|
||||||
|
-->
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.apache.dolphinscheduler</groupId>
|
||||||
|
<artifactId>dolphinscheduler-storage-plugin</artifactId>
|
||||||
|
<version>dev-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>dolphinscheduler-storage-hdfs</artifactId>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<!-- This is used to load Kerberos Conf -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.dolphinscheduler</groupId>
|
||||||
|
<artifactId>dolphinscheduler-datasource-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.dolphinscheduler</groupId>
|
||||||
|
<artifactId>dolphinscheduler-storage-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.hadoop</groupId>
|
||||||
|
<artifactId>hadoop-common</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-log4j12</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>jdk.tools</groupId>
|
||||||
|
<artifactId>jdk.tools</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>javax.servlet</groupId>
|
||||||
|
<artifactId>servlet-api</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>javax.servlet</groupId>
|
||||||
|
<artifactId>servlet-api</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>log4j</groupId>
|
||||||
|
<artifactId>log4j</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.apache.curator</groupId>
|
||||||
|
<artifactId>curator-client</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
|
||||||
|
<exclusion>
|
||||||
|
<groupId>commons-configuration</groupId>
|
||||||
|
<artifactId>commons-configuration</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>io.grpc</groupId>
|
||||||
|
<artifactId>grpc-protobuf</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>io.netty</groupId>
|
||||||
|
<artifactId>netty</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.codehaus.jackson</groupId>
|
||||||
|
<artifactId>jackson-core-asl</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.codehaus.jackson</groupId>
|
||||||
|
<artifactId>jackson-mapper-asl</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>com.google.protobuf</groupId>
|
||||||
|
<artifactId>jackson-mapper-asl</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>com.google.code.gson</groupId>
|
||||||
|
<artifactId>gson</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>xmlenc</groupId>
|
||||||
|
<artifactId>xmlenc</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>commons-net</groupId>
|
||||||
|
<artifactId>commons-net</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.apache.avro</groupId>
|
||||||
|
<artifactId>avro</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.apache.zookeeper</groupId>
|
||||||
|
<artifactId>zookeeper</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>javax.servlet.jsp</groupId>
|
||||||
|
<artifactId>jsp-api</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>com.sun.jersey</groupId>
|
||||||
|
<artifactId>jersey-json</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>com.sun.jersey</groupId>
|
||||||
|
<artifactId>jersey-server</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>com.sun.jersey</groupId>
|
||||||
|
<artifactId>jersey-core</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.mortbay.jetty</groupId>
|
||||||
|
<artifactId>jetty</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.hadoop</groupId>
|
||||||
|
<artifactId>hadoop-client</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-log4j12</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>javax.servlet</groupId>
|
||||||
|
<artifactId>servlet-api</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.codehaus.jackson</groupId>
|
||||||
|
<artifactId>jackson-jaxrs</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.codehaus.jackson</groupId>
|
||||||
|
<artifactId>jackson-xc</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.fusesource.leveldbjni</groupId>
|
||||||
|
<artifactId>leveldbjni-all</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.apache.zookeeper</groupId>
|
||||||
|
<artifactId>zookeeper</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.apache.hadoop</groupId>
|
||||||
|
<artifactId>hadoop-mapreduce-client-shuffle</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>com.sun.jersey</groupId>
|
||||||
|
<artifactId>jersey-client</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>com.sun.jersey</groupId>
|
||||||
|
<artifactId>jersey-core</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>javax.xml.bind</groupId>
|
||||||
|
<artifactId>jaxb-api</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>log4j</groupId>
|
||||||
|
<artifactId>log4j</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.hadoop</groupId>
|
||||||
|
<artifactId>hadoop-hdfs</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>javax.servlet</groupId>
|
||||||
|
<artifactId>servlet-api</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>io.netty</groupId>
|
||||||
|
<artifactId>netty</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>com.google.protobuf</groupId>
|
||||||
|
<artifactId>protobuf-java</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>xmlenc</groupId>
|
||||||
|
<artifactId>xmlenc</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>io.netty</groupId>
|
||||||
|
<artifactId>netty-all</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.fusesource.leveldbjni</groupId>
|
||||||
|
<artifactId>leveldbjni-all</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>com.sun.jersey</groupId>
|
||||||
|
<artifactId>jersey-core</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>com.sun.jersey</groupId>
|
||||||
|
<artifactId>jersey-server</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>log4j</groupId>
|
||||||
|
<artifactId>log4j</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.service.storage.impl;
|
package org.apache.dolphinscheduler.plugin.storage.hdfs;
|
||||||
|
|
||||||
import static org.apache.dolphinscheduler.common.constants.Constants.FOLDER_SEPARATOR;
|
import static org.apache.dolphinscheduler.common.constants.Constants.FOLDER_SEPARATOR;
|
||||||
import static org.apache.dolphinscheduler.common.constants.Constants.FORMAT_S_S;
|
import static org.apache.dolphinscheduler.common.constants.Constants.FORMAT_S_S;
|
||||||
|
|
@ -29,10 +29,9 @@ import org.apache.dolphinscheduler.common.utils.HttpUtils;
|
||||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||||
import org.apache.dolphinscheduler.common.utils.KerberosHttpClient;
|
import org.apache.dolphinscheduler.common.utils.KerberosHttpClient;
|
||||||
import org.apache.dolphinscheduler.common.utils.PropertyUtils;
|
import org.apache.dolphinscheduler.common.utils.PropertyUtils;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
|
import org.apache.dolphinscheduler.plugin.datasource.api.utils.CommonUtils;
|
||||||
import org.apache.dolphinscheduler.service.storage.StorageEntity;
|
import org.apache.dolphinscheduler.plugin.storage.api.StorageEntity;
|
||||||
import org.apache.dolphinscheduler.service.storage.StorageOperate;
|
import org.apache.dolphinscheduler.plugin.storage.api.StorageOperate;
|
||||||
import org.apache.dolphinscheduler.service.utils.CommonUtils;
|
|
||||||
import org.apache.dolphinscheduler.spi.enums.ResourceType;
|
import org.apache.dolphinscheduler.spi.enums.ResourceType;
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
@ -75,14 +74,9 @@ import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
import com.google.common.cache.LoadingCache;
|
import com.google.common.cache.LoadingCache;
|
||||||
|
|
||||||
/**
|
public class HdfsStorageOperator implements Closeable, StorageOperate {
|
||||||
* hadoop utils
|
|
||||||
* single instance
|
|
||||||
* By default, directory path does NOT end with '/'
|
|
||||||
*/
|
|
||||||
public class HadoopUtils implements Closeable, StorageOperate {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(HadoopUtils.class);
|
private static final Logger logger = LoggerFactory.getLogger(HdfsStorageOperator.class);
|
||||||
private String hdfsUser;
|
private String hdfsUser;
|
||||||
public static final String RM_HA_IDS = PropertyUtils.getString(Constants.YARN_RESOURCEMANAGER_HA_RM_IDS);
|
public static final String RM_HA_IDS = PropertyUtils.getString(Constants.YARN_RESOURCEMANAGER_HA_RM_IDS);
|
||||||
public static final String APP_ADDRESS = PropertyUtils.getString(Constants.YARN_APPLICATION_STATUS_ADDRESS);
|
public static final String APP_ADDRESS = PropertyUtils.getString(Constants.YARN_APPLICATION_STATUS_ADDRESS);
|
||||||
|
|
@ -91,14 +85,14 @@ public class HadoopUtils implements Closeable, StorageOperate {
|
||||||
PropertyUtils.getInt(Constants.HADOOP_RESOURCE_MANAGER_HTTPADDRESS_PORT, 8088);
|
PropertyUtils.getInt(Constants.HADOOP_RESOURCE_MANAGER_HTTPADDRESS_PORT, 8088);
|
||||||
private static final String HADOOP_UTILS_KEY = "HADOOP_UTILS_KEY";
|
private static final String HADOOP_UTILS_KEY = "HADOOP_UTILS_KEY";
|
||||||
|
|
||||||
private static final LoadingCache<String, HadoopUtils> cache = CacheBuilder
|
private static final LoadingCache<String, HdfsStorageOperator> cache = CacheBuilder
|
||||||
.newBuilder()
|
.newBuilder()
|
||||||
.expireAfterWrite(PropertyUtils.getInt(Constants.KERBEROS_EXPIRE_TIME, 2), TimeUnit.HOURS)
|
.expireAfterWrite(PropertyUtils.getInt(Constants.KERBEROS_EXPIRE_TIME, 2), TimeUnit.HOURS)
|
||||||
.build(new CacheLoader<String, HadoopUtils>() {
|
.build(new CacheLoader<String, HdfsStorageOperator>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HadoopUtils load(String key) throws Exception {
|
public HdfsStorageOperator load(String key) throws Exception {
|
||||||
return new HadoopUtils();
|
return new HdfsStorageOperator();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -107,13 +101,13 @@ public class HadoopUtils implements Closeable, StorageOperate {
|
||||||
private Configuration configuration;
|
private Configuration configuration;
|
||||||
private FileSystem fs;
|
private FileSystem fs;
|
||||||
|
|
||||||
private HadoopUtils() {
|
private HdfsStorageOperator() {
|
||||||
hdfsUser = PropertyUtils.getString(Constants.HDFS_ROOT_USER);
|
hdfsUser = PropertyUtils.getString(Constants.HDFS_ROOT_USER);
|
||||||
init();
|
init();
|
||||||
initHdfsPath();
|
initHdfsPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HadoopUtils getInstance() {
|
public static HdfsStorageOperator getInstance() {
|
||||||
return cache.getUnchecked(HADOOP_UTILS_KEY);
|
return cache.getUnchecked(HADOOP_UTILS_KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -601,75 +595,6 @@ public class HadoopUtils implements Closeable, StorageOperate {
|
||||||
return yarnEnabled;
|
return yarnEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* get the state of an application
|
|
||||||
*
|
|
||||||
* @param applicationId application id
|
|
||||||
* @return the return may be null or there may be other parse exceptions
|
|
||||||
*/
|
|
||||||
public TaskExecutionStatus getApplicationStatus(String applicationId) throws BaseException {
|
|
||||||
if (StringUtils.isEmpty(applicationId)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
String result;
|
|
||||||
String applicationUrl = getApplicationUrl(applicationId);
|
|
||||||
logger.debug("generate yarn application url, applicationUrl={}", applicationUrl);
|
|
||||||
|
|
||||||
String responseContent = Boolean.TRUE
|
|
||||||
.equals(PropertyUtils.getBoolean(Constants.HADOOP_SECURITY_AUTHENTICATION_STARTUP_STATE, false))
|
|
||||||
? KerberosHttpClient.get(applicationUrl)
|
|
||||||
: HttpUtils.get(applicationUrl);
|
|
||||||
if (responseContent != null) {
|
|
||||||
ObjectNode jsonObject = JSONUtils.parseObject(responseContent);
|
|
||||||
if (!jsonObject.has("app")) {
|
|
||||||
return TaskExecutionStatus.FAILURE;
|
|
||||||
}
|
|
||||||
result = jsonObject.path("app").path("finalStatus").asText();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// may be in job history
|
|
||||||
String jobHistoryUrl = getJobHistoryUrl(applicationId);
|
|
||||||
logger.debug("generate yarn job history application url, jobHistoryUrl={}", jobHistoryUrl);
|
|
||||||
responseContent = Boolean.TRUE
|
|
||||||
.equals(PropertyUtils.getBoolean(Constants.HADOOP_SECURITY_AUTHENTICATION_STARTUP_STATE, false))
|
|
||||||
? KerberosHttpClient.get(jobHistoryUrl)
|
|
||||||
: HttpUtils.get(jobHistoryUrl);
|
|
||||||
|
|
||||||
if (null != responseContent) {
|
|
||||||
ObjectNode jsonObject = JSONUtils.parseObject(responseContent);
|
|
||||||
if (!jsonObject.has("job")) {
|
|
||||||
return TaskExecutionStatus.FAILURE;
|
|
||||||
}
|
|
||||||
result = jsonObject.path("job").path("state").asText();
|
|
||||||
} else {
|
|
||||||
return TaskExecutionStatus.FAILURE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return getExecutionStatus(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
private TaskExecutionStatus getExecutionStatus(String result) {
|
|
||||||
switch (result) {
|
|
||||||
case Constants.ACCEPTED:
|
|
||||||
return TaskExecutionStatus.SUBMITTED_SUCCESS;
|
|
||||||
case Constants.SUCCEEDED:
|
|
||||||
case Constants.ENDED:
|
|
||||||
return TaskExecutionStatus.SUCCESS;
|
|
||||||
case Constants.NEW:
|
|
||||||
case Constants.NEW_SAVING:
|
|
||||||
case Constants.SUBMITTED:
|
|
||||||
case Constants.FAILED:
|
|
||||||
return TaskExecutionStatus.FAILURE;
|
|
||||||
case Constants.KILLED:
|
|
||||||
return TaskExecutionStatus.KILL;
|
|
||||||
case Constants.RUNNING:
|
|
||||||
default:
|
|
||||||
return TaskExecutionStatus.RUNNING_EXECUTION;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get data hdfs path
|
* get data hdfs path
|
||||||
*
|
*
|
||||||
|
|
@ -14,37 +14,25 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.apache.dolphinscheduler.service.log;
|
|
||||||
|
|
||||||
import ch.qos.logback.classic.Level;
|
package org.apache.dolphinscheduler.plugin.storage.hdfs;
|
||||||
import ch.qos.logback.classic.spi.ILoggingEvent;
|
|
||||||
import ch.qos.logback.core.filter.Filter;
|
|
||||||
import ch.qos.logback.core.spi.FilterReply;
|
|
||||||
|
|
||||||
/**
|
import org.apache.dolphinscheduler.plugin.storage.api.StorageOperate;
|
||||||
* worker log filter
|
import org.apache.dolphinscheduler.plugin.storage.api.StorageOperateFactory;
|
||||||
*/
|
import org.apache.dolphinscheduler.plugin.storage.api.StorageType;
|
||||||
public class WorkerLogFilter extends Filter<ILoggingEvent> {
|
|
||||||
|
|
||||||
/**
|
import com.google.auto.service.AutoService;
|
||||||
* level
|
|
||||||
*/
|
@AutoService(StorageOperateFactory.class)
|
||||||
Level level;
|
public class HdfsStorageOperatorFactory implements StorageOperateFactory {
|
||||||
|
|
||||||
/**
|
|
||||||
* Accept or reject based on thread name
|
|
||||||
* @param event event
|
|
||||||
* @return FilterReply
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public FilterReply decide(ILoggingEvent event) {
|
public StorageOperate createStorageOperate() {
|
||||||
if (event.getThreadName().startsWith("Worker-")) {
|
return HdfsStorageOperator.getInstance();
|
||||||
return FilterReply.ACCEPT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return FilterReply.DENY;
|
@Override
|
||||||
}
|
public StorageType getStorageOperate() {
|
||||||
public void setLevel(String level) {
|
return StorageType.HDFS;
|
||||||
this.level = Level.toLevel(level);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.service.storage.impl;
|
package org.apache.dolphinscheduler.plugin.storage.hdfs;
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.common.utils.HttpUtils;
|
import org.apache.dolphinscheduler.common.utils.HttpUtils;
|
||||||
import org.apache.dolphinscheduler.spi.enums.ResourceType;
|
import org.apache.dolphinscheduler.spi.enums.ResourceType;
|
||||||
|
|
@ -33,31 +33,31 @@ import org.slf4j.LoggerFactory;
|
||||||
* hadoop utils test
|
* hadoop utils test
|
||||||
*/
|
*/
|
||||||
@ExtendWith(MockitoExtension.class)
|
@ExtendWith(MockitoExtension.class)
|
||||||
public class HadoopUtilsTest {
|
public class HdfsStorageOperatorTest {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(HadoopUtilsTest.class);
|
private static final Logger logger = LoggerFactory.getLogger(HdfsStorageOperatorTest.class);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getHdfsTenantDir() {
|
public void getHdfsTenantDir() {
|
||||||
logger.info(HadoopUtils.getHdfsTenantDir("1234"));
|
logger.info(HdfsStorageOperator.getHdfsTenantDir("1234"));
|
||||||
Assertions.assertTrue(true);
|
Assertions.assertTrue(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getHdfsUdfFileName() {
|
public void getHdfsUdfFileName() {
|
||||||
logger.info(HadoopUtils.getHdfsUdfFileName("admin", "file_name"));
|
logger.info(HdfsStorageOperator.getHdfsUdfFileName("admin", "file_name"));
|
||||||
Assertions.assertTrue(true);
|
Assertions.assertTrue(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getHdfsResourceFileName() {
|
public void getHdfsResourceFileName() {
|
||||||
logger.info(HadoopUtils.getHdfsResourceFileName("admin", "file_name"));
|
logger.info(HdfsStorageOperator.getHdfsResourceFileName("admin", "file_name"));
|
||||||
Assertions.assertTrue(true);
|
Assertions.assertTrue(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getHdfsFileName() {
|
public void getHdfsFileName() {
|
||||||
logger.info(HadoopUtils.getHdfsFileName(ResourceType.FILE, "admin", "file_name"));
|
logger.info(HdfsStorageOperator.getHdfsFileName(ResourceType.FILE, "admin", "file_name"));
|
||||||
Assertions.assertTrue(true);
|
Assertions.assertTrue(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -66,7 +66,7 @@ public class HadoopUtilsTest {
|
||||||
try (MockedStatic<HttpUtils> mockedHttpUtils = Mockito.mockStatic(HttpUtils.class)) {
|
try (MockedStatic<HttpUtils> mockedHttpUtils = Mockito.mockStatic(HttpUtils.class)) {
|
||||||
mockedHttpUtils.when(() -> HttpUtils.get("http://ds1:8088/ws/v1/cluster/info"))
|
mockedHttpUtils.when(() -> HttpUtils.get("http://ds1:8088/ws/v1/cluster/info"))
|
||||||
.thenReturn("{\"clusterInfo\":{\"state\":\"STARTED\",\"haState\":\"ACTIVE\"}}");
|
.thenReturn("{\"clusterInfo\":{\"state\":\"STARTED\",\"haState\":\"ACTIVE\"}}");
|
||||||
logger.info(HadoopUtils.getAppAddress("http://ds1:8088/ws/v1/cluster/apps/%s", "ds1,ds2"));
|
logger.info(HdfsStorageOperator.getAppAddress("http://ds1:8088/ws/v1/cluster/apps/%s", "ds1,ds2"));
|
||||||
Assertions.assertTrue(true);
|
Assertions.assertTrue(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
~ 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.
|
||||||
|
-->
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.apache.dolphinscheduler</groupId>
|
||||||
|
<artifactId>dolphinscheduler-storage-plugin</artifactId>
|
||||||
|
<version>dev-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>dolphinscheduler-storage-oss</artifactId>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.dolphinscheduler</groupId>
|
||||||
|
<artifactId>dolphinscheduler-storage-api</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.dolphinscheduler</groupId>
|
||||||
|
<artifactId>dolphinscheduler-task-api</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.service.storage.impl;
|
package org.apache.dolphinscheduler.plugin.storage.oss;
|
||||||
|
|
||||||
import static org.apache.dolphinscheduler.common.constants.Constants.FOLDER_SEPARATOR;
|
import static org.apache.dolphinscheduler.common.constants.Constants.FOLDER_SEPARATOR;
|
||||||
import static org.apache.dolphinscheduler.common.constants.Constants.FORMAT_S_S;
|
import static org.apache.dolphinscheduler.common.constants.Constants.FORMAT_S_S;
|
||||||
|
|
@ -27,9 +27,9 @@ import org.apache.dolphinscheduler.common.enums.ResUploadType;
|
||||||
import org.apache.dolphinscheduler.common.factory.OssClientFactory;
|
import org.apache.dolphinscheduler.common.factory.OssClientFactory;
|
||||||
import org.apache.dolphinscheduler.common.model.OssConnection;
|
import org.apache.dolphinscheduler.common.model.OssConnection;
|
||||||
import org.apache.dolphinscheduler.common.utils.PropertyUtils;
|
import org.apache.dolphinscheduler.common.utils.PropertyUtils;
|
||||||
|
import org.apache.dolphinscheduler.plugin.storage.api.StorageEntity;
|
||||||
|
import org.apache.dolphinscheduler.plugin.storage.api.StorageOperate;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
|
import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
|
||||||
import org.apache.dolphinscheduler.service.storage.StorageEntity;
|
|
||||||
import org.apache.dolphinscheduler.service.storage.StorageOperate;
|
|
||||||
import org.apache.dolphinscheduler.spi.enums.ResourceType;
|
import org.apache.dolphinscheduler.spi.enums.ResourceType;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
@ -62,9 +62,9 @@ import com.aliyun.oss.model.ObjectMetadata;
|
||||||
import com.aliyun.oss.model.PutObjectRequest;
|
import com.aliyun.oss.model.PutObjectRequest;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class OssOperator implements Closeable, StorageOperate {
|
public class OssStorageOperator implements Closeable, StorageOperate {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(OssOperator.class);
|
private static final Logger logger = LoggerFactory.getLogger(OssStorageOperator.class);
|
||||||
|
|
||||||
private String accessKeyId;
|
private String accessKeyId;
|
||||||
|
|
||||||
|
|
@ -80,7 +80,7 @@ public class OssOperator implements Closeable, StorageOperate {
|
||||||
|
|
||||||
private OSS ossClient;
|
private OSS ossClient;
|
||||||
|
|
||||||
public OssOperator() {
|
public OssStorageOperator() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
|
|
@ -360,5 +360,4 @@ public class OssOperator implements Closeable, StorageOperate {
|
||||||
protected OSS buildOssClient() {
|
protected OSS buildOssClient() {
|
||||||
return OssClientFactory.buildOssClient(ossConnection);
|
return OssClientFactory.buildOssClient(ossConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -14,37 +14,27 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.apache.dolphinscheduler.service.log;
|
|
||||||
|
|
||||||
import ch.qos.logback.classic.Level;
|
package org.apache.dolphinscheduler.plugin.storage.oss;
|
||||||
import ch.qos.logback.classic.spi.ILoggingEvent;
|
|
||||||
import ch.qos.logback.core.filter.Filter;
|
|
||||||
import ch.qos.logback.core.spi.FilterReply;
|
|
||||||
|
|
||||||
/**
|
import org.apache.dolphinscheduler.plugin.storage.api.StorageOperate;
|
||||||
* master log filter
|
import org.apache.dolphinscheduler.plugin.storage.api.StorageOperateFactory;
|
||||||
*/
|
import org.apache.dolphinscheduler.plugin.storage.api.StorageType;
|
||||||
public class MasterLogFilter extends Filter<ILoggingEvent> {
|
|
||||||
|
|
||||||
/**
|
import com.google.auto.service.AutoService;
|
||||||
* log level
|
|
||||||
*/
|
@AutoService(StorageOperateFactory.class)
|
||||||
Level level;
|
public class OssStorageOperatorFactory implements StorageOperateFactory {
|
||||||
|
|
||||||
/**
|
|
||||||
* Accept or reject based on thread name
|
|
||||||
* @param event event
|
|
||||||
* @return FilterReply
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public FilterReply decide(ILoggingEvent event) {
|
public StorageOperate createStorageOperate() {
|
||||||
if (event.getThreadName().startsWith("Master-")) {
|
OssStorageOperator ossOperator = new OssStorageOperator();
|
||||||
return FilterReply.ACCEPT;
|
ossOperator.init();
|
||||||
}
|
return ossOperator;
|
||||||
return FilterReply.DENY;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLevel(String level) {
|
@Override
|
||||||
this.level = Level.toLevel(level);
|
public StorageType getStorageOperate() {
|
||||||
|
return StorageType.OSS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.service.storage.impl;
|
package org.apache.dolphinscheduler.plugin.storage.oss;
|
||||||
|
|
||||||
import static org.apache.dolphinscheduler.common.constants.Constants.FOLDER_SEPARATOR;
|
import static org.apache.dolphinscheduler.common.constants.Constants.FOLDER_SEPARATOR;
|
||||||
import static org.apache.dolphinscheduler.common.constants.Constants.FORMAT_S_S;
|
import static org.apache.dolphinscheduler.common.constants.Constants.FORMAT_S_S;
|
||||||
|
|
@ -41,7 +41,7 @@ import org.mockito.junit.jupiter.MockitoExtension;
|
||||||
import com.aliyun.oss.OSS;
|
import com.aliyun.oss.OSS;
|
||||||
|
|
||||||
@ExtendWith(MockitoExtension.class)
|
@ExtendWith(MockitoExtension.class)
|
||||||
public class OssOperatorTest {
|
public class OssStorageOperatorTest {
|
||||||
|
|
||||||
private static final String ACCESS_KEY_ID_MOCK = "ACCESS_KEY_ID_MOCK";
|
private static final String ACCESS_KEY_ID_MOCK = "ACCESS_KEY_ID_MOCK";
|
||||||
private static final String ACCESS_KEY_SECRET_MOCK = "ACCESS_KEY_SECRET_MOCK";
|
private static final String ACCESS_KEY_SECRET_MOCK = "ACCESS_KEY_SECRET_MOCK";
|
||||||
|
|
@ -56,11 +56,11 @@ public class OssOperatorTest {
|
||||||
@Mock
|
@Mock
|
||||||
private OSS ossClientMock;
|
private OSS ossClientMock;
|
||||||
|
|
||||||
private OssOperator ossOperator;
|
private OssStorageOperator ossOperator;
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
ossOperator = spy(new OssOperator());
|
ossOperator = spy(new OssStorageOperator());
|
||||||
doReturn(ACCESS_KEY_ID_MOCK).when(ossOperator)
|
doReturn(ACCESS_KEY_ID_MOCK).when(ossOperator)
|
||||||
.readOssAccessKeyID();
|
.readOssAccessKeyID();
|
||||||
doReturn(ACCESS_KEY_SECRET_MOCK).when(ossOperator)
|
doReturn(ACCESS_KEY_SECRET_MOCK).when(ossOperator)
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
~ 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.
|
||||||
|
-->
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.apache.dolphinscheduler</groupId>
|
||||||
|
<artifactId>dolphinscheduler-storage-plugin</artifactId>
|
||||||
|
<version>dev-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>dolphinscheduler-storage-s3</artifactId>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.dolphinscheduler</groupId>
|
||||||
|
<artifactId>dolphinscheduler-task-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.dolphinscheduler</groupId>
|
||||||
|
<artifactId>dolphinscheduler-storage-api</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.amazonaws</groupId>
|
||||||
|
<artifactId>aws-java-sdk-s3</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
|
|
@ -15,22 +15,20 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.service.storage.impl;
|
package org.apache.dolphinscheduler.plugin.storage.s3;
|
||||||
|
|
||||||
import static org.apache.dolphinscheduler.common.constants.Constants.AWS_END_POINT;
|
import static org.apache.dolphinscheduler.common.constants.Constants.AWS_END_POINT;
|
||||||
import static org.apache.dolphinscheduler.common.constants.Constants.FOLDER_SEPARATOR;
|
import static org.apache.dolphinscheduler.common.constants.Constants.FOLDER_SEPARATOR;
|
||||||
import static org.apache.dolphinscheduler.common.constants.Constants.FORMAT_S_S;
|
import static org.apache.dolphinscheduler.common.constants.Constants.FORMAT_S_S;
|
||||||
import static org.apache.dolphinscheduler.common.constants.Constants.RESOURCE_STORAGE_TYPE;
|
|
||||||
import static org.apache.dolphinscheduler.common.constants.Constants.RESOURCE_TYPE_FILE;
|
import static org.apache.dolphinscheduler.common.constants.Constants.RESOURCE_TYPE_FILE;
|
||||||
import static org.apache.dolphinscheduler.common.constants.Constants.RESOURCE_TYPE_UDF;
|
import static org.apache.dolphinscheduler.common.constants.Constants.RESOURCE_TYPE_UDF;
|
||||||
import static org.apache.dolphinscheduler.common.constants.Constants.STORAGE_S3;
|
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.common.constants.Constants;
|
import org.apache.dolphinscheduler.common.constants.Constants;
|
||||||
import org.apache.dolphinscheduler.common.enums.ResUploadType;
|
import org.apache.dolphinscheduler.common.enums.ResUploadType;
|
||||||
import org.apache.dolphinscheduler.common.utils.PropertyUtils;
|
import org.apache.dolphinscheduler.common.utils.PropertyUtils;
|
||||||
|
import org.apache.dolphinscheduler.plugin.storage.api.StorageEntity;
|
||||||
|
import org.apache.dolphinscheduler.plugin.storage.api.StorageOperate;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
|
import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
|
||||||
import org.apache.dolphinscheduler.service.storage.StorageEntity;
|
|
||||||
import org.apache.dolphinscheduler.service.storage.StorageOperate;
|
|
||||||
import org.apache.dolphinscheduler.spi.enums.ResourceType;
|
import org.apache.dolphinscheduler.spi.enums.ResourceType;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
@ -78,26 +76,22 @@ import com.amazonaws.services.s3.transfer.TransferManager;
|
||||||
import com.amazonaws.services.s3.transfer.TransferManagerBuilder;
|
import com.amazonaws.services.s3.transfer.TransferManagerBuilder;
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
|
|
||||||
/**
|
public class S3StorageOperator implements Closeable, StorageOperate {
|
||||||
* By default, directory path does end with '/'
|
|
||||||
*/
|
|
||||||
public class S3Utils implements Closeable, StorageOperate {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(S3Utils.class);
|
private static final Logger logger = LoggerFactory.getLogger(S3StorageOperator.class);
|
||||||
|
|
||||||
public static final String ACCESS_KEY_ID = PropertyUtils.getString(TaskConstants.AWS_ACCESS_KEY_ID);
|
// todo: move to s3
|
||||||
|
private static final String ACCESS_KEY_ID = PropertyUtils.getString(TaskConstants.AWS_ACCESS_KEY_ID);
|
||||||
|
|
||||||
public static final String SECRET_KEY_ID = PropertyUtils.getString(TaskConstants.AWS_SECRET_ACCESS_KEY);
|
private static final String SECRET_KEY_ID = PropertyUtils.getString(TaskConstants.AWS_SECRET_ACCESS_KEY);
|
||||||
|
|
||||||
public static final String REGION = PropertyUtils.getString(TaskConstants.AWS_REGION);
|
private static final String REGION = PropertyUtils.getString(TaskConstants.AWS_REGION);
|
||||||
|
|
||||||
public static final String BUCKET_NAME = PropertyUtils.getString(Constants.AWS_S3_BUCKET_NAME);
|
private static final String BUCKET_NAME = PropertyUtils.getString(Constants.AWS_S3_BUCKET_NAME);
|
||||||
|
|
||||||
private AmazonS3 s3Client = null;
|
private final AmazonS3 s3Client;
|
||||||
|
|
||||||
private S3Utils() {
|
|
||||||
if (PropertyUtils.getString(RESOURCE_STORAGE_TYPE).equals(STORAGE_S3)) {
|
|
||||||
|
|
||||||
|
public S3StorageOperator() {
|
||||||
if (!StringUtils.isEmpty(PropertyUtils.getString(AWS_END_POINT))) {
|
if (!StringUtils.isEmpty(PropertyUtils.getString(AWS_END_POINT))) {
|
||||||
s3Client = AmazonS3ClientBuilder
|
s3Client = AmazonS3ClientBuilder
|
||||||
.standard()
|
.standard()
|
||||||
|
|
@ -117,29 +111,6 @@ public class S3Utils implements Closeable, StorageOperate {
|
||||||
}
|
}
|
||||||
checkBucketNameExists(BUCKET_NAME);
|
checkBucketNameExists(BUCKET_NAME);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* S3Utils single
|
|
||||||
*/
|
|
||||||
private enum S3Singleton {
|
|
||||||
|
|
||||||
INSTANCE;
|
|
||||||
|
|
||||||
private final S3Utils instance;
|
|
||||||
|
|
||||||
S3Singleton() {
|
|
||||||
instance = new S3Utils();
|
|
||||||
}
|
|
||||||
|
|
||||||
private S3Utils getInstance() {
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static S3Utils getInstance() {
|
|
||||||
return S3Singleton.INSTANCE.getInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
|
|
@ -148,8 +119,8 @@ public class S3Utils implements Closeable, StorageOperate {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createTenantDirIfNotExists(String tenantCode) throws Exception {
|
public void createTenantDirIfNotExists(String tenantCode) throws Exception {
|
||||||
getInstance().mkdir(tenantCode, getS3ResDir(tenantCode));
|
mkdir(tenantCode, getS3ResDir(tenantCode));
|
||||||
getInstance().mkdir(tenantCode, getS3UdfDir(tenantCode));
|
mkdir(tenantCode, getS3UdfDir(tenantCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -15,20 +15,24 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.server.worker.config;
|
package org.apache.dolphinscheduler.plugin.storage.s3;
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.service.alert.AlertClientService;
|
import org.apache.dolphinscheduler.plugin.storage.api.StorageOperate;
|
||||||
|
import org.apache.dolphinscheduler.plugin.storage.api.StorageOperateFactory;
|
||||||
|
import org.apache.dolphinscheduler.plugin.storage.api.StorageType;
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import com.google.auto.service.AutoService;
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
@Configuration
|
@AutoService(StorageOperateFactory.class)
|
||||||
public class BeanConfig {
|
public class S3StorageOperatorFactory implements StorageOperateFactory {
|
||||||
|
|
||||||
@Bean
|
@Override
|
||||||
public AlertClientService alertClientService(WorkerConfig workerConfig) {
|
public StorageOperate createStorageOperate() {
|
||||||
return new AlertClientService(
|
return new S3StorageOperator();
|
||||||
workerConfig.getAlertListenHost(),
|
}
|
||||||
workerConfig.getAlertListenPort());
|
|
||||||
|
@Override
|
||||||
|
public StorageType getStorageOperate() {
|
||||||
|
return StorageType.S3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
~ 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.
|
||||||
|
-->
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.apache.dolphinscheduler</groupId>
|
||||||
|
<artifactId>dolphinscheduler</artifactId>
|
||||||
|
<version>dev-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>dolphinscheduler-storage-plugin</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
<modules>
|
||||||
|
<module>dolphinscheduler-storage-api</module>
|
||||||
|
<module>dolphinscheduler-storage-all</module>
|
||||||
|
<module>dolphinscheduler-storage-s3</module>
|
||||||
|
<module>dolphinscheduler-storage-hdfs</module>
|
||||||
|
<module>dolphinscheduler-storage-oss</module>
|
||||||
|
</modules>
|
||||||
|
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.dolphinscheduler</groupId>
|
||||||
|
<artifactId>dolphinscheduler-bom</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
</project>
|
||||||
|
|
@ -17,14 +17,15 @@
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.plugin.task.api;
|
package org.apache.dolphinscheduler.plugin.task.api;
|
||||||
|
|
||||||
import static org.apache.dolphinscheduler.plugin.task.api.ProcessUtils.getPidsStr;
|
|
||||||
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.EXIT_CODE_FAILURE;
|
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.EXIT_CODE_FAILURE;
|
||||||
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.EXIT_CODE_KILL;
|
import static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.EXIT_CODE_KILL;
|
||||||
|
import static org.apache.dolphinscheduler.plugin.task.api.utils.ProcessUtils.getPidsStr;
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.common.utils.PropertyUtils;
|
import org.apache.dolphinscheduler.common.utils.PropertyUtils;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.model.TaskResponse;
|
import org.apache.dolphinscheduler.plugin.task.api.model.TaskResponse;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.utils.AbstractCommandExecutorConstants;
|
import org.apache.dolphinscheduler.plugin.task.api.utils.AbstractCommandExecutorConstants;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.utils.OSUtils;
|
import org.apache.dolphinscheduler.plugin.task.api.utils.OSUtils;
|
||||||
|
import org.apache.dolphinscheduler.plugin.task.api.utils.ProcessUtils;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.lang3.SystemUtils;
|
import org.apache.commons.lang3.SystemUtils;
|
||||||
|
|
|
||||||
|
|
@ -1,106 +0,0 @@
|
||||||
/*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership.
|
|
||||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
|
||||||
* (the "License"); you may not use this file except in compliance with
|
|
||||||
* the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.plugin.task.api;
|
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.utils.OSUtils;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.SystemUtils;
|
|
||||||
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
import lombok.NonNull;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
public final class ProcessUtils {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ProcessUtils.class);
|
|
||||||
|
|
||||||
private ProcessUtils() {
|
|
||||||
throw new IllegalStateException("Utility class");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialization regularization, solve the problem of pre-compilation performance,
|
|
||||||
* avoid the thread safety problem of multi-thread operation
|
|
||||||
*/
|
|
||||||
private static final Pattern MACPATTERN = Pattern.compile("-[+|-]-\\s(\\d+)");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Expression of PID recognition in Windows scene
|
|
||||||
*/
|
|
||||||
private static final Pattern WINDOWSATTERN = Pattern.compile("(\\d+)");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* kill tasks according to different task types.
|
|
||||||
*/
|
|
||||||
public static boolean kill(@NonNull TaskExecutionContext request) {
|
|
||||||
try {
|
|
||||||
logger.info("Begin kill task instance, processId: {}", request.getProcessId());
|
|
||||||
int processId = request.getProcessId();
|
|
||||||
if (processId == 0) {
|
|
||||||
logger.error("Task instance kill failed, processId is not exist");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
String cmd = String.format("kill -9 %s", getPidsStr(processId));
|
|
||||||
cmd = OSUtils.getSudoCmd(request.getTenantCode(), cmd);
|
|
||||||
logger.info("process id:{}, cmd:{}", processId, cmd);
|
|
||||||
|
|
||||||
OSUtils.exeCmd(cmd);
|
|
||||||
logger.info("Success kill task instance, processId: {}", request.getProcessId());
|
|
||||||
return true;
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("Kill task instance error, processId: {}", request.getProcessId(), e);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get pids str.
|
|
||||||
*
|
|
||||||
* @param processId process id
|
|
||||||
* @return pids pid String
|
|
||||||
* @throws Exception exception
|
|
||||||
*/
|
|
||||||
public static String getPidsStr(int processId) throws Exception {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
Matcher mat = null;
|
|
||||||
// pstree pid get sub pids
|
|
||||||
if (SystemUtils.IS_OS_MAC) {
|
|
||||||
String pids = OSUtils.exeCmd(String.format("%s -sp %d", TaskConstants.PSTREE, processId));
|
|
||||||
if (null != pids) {
|
|
||||||
mat = MACPATTERN.matcher(pids);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
String pids = OSUtils.exeCmd(String.format("%s -p %d", TaskConstants.PSTREE, processId));
|
|
||||||
mat = WINDOWSATTERN.matcher(pids);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (null != mat) {
|
|
||||||
while (mat.find()) {
|
|
||||||
sb.append(mat.group(1)).append(" ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return sb.toString().trim();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -15,12 +15,9 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.service.task;
|
package org.apache.dolphinscheduler.plugin.task.api;
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.TaskChannel;
|
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.TaskChannelFactory;
|
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
|
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
|
import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.parameters.BlockingParameters;
|
import org.apache.dolphinscheduler.plugin.task.api.parameters.BlockingParameters;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.parameters.ConditionsParameters;
|
import org.apache.dolphinscheduler.plugin.task.api.parameters.ConditionsParameters;
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.apache.dolphinscheduler.service.log;
|
package org.apache.dolphinscheduler.plugin.task.api.log;
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.common.constants.Constants;
|
import org.apache.dolphinscheduler.common.constants.Constants;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
|
import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.service.log;
|
package org.apache.dolphinscheduler.plugin.task.api.log;
|
||||||
|
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
|
import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
|
||||||
|
|
||||||
|
|
@ -17,18 +17,29 @@
|
||||||
|
|
||||||
package org.apache.dolphinscheduler.plugin.task.api.utils;
|
package org.apache.dolphinscheduler.plugin.task.api.utils;
|
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.common.constants.Constants;
|
||||||
|
import org.apache.dolphinscheduler.common.constants.DateConstants;
|
||||||
|
import org.apache.dolphinscheduler.common.utils.DateUtils;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
|
import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
|
||||||
|
import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
|
||||||
|
import org.apache.dolphinscheduler.plugin.task.api.log.TaskLogDiscriminator;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
@ -39,11 +50,18 @@ import lombok.experimental.UtilityClass;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.slf4j.MDC;
|
||||||
|
|
||||||
|
import ch.qos.logback.classic.sift.SiftingAppender;
|
||||||
|
import ch.qos.logback.classic.spi.ILoggingEvent;
|
||||||
|
import ch.qos.logback.core.spi.AppenderAttachable;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class LogUtils {
|
public class LogUtils {
|
||||||
|
|
||||||
|
private static final String LOG_TAILFIX = ".log";
|
||||||
private static final Pattern APPLICATION_REGEX = Pattern.compile(TaskConstants.YARN_APPLICATION_REGEX);
|
private static final Pattern APPLICATION_REGEX = Pattern.compile(TaskConstants.YARN_APPLICATION_REGEX);
|
||||||
|
|
||||||
public List<String> getAppIds(@NonNull String logPath, @NonNull String appInfoPath, String fetchWay) {
|
public List<String> getAppIds(@NonNull String logPath, @NonNull String appInfoPath, String fetchWay) {
|
||||||
|
|
@ -56,6 +74,55 @@ public class LogUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getTaskLogPath(TaskExecutionContext taskExecutionContext) {
|
||||||
|
return getTaskLogPath(DateUtils.timeStampToDate(taskExecutionContext.getFirstSubmitTime()),
|
||||||
|
taskExecutionContext.getProcessDefineCode(),
|
||||||
|
taskExecutionContext.getProcessDefineVersion(),
|
||||||
|
taskExecutionContext.getProcessInstanceId(),
|
||||||
|
taskExecutionContext.getTaskInstanceId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getTaskLogPath(Date firstSubmitTime,
|
||||||
|
Long processDefineCode,
|
||||||
|
int processDefineVersion,
|
||||||
|
int processInstanceId,
|
||||||
|
int taskInstanceId) {
|
||||||
|
// format /logs/YYYYMMDD/defintion-code_defintion_version-processInstanceId-taskInstanceId.log
|
||||||
|
final String taskLogFileName = new StringBuilder(String.valueOf(processDefineCode))
|
||||||
|
.append(Constants.UNDERLINE)
|
||||||
|
.append(processDefineVersion)
|
||||||
|
.append(Constants.SUBTRACT_CHAR)
|
||||||
|
.append(processInstanceId)
|
||||||
|
.append(Constants.SUBTRACT_CHAR)
|
||||||
|
.append(taskInstanceId)
|
||||||
|
.append(LOG_TAILFIX)
|
||||||
|
.toString();
|
||||||
|
// Optional.map will be skipped if null
|
||||||
|
return Optional.of(LoggerFactory.getILoggerFactory())
|
||||||
|
.map(e -> (AppenderAttachable<ILoggingEvent>) (e.getLogger("ROOT")))
|
||||||
|
.map(e -> (SiftingAppender) (e.getAppender("TASKLOGFILE")))
|
||||||
|
.map(e -> ((TaskLogDiscriminator) (e.getDiscriminator())))
|
||||||
|
.map(TaskLogDiscriminator::getLogBase)
|
||||||
|
.map(e -> Paths.get(e)
|
||||||
|
.toAbsolutePath()
|
||||||
|
.resolve(DateUtils.format(firstSubmitTime, DateConstants.YYYYMMDD, null))
|
||||||
|
.resolve(taskLogFileName))
|
||||||
|
.map(Path::toString)
|
||||||
|
.orElse("");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String buildTaskId(Date firstSubmitTime,
|
||||||
|
Long processDefineCode,
|
||||||
|
int processDefineVersion,
|
||||||
|
int processInstId,
|
||||||
|
int taskId) {
|
||||||
|
// like TaskAppId=TASK-20211107-798_1-4084-15210
|
||||||
|
String firstSubmitTimeStr = DateUtils.format(firstSubmitTime, DateConstants.YYYYMMDD, null);
|
||||||
|
return String.format("%s=%s-%s-%s_%s-%s-%s",
|
||||||
|
TaskConstants.TASK_APPID_LOG_FORMAT, TaskConstants.TASK_LOGGER_INFO_PREFIX, firstSubmitTimeStr,
|
||||||
|
processDefineCode, processDefineVersion, processInstId, taskId);
|
||||||
|
}
|
||||||
|
|
||||||
public List<String> getAppIdsFromAppInfoFile(@NonNull String appInfoPath, Logger logger) {
|
public List<String> getAppIdsFromAppInfoFile(@NonNull String appInfoPath, Logger logger) {
|
||||||
File appInfoFile = new File(appInfoPath);
|
File appInfoFile = new File(appInfoPath);
|
||||||
if (!appInfoFile.exists() || !appInfoFile.isFile()) {
|
if (!appInfoFile.exists() || !appInfoFile.isFile()) {
|
||||||
|
|
@ -96,4 +163,44 @@ public class LogUtils {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String readWholeFileContent(String filePath) {
|
||||||
|
String line;
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(filePath)))) {
|
||||||
|
while ((line = br.readLine()) != null) {
|
||||||
|
sb.append(line + "\r\n");
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("read file error", e);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setWorkflowAndTaskInstanceIDMDC(Integer workflowInstanceId, Integer taskInstanceId) {
|
||||||
|
setWorkflowInstanceIdMDC(workflowInstanceId);
|
||||||
|
setTaskInstanceIdMDC(taskInstanceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setWorkflowInstanceIdMDC(Integer workflowInstanceId) {
|
||||||
|
MDC.put(Constants.WORKFLOW_INSTANCE_ID_MDC_KEY, String.valueOf(workflowInstanceId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setTaskInstanceIdMDC(Integer taskInstanceId) {
|
||||||
|
MDC.put(Constants.TASK_INSTANCE_ID_MDC_KEY, String.valueOf(taskInstanceId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void removeWorkflowAndTaskInstanceIdMDC() {
|
||||||
|
removeWorkflowInstanceIdMDC();
|
||||||
|
removeTaskInstanceIdMDC();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void removeWorkflowInstanceIdMDC() {
|
||||||
|
MDC.remove(Constants.WORKFLOW_INSTANCE_ID_MDC_KEY);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void removeTaskInstanceIdMDC() {
|
||||||
|
MDC.remove(Constants.TASK_INSTANCE_ID_MDC_KEY);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,402 @@
|
||||||
|
/*
|
||||||
|
* 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.plugin.task.api.utils;
|
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.common.constants.Constants;
|
||||||
|
import org.apache.dolphinscheduler.common.exception.BaseException;
|
||||||
|
import org.apache.dolphinscheduler.common.utils.HttpUtils;
|
||||||
|
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||||
|
import org.apache.dolphinscheduler.common.utils.KerberosHttpClient;
|
||||||
|
import org.apache.dolphinscheduler.common.utils.PropertyUtils;
|
||||||
|
import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
|
||||||
|
import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
|
||||||
|
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.commons.lang3.SystemUtils;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import lombok.NonNull;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||||
|
|
||||||
|
public final class ProcessUtils {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(ProcessUtils.class);
|
||||||
|
|
||||||
|
private ProcessUtils() {
|
||||||
|
throw new IllegalStateException("Utility class");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialization regularization, solve the problem of pre-compilation performance,
|
||||||
|
* avoid the thread safety problem of multi-thread operation
|
||||||
|
*/
|
||||||
|
private static final Pattern MACPATTERN = Pattern.compile("-[+|-]-\\s(\\d+)");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expression of PID recognition in Windows scene
|
||||||
|
*/
|
||||||
|
private static final Pattern WINDOWSATTERN = Pattern.compile("(\\d+)");
|
||||||
|
|
||||||
|
private static final String RM_HA_IDS = PropertyUtils.getString(Constants.YARN_RESOURCEMANAGER_HA_RM_IDS);
|
||||||
|
private static final String APP_ADDRESS = PropertyUtils.getString(Constants.YARN_APPLICATION_STATUS_ADDRESS);
|
||||||
|
private static final String JOB_HISTORY_ADDRESS =
|
||||||
|
PropertyUtils.getString(Constants.YARN_JOB_HISTORY_STATUS_ADDRESS);
|
||||||
|
private static final int HADOOP_RESOURCE_MANAGER_HTTP_ADDRESS_PORT_VALUE =
|
||||||
|
PropertyUtils.getInt(Constants.HADOOP_RESOURCE_MANAGER_HTTPADDRESS_PORT, 8088);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* kill tasks according to different task types.
|
||||||
|
*/
|
||||||
|
public static boolean kill(@NonNull TaskExecutionContext request) {
|
||||||
|
try {
|
||||||
|
logger.info("Begin kill task instance, processId: {}", request.getProcessId());
|
||||||
|
int processId = request.getProcessId();
|
||||||
|
if (processId == 0) {
|
||||||
|
logger.error("Task instance kill failed, processId is not exist");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
String cmd = String.format("kill -9 %s", getPidsStr(processId));
|
||||||
|
cmd = OSUtils.getSudoCmd(request.getTenantCode(), cmd);
|
||||||
|
logger.info("process id:{}, cmd:{}", processId, cmd);
|
||||||
|
|
||||||
|
OSUtils.exeCmd(cmd);
|
||||||
|
logger.info("Success kill task instance, processId: {}", request.getProcessId());
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Kill task instance error, processId: {}", request.getProcessId(), e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get pids str.
|
||||||
|
*
|
||||||
|
* @param processId process id
|
||||||
|
* @return pids pid String
|
||||||
|
* @throws Exception exception
|
||||||
|
*/
|
||||||
|
public static String getPidsStr(int processId) throws Exception {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
Matcher mat = null;
|
||||||
|
// pstree pid get sub pids
|
||||||
|
if (SystemUtils.IS_OS_MAC) {
|
||||||
|
String pids = OSUtils.exeCmd(String.format("%s -sp %d", TaskConstants.PSTREE, processId));
|
||||||
|
if (null != pids) {
|
||||||
|
mat = MACPATTERN.matcher(pids);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String pids = OSUtils.exeCmd(String.format("%s -p %d", TaskConstants.PSTREE, processId));
|
||||||
|
mat = WINDOWSATTERN.matcher(pids);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null != mat) {
|
||||||
|
while (mat.find()) {
|
||||||
|
sb.append(mat.group(1)).append(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.toString().trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* kill yarn application.
|
||||||
|
*
|
||||||
|
* @param appIds app id list
|
||||||
|
* @param logger logger
|
||||||
|
* @param tenantCode tenant code
|
||||||
|
* @param executePath execute path
|
||||||
|
*/
|
||||||
|
public static void cancelApplication(List<String> appIds, Logger logger, String tenantCode, String executePath) {
|
||||||
|
if (appIds == null || appIds.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String appId : appIds) {
|
||||||
|
try {
|
||||||
|
TaskExecutionStatus applicationStatus = getApplicationStatus(appId);
|
||||||
|
|
||||||
|
if (!applicationStatus.isFinished()) {
|
||||||
|
String commandFile = String.format("%s/%s.kill", executePath, appId);
|
||||||
|
String cmd = getKerberosInitCommand() + "yarn application -kill " + appId;
|
||||||
|
execYarnKillCommand(logger, tenantCode, appId, commandFile, cmd);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("Get yarn application app id [{}}] status failed", appId, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the state of an application
|
||||||
|
*
|
||||||
|
* @param applicationId application id
|
||||||
|
* @return the return may be null or there may be other parse exceptions
|
||||||
|
*/
|
||||||
|
public static TaskExecutionStatus getApplicationStatus(String applicationId) throws BaseException {
|
||||||
|
if (StringUtils.isEmpty(applicationId)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
String result;
|
||||||
|
String applicationUrl = getApplicationUrl(applicationId);
|
||||||
|
logger.debug("generate yarn application url, applicationUrl={}", applicationUrl);
|
||||||
|
|
||||||
|
String responseContent = Boolean.TRUE
|
||||||
|
.equals(PropertyUtils.getBoolean(Constants.HADOOP_SECURITY_AUTHENTICATION_STARTUP_STATE, false))
|
||||||
|
? KerberosHttpClient.get(applicationUrl)
|
||||||
|
: HttpUtils.get(applicationUrl);
|
||||||
|
if (responseContent != null) {
|
||||||
|
ObjectNode jsonObject = JSONUtils.parseObject(responseContent);
|
||||||
|
if (!jsonObject.has("app")) {
|
||||||
|
return TaskExecutionStatus.FAILURE;
|
||||||
|
}
|
||||||
|
result = jsonObject.path("app").path("finalStatus").asText();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// may be in job history
|
||||||
|
String jobHistoryUrl = getJobHistoryUrl(applicationId);
|
||||||
|
logger.debug("generate yarn job history application url, jobHistoryUrl={}", jobHistoryUrl);
|
||||||
|
responseContent = Boolean.TRUE
|
||||||
|
.equals(PropertyUtils.getBoolean(Constants.HADOOP_SECURITY_AUTHENTICATION_STARTUP_STATE, false))
|
||||||
|
? KerberosHttpClient.get(jobHistoryUrl)
|
||||||
|
: HttpUtils.get(jobHistoryUrl);
|
||||||
|
|
||||||
|
if (null != responseContent) {
|
||||||
|
ObjectNode jsonObject = JSONUtils.parseObject(responseContent);
|
||||||
|
if (!jsonObject.has("job")) {
|
||||||
|
return TaskExecutionStatus.FAILURE;
|
||||||
|
}
|
||||||
|
result = jsonObject.path("job").path("state").asText();
|
||||||
|
} else {
|
||||||
|
return TaskExecutionStatus.FAILURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return getExecutionStatus(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get application url
|
||||||
|
* if rmHaIds contains xx, it signs not use resourcemanager
|
||||||
|
* otherwise:
|
||||||
|
* if rmHaIds is empty, single resourcemanager enabled
|
||||||
|
* if rmHaIds not empty: resourcemanager HA enabled
|
||||||
|
*
|
||||||
|
* @param applicationId application id
|
||||||
|
* @return url of application
|
||||||
|
*/
|
||||||
|
private static String getApplicationUrl(String applicationId) throws BaseException {
|
||||||
|
|
||||||
|
String appUrl = StringUtils.isEmpty(RM_HA_IDS) ? APP_ADDRESS : getAppAddress(APP_ADDRESS, RM_HA_IDS);
|
||||||
|
if (StringUtils.isBlank(appUrl)) {
|
||||||
|
throw new BaseException("yarn application url generation failed");
|
||||||
|
}
|
||||||
|
logger.debug("yarn application url:{}, applicationId:{}", appUrl, applicationId);
|
||||||
|
return String.format(appUrl, HADOOP_RESOURCE_MANAGER_HTTP_ADDRESS_PORT_VALUE, applicationId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getJobHistoryUrl(String applicationId) {
|
||||||
|
// eg:application_1587475402360_712719 -> job_1587475402360_712719
|
||||||
|
String jobId = applicationId.replace("application", "job");
|
||||||
|
return String.format(JOB_HISTORY_ADDRESS, jobId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* build kill command for yarn application
|
||||||
|
*
|
||||||
|
* @param logger logger
|
||||||
|
* @param tenantCode tenant code
|
||||||
|
* @param appId app id
|
||||||
|
* @param commandFile command file
|
||||||
|
* @param cmd cmd
|
||||||
|
*/
|
||||||
|
private static void execYarnKillCommand(Logger logger, String tenantCode, String appId, String commandFile,
|
||||||
|
String cmd) {
|
||||||
|
try {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("#!/bin/sh\n");
|
||||||
|
sb.append("BASEDIR=$(cd `dirname $0`; pwd)\n");
|
||||||
|
sb.append("cd $BASEDIR\n");
|
||||||
|
|
||||||
|
sb.append("\n\n");
|
||||||
|
sb.append(cmd);
|
||||||
|
|
||||||
|
File f = new File(commandFile);
|
||||||
|
|
||||||
|
if (!f.exists()) {
|
||||||
|
org.apache.commons.io.FileUtils.writeStringToFile(new File(commandFile), sb.toString(),
|
||||||
|
StandardCharsets.UTF_8);
|
||||||
|
}
|
||||||
|
|
||||||
|
String runCmd = String.format("%s %s", Constants.SH, commandFile);
|
||||||
|
runCmd = org.apache.dolphinscheduler.common.utils.OSUtils.getSudoCmd(tenantCode, runCmd);
|
||||||
|
logger.info("kill cmd:{}", runCmd);
|
||||||
|
org.apache.dolphinscheduler.common.utils.OSUtils.exeCmd(runCmd);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(String.format("Kill yarn application app id [%s] failed: [%s]", appId, e.getMessage()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static TaskExecutionStatus getExecutionStatus(String result) {
|
||||||
|
switch (result) {
|
||||||
|
case Constants.ACCEPTED:
|
||||||
|
return TaskExecutionStatus.SUBMITTED_SUCCESS;
|
||||||
|
case Constants.SUCCEEDED:
|
||||||
|
case Constants.ENDED:
|
||||||
|
return TaskExecutionStatus.SUCCESS;
|
||||||
|
case Constants.NEW:
|
||||||
|
case Constants.NEW_SAVING:
|
||||||
|
case Constants.SUBMITTED:
|
||||||
|
case Constants.FAILED:
|
||||||
|
return TaskExecutionStatus.FAILURE;
|
||||||
|
case Constants.KILLED:
|
||||||
|
return TaskExecutionStatus.KILL;
|
||||||
|
case Constants.RUNNING:
|
||||||
|
default:
|
||||||
|
return TaskExecutionStatus.RUNNING_EXECUTION;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* getAppAddress
|
||||||
|
*
|
||||||
|
* @param appAddress app address
|
||||||
|
* @param rmHa resource manager ha
|
||||||
|
* @return app address
|
||||||
|
*/
|
||||||
|
private static String getAppAddress(String appAddress, String rmHa) {
|
||||||
|
|
||||||
|
String[] split1 = appAddress.split(Constants.DOUBLE_SLASH);
|
||||||
|
|
||||||
|
if (split1.length != 2) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
String start = split1[0] + Constants.DOUBLE_SLASH;
|
||||||
|
String[] split2 = split1[1].split(Constants.COLON);
|
||||||
|
|
||||||
|
if (split2.length != 2) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
String end = Constants.COLON + split2[1];
|
||||||
|
|
||||||
|
// get active ResourceManager
|
||||||
|
String activeRM = YarnHAAdminUtils.getActiveRMName(start, rmHa);
|
||||||
|
|
||||||
|
if (StringUtils.isEmpty(activeRM)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return start + activeRM + end;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get kerberos init command
|
||||||
|
*/
|
||||||
|
private static String getKerberosInitCommand() {
|
||||||
|
logger.info("get kerberos init command");
|
||||||
|
StringBuilder kerberosCommandBuilder = new StringBuilder();
|
||||||
|
boolean hadoopKerberosState =
|
||||||
|
PropertyUtils.getBoolean(Constants.HADOOP_SECURITY_AUTHENTICATION_STARTUP_STATE, false);
|
||||||
|
if (hadoopKerberosState) {
|
||||||
|
kerberosCommandBuilder.append("export KRB5_CONFIG=")
|
||||||
|
.append(PropertyUtils.getString(Constants.JAVA_SECURITY_KRB5_CONF_PATH))
|
||||||
|
.append("\n\n")
|
||||||
|
.append(String.format("kinit -k -t %s %s || true",
|
||||||
|
PropertyUtils.getString(Constants.LOGIN_USER_KEY_TAB_PATH),
|
||||||
|
PropertyUtils.getString(Constants.LOGIN_USER_KEY_TAB_USERNAME)))
|
||||||
|
.append("\n\n");
|
||||||
|
logger.info("kerberos init command: {}", kerberosCommandBuilder);
|
||||||
|
}
|
||||||
|
return kerberosCommandBuilder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* yarn ha admin utils
|
||||||
|
*/
|
||||||
|
private static final class YarnHAAdminUtils {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get active resourcemanager node
|
||||||
|
*
|
||||||
|
* @param protocol http protocol
|
||||||
|
* @param rmIds yarn ha ids
|
||||||
|
* @return yarn active node
|
||||||
|
*/
|
||||||
|
public static String getActiveRMName(String protocol, String rmIds) {
|
||||||
|
|
||||||
|
String[] rmIdArr = rmIds.split(Constants.COMMA);
|
||||||
|
|
||||||
|
String yarnUrl = protocol + "%s:" + HADOOP_RESOURCE_MANAGER_HTTP_ADDRESS_PORT_VALUE + "/ws/v1/cluster/info";
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* send http get request to rm
|
||||||
|
*/
|
||||||
|
|
||||||
|
for (String rmId : rmIdArr) {
|
||||||
|
String state = getRMState(String.format(yarnUrl, rmId));
|
||||||
|
if (Constants.HADOOP_RM_STATE_ACTIVE.equals(state)) {
|
||||||
|
return rmId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("yarn ha application url generation failed, message:{}", e.getMessage());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get ResourceManager state
|
||||||
|
*/
|
||||||
|
public static String getRMState(String url) {
|
||||||
|
|
||||||
|
String retStr = Boolean.TRUE
|
||||||
|
.equals(PropertyUtils.getBoolean(Constants.HADOOP_SECURITY_AUTHENTICATION_STARTUP_STATE, false))
|
||||||
|
? KerberosHttpClient.get(url)
|
||||||
|
: HttpUtils.get(url);
|
||||||
|
|
||||||
|
if (StringUtils.isEmpty(retStr)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// to json
|
||||||
|
ObjectNode jsonObject = JSONUtils.parseObject(retStr);
|
||||||
|
|
||||||
|
// get ResourceManager state
|
||||||
|
if (!jsonObject.has("clusterInfo")) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return jsonObject.get("clusterInfo").path("haState").asText();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -42,18 +42,14 @@
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.dolphinscheduler</groupId>
|
|
||||||
<artifactId>dolphinscheduler-service</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.dolphinscheduler</groupId>
|
|
||||||
<artifactId>dolphinscheduler-spi</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.dolphinscheduler</groupId>
|
<groupId>org.apache.dolphinscheduler</groupId>
|
||||||
<artifactId>dolphinscheduler-common</artifactId>
|
<artifactId>dolphinscheduler-common</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.dolphinscheduler</groupId>
|
||||||
|
<artifactId>dolphinscheduler-remote</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.dolphinscheduler</groupId>
|
<groupId>org.apache.dolphinscheduler</groupId>
|
||||||
<artifactId>dolphinscheduler-meter</artifactId>
|
<artifactId>dolphinscheduler-meter</artifactId>
|
||||||
|
|
@ -68,6 +64,11 @@
|
||||||
<artifactId>dolphinscheduler-task-all</artifactId>
|
<artifactId>dolphinscheduler-task-all</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.dolphinscheduler</groupId>
|
||||||
|
<artifactId>dolphinscheduler-storage-all</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter</artifactId>
|
<artifactId>spring-boot-starter</artifactId>
|
||||||
|
|
|
||||||
|
|
@ -21,19 +21,17 @@ import org.apache.dolphinscheduler.common.IStoppable;
|
||||||
import org.apache.dolphinscheduler.common.constants.Constants;
|
import org.apache.dolphinscheduler.common.constants.Constants;
|
||||||
import org.apache.dolphinscheduler.common.lifecycle.ServerLifeCycleManager;
|
import org.apache.dolphinscheduler.common.lifecycle.ServerLifeCycleManager;
|
||||||
import org.apache.dolphinscheduler.common.thread.ThreadUtils;
|
import org.apache.dolphinscheduler.common.thread.ThreadUtils;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.ProcessUtils;
|
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
|
import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
|
||||||
import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContextCacheManager;
|
import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContextCacheManager;
|
||||||
|
import org.apache.dolphinscheduler.plugin.task.api.TaskPluginManager;
|
||||||
|
import org.apache.dolphinscheduler.plugin.task.api.utils.LogUtils;
|
||||||
|
import org.apache.dolphinscheduler.plugin.task.api.utils.ProcessUtils;
|
||||||
import org.apache.dolphinscheduler.server.worker.config.WorkerConfig;
|
import org.apache.dolphinscheduler.server.worker.config.WorkerConfig;
|
||||||
import org.apache.dolphinscheduler.server.worker.message.MessageRetryRunner;
|
import org.apache.dolphinscheduler.server.worker.message.MessageRetryRunner;
|
||||||
import org.apache.dolphinscheduler.server.worker.registry.WorkerRegistryClient;
|
import org.apache.dolphinscheduler.server.worker.registry.WorkerRegistryClient;
|
||||||
import org.apache.dolphinscheduler.server.worker.rpc.WorkerRpcClient;
|
import org.apache.dolphinscheduler.server.worker.rpc.WorkerRpcClient;
|
||||||
import org.apache.dolphinscheduler.server.worker.rpc.WorkerRpcServer;
|
import org.apache.dolphinscheduler.server.worker.rpc.WorkerRpcServer;
|
||||||
import org.apache.dolphinscheduler.server.worker.runner.WorkerManagerThread;
|
import org.apache.dolphinscheduler.server.worker.runner.WorkerManagerThread;
|
||||||
import org.apache.dolphinscheduler.service.alert.AlertClientService;
|
|
||||||
import org.apache.dolphinscheduler.service.bean.SpringApplicationContext;
|
|
||||||
import org.apache.dolphinscheduler.service.task.TaskPluginManager;
|
|
||||||
import org.apache.dolphinscheduler.service.utils.LoggerUtils;
|
|
||||||
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
|
||||||
|
|
@ -65,19 +63,6 @@ public class WorkerServer implements IStoppable {
|
||||||
*/
|
*/
|
||||||
private static final Logger logger = LoggerFactory.getLogger(WorkerServer.class);
|
private static final Logger logger = LoggerFactory.getLogger(WorkerServer.class);
|
||||||
|
|
||||||
/**
|
|
||||||
* spring application context
|
|
||||||
* only use it for initialization
|
|
||||||
*/
|
|
||||||
@Autowired
|
|
||||||
private SpringApplicationContext springApplicationContext;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* alert model netty remote server
|
|
||||||
*/
|
|
||||||
@Autowired
|
|
||||||
private AlertClientService alertClientService;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private WorkerManagerThread workerManagerThread;
|
private WorkerManagerThread workerManagerThread;
|
||||||
|
|
||||||
|
|
@ -144,9 +129,7 @@ public class WorkerServer implements IStoppable {
|
||||||
|
|
||||||
try (
|
try (
|
||||||
WorkerRpcServer closedWorkerRpcServer = workerRpcServer;
|
WorkerRpcServer closedWorkerRpcServer = workerRpcServer;
|
||||||
WorkerRegistryClient closedRegistryClient = workerRegistryClient;
|
WorkerRegistryClient closedRegistryClient = workerRegistryClient) {
|
||||||
AlertClientService closedAlertClientService = alertClientService;
|
|
||||||
SpringApplicationContext closedSpringContext = springApplicationContext;) {
|
|
||||||
logger.info("Worker server is stopping, current cause : {}", cause);
|
logger.info("Worker server is stopping, current cause : {}", cause);
|
||||||
// kill running tasks
|
// kill running tasks
|
||||||
this.killAllRunningTasks();
|
this.killAllRunningTasks();
|
||||||
|
|
@ -175,13 +158,13 @@ public class WorkerServer implements IStoppable {
|
||||||
for (TaskExecutionContext taskRequest : taskRequests) {
|
for (TaskExecutionContext taskRequest : taskRequests) {
|
||||||
// kill task when it's not finished yet
|
// kill task when it's not finished yet
|
||||||
try {
|
try {
|
||||||
LoggerUtils.setWorkflowAndTaskInstanceIDMDC(taskRequest.getProcessInstanceId(),
|
LogUtils.setWorkflowAndTaskInstanceIDMDC(taskRequest.getProcessInstanceId(),
|
||||||
taskRequest.getTaskInstanceId());
|
taskRequest.getTaskInstanceId());
|
||||||
if (ProcessUtils.kill(taskRequest)) {
|
if (ProcessUtils.kill(taskRequest)) {
|
||||||
killNumber++;
|
killNumber++;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
LoggerUtils.removeWorkflowAndTaskInstanceIdMDC();
|
LogUtils.removeWorkflowAndTaskInstanceIdMDC();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logger.info("Worker after kill all cache task, task size: {}, killed number: {}", taskRequests.size(),
|
logger.info("Worker after kill all cache task, task size: {}, killed number: {}", taskRequests.size(),
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,9 @@ package org.apache.dolphinscheduler.server.worker.message;
|
||||||
import org.apache.dolphinscheduler.common.constants.Constants;
|
import org.apache.dolphinscheduler.common.constants.Constants;
|
||||||
import org.apache.dolphinscheduler.common.lifecycle.ServerLifeCycleManager;
|
import org.apache.dolphinscheduler.common.lifecycle.ServerLifeCycleManager;
|
||||||
import org.apache.dolphinscheduler.common.thread.BaseDaemonThread;
|
import org.apache.dolphinscheduler.common.thread.BaseDaemonThread;
|
||||||
|
import org.apache.dolphinscheduler.plugin.task.api.utils.LogUtils;
|
||||||
import org.apache.dolphinscheduler.remote.command.BaseCommand;
|
import org.apache.dolphinscheduler.remote.command.BaseCommand;
|
||||||
import org.apache.dolphinscheduler.remote.command.CommandType;
|
import org.apache.dolphinscheduler.remote.command.CommandType;
|
||||||
import org.apache.dolphinscheduler.service.utils.LoggerUtils;
|
|
||||||
|
|
||||||
import org.apache.commons.collections4.MapUtils;
|
import org.apache.commons.collections4.MapUtils;
|
||||||
|
|
||||||
|
|
@ -119,7 +119,7 @@ public class MessageRetryRunner extends BaseDaemonThread {
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
LoggerUtils.setTaskInstanceIdMDC(taskInstanceId);
|
LogUtils.setTaskInstanceIdMDC(taskInstanceId);
|
||||||
try {
|
try {
|
||||||
for (Map.Entry<CommandType, BaseCommand> messageEntry : retryMessageMap.entrySet()) {
|
for (Map.Entry<CommandType, BaseCommand> messageEntry : retryMessageMap.entrySet()) {
|
||||||
CommandType messageType = messageEntry.getKey();
|
CommandType messageType = messageEntry.getKey();
|
||||||
|
|
@ -134,7 +134,7 @@ public class MessageRetryRunner extends BaseDaemonThread {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.warn("Retry send message to master error", e);
|
logger.warn("Retry send message to master error", e);
|
||||||
} finally {
|
} finally {
|
||||||
LoggerUtils.removeTaskInstanceIdMDC();
|
LogUtils.removeTaskInstanceIdMDC();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Thread.sleep(Constants.SLEEP_TIME_MILLIS);
|
Thread.sleep(Constants.SLEEP_TIME_MILLIS);
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue