forked from apache/dolphinscheduler
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev-usable-fix-all' into fix-cant-detect-workgroup
- Loading branch information
Showing
18 changed files
with
539 additions
and
73 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
36 changes: 36 additions & 0 deletions
36
...java/org/apache/dolphinscheduler/extract/master/transportor/LogicTaskTakeOverRequest.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,36 @@ | ||
/* | ||
* 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.extract.master.transportor; | ||
|
||
import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; | ||
|
||
import java.io.Serializable; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class LogicTaskTakeOverRequest implements Serializable { | ||
|
||
private static final long serialVersionUID = -1L; | ||
|
||
private TaskExecutionContext taskExecutionContext; | ||
} |
42 changes: 42 additions & 0 deletions
42
...ava/org/apache/dolphinscheduler/extract/master/transportor/LogicTaskTakeOverResponse.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,42 @@ | ||
/* | ||
* 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.extract.master.transportor; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class LogicTaskTakeOverResponse { | ||
|
||
private Integer taskInstanceId; | ||
|
||
private boolean success; | ||
|
||
private String message; | ||
|
||
public static LogicTaskTakeOverResponse success(Integer taskInstanceId) { | ||
return new LogicTaskTakeOverResponse(taskInstanceId, true, "take over success"); | ||
} | ||
|
||
public static LogicTaskTakeOverResponse failed(Integer taskInstanceId, String message) { | ||
return new LogicTaskTakeOverResponse(taskInstanceId, false, message); | ||
} | ||
} |
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
82 changes: 82 additions & 0 deletions
82
...pache/dolphinscheduler/server/master/rpc/LogicITaskInstanceTakeOverOperationFunction.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,82 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.dolphinscheduler.server.master.rpc; | ||
|
||
import org.apache.dolphinscheduler.extract.master.transportor.LogicTaskTakeOverRequest; | ||
import org.apache.dolphinscheduler.extract.master.transportor.LogicTaskTakeOverResponse; | ||
import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext; | ||
import org.apache.dolphinscheduler.plugin.task.api.utils.LogUtils; | ||
import org.apache.dolphinscheduler.server.master.runner.execute.MasterTaskExecutionContextHolder; | ||
import org.apache.dolphinscheduler.server.master.runner.execute.MasterTaskExecutor; | ||
import org.apache.dolphinscheduler.server.master.runner.execute.MasterTaskExecutorFactoryBuilder; | ||
import org.apache.dolphinscheduler.server.master.runner.execute.MasterTaskExecutorThreadPoolManager; | ||
import org.apache.dolphinscheduler.server.master.runner.message.LogicTaskInstanceExecutionEventSenderManager; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Slf4j | ||
@Component | ||
public class LogicITaskInstanceTakeOverOperationFunction | ||
implements | ||
ITaskInstanceOperationFunction<LogicTaskTakeOverRequest, LogicTaskTakeOverResponse> { | ||
|
||
@Autowired | ||
private MasterTaskExecutorFactoryBuilder masterTaskExecutorFactoryBuilder; | ||
|
||
@Autowired | ||
private MasterTaskExecutorThreadPoolManager masterTaskExecutorThreadPool; | ||
|
||
@Autowired | ||
private LogicTaskInstanceExecutionEventSenderManager logicTaskInstanceExecutionEventSenderManager; | ||
|
||
@Override | ||
public LogicTaskTakeOverResponse operate(LogicTaskTakeOverRequest taskTakeoverRequest) { | ||
log.info("Received dispatchLogicTask request: {}", taskTakeoverRequest); | ||
TaskExecutionContext taskExecutionContext = taskTakeoverRequest.getTaskExecutionContext(); | ||
try { | ||
final int taskInstanceId = taskExecutionContext.getTaskInstanceId(); | ||
final int workflowInstanceId = taskExecutionContext.getWorkflowInstanceId(); | ||
final String taskInstanceName = taskExecutionContext.getTaskName(); | ||
|
||
taskExecutionContext.setLogPath(LogUtils.getTaskInstanceLogFullPath(taskExecutionContext)); | ||
|
||
LogUtils.setWorkflowAndTaskInstanceIDMDC(workflowInstanceId, taskInstanceId); | ||
LogUtils.setTaskInstanceLogFullPathMDC(taskExecutionContext.getLogPath()); | ||
|
||
MasterTaskExecutionContextHolder.putTaskExecutionContext(taskExecutionContext); | ||
|
||
final MasterTaskExecutor masterTaskExecutor = masterTaskExecutorFactoryBuilder | ||
.createMasterTaskExecutorFactory(taskExecutionContext.getTaskType()) | ||
.createMasterTaskExecutor(taskExecutionContext); | ||
|
||
if (masterTaskExecutorThreadPool.takeOverMasterTaskExecutor(masterTaskExecutor)) { | ||
log.info("Take over LogicTask: {} to MasterTaskExecutorThreadPool success", taskInstanceName); | ||
return LogicTaskTakeOverResponse.success(taskInstanceId); | ||
} else { | ||
log.error("Take over LogicTask: {} to MasterTaskExecutorThreadPool failed", taskInstanceName); | ||
return LogicTaskTakeOverResponse.failed(taskInstanceId, "MasterTaskExecutorThreadPool is full"); | ||
} | ||
} finally { | ||
LogUtils.removeWorkflowAndTaskInstanceIdMDC(); | ||
LogUtils.removeTaskInstanceLogFullPathMDC(); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.