-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize Daemon Schedule, and add delete jobhistory Task (#2548)
* Optimize the process * Optimize Daemon Schedule * Optimize Daemon Schedule * Move the Build Config package location, and then delete it * formate code * formate code
- Loading branch information
1 parent
2ab7026
commit 484f898
Showing
22 changed files
with
439 additions
and
254 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
dinky-admin/src/main/java/org/dinky/job/ClearJobHistoryTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* | ||
* 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.dinky.job; | ||
|
||
import org.dinky.context.SpringContextUtils; | ||
import org.dinky.daemon.task.DaemonTask; | ||
import org.dinky.daemon.task.DaemonTaskConfig; | ||
import org.dinky.job.handler.ClearJobHistoryHandler; | ||
import org.dinky.service.HistoryService; | ||
import org.dinky.service.JobHistoryService; | ||
import org.dinky.service.JobInstanceService; | ||
|
||
import org.springframework.context.annotation.DependsOn; | ||
|
||
import lombok.Data; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@DependsOn("springContextUtils") | ||
@Slf4j | ||
@Data | ||
public class ClearJobHistoryTask implements DaemonTask { | ||
|
||
public static final String TYPE = ClearJobHistoryTask.class.toString(); | ||
|
||
private static final JobInstanceService jobInstanceService; | ||
private static final JobHistoryService jobHistoryService; | ||
private static final HistoryService historyService; | ||
private static final ClearJobHistoryHandler clearJobHistoryHandler; | ||
|
||
static { | ||
jobInstanceService = SpringContextUtils.getBean("jobInstanceServiceImpl", JobInstanceService.class); | ||
jobHistoryService = SpringContextUtils.getBean("jobHistoryServiceImpl", JobHistoryService.class); | ||
historyService = SpringContextUtils.getBean("historyServiceImpl", HistoryService.class); | ||
clearJobHistoryHandler = ClearJobHistoryHandler.builder() | ||
.historyService(historyService) | ||
.jobInstanceService(jobInstanceService) | ||
.jobHistoryService(jobHistoryService) | ||
.build(); | ||
} | ||
|
||
@Override | ||
public boolean dealTask() { | ||
clearJobHistoryHandler.clearDinkyHistory(30, 20); | ||
clearJobHistoryHandler.clearJobHistory(30, 20); | ||
return false; | ||
} | ||
|
||
@Override | ||
public DaemonTask setConfig(DaemonTaskConfig config) { | ||
return this; | ||
} | ||
|
||
@Override | ||
public DaemonTaskConfig getConfig() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getType() { | ||
return TYPE; | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
dinky-admin/src/main/java/org/dinky/job/DynamicResizeFlinkJobPoolTask.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package org.dinky.job; | ||
|
||
import org.dinky.daemon.pool.FlinkJobThreadPool; | ||
import org.dinky.daemon.task.DaemonTask; | ||
import org.dinky.daemon.task.DaemonTaskConfig; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Slf4j | ||
public class DynamicResizeFlinkJobPoolTask implements DaemonTask { | ||
|
||
private DaemonTaskConfig config; | ||
public static final String TYPE = DynamicResizeFlinkJobPoolTask.class.toString(); | ||
private final FlinkJobThreadPool defaultThreadPool = FlinkJobThreadPool.getInstance(); | ||
|
||
@Override | ||
public boolean dealTask() { | ||
int taskSize = defaultThreadPool.getTaskSize(); | ||
// Calculate the desired number of worker threads, adding one worker for every 100 tasks | ||
int num = taskSize / 100 + 1; | ||
// Dynamically adjust the number of worker threads in the thread pool | ||
if (defaultThreadPool.getWorkCount() < num) { | ||
defaultThreadPool.addWorkers(num - defaultThreadPool.getWorkCount()); | ||
} else if (defaultThreadPool.getWorkCount() > num) { | ||
defaultThreadPool.removeWorker(defaultThreadPool.getWorkCount() - num); | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public DaemonTask setConfig(DaemonTaskConfig config) { | ||
this.config = config; | ||
return this; | ||
} | ||
|
||
@Override | ||
public DaemonTaskConfig getConfig() { | ||
return config; | ||
} | ||
|
||
@Override | ||
public String getType() { | ||
return TYPE; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.