Skip to content

Commit 344ad4a

Browse files
authored
[Chore] Remove unused code in api-server (#17871)
1 parent d0e2ff5 commit 344ad4a

File tree

15 files changed

+20
-289
lines changed

15 files changed

+20
-289
lines changed

dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/ApiApplicationServer.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import org.apache.dolphinscheduler.common.lifecycle.ServerLifeCycleManager;
2323
import org.apache.dolphinscheduler.common.thread.DefaultUncaughtExceptionHandler;
2424
import org.apache.dolphinscheduler.dao.DaoConfiguration;
25-
import org.apache.dolphinscheduler.dao.PluginDao;
2625
import org.apache.dolphinscheduler.plugin.datasource.api.plugin.DataSourceProcessorProvider;
2726
import org.apache.dolphinscheduler.plugin.storage.api.StorageConfiguration;
2827
import org.apache.dolphinscheduler.plugin.task.api.TaskPluginManager;
@@ -31,7 +30,6 @@
3130

3231
import lombok.extern.slf4j.Slf4j;
3332

34-
import org.springframework.beans.factory.annotation.Autowired;
3533
import org.springframework.boot.SpringApplication;
3634
import org.springframework.boot.autoconfigure.SpringBootApplication;
3735
import org.springframework.boot.context.event.ApplicationReadyEvent;
@@ -49,9 +47,6 @@
4947
@SpringBootApplication
5048
public class ApiApplicationServer {
5149

52-
@Autowired
53-
private PluginDao pluginDao;
54-
5550
public static void main(String[] args) {
5651
ApiServerMetrics.registerUncachedException(DefaultUncaughtExceptionHandler::getUncaughtExceptionCount);
5752
Thread.setDefaultUncaughtExceptionHandler(DefaultUncaughtExceptionHandler.getInstance());

dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,6 @@ public enum Status {
561561
"查询工作流自定义变量信息错误"),
562562

563563
NO_CURRENT_OPERATING_PERMISSION(1400001, "The current user does not have this permission.", "当前用户无此权限"),
564-
FUNCTION_DISABLED(1400002, "The current feature is disabled.", "当前功能已被禁用"),
565564
SCHEDULE_TIME_NUMBER_EXCEED(1400003, "The number of complement dates exceed 100.", "补数日期个数超过100"),
566565
DESCRIPTION_TOO_LONG_ERROR(1400004, "description is too long error", "描述过长"),
567566
DELETE_WORKER_GROUP_BY_ID_FAIL_ENV(1400005,

dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/k8s/K8sClientService.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,16 @@
2323

2424
import org.springframework.beans.factory.annotation.Autowired;
2525
import org.springframework.stereotype.Component;
26-
import org.yaml.snakeyaml.Yaml;
2726

2827
import io.fabric8.kubernetes.api.model.Namespace;
2928
import io.fabric8.kubernetes.api.model.NamespaceList;
30-
import io.fabric8.kubernetes.api.model.ObjectMeta;
31-
import io.fabric8.kubernetes.client.KubernetesClient;
3229

3330
/**
3431
* Encapsulates all client-related operations, not involving the db
3532
*/
3633
@Component
3734
public class K8sClientService {
3835

39-
private static Yaml yaml = new Yaml();
4036
@Autowired
4137
private K8sManager k8sManager;
4238

@@ -48,20 +44,6 @@ public void upsertNamespaceAndResourceToK8s(K8sNamespace k8sNamespace) {
4844
}
4945
}
5046

51-
public Optional<Namespace> deleteNamespaceToK8s(String name, Long clusterCode) {
52-
Optional<Namespace> result = getNamespaceFromK8s(name, clusterCode);
53-
if (result.isPresent()) {
54-
KubernetesClient client = k8sManager.getK8sClient(clusterCode);
55-
Namespace body = new Namespace();
56-
ObjectMeta meta = new ObjectMeta();
57-
meta.setNamespace(name);
58-
meta.setName(name);
59-
body.setMetadata(meta);
60-
client.namespaces().delete(body);
61-
}
62-
return getNamespaceFromK8s(name, clusterCode);
63-
}
64-
6547
private Optional<Namespace> getNamespaceFromK8s(String name, Long clusterCode) {
6648
NamespaceList listNamespace =
6749
k8sManager.getK8sClient(clusterCode).namespaces().list();

dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/metrics/ApiServerMetrics.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,13 @@
1717

1818
package org.apache.dolphinscheduler.api.metrics;
1919

20-
import java.util.concurrent.TimeUnit;
2120
import java.util.function.Supplier;
2221

2322
import lombok.experimental.UtilityClass;
2423
import io.micrometer.core.instrument.Counter;
2524
import io.micrometer.core.instrument.DistributionSummary;
2625
import io.micrometer.core.instrument.Gauge;
2726
import io.micrometer.core.instrument.Metrics;
28-
import io.micrometer.core.instrument.Timer;
2927

3028
@UtilityClass
3129
public class ApiServerMetrics {
@@ -75,13 +73,6 @@ public class ApiServerMetrics {
7573
.description("size of download resource files on api")
7674
.register(Metrics.globalRegistry);
7775

78-
static {
79-
Timer.builder("ds.api.response.time")
80-
.tag("user.id", "dummy")
81-
.description("response time on api")
82-
.register(Metrics.globalRegistry);
83-
}
84-
8576
public void incApiRequestCount() {
8677
apiRequestCounter.increment();
8778
}
@@ -110,12 +101,6 @@ public void recordApiResourceDownloadSize(final long size) {
110101
apiResourceDownloadSizeDistribution.record(size);
111102
}
112103

113-
public void recordApiResponseTime(final long milliseconds, final int userId) {
114-
Metrics.globalRegistry.timer(
115-
"ds.api.response.time",
116-
"user.id", String.valueOf(userId)).record(milliseconds, TimeUnit.MILLISECONDS);
117-
}
118-
119104
public void cleanUpApiResponseTimeMetricsByUserId(final int userId) {
120105
Metrics.globalRegistry.remove(
121106
Metrics.globalRegistry.timer(

dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/PermissionCheck.java

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -61,31 +61,6 @@ public class PermissionCheck<T> {
6161
*/
6262
private int userId;
6363

64-
/**
65-
* permission check
66-
*
67-
* @param authorizationType authorization type
68-
* @param processService process dao
69-
*/
70-
public PermissionCheck(AuthorizationType authorizationType, ProcessService processService) {
71-
this.authorizationType = authorizationType;
72-
this.processService = processService;
73-
}
74-
75-
/**
76-
* permission check
77-
*/
78-
public PermissionCheck(AuthorizationType authorizationType, ProcessService processService, T[] needChecks,
79-
int userId) {
80-
this.authorizationType = authorizationType;
81-
this.processService = processService;
82-
this.needChecks = needChecks;
83-
this.userId = userId;
84-
}
85-
86-
/**
87-
* permission check
88-
*/
8964
public PermissionCheck(AuthorizationType authorizationType, ProcessService processService, T[] needChecks,
9065
int userId, Logger logger) {
9166
this.authorizationType = authorizationType;
@@ -95,26 +70,6 @@ public PermissionCheck(AuthorizationType authorizationType, ProcessService proce
9570
this.logger = logger;
9671
}
9772

98-
/**
99-
* permission check
100-
*/
101-
public PermissionCheck(AuthorizationType authorizationType, ProcessService processService,
102-
List<ResourceInfo> resourceList, int userId, Logger logger) {
103-
this.authorizationType = authorizationType;
104-
this.processService = processService;
105-
this.resourceList = resourceList;
106-
this.userId = userId;
107-
this.logger = logger;
108-
}
109-
110-
public AuthorizationType getAuthorizationType() {
111-
return authorizationType;
112-
}
113-
114-
public void setAuthorizationType(AuthorizationType authorizationType) {
115-
this.authorizationType = authorizationType;
116-
}
117-
11873
public ProcessService getProcessService() {
11974
return processService;
12075
}
@@ -123,14 +78,6 @@ public void setProcessService(ProcessService processService) {
12378
this.processService = processService;
12479
}
12580

126-
public T[] getNeedChecks() {
127-
return needChecks;
128-
}
129-
130-
public void setNeedChecks(T[] needChecks) {
131-
this.needChecks = needChecks;
132-
}
133-
13481
public int getUserId() {
13582
return userId;
13683
}
@@ -147,20 +94,6 @@ public void setResourceList(List<ResourceInfo> resourceList) {
14794
this.resourceList = resourceList;
14895
}
14996

150-
/**
151-
* has permission
152-
*
153-
* @return true if has permission
154-
*/
155-
public boolean hasPermission() {
156-
try {
157-
checkPermission();
158-
return true;
159-
} catch (Exception e) {
160-
return false;
161-
}
162-
}
163-
16497
/**
16598
* check permission
16699
*

dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckService.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
package org.apache.dolphinscheduler.api.permission;
1919

20+
import org.apache.dolphinscheduler.common.enums.AuthorizationType;
21+
2022
import java.util.Set;
2123

2224
import org.slf4j.Logger;
@@ -50,13 +52,7 @@ public interface ResourcePermissionCheckService<T> {
5052
* @param logger
5153
* @return
5254
*/
53-
boolean operationPermissionCheck(Object authorizationType, Integer userId,
54-
String permissionKey, Logger logger);
55-
56-
/**
57-
* functionDisabled
58-
* @return
59-
*/
60-
boolean functionDisabled();
55+
boolean operationPermissionCheck(AuthorizationType authorizationType, Integer userId, String permissionKey,
56+
Logger logger);
6157

6258
}

dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/permission/ResourcePermissionCheckServiceImpl.java

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
import org.apache.dolphinscheduler.dao.mapper.TenantMapper;
4545
import org.apache.dolphinscheduler.dao.repository.UserDao;
4646
import org.apache.dolphinscheduler.dao.repository.WorkerGroupDao;
47-
import org.apache.dolphinscheduler.service.process.ProcessService;
4847

4948
import java.util.Arrays;
5049
import java.util.Collections;
@@ -70,9 +69,9 @@ public class ResourcePermissionCheckServiceImpl
7069
ApplicationContextAware {
7170

7271
@Autowired
73-
private ProcessService processService;
72+
private UserDao userDao;
7473

75-
public static final Map<AuthorizationType, ResourceAcquisitionAndPermissionCheck<?>> RESOURCE_LIST_MAP =
74+
static final Map<AuthorizationType, ResourceAcquisitionAndPermissionCheck<?>> RESOURCE_LIST_MAP =
7675
new ConcurrentHashMap<>();
7776

7877
@Override
@@ -100,9 +99,9 @@ public boolean resourcePermissionCheck(Object authorizationType, Object[] needCh
10099
}
101100

102101
@Override
103-
public boolean operationPermissionCheck(Object authorizationType, Integer userId,
104-
String permissionKey, Logger logger) {
105-
User user = processService.getUserById(userId);
102+
public boolean operationPermissionCheck(AuthorizationType authorizationType, Integer userId, String permissionKey,
103+
Logger logger) {
104+
User user = userDao.queryById(userId);
106105
if (user == null) {
107106
logger.error("User does not exist, userId:{}.", userId);
108107
return false;
@@ -113,14 +112,9 @@ public boolean operationPermissionCheck(Object authorizationType, Integer userId
113112
return RESOURCE_LIST_MAP.get(authorizationType).permissionCheck(userId, permissionKey, logger);
114113
}
115114

116-
@Override
117-
public boolean functionDisabled() {
118-
return false;
119-
}
120-
121115
@Override
122116
public Set<Object> userOwnedResourceIdsAcquisition(Object authorizationType, Integer userId, Logger logger) {
123-
User user = processService.getUserById(userId);
117+
User user = userDao.queryById(userId);
124118
if (user == null) {
125119
logger.error("User does not exist, userId:{}.", userId);
126120
return Collections.emptySet();

dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/BaseServiceImpl.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -124,19 +124,6 @@ public boolean check(Map<String, Object> result, boolean bool, Status userNoOper
124124
return false;
125125
}
126126

127-
/**
128-
* create tenant dir if not exists
129-
*
130-
* @param tenantCode tenant code
131-
* @throws IOException if hdfs operation exception
132-
*/
133-
// @Override
134-
// public void createTenantDirIfNotExists(String tenantCode) throws IOException {
135-
// String resourcePath = HadoopUtils.getHdfsResDir(tenantCode);
136-
// // init resource path
137-
// HadoopUtils.getInstance().mkdir(tenantCode,resourcePath);
138-
// }
139-
140127
/**
141128
* Verify that the operator has permissions
142129
*

0 commit comments

Comments
 (0)